mm: avoid duplication of setup_nr_node_ids()
Subsystems (6)
cover mm: avoid duplication of setup_nr_node_ids()
In arch/powerpc, arch/x86, and mm/page_alloc code to setup nr_node_ids based on node_possible_map is duplicated.
This patchset switches those copies to calling the function provided by page_alloc.
PATCH 1/3 page_alloc: make setup_nr_node_ids() usable for arch init code
powerpc and x86 were opencoding copies of setup_nr_node_ids(), which page_alloc provides but makes static. Make it avaliable to the archs in linux/mm.h.
--- include/linux/mm.h | 6 ++++++ mm/page_alloc.c | 6 +----- 2 files changed, 7 insertions(+), 5 deletions(-)
include/linux/mm.h +6 -0
@@ -1755,5 +1755,11 @@ static inline unsigned int debug_guardpage_minorder(void) { return 0; }static inline bool page_is_guard (struct page *page) {return false; }#endif /* CONFIG_DEBUG_PAGEALLOC */ +#if MAX_NUMNODES >1 +void __init setup_nr_node_ids (void ); +#else +static inline void setup_nr_node_ids (void ) {} +#endif +#endif /* __KERNEL__ */ #endif /* _LINUX_MM_H */
mm/page_alloc.c +1 -5
@@ -4710,7 +4710,7 @@ void __paginginit free_area_init_node(int nid, unsigned long *zones_size,/* * Figure out the number of possible node ids. */ -static void __init setup_nr_node_ids (void ) +void __init setup_nr_node_ids (void ) {unsigned int node;unsigned int highest =0 ;
@@ -4719,10 +4719,6 @@ static void __init setup_nr_node_ids(void) highest = node; nr_node_ids = highest + 1; } -#else -static inline void setup_nr_node_ids (void ) -{ -}#endif /**
Signature · 7 lines
1.8.2 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 2/3 x86/mm/numa: use setup_nr_node_ids() instead of opencoding.
In reply to Cody P Schafer--- arch/x86/mm/numa.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
arch/x86/mm/numa.c +3 -6
@@ -114,14 +114,11 @@ void numa_clear_node(int cpu)*/ void __init setup_node_to_cpumask_map (void ) { -unsigned int node, num =0 ; +unsigned int node;/* setup nr_node_ids if not done yet */ -if (nr_node_ids ==MAX_NUMNODES ) { -for_each_node_mask (node, node_possible_map) - num = node; - nr_node_ids = num +1 ; - } +if (nr_node_ids ==MAX_NUMNODES ) +setup_nr_node_ids ();/* allocate the map */ for (node =0 ; node < nr_node_ids; node++)
Signature · 7 lines
1.8.2 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH 2/3] x86/mm/numa: use setup_nr_node_ids() instead of opencoding.
Quoted 14 lines · Cody P Schafer
Signed-off-by Cody P Schafer <[email protected]>--- arch/x86/mm/numa.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)arch/x86/mm/numa.c +0
-1@@ -114,14 +114,11 @@ void numa_clear_node(int cpu)*/ void __init setup_node_to_cpumask_map (void ) { -unsigned int node, num =0 ;
arch/x86/mm/numa.c void numa_clear_node(int cpu) · line 121
Quoted 10 lines
arch/x86/mm/numa.c +3
-5+unsigned int node;/* setup nr_node_ids if not done yet */ -if (nr_node_ids ==MAX_NUMNODES ) { -for_each_node_mask (node, node_possible_map) - num = node; - nr_node_ids = num +1 ; - } +if (nr_node_ids ==MAX_NUMNODES ) +setup_nr_node_ids ();
For 1 and 2,
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH 2/3] x86/mm/numa: use setup_nr_node_ids() instead of opencoding.
Quoted 5 lines · Yinghai Lu
For 1 and 2,
Acked-by Yinghai Lu <[email protected]>
Similarly:
-hpa
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 3/3 powerpc/mm/numa: use setup_nr_node_ids() instead of opencoding.
In reply to Cody P Schafer--- arch/powerpc/mm/numa.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
arch/powerpc/mm/numa.c +3 -6
@@ -62,14 +62,11 @@ static int distance_lookup_table[MAX_NUMNODES][MAX_DISTANCE_REF_POINTS];*/ static void __init setup_node_to_cpumask_map (void ) { -unsigned int node, num =0 ; +unsigned int node;/* setup nr_node_ids if not done yet */ -if (nr_node_ids ==MAX_NUMNODES ) { -for_each_node_mask (node, node_possible_map) - num = node; - nr_node_ids = num +1 ; - } +if (nr_node_ids ==MAX_NUMNODES ) +setup_nr_node_ids () /* allocate the map */for (node =0 ; node < nr_node_ids; node++)
Signature · 1 line
1.8.2