From: Raghavendra K T <hidden> Date: 2015-09-15 02:08:09
Many places in the kernel use 'for' loop with nr_node_ids. For the architectures
which supports sparse numa ids, this will result in some unnecessary allocations
for non existing nodes.
(for e.g., numa node numbers such as 0,1,16,17 is common in powerpc.)
So replace the for loop with for_each_node so that allocations happen only for
existing numa nodes.
Please note that, though there are many places where nr_node_ids is used,
current patchset uses for_each_node only for slowpath to avoid find_next_bit
traversal.
Changes in V2:
- Take memcg_aware check outside for_each loop (Vldimir)
- Add comment that node 0 should always be present (Vladimir)
Raghavendra K T (2):
mm: Replace nr_node_ids for loop with for_each_node in list lru
powerpc:numa Do not allocate bootmem memory for non existing nodes
arch/powerpc/mm/numa.c | 2 +-
mm/list_lru.c | 34 +++++++++++++++++++++++-----------
2 files changed, 24 insertions(+), 12 deletions(-)
--
1.7.11.7
From: Raghavendra K T <hidden> Date: 2015-09-15 02:07:27
The functions used in the patch are in slowpath, which gets called
whenever alloc_super is called during mounts.
Though this should not make difference for the architectures with
sequential numa node ids, for the powerpc which can potentially have
sparse node ids (for e.g., 4 node system having numa ids, 0,1,16,17
is common), this patch saves some unnecessary allocations for
non existing numa nodes.
Even without that saving, perhaps patch makes code more readable.
[ Take memcg_aware check outside for_each loop: Vldimir]
Signed-off-by: Raghavendra K T <redacted>
---
mm/list_lru.c | 34 +++++++++++++++++++++++-----------
1 file changed, 23 insertions(+), 11 deletions(-)
Changes in V2:
- Take memcg_aware check outside for_each loop (Vldimir)
- Add comment that node 0 should always be present (Vladimir)
@@ -80,7 +80,7 @@ static void __init setup_node_to_cpumask_map(void)setup_nr_node_ids();/* allocate the map */-for(node=0;node<nr_node_ids;node++)+for_each_node(node)alloc_bootmem_cpumask_var(&node_to_cpumask_map[node]);/* cpumask_of_node() will now work */
From: Raghavendra K T <hidden> Date: 2015-09-15 02:15:54
On 09/15/2015 07:38 AM, Raghavendra K T wrote:
The functions used in the patch are in slowpath, which gets called
whenever alloc_super is called during mounts.
Though this should not make difference for the architectures with
sequential numa node ids, for the powerpc which can potentially have
sparse node ids (for e.g., 4 node system having numa ids, 0,1,16,17
is common), this patch saves some unnecessary allocations for
non existing numa nodes.
Even without that saving, perhaps patch makes code more readable.
[ Take memcg_aware check outside for_each loop: Vladimir]
Signed-off-by: Raghavendra K T <redacted>
---
From: Vladimir Davydov <hidden> Date: 2015-09-15 07:59:48
On Tue, Sep 15, 2015 at 07:38:36AM +0530, Raghavendra K T wrote:
The functions used in the patch are in slowpath, which gets called
whenever alloc_super is called during mounts.
Though this should not make difference for the architectures with
sequential numa node ids, for the powerpc which can potentially have
sparse node ids (for e.g., 4 node system having numa ids, 0,1,16,17
is common), this patch saves some unnecessary allocations for
non existing numa nodes.
Even without that saving, perhaps patch makes code more readable.
[ Take memcg_aware check outside for_each loop: Vldimir]
Signed-off-by: Raghavendra K T <redacted>
From: Michael Ellerman <mpe@ellerman.id.au> Date: 2015-09-22 05:29:08
On Tue, 2015-09-15 at 07:38 +0530, Raghavendra K T wrote:
... nothing
Sure this patch looks obvious, but please give me a changelog that proves
you've thought about it thoroughly.
For example is it OK to use for_each_node() at this point in boot? Is there any
historical reason why we did it with a hard coded loop? If so what has changed.
What systems have you tested on? etc. etc.
cheers
quoted hunk
Signed-off-by: Raghavendra K T <redacted>
---
arch/powerpc/mm/numa.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
@@ -80,7 +80,7 @@ static void __init setup_node_to_cpumask_map(void)setup_nr_node_ids();/* allocate the map */-for(node=0;node<nr_node_ids;node++)+for_each_node(node)alloc_bootmem_cpumask_var(&node_to_cpumask_map[node]);/* cpumask_of_node() will now work */
From: Raghavendra K T <hidden> Date: 2015-09-22 10:47:45
On 09/22/2015 10:59 AM, Michael Ellerman wrote:
On Tue, 2015-09-15 at 07:38 +0530, Raghavendra K T wrote:
quoted
... nothing
Sure this patch looks obvious, but please give me a changelog that proves
you've thought about it thoroughly.
For example is it OK to use for_each_node() at this point in boot? Is there any
historical reason why we did it with a hard coded loop? If so what has changed.
What systems have you tested on? etc. etc.
cheers
Changelog:
With the setup_nr_nodes(), we have already initialized
node_possible_map. So it is safe to use for_each_node here.
There are many places in the kernel that use hardcoded 'for' loop with
nr_node_ids, because all other architectures have numa nodes populated
serially. That should be reason we had maintained same for powerpc.
But since on power we have sparse numa node ids possible, we
unnecessarily allocate memory for non existent numa nodes.
For e.g., on a system with 0,1,16,17 as numa nodes nr_node_ids=18
and we allocate memory for nodes 2-14.
The patch is boot tested on a 4 node tuleta [ confirming with printks ].
that it works as expected.
quoted
Signed-off-by: Raghavendra K T <redacted>
---
arch/powerpc/mm/numa.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
@@ -80,7 +80,7 @@ static void __init setup_node_to_cpumask_map(void)setup_nr_node_ids();/* allocate the map */-for(node=0;node<nr_node_ids;node++)+for_each_node(node)alloc_bootmem_cpumask_var(&node_to_cpumask_map[node]);/* cpumask_of_node() will now work */
From: Raghavendra K T <hidden> Date: 2015-09-22 19:34:56
* Michael Ellerman [off-list ref] [2015-09-22 15:29:03]:
On Tue, 2015-09-15 at 07:38 +0530, Raghavendra K T wrote:
quoted
... nothing
Sure this patch looks obvious, but please give me a changelog that proves
you've thought about it thoroughly.
For example is it OK to use for_each_node() at this point in boot? Is there any
historical reason why we did it with a hard coded loop? If so what has changed.
What systems have you tested on? etc. etc.
cheers
Hi Michael,
resending the patches with the changelog.
Please note that the patch is in -mm tree already.
---8<---
From 86ead2520662c362d7b9ebd452ce1c33e156016f Mon Sep 17 00:00:00 2001
From: Raghavendra K T <redacted>
Date: Sun, 6 Sep 2015 12:54:40 +0530
Subject: [PATCH V2 2/2] powerpc:numa Do not allocate bootmem memory for non
existing nodes
With the setup_nr_nodes(), we have already initialized
node_possible_map. So it is safe to use for_each_node here.
There are many places in the kernel that use hardcoded 'for' loop with
nr_node_ids, because all other architectures have numa nodes populated
serially. That should be reason we had maintained the same for powerpc.
But, since sparse numa node ids possible on powerpc, we
unnecessarily allocate memory for non existent numa nodes.
For e.g., on a system with 0,1,16,17 as numa nodes nr_node_ids=18
and we allocate memory for nodes 2-14. This patch we allocate
memory for only existing numa nodes.
The patch is boot tested on a 4 node tuleta [ confirming with printks ].
that it works as expected.
Signed-off-by: Raghavendra K T <redacted>
---
arch/powerpc/mm/numa.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
@@ -80,7 +80,7 @@ static void __init setup_node_to_cpumask_map(void)setup_nr_node_ids();/* allocate the map */-for(node=0;node<nr_node_ids;node++)+for_each_node(node)alloc_bootmem_cpumask_var(&node_to_cpumask_map[node]);/* cpumask_of_node() will now work */