[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
Signed-off-by: Yinghai Lu <[email protected]>
Index: linux-2.6/arch/x86/mm/numa_64.c
===================================================================
--- linux-2.6.orig/arch/x86/mm/numa_64.c
+++ linux-2.6/arch/x86/mm/numa_64.c
@@ -227,15 +227,16 @@ void __init setup_node_bootmem(int nodei
srat_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);
}
On Tue, 8 Jan 2008, Yinghai Lu wrote:
> [PATCH] x86_64: cleanup setup_node_zones called by paging_init
The whitespace cleanups make it difficult to review the patch. Could you
send those separately?
[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
Signed-off-by: Yinghai Lu <[email protected]>
Index: linux-2.6/arch/x86/mm/numa_64.c
===================================================================
--- linux-2.6.orig/arch/x86/mm/numa_64.c
+++ linux-2.6/arch/x86/mm/numa_64.c
@@ -229,8 +229,9 @@ void __init setup_node_bootmem(int nodei
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;
@@ -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);
}
On Wed, 2008-01-09 at 10:30 -0800, Yinghai Lu wrote:
>
> [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
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
On Wed, 9 Jan 2008, Yinghai Lu wrote:
> +#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
> }
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] 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
Signed-off-by: Yinghai Lu <[email protected]>
Index: linux-2.6/arch/x86/mm/numa_64.c
===================================================================
--- linux-2.6.orig/arch/x86/mm/numa_64.c
+++ linux-2.6/arch/x86/mm/numa_64.c
@@ -229,8 +229,9 @@ void __init setup_node_bootmem(int nodei
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;
@@ -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);
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
Signed-off-by: Yinghai Lu <[email protected]>
diff --git a/arch/x86/mm/numa_64.c b/arch/x86/mm/numa_64.c
index 8482314..551e359 100644
--- a/arch/x86/mm/numa_64.c
+++ b/arch/x86/mm/numa_64.c
@@ -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);
}
On Wednesday 09 January 2008 11:19:01 am Christoph Lameter wrote:
> 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
Signed-off-by: Yinghai Lu <[email protected]>
diff --git a/arch/x86/mm/numa_64.c b/arch/x86/mm/numa_64.c
index 8482314..4c286b7 100644
--- a/arch/x86/mm/numa_64.c
+++ b/arch/x86/mm/numa_64.c
@@ -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);
}
On Sat, 12 Jan 2008, Yinghai Lu wrote:
> please check the following patch.
Exactly!
Reviewed-by: Christoph Lameter <[email protected]>
[PATCH] x86_64: only support sparsemem fix
sparsemem is only one supported, so could remove FLAT_NODE_MEM related, that is
only needed !SPARSEMEM
Signed-off-by: Yinghai Lu <[email protected]>
Reviewed-by: Christoph Lameter <[email protected]>
--- a/arch/x86/mm/numa_64.c
+++ b/arch/x86/mm/numa_64.c
@@ -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);
}