x86_64: cleanup setup_node_zones called by paging_init
PATCH 1/1 x86_64: cleanup setup_node_zones called by paging_init
[PATCH] x86_64: cleanup setup_node_zones called by paging_init
setup_node_zones calcuates some variable but only use them when FLAT_NODE_MEM_MAP is set
so change the MACRO postion to avoid calculating.
also change it to static
arch/x86/mm/numa_64.c +14 -12
@@ -227,15 +227,16 @@ void __init setup_node_bootmem(int nodeisrat_reserve_add_area (nodeid);#endif node_set_online (nodeid); -} +} +#ifdef CONFIG_FLAT_NODE_MEM_MAP /* Initialize final allocator for a zone */ -void __init setup_node_zones (int nodeid) -{ +static void __init setup_node_zones (int nodeid) +{unsigned long start_pfn, end_pfn, memmapsize, limit; - start_pfn =node_start_pfn (nodeid); - end_pfn =node_end_pfn (nodeid); + start_pfn =node_start_pfn (nodeid); + end_pfn =node_end_pfn (nodeid);Dprintk (KERN_INFO "Setting up memmap for node %d %lx-%lx\n" , nodeid, start_pfn, end_pfn);
@@ -244,14 +245,13 @@ void __init setup_node_zones(int nodeid)memory. */ memmapsize =sizeof (struct page ) * (end_pfn-start_pfn); limit = end_pfn <<PAGE_SHIFT ; -#ifdef CONFIG_FLAT_NODE_MEM_MAP -NODE_DATA (nodeid)->node_mem_map = -__alloc_bootmem_core (NODE_DATA (nodeid)->bdata, - memmapsize,SMP_CACHE_BYTES , -round_down (limit - memmapsize,PAGE_SIZE ), +NODE_DATA (nodeid)->node_mem_map = +__alloc_bootmem_core (NODE_DATA (nodeid)->bdata, + memmapsize,SMP_CACHE_BYTES , +round_down (limit - memmapsize,PAGE_SIZE ), limit); +}#endif -}void __init numa_init_array (void ) {
@@ -570,9 +570,11 @@ void __init paging_init(void)sparse_memory_present_with_active_regions (MAX_NUMNODES );sparse_init (); +#ifdef CONFIG_FLAT_NODE_MEM_MAP for_each_online_node (i) { -setup_node_zones (i); +setup_node_zones (i); } +#endif free_area_init_nodes (max_zone_pfns); }
Quoted 1 line · Yinghai Lu
[PATCH]
x86_64: cleanupsetup_node_zonescalled bypaging_init
The whitespace cleanups make it difficult to review the patch. Could you send those separately?
PATCH 1/1 x86_64: cleanup setup_node_zones called by paging_init v2
[PATCH] x86_64: cleanup setup_node_zones called by paging_init v2
setup_node_zones calcuates some variable but only use them when FLAT_NODE_MEM_MAP is set
so change the MACRO postion to avoid calculating.
also change it to static
arch/x86/mm/numa_64.c +6 -3
@@ -229,8 +229,9 @@ void __init setup_node_bootmem(int nodeinode_set_online (nodeid); } +#ifdef CONFIG_FLAT_NODE_MEM_MAP /* Initialize final allocator for a zone */ -void __init setup_node_zones (int nodeid) +static void __init setup_node_zones (int nodeid) {unsigned long start_pfn, end_pfn, memmapsize, limit;
@@ -244,14 +245,14 @@ void __init setup_node_zones(int nodeid)memory. */ memmapsize =sizeof (struct page ) * (end_pfn-start_pfn); limit = end_pfn <<PAGE_SHIFT ; -#ifdef CONFIG_FLAT_NODE_MEM_MAP +NODE_DATA (nodeid)->node_mem_map =__alloc_bootmem_core (NODE_DATA (nodeid)->bdata, memmapsize,SMP_CACHE_BYTES ,round_down (limit - memmapsize,PAGE_SIZE ), limit); -#endif } +#endif void __init numa_init_array (void ) {
@@ -570,9 +571,11 @@ void __init paging_init(void)sparse_memory_present_with_active_regions (MAX_NUMNODES );sparse_init (); +#ifdef CONFIG_FLAT_NODE_MEM_MAP for_each_online_node (i) {setup_node_zones (i); } +#endif free_area_init_nodes (max_zone_pfns); }
Re: [PATCH] x86_64: cleanup setup_node_zones called by paging_init v2
Quoted 9 lines · Yinghai Lu
[PATCH]
x86_64: cleanupsetup_node_zonescalled bypaging_initv2
setup_node_zonescalcuates some variable but only use them whenFLAT_NODE_MEM_MAPis setso change the MACRO postion to avoid calculating.
also change it to static
I just see the patch adding a net of one #ifdef (and 3 lines of .c file), and I don't consider that a cleanup. :(
If you make the function static, and make sure to cover that Dprintk up with the #ifdef, I think the compiler should take care of the rest and just throw away the function. Then, you won't need to add the second #ifdef. You can even kill the brackets in that for loop.
Also, if you're going to be mucking around in there, can you give setup_node_zones() a better name? It doesn't exactly setup any zones any more. alloc_node_mem_map(), perhaps? The comment above it is bogus, too.
-- Dave
Re: [PATCH] x86_64: cleanup setup_node_zones called by paging_init v2
In reply to Yinghai LuQuoted 10 lines · Yinghai Lu
arch/x86/mm/numa_64.c +2
-1+#ifdef CONFIG_FLAT_NODE_MEM_MAP /* Initialize final allocator for a zone */ -void __init setup_node_zones (int nodeid) +static void __init setup_node_zones (int nodeid) {unsigned long start_pfn, end_pfn, memmapsize, limit;@@ -244,14 +245,14 @@ void __init setup_node_zones(int nodeid)memory. */ memmapsize =sizeof (struct page ) * (end_pfn-start_pfn);
arch/x86/mm/numa_64.c void __init setup_node_zones(int nodeid) · line 254
Quoted 10 lines
arch/x86/mm/numa_64.c +1
-2limit = end_pfn <<PAGE_SHIFT ; -#ifdef CONFIG_FLAT_NODE_MEM_MAP +NODE_DATA (nodeid)->node_mem_map =__alloc_bootmem_core (NODE_DATA (nodeid)->bdata, memmapsize,SMP_CACHE_BYTES ,round_down (limit - memmapsize,PAGE_SIZE ), limit); -#endif }
Here you could do an
#else
<empty def of setup_node_zones>
which would avoid the additional #ifdef later.
Also move the for_each statement into that function.
The current version will have an unused variable i if CONFIG_FLAG_NODE_MEM_MAP is not set.
PATCH 1/1 x86_64: cleanup setup_node_zones called by paging_init v3
[PATCH] x86_64: cleanup setup_node_zones called by paging_init v3
setup_node_zones calcuates some variables but only use them when FLAT_NODE_MEM_MAP is set
so change the MACRO postion to avoid calculating.
also change it to static, rename it to flat_setup_node_zones
arch/x86/mm/numa_64.c +7 -4
@@ -229,8 +229,9 @@ void __init setup_node_bootmem(int nodeinode_set_online (nodeid); } +#ifdef CONFIG_FLAT_NODE_MEM_MAP /* Initialize final allocator for a zone */ -void __init setup_node_zones (int nodeid) +static void __init flat_setup_node_zones (int nodeid) {unsigned long start_pfn, end_pfn, memmapsize, limit;
@@ -244,14 +245,16 @@ void __init setup_node_zones(int nodeid)memory. */ memmapsize =sizeof (struct page ) * (end_pfn-start_pfn); limit = end_pfn <<PAGE_SHIFT ; -#ifdef CONFIG_FLAT_NODE_MEM_MAP +NODE_DATA (nodeid)->node_mem_map =__alloc_bootmem_core (NODE_DATA (nodeid)->bdata, memmapsize,SMP_CACHE_BYTES ,round_down (limit - memmapsize,PAGE_SIZE ), limit); +} +#else +#define flat_setup_node_zones (i) do {} while (0)#endif -}void __init numa_init_array (void ) {
@@ -571,7 +574,7 @@ void __init paging_init(void)sparse_init ();for_each_online_node (i) { -setup_node_zones (i); +flat_setup_node_zones (i); }free_area_init_nodes (max_zone_pfns);
PATCH 1/1 x86_64: cleanup setup_node_zones called by paging_init v4
please check the one against to x86.git mm
[PATCH] x86_64: cleanup setup_node_zones called by paging_init v4
setup_node_zones calcuates some variables but only use them when FLAT_NODE_MEM_MAP is set
so change the MACRO postion to avoid calculating.
also change it to static, and rename it to flat_setup_node_zones
arch/x86/mm/numa_64.c +7 -4
@@ -233,8 +233,9 @@ void __init setup_node_bootmem(int nodeid, unsigned long start,node_set_online (nodeid); } +#ifdef CONFIG_FLAT_NODE_MEM_MAP /* Initialize final allocator for a zone */ -void __init setup_node_zones (int nodeid) +static void __init flat_setup_node_zones (int nodeid) {unsigned long start_pfn, end_pfn, memmapsize, limit;
@@ -250,14 +251,16 @@ void __init setup_node_zones(int nodeid)*/ memmapsize =sizeof (struct page ) * (end_pfn-start_pfn); limit = end_pfn <<PAGE_SHIFT ; -#ifdef CONFIG_FLAT_NODE_MEM_MAP +NODE_DATA (nodeid)->node_mem_map =__alloc_bootmem_core (NODE_DATA (nodeid)->bdata, memmapsize,SMP_CACHE_BYTES ,round_down (limit - memmapsize,PAGE_SIZE ), limit); -#endif } +#else +#define flat_setup_node_zones (i) do {} while (0) +#endif /* * There are unfortunately some poorly designed mainboards around that
@@ -581,7 +584,7 @@ void __init paging_init(void)sparse_init ();for_each_online_node (i) -setup_node_zones (i); +flat_setup_node_zones (i);free_area_init_nodes (max_zone_pfns); }
Re: [PATCH] x86_64: cleanup setup_node_zones called by paging_init v2
In reply to Christoph LameterQuoted 2 lines · Christoph Lameter
On Wed, 9 Jan 2008, Yinghai Lu wrote:
Christoph's
x86: 64-bit, make sparsemem vmemmap the only memory model
is in x86.git mm
so we could remove setup_node_zones because it is not needed by SPARSEMEM
please check the following patch.
YH
[PATCH] x86_84: only support sparsemem fix
sparsemem is only one supported, so could remove FLAT_NODE_MEM related code, that is only needed !SPARSEMEM
arch/x86/mm/numa_64.c +0 -29
@@ -233,32 +233,6 @@ void __init setup_node_bootmem(int nodeid, unsigned long start,node_set_online (nodeid); } -/* Initialize final allocator for a zone */ -void __init setup_node_zones (int nodeid) -{ -unsigned long start_pfn, end_pfn, memmapsize, limit; - - start_pfn =node_start_pfn (nodeid); - end_pfn =node_end_pfn (nodeid); - -Dprintk (KERN_INFO "Setting up memmap for node %d %lx-%lx\n" , - nodeid, start_pfn, end_pfn); - -/* -* Try to allocate mem_map at end to not fill up precious <4GB -* memory. -*/ - memmapsize =sizeof (struct page ) * (end_pfn-start_pfn); - limit = end_pfn <<PAGE_SHIFT ; -#ifdef CONFIG_FLAT_NODE_MEM_MAP -NODE_DATA (nodeid)->node_mem_map = -__alloc_bootmem_core (NODE_DATA (nodeid)->bdata, - memmapsize,SMP_CACHE_BYTES , -round_down (limit - memmapsize,PAGE_SIZE ), - limit); -#endif -} -/* * There are unfortunately some poorly designed mainboards around that * only connect memory to a single CPU. This breaks the 1:1 cpu->node
@@ -580,9 +554,6 @@ void __init paging_init(void)sparse_memory_present_with_active_regions (MAX_NUMNODES );sparse_init (); -for_each_online_node (i) -setup_node_zones (i); -free_area_init_nodes (max_zone_pfns); }
Christoph Lameter
Reviewed-byRe: [PATCH] x86_64: cleanup setup_node_zones called by paging_init v2
Quoted 1 line · Yinghai Lu
please check the following patch.
Exactly!
PATCH 1/1 x86_64: only support sparsemem fix
[PATCH] x86_64: only support sparsemem fix
sparsemem is only one supported, so could remove FLAT_NODE_MEM related, that is only needed !SPARSEMEM
arch/x86/mm/numa_64.c +0 -32
@@ -240,35 +240,6 @@ void __init setup_node_bootmem(int nodeid, unsigned long start,node_set_online (nodeid); } -#ifdef CONFIG_FLAT_NODE_MEM_MAP -/* Initialize final allocator for a zone */ -static void __init flat_setup_node_zones (int nodeid) -{ -unsigned long start_pfn, end_pfn, memmapsize, limit; - - start_pfn =node_start_pfn (nodeid); - end_pfn =node_end_pfn (nodeid); - -Dprintk (KERN_INFO "Setting up memmap for node %d %lx-%lx\n" , - nodeid, start_pfn, end_pfn); - -/* -* Try to allocate mem_map at end to not fill up precious <4GB -* memory. -*/ - memmapsize =sizeof (struct page ) * (end_pfn-start_pfn); - limit = end_pfn <<PAGE_SHIFT ; - -NODE_DATA (nodeid)->node_mem_map = -__alloc_bootmem_core (NODE_DATA (nodeid)->bdata, - memmapsize,SMP_CACHE_BYTES , -round_down (limit - memmapsize,PAGE_SIZE ), - limit); -} -#else -#define flat_setup_node_zones (i) do {} while (0) -#endif -/* * There are unfortunately some poorly designed mainboards around that * only connect memory to a single CPU. This breaks the 1:1 cpu->node
@@ -600,9 +571,6 @@ void __init paging_init(void)sparse_memory_present_with_active_regions (MAX_NUMNODES );sparse_init (); -for_each_online_node (i) -flat_setup_node_zones (i); -free_area_init_nodes (max_zone_pfns); }