[External] [RFC PATCH v1 2/6] mm/page_alloc.c: get pfn range with flags of memblock

From: Huaisheng HS1 Ye
Date: Mon May 07 2018 - 22:33:14 EST


This is used to expand the interface of get_pfn_range_for_nid with
flags of memblock, so mm can get pfn range with special flags.

Signed-off-by: Huaisheng Ye <yehs1@xxxxxxxxxx>
Signed-off-by: Ocean He <hehy1@xxxxxxxxxx>
---
include/linux/mm.h | 4 ++++
mm/page_alloc.c | 17 ++++++++++++++++-
2 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/include/linux/mm.h b/include/linux/mm.h
index ad06d42..8abf9c9 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -2046,6 +2046,10 @@ extern unsigned long absent_pages_in_range(unsigned long start_pfn,
unsigned long end_pfn);
extern void get_pfn_range_for_nid(unsigned int nid,
unsigned long *start_pfn, unsigned long *end_pfn);
+extern void get_pfn_range_for_nid_with_flags(unsigned int nid,
+ unsigned long *start_pfn,
+ unsigned long *end_pfn,
+ unsigned long flags);
extern unsigned long find_min_pfn_with_active_regions(void);
extern void free_bootmem_with_active_regions(int nid,
unsigned long max_low_pfn);
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 1741dd2..266c065 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -5705,13 +5705,28 @@ void __init sparse_memory_present_with_active_regions(int nid)
void __meminit get_pfn_range_for_nid(unsigned int nid,
unsigned long *start_pfn, unsigned long *end_pfn)
{
+ get_pfn_range_for_nid_with_flags(nid, start_pfn, end_pfn,
+ MEMBLOCK_MAX_TYPE);
+}
+
+/*
+ * If MAX_NUMNODES, includes all node memmory regions.
+ * If MEMBLOCK_MAX_TYPE, includes all memory regions with or without Flags.
+ */
+
+void __meminit get_pfn_range_for_nid_with_flags(unsigned int nid,
+ unsigned long *start_pfn,
+ unsigned long *end_pfn,
+ unsigned long flags)
+{
unsigned long this_start_pfn, this_end_pfn;
int i;

*start_pfn = -1UL;
*end_pfn = 0;

- for_each_mem_pfn_range(i, nid, &this_start_pfn, &this_end_pfn, NULL) {
+ for_each_mem_pfn_range_with_flags(i, nid, &this_start_pfn,
+ &this_end_pfn, NULL, flags) {
*start_pfn = min(*start_pfn, this_start_pfn);
*end_pfn = max(*end_pfn, this_end_pfn);
}
--
1.8.3.1