From: Raghavendra K T <hidden> Date: 2015-09-08 18:30:20
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.
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 | 23 +++++++++++++++--------
2 files changed, 16 insertions(+), 9 deletions(-)
--
1.7.11.7
From: Raghavendra K T <hidden> Date: 2015-09-08 18:30:34
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.
Signed-off-by: Raghavendra K T <redacted>
---
mm/list_lru.c | 23 +++++++++++++++--------
1 file changed, 15 insertions(+), 8 deletions(-)
@@ -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: Vladimir Davydov <hidden> Date: 2015-09-14 09:00:35
Hi,
On Wed, Sep 09, 2015 at 12:01:46AM +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.
Do I understand correctly that node 0 must always be in
node_possible_map? I ask, because we currently test
lru->node[0].memcg_lrus to determine if the list is memcg aware.
quoted hunk
Signed-off-by: Raghavendra K T <redacted>
---
mm/list_lru.c | 23 +++++++++++++++--------
1 file changed, 15 insertions(+), 8 deletions(-)
So, we don't explicitly initialize memcg_lrus for nodes that are not in
node_possible_map. That's OK, because we allocate lru->node using
kzalloc. However, this partial nullifying in case !memcg_aware looks
confusing IMO. Let's drop it, I mean something like this:
static int memcg_init_list_lru(struct list_lru *lru, bool memcg_aware)
{
int i;
if (!memcg_aware)
return 0;
for_each_node(i) {
if (memcg_init_list_lru_node(&lru->node[i]))
goto fail;
}
Thanks,
Vladimir
From: Raghavendra K T <hidden> Date: 2015-09-14 11:38:48
On 09/14/2015 02:30 PM, Vladimir Davydov wrote:
Hi,
On Wed, Sep 09, 2015 at 12:01:46AM +0530, Raghavendra K T wrote:
quoted
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.
Do I understand correctly that node 0 must always be in
node_possible_map? I ask, because we currently test
lru->node[0].memcg_lrus to determine if the list is memcg aware.
Yes, node 0 is always there. So it should not be a problem.
quoted
Signed-off-by: Raghavendra K T <redacted>
---
mm/list_lru.c | 23 +++++++++++++++--------
1 file changed, 15 insertions(+), 8 deletions(-)
So, we don't explicitly initialize memcg_lrus for nodes that are not in
node_possible_map. That's OK, because we allocate lru->node using
kzalloc. However, this partial nullifying in case !memcg_aware looks
confusing IMO. Let's drop it, I mean something like this:
Yes, you are right. and we do not have to have memcg_aware check inside
for loop too.
Will change as per your suggestion and send V2.
Thanks for the review.
static int memcg_init_list_lru(struct list_lru *lru, bool memcg_aware)
{
int i;
if (!memcg_aware)
return 0;
for_each_node(i) {
if (memcg_init_list_lru_node(&lru->node[i]))
goto fail;
}
From: Vladimir Davydov <hidden> Date: 2015-09-14 12:05:17
On Mon, Sep 14, 2015 at 05:09:31PM +0530, Raghavendra K T wrote:
On 09/14/2015 02:30 PM, Vladimir Davydov wrote:
quoted
On Wed, Sep 09, 2015 at 12:01:46AM +0530, Raghavendra K T wrote:
quoted
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.
Do I understand correctly that node 0 must always be in
node_possible_map? I ask, because we currently test
lru->node[0].memcg_lrus to determine if the list is memcg aware.
Yes, node 0 is always there. So it should not be a problem.
I think it should be mentioned in the comment to list_lru_memcg_aware
then.
Thanks,
Vladimir
From: Raghavendra K T <hidden> Date: 2015-09-14 13:05:17
On 09/14/2015 05:34 PM, Vladimir Davydov wrote:
On Mon, Sep 14, 2015 at 05:09:31PM +0530, Raghavendra K T wrote:
quoted
On 09/14/2015 02:30 PM, Vladimir Davydov wrote:
quoted
On Wed, Sep 09, 2015 at 12:01:46AM +0530, Raghavendra K T wrote:
quoted
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.
Do I understand correctly that node 0 must always be in
node_possible_map? I ask, because we currently test
lru->node[0].memcg_lrus to determine if the list is memcg aware.
Yes, node 0 is always there. So it should not be a problem.
I think it should be mentioned in the comment to list_lru_memcg_aware
then.
Something like this: ?
static inline bool list_lru_memcg_aware(struct list_lru *lru)
{
/*
* This needs node 0 to be always present, even
* in the systems supporting sparse numa ids.
*/
return !!lru->node[0].memcg_lrus;
}
From: Vladimir Davydov <hidden> Date: 2015-09-14 13:27:41
On Mon, Sep 14, 2015 at 06:35:59PM +0530, Raghavendra K T wrote:
On 09/14/2015 05:34 PM, Vladimir Davydov wrote:
quoted
On Mon, Sep 14, 2015 at 05:09:31PM +0530, Raghavendra K T wrote:
quoted
On 09/14/2015 02:30 PM, Vladimir Davydov wrote:
quoted
On Wed, Sep 09, 2015 at 12:01:46AM +0530, Raghavendra K T wrote:
quoted
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.
Do I understand correctly that node 0 must always be in
node_possible_map? I ask, because we currently test
lru->node[0].memcg_lrus to determine if the list is memcg aware.
Yes, node 0 is always there. So it should not be a problem.
I think it should be mentioned in the comment to list_lru_memcg_aware
then.
Something like this: ?
Yeah, looks good to me.
Thanks,
Vladimir
static inline bool list_lru_memcg_aware(struct list_lru *lru)
{
/*
* This needs node 0 to be always present, even
* in the systems supporting sparse numa ids.
*/
return !!lru->node[0].memcg_lrus;
}