mm: move function ‘is_pageblock_removable_nolock’ inside blockers
Subsystems (3)
PATCH 1/1 mm: move function ‘is_pageblock_removable_nolock’ inside blockers
Function a??is_pageblock_removable_nolocka?? is not used unless CONFIG_MEMORY_HOTREMOVE is activated. Move it in between #ifdef sentinel to match prototype in <linux/memory_hotplug.h>. Silence gcc warning (W=1):
mm/page_alloc.c:7704:6: warning: no previous prototype for a??is_pageblock_removable_nolocka?? [-Wmissing-prototypes]
--- mm/page_alloc.c | 2 ++ 1 file changed, 2 insertions(+)
mm/page_alloc.c +2 -0
@@ -7701,6 +7701,7 @@ bool has_unmovable_pages(struct zone *zone, struct page *page, int count,return false; } +#ifdef CONFIG_MEMORY_HOTREMOVE bool is_pageblock_removable_nolock (struct page *page) {struct zone *zone;
@@ -7723,6 +7724,7 @@ bool is_pageblock_removable_nolock(struct page *page) return !has_unmovable_pages(zone, page, 0, MIGRATE_MOVABLE, true); } +#endif #if (defined(CONFIG_MEMORY_ISOLATION ) && defined(CONFIG_COMPACTION )) || defined(CONFIG_CMA )
Signature · 1 line
2.11.0
Quoted 5 lines · Mathieu Malaterre
Function a??is_pageblock_removable_nolocka?? is not used unless
CONFIG_MEMORY_HOTREMOVEis activated. Move it in between #ifdef sentinel to match prototype in <linux/memory_hotplug.h>. Silence gcc warning (W=1):
mm/page_alloc.c:7704:6: warning: no previous prototype for a??is_pageblock_removable_nolocka?? [-Wmissing-prototypes]
Could you move is_pageblock_removable_nolock to mm/memory_hotplug.c and make it static instead? There is only one caller is_mem_section_removable so there shouldn't be any real reason to have it extern and add more ifdefs.
Quoted 28 lines
Signed-off-by Mathieu Malaterre <[email protected]>--- mm/page_alloc.c | 2 ++ 1 file changed, 2 insertions(+)mm/page_alloc.c +2
-0@@ -7701,6 +7701,7 @@ bool has_unmovable_pages(struct zone *zone, struct page *page, int count,return false; } +#ifdef CONFIG_MEMORY_HOTREMOVE bool is_pageblock_removable_nolock (struct page *page) {struct zone *zone;@@ -7723,6 +7724,7 @@ bool is_pageblock_removable_nolock(struct page *page) return !has_unmovable_pages(zone, page, 0, MIGRATE_MOVABLE, true); } +#endif #if (defined(CONFIG_MEMORY_ISOLATION ) && defined(CONFIG_COMPACTION )) || defined(CONFIG_CMA )Signature · 1 line
2.11.0
Signature · 2 lines
Michal Hocko SUSE Labs
PATCH v2 1/1 mm: move function ‘is_pageblock_removable_nolock’ to mm/memory_hotplug.c
In reply to Mathieu MalaterreFunction ‘is_pageblock_removable_nolock’ is not used outside of mm/memory_hotplug.c. Move it next to unique caller:
‘is_mem_section_removable’ and make it static.
Remove prototype in <linux/memory_hotplug.h>. Silence gcc warning (W=1):
mm/page_alloc.c:7704:6: warning: no previous prototype for ‘is_pageblock_removable_nolock’ [-Wmissing-prototypes]
---
v2: this function can be made static, make it so
include/linux/memory_hotplug.h | 1 - mm/memory_hotplug.c | 23 +++++++++++++++++++++++ mm/page_alloc.c | 23 ----------------------- 3 files changed, 23 insertions(+), 24 deletions(-)
include/linux/memory_hotplug.h +0 -1
@@ -107,7 +107,6 @@ static inline bool movable_node_is_enabled(void) }#ifdef CONFIG_MEMORY_HOTREMOVE -extern bool is_pageblock_removable_nolock (struct page *page);extern int arch_remove_memory (u64 start,u64 size,struct vmem_altmap *altmap); extern int __remove_pages(struct zone *zone, unsigned long start_pfn,
mm/memory_hotplug.c +23 -0
@@ -1237,6 +1237,29 @@ static struct page *next_active_pageblock(struct page *page)return page + pageblock_nr_pages; } +static bool is_pageblock_removable_nolock (struct page *page) +{ +struct zone *zone; +unsigned long pfn; + +/* +* We have to be careful here because we are iterating over memory +* sections which are not zone aware so we might end up outside of +* the zone but still within the section. +* We have to take care about the node as well. If the node is offline +* its NODE_DATA will be NULL - see page_zone. +*/ +if (!node_online (page_to_nid (page))) +return false; + + zone =page_zone (page); + pfn =page_to_pfn (page); +if (!zone_spans_pfn (zone, pfn)) +return false; + +return !has_unmovable_pages (zone, page,0 ,MIGRATE_MOVABLE , true); +} +/* Checks if this range of memory is likely to be hot-removable. */ bool is_mem_section_removable (unsigned long start_pfn,unsigned long nr_pages) {
mm/page_alloc.c +0 -23
@@ -7701,29 +7701,6 @@ bool has_unmovable_pages(struct zone *zone, struct page *page, int count,return false; } -bool is_pageblock_removable_nolock (struct page *page) -{ -struct zone *zone; -unsigned long pfn; - -/* -* We have to be careful here because we are iterating over memory -* sections which are not zone aware so we might end up outside of -* the zone but still within the section. -* We have to take care about the node as well. If the node is offline -* its NODE_DATA will be NULL - see page_zone. -*/ -if (!node_online (page_to_nid (page))) -return false; - - zone =page_zone (page); - pfn =page_to_pfn (page); -if (!zone_spans_pfn (zone, pfn)) -return false; - -return !has_unmovable_pages (zone, page,0 ,MIGRATE_MOVABLE , true); -} -#if (defined(CONFIG_MEMORY_ISOLATION ) && defined(CONFIG_COMPACTION )) || defined(CONFIG_CMA )static unsigned long pfn_max_align_down (unsigned long pfn)
Signature · 1 line
2.11.0
Re: [PATCH v2] mm: move function ‘is_pageblock_removable_nolock’ to mm/memory_hotplug.c
Quoted 9 lines · Mathieu Malaterre
Function ‘is_pageblock_removable_nolock’ is not used outside of
mm/memory_hotplug.c. Move it next to unique caller:
‘is_mem_section_removable’ and make it static.
Remove prototype in <linux/memory_hotplug.h>. Silence gcc warning (W=1):
mm/page_alloc.c:7704:6: warning: no previous prototype for ‘is_pageblock_removable_nolock’ [-Wmissing-prototypes]Suggested-by Michal Hocko <[email protected]>Signed-off-by Mathieu Malaterre <[email protected]>
Thanks!
Quoted 91 lines
---
v2: this function can be made static, make it soinclude/linux/memory_hotplug.h | 1 - mm/memory_hotplug.c | 23 +++++++++++++++++++++++ mm/page_alloc.c | 23 ----------------------- 3 files changed, 23 insertions(+), 24 deletions(-)include/linux/memory_hotplug.h +0
-1@@ -107,7 +107,6 @@ static inline bool movable_node_is_enabled(void) }#ifdef CONFIG_MEMORY_HOTREMOVE -extern bool is_pageblock_removable_nolock (struct page *page);extern int arch_remove_memory (u64 start,u64 size,struct vmem_altmap *altmap); extern int __remove_pages(struct zone *zone, unsigned long start_pfn,mm/memory_hotplug.c +23
-0@@ -1237,6 +1237,29 @@ static struct page *next_active_pageblock(struct page *page)return page + pageblock_nr_pages; } +static bool is_pageblock_removable_nolock (struct page *page) +{ +struct zone *zone; +unsigned long pfn; + +/* +* We have to be careful here because we are iterating over memory +* sections which are not zone aware so we might end up outside of +* the zone but still within the section. +* We have to take care about the node as well. If the node is offline +* its NODE_DATA will be NULL - see page_zone. +*/ +if (!node_online (page_to_nid (page))) +return false; + + zone =page_zone (page); + pfn =page_to_pfn (page); +if (!zone_spans_pfn (zone, pfn)) +return false; + +return !has_unmovable_pages (zone, page,0 ,MIGRATE_MOVABLE , true); +} +/* Checks if this range of memory is likely to be hot-removable. */ bool is_mem_section_removable (unsigned long start_pfn,unsigned long nr_pages) {mm/page_alloc.c +0
-23@@ -7701,29 +7701,6 @@ bool has_unmovable_pages(struct zone *zone, struct page *page, int count,return false; } -bool is_pageblock_removable_nolock (struct page *page) -{ -struct zone *zone; -unsigned long pfn; - -/* -* We have to be careful here because we are iterating over memory -* sections which are not zone aware so we might end up outside of -* the zone but still within the section. -* We have to take care about the node as well. If the node is offline -* its NODE_DATA will be NULL - see page_zone. -*/ -if (!node_online (page_to_nid (page))) -return false; - - zone =page_zone (page); - pfn =page_to_pfn (page); -if (!zone_spans_pfn (zone, pfn)) -return false; - -return !has_unmovable_pages (zone, page,0 ,MIGRATE_MOVABLE , true); -} -#if (defined(CONFIG_MEMORY_ISOLATION ) && defined(CONFIG_COMPACTION )) || defined(CONFIG_CMA )static unsigned long pfn_max_align_down (unsigned long pfn)Signature · 1 line
2.11.0
Signature · 2 lines
Michal Hocko SUSE Labs