mm/memcg: use NUMA_NO_NODE to indicate allocation from unspecified node
Subsystems (3)
PATCH 1/4 mm/memcg: use NUMA_NO_NODE to indicate allocation from unspecified node
Instead of use "-1", let's use NUMA_NO_NODE for consistency.
--- mm/memcontrol.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/memcontrol.c +1 -1
@@ -5054,7 +5054,7 @@ static int alloc_mem_cgroup_per_node_info(struct mem_cgroup *memcg, int node)* function. */ if (!node_state (node,N_NORMAL_MEMORY )) - tmp =-1 ; + tmp =NUMA_NO_NODE ; pn =kzalloc_node (sizeof (*pn),GFP_KERNEL , tmp);if (!pn)return 1 ;
Signature · 1 line
2.33.1
PATCH 2/4 mm/memcg: mem_cgroup_per_node is already set to 0 on allocation
kzalloc_node() would set data to 0, so it's not necessary to set it again.
--- mm/memcontrol.c | 2 -- 1 file changed, 2 deletions(-)
mm/memcontrol.c +0 -2
@@ -5067,8 +5067,6 @@ static int alloc_mem_cgroup_per_node_info(struct mem_cgroup *memcg, int node) }lruvec_init (&pn->lruvec); - pn->usage_in_excess =0 ; - pn->on_tree = false; pn->memcg = memcg; memcg->nodeinfo[node] = pn;
Signature · 1 line
2.33.1
PATCH 3/4 mm/memcg: retrieve parent memcg from css.parent
In reply to Wei YangThe parent we get from page_counter is correct, while this is two different hierarchy.
Let's retrieve the parent memcg from css.parent just like parent_cs(), blkcg_parent(), etc.
--- include/linux/memcontrol.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
include/linux/memcontrol.h +1 -3
@@ -886,9 +886,7 @@ static inline struct mem_cgroup *lruvec_memcg(struct lruvec *lruvec)*/ static inline struct mem_cgroup *parent_mem_cgroup (struct mem_cgroup *memcg) { -if (!memcg->memory.parent) -return NULL ; -return mem_cgroup_from_counter (memcg->memory.parent, memory); +return mem_cgroup_from_css (memcg->css.parent); } static inline bool mem_cgroup_is_descendant(struct mem_cgroup *memcg,
Signature · 1 line
2.33.1
PATCH 4/4 mm/memcg: refine mem_cgroup_threshold_ary->current_threshold calculation
In reply to Wei Yangmem_cgroup_threshold_ary->current_threshold points to the last entry who's threshold is less or equal to usage.
Instead of iterating entries to get the correct index, we can leverage primary->current_threshold to get it. If the threshold added is less or equal to usage, current_threshold should increase by one. Otherwise, it doesn't change.
--- mm/memcontrol.c | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-)
mm/memcontrol.c +17 -14
@@ -4161,7 +4161,7 @@ static int __mem_cgroup_usage_register_event(struct mem_cgroup *memcg,struct mem_cgroup_threshold_ary *new;unsigned long threshold;unsigned long usage; -int i, size, ret; +int size, ret; ret =page_counter_memparse (args,"-1" , &threshold);if (ret)
@@ -4193,9 +4193,13 @@ static int __mem_cgroup_usage_register_event(struct mem_cgroup *memcg, new->size = size;/* Copy thresholds (if any) to new array */ -if (thresholds->primary) +if (thresholds->primary) {memcpy (new->entries, thresholds->primary->entries,flex_array_size (new, entries, size -1 )); + new->current_threshold = thresholds->primary->current_threshold; + }else { + new->current_threshold =-1 ; + }/* Add new threshold */ new->entries[size -1 ].eventfd = eventfd;
@@ -4205,18 +4209,17 @@ static int __mem_cgroup_usage_register_event(struct mem_cgroup *memcg,sort (new->entries, size,sizeof (*new->entries), compare_thresholds,NULL ); -/* Find current threshold */ - new->current_threshold =-1 ; -for (i =0 ; i < size; i++) { -if (new->entries[i].threshold <= usage) { -/* -* new->current_threshold will not be used until -* rcu_assign_pointer(), so it's safe to increment -* it here. -*/ - ++new->current_threshold; - }else -break ; +/* +* If the threshold added here is less or equal to usage, this means +* current_threshold need to increase by one. +*/ +if (threshold <= usage) { +/* +* new->current_threshold will not be used until +* rcu_assign_pointer(), so it's safe to increment +* it here. +*/ + new->current_threshold++; }/* Free old spare buffer and save old primary buffer as spare */
Signature · 1 line
2.33.1
Quoted 4 lines · Wei Yang
Instead of use "-1", let's use
NUMA_NO_NODEfor consistency.Signed-off-by Wei Yang <[email protected]>
Thanks.
Re: [PATCH 2/4] mm/memcg: mem_cgroup_per_node is already set to 0 on allocation
In reply to Wei YangQuoted 5 lines · Wei Yang
kzalloc_node()would set data to 0, so it's not necessary to set it again.Signed-off-by Wei Yang <[email protected]>
Thanks.
Re: [PATCH 3/4] mm/memcg: retrieve parent memcg from css.parent
In reply to Wei YangQuoted 8 lines · Wei Yang
The parent we get from
page_counteris correct, while this is two different hierarchy.Let's retrieve the parent memcg from css.parent just like
parent_cs(),blkcg_parent(), etc.Signed-off-by Wei Yang <[email protected]>
Thanks.
Quoted 3 lines · Wei Yang
Instead of use "-1", let's use
NUMA_NO_NODEfor consistency.Signed-off-by Wei Yang <[email protected]>
I am not really sure this is worth it. After the merge window I plan to
post http://lkml.kernel.org/r/20211214100732.26335-1-mhocko-DgEjT+Ai2yi4UlQgPVntAg@public.gmane.org
With that in place we can drop the check and a node rewrite so the net
result will be a less and more straightforward code. If you agree I can
add this with your s-o-b into my series:
mm/memcontrol.c +2 -12
@@ -5044,18 +5044,8 @@ struct mem_cgroup *mem_cgroup_from_id(unsigned short id)static int alloc_mem_cgroup_per_node_info (struct mem_cgroup *memcg,int node) {struct mem_cgroup_per_node *pn; -int tmp = node; -/* -* This routine is called against possible nodes. -* But it's BUG to call kmalloc() against offline node. -* -* TODO: this routine can waste much memory for nodes which will -* never be onlined. It's better to use memory hotplug callback -* function. -*/ -if (!node_state (node,N_NORMAL_MEMORY )) - tmp =-1 ; - pn =kzalloc_node (sizeof (*pn),GFP_KERNEL , tmp); + + pn =kzalloc_node (sizeof (*pn),GFP_KERNEL , node);if (!pn)return 1 ;
Signature · 2 lines
Michal Hocko SUSE Labs
Re: [PATCH 2/4] mm/memcg: mem_cgroup_per_node is already set to 0 on allocation
In reply to Wei YangQuoted 4 lines · Wei Yang
kzalloc_node()would set data to 0, so it's not necessary to set it again.Signed-off-by Wei Yang <[email protected]>
Quoted 19 lines
--- mm/memcontrol.c | 2 -- 1 file changed, 2 deletions(-)mm/memcontrol.c +0
-2@@ -5067,8 +5067,6 @@ static int alloc_mem_cgroup_per_node_info(struct mem_cgroup *memcg, int node) }lruvec_init (&pn->lruvec); - pn->usage_in_excess =0 ; - pn->on_tree = false; pn->memcg = memcg; memcg->nodeinfo[node] = pn;Signature · 1 line
2.33.1
Signature · 2 lines
Michal Hocko SUSE Labs
Re: [PATCH 3/4] mm/memcg: retrieve parent memcg from css.parent
In reply to Wei YangQuoted 7 lines · Wei Yang
The parent we get from
page_counteris correct, while this is two different hierarchy.Let's retrieve the parent memcg from css.parent just like
parent_cs(),blkcg_parent(), etc.Signed-off-by Wei Yang <[email protected]>
Quoted 21 lines
--- include/linux/memcontrol.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)include/linux/memcontrol.h +1
-3@@ -886,9 +886,7 @@ static inline struct mem_cgroup *lruvec_memcg(struct lruvec *lruvec)*/ static inline struct mem_cgroup *parent_mem_cgroup (struct mem_cgroup *memcg) { -if (!memcg->memory.parent) -return NULL ; -return mem_cgroup_from_counter (memcg->memory.parent, memory); +return mem_cgroup_from_css (memcg->css.parent); } static inline bool mem_cgroup_is_descendant(struct mem_cgroup *memcg,Signature · 1 line
2.33.1
Signature · 2 lines
Michal Hocko SUSE Labs
Re: [PATCH 4/4] mm/memcg: refine mem_cgroup_threshold_ary->current_threshold calculation
In reply to Wei YangQuoted 7 lines · Wei Yang
mem_cgroup_threshold_ary->current_thresholdpoints to the last entry who's threshold is less or equal to usage.Instead of iterating entries to get the correct index, we can leverage
primary->current_thresholdto get it. If the threshold added is less or equal to usage,current_thresholdshould increase by one. Otherwise, it doesn't change.
Why do we want/need this change?
Quoted 65 lines
Signed-off-by Wei Yang <[email protected]>--- mm/memcontrol.c | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-)mm/memcontrol.c +17
-14@@ -4161,7 +4161,7 @@ static int __mem_cgroup_usage_register_event(struct mem_cgroup *memcg,struct mem_cgroup_threshold_ary *new;unsigned long threshold;unsigned long usage; -int i, size, ret; +int size, ret; ret =page_counter_memparse (args,"-1" , &threshold);if (ret)@@ -4193,9 +4193,13 @@ static int __mem_cgroup_usage_register_event(struct mem_cgroup *memcg, new->size = size;/* Copy thresholds (if any) to new array */ -if (thresholds->primary) +if (thresholds->primary) {memcpy (new->entries, thresholds->primary->entries,flex_array_size (new, entries, size -1 )); + new->current_threshold = thresholds->primary->current_threshold; + }else { + new->current_threshold =-1 ; + }/* Add new threshold */ new->entries[size -1 ].eventfd = eventfd;@@ -4205,18 +4209,17 @@ static int __mem_cgroup_usage_register_event(struct mem_cgroup *memcg,sort (new->entries, size,sizeof (*new->entries), compare_thresholds,NULL ); -/* Find current threshold */ - new->current_threshold =-1 ; -for (i =0 ; i < size; i++) { -if (new->entries[i].threshold <= usage) { -/* -* new->current_threshold will not be used until -* rcu_assign_pointer(), so it's safe to increment -* it here. -*/ - ++new->current_threshold; - }else -break ; +/* +* If the threshold added here is less or equal to usage, this means +* current_threshold need to increase by one. +*/ +if (threshold <= usage) { +/* +* new->current_threshold will not be used until +* rcu_assign_pointer(), so it's safe to increment +* it here. +*/ + new->current_threshold++; }/* Free old spare buffer and save old primary buffer as spare */ Signature · 1 line
2.33.1
Signature · 2 lines
Michal Hocko SUSE Labs
Quoted 3 lines · Wei Yang
Instead of use "-1", let's use
NUMA_NO_NODEfor consistency.Signed-off-by Wei Yang <[email protected]>
If the patch won't be dropped for Michal's work, please, feel free to add
Thanks!
Re: [PATCH 2/4] mm/memcg: mem_cgroup_per_node is already set to 0 on allocation
In reply to Wei YangQuoted 4 lines · Wei Yang
kzalloc_node()would set data to 0, so it's not necessary to set it again.Signed-off-by Wei Yang <[email protected]>
Thanks!
Re: [PATCH 3/4] mm/memcg: retrieve parent memcg from css.parent
In reply to Wei YangQuoted 5 lines · Wei Yang
The parent we get from
page_counteris correct, while this is two different hierarchy.Let's retrieve the parent memcg from css.parent just like
parent_cs(),blkcg_parent(), etc.
Does it bring any benefits except consistency?
Quoted 2 lines
Signed-off-by Wei Yang <[email protected]>
Thanks!
Re: [PATCH 4/4] mm/memcg: refine mem_cgroup_threshold_ary->current_threshold calculation
In reply to Wei YangQuoted 7 lines · Wei Yang
mem_cgroup_threshold_ary->current_thresholdpoints to the last entry who's threshold is less or equal to usage.Instead of iterating entries to get the correct index, we can leverage
primary->current_thresholdto get it. If the threshold added is less or equal to usage,current_thresholdshould increase by one. Otherwise, it doesn't change.
How big is usually an array of thresholds? If it's not huge, likely any savings won't be really noticeable (it's not a hot path and there is an rc_synchronize() below).
So I agree with Michal that a better justification is really needed.
Thanks!
Re: [PATCH 3/4] mm/memcg: retrieve parent memcg from css.parent
In reply to Roman GushchinQuoted 9 lines · Roman Gushchin
Quoted 5 lines · Wei Yang
The parent we get from
page_counteris correct, while this is two different hierarchy.Let's retrieve the parent memcg from css.parent just like
parent_cs(),blkcg_parent(), etc.Does it bring any benefits except consistency?
I am afraid no.
Quoted 6 lines
Quoted 2 lines
Signed-off-by Wei Yang <[email protected]>Reviewed-by Roman Gushchin <[email protected]>Thanks!
Signature · 2 lines
Wei Yang Help you, Help me
Re: [PATCH 4/4] mm/memcg: refine mem_cgroup_threshold_ary->current_threshold calculation
In reply to Roman GushchinQuoted 4 lines · Roman Gushchin
Quoted 3 lines · Wei Yang
mem_cgroup_threshold_ary->current_thresholdpoints to the last entry who's threshold is less or equal to usage.
Quoted 8 lines
Quoted 4 lines
Instead of iterating entries to get the correct index, we can leverage
primary->current_thresholdto get it. If the threshold added is less or equal to usage,current_thresholdshould increase by one. Otherwise, it doesn't change.How big is usually an array of thresholds? If it's not huge, likely any savings won't be really noticeable (it's not a hot path and there is an
rc_synchronize()below).
Usually the size is small I think.
Quoted 2 lines
So I agree with Michal that a better justification is really needed.
Yep.
Quoted 2 lines
Thanks!
Signature · 2 lines
Wei Yang Help you, Help me
Quoted 7 lines · Michal Hocko
Quoted 3 lines · Wei Yang
Instead of use "-1", let's use
NUMA_NO_NODEfor consistency.Signed-off-by Wei Yang <[email protected]>I am not really sure this is worth it. After the merge window I plan to
post http://lkml.kernel.org/r/20211214100732.26335-1-mhocko-DgEjT+Ai2yi4UlQgPVntAg@public.gmane.org
Give me some time to understand it :-)
Quoted 10 lines · Wei Yang
Quoted 7 lines · Michal Hocko
Quoted 3 lines · Wei Yang
Instead of use "-1", let's use
NUMA_NO_NODEfor consistency.Signed-off-by Wei Yang <[email protected]>I am not really sure this is worth it. After the merge window I plan to
post http://lkml.kernel.org/r/20211214100732.26335-1-mhocko-DgEjT+Ai2yi4UlQgPVntAg@public.gmane.orgGive me some time to understand it :-)
Just for the record, here is what I have put on top of that series:
---
From b7195eba02fe6308a6927450f4630057c05e808e Mon Sep 17 00:00:00 2001
From: Wei Yang <[email protected]>
Date: Tue, 11 Jan 2022 09:45:25 +0100
Subject: [PATCH] memcg: do not tweak node in alloc_mem_cgroup_per_node_info
alloc_mem_cgroup_per_node_info is allocated for each possible node and this used to be a problem because not !node_online nodes didn't have appropriate data structure allocated. This has changed by "mm: handle uninitialized numa nodes gracefully" so we can drop the special casing here.
--- mm/memcontrol.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-)
mm/memcontrol.c +2 -12
@@ -5044,18 +5044,8 @@ struct mem_cgroup *mem_cgroup_from_id(unsigned short id)static int alloc_mem_cgroup_per_node_info (struct mem_cgroup *memcg,int node) {struct mem_cgroup_per_node *pn; -int tmp = node; -/* -* This routine is called against possible nodes. -* But it's BUG to call kmalloc() against offline node. -* -* TODO: this routine can waste much memory for nodes which will -* never be onlined. It's better to use memory hotplug callback -* function. -*/ -if (!node_state (node,N_NORMAL_MEMORY )) - tmp =-1 ; - pn =kzalloc_node (sizeof (*pn),GFP_KERNEL , tmp); + + pn =kzalloc_node (sizeof (*pn),GFP_KERNEL , node);if (!pn)return 1 ;
Signature · 6 lines
2.30.2 -- Michal Hocko SUSE Labs
Quoted 5 lines · Michal Hocko
Quoted 4 lines · Wei Yang
Quoted 3 lines · Michal Hocko
Quoted 2 lines · Wei Yang
Instead of use "-1", let's use
NUMA_NO_NODEfor consistency.
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
Signed-off-by Wei Yang <[email protected]>I am not really sure this is worth it. After the merge window I plan to
post http://lkml.kernel.org/r/20211214100732.26335-1-mhocko-DgEjT+Ai2yi4UlQgPVntAg@public.gmane.orgGive me some time to understand it :-)
Just for the record, here is what I have put on top of that series:
Ok, I got what you try to resolve. I am ok with the following change except one point.
Quoted 25 lines
---
Quoted 1 line
From
b7195eba02fe6308a6927450f4630057c05e808eMon Sep 17 00:00:00 2001From: Wei Yang <[email protected]>
Date: Tue, 11 Jan 2022 09:45:25 +0100
Subject: [PATCH] memcg: do not tweak node inalloc_mem_cgroup_per_node_info
alloc_mem_cgroup_per_node_infois allocated for each possible node and this used to be a problem because not !node_online nodes didn't have appropriate data structure allocated. This has changed by "mm: handle uninitialized numa nodes gracefully" so we can drop the special casing here.Signed-off-by Wei Yang <[email protected]>Signed-off-by Michal Hocko <mhocko-IBi9RG/[email protected]>---
mm/memcontrol.c| 14 ++------------1 file changed, 2 insertions(+), 12 deletions(-)mm/memcontrol.c +0
-0@@ -5044,18 +5044,8 @@ struct mem_cgroup *mem_cgroup_from_id(unsigned short id)static int alloc_mem_cgroup_per_node_info (struct mem_cgroup *memcg,int node) {
mm/memcontrol.c struct mem_cgroup *mem_cgroup_from_id(unsigned short id) · line 5055
Quoted 10 lines
mm/memcontrol.c +0
-9struct mem_cgroup_per_node *pn; -int tmp = node; -/* -* This routine is called against possible nodes. -* But it's BUG to call kmalloc() against offline node. -* -* TODO: this routine can waste much memory for nodes which will -* never be onlined. It's better to use memory hotplug callback -* function. -*/
Do you think this TODO is not related to this change?
Quoted 15 lines
mm/memcontrol.c +2
-3-if (!node_state (node,N_NORMAL_MEMORY )) - tmp =-1 ; - pn =kzalloc_node (sizeof (*pn),GFP_KERNEL , tmp); + + pn =kzalloc_node (sizeof (*pn),GFP_KERNEL , node);if (!pn)return 1 ;Signature · 6 lines
2.30.2 -- Michal Hocko SUSE Labs
Signature · 2 lines
Wei Yang Help you, Help me
Quoted 47 lines · Wei Yang
Quoted 5 lines · Michal Hocko
Quoted 4 lines · Wei Yang
Quoted 3 lines · Michal Hocko
Quoted 2 lines · Wei Yang
Instead of use "-1", let's use
NUMA_NO_NODEfor consistency.Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
Signed-off-by Wei Yang <[email protected]>I am not really sure this is worth it. After the merge window I plan to
post http://lkml.kernel.org/r/20211214100732.26335-1-mhocko-DgEjT+Ai2yi4UlQgPVntAg@public.gmane.orgGive me some time to understand it :-)
Just for the record, here is what I have put on top of that series:
Ok, I got what you try to resolve. I am ok with the following change except one point.
Quoted 29 lines
---
Quoted 1 line
From
b7195eba02fe6308a6927450f4630057c05e808eMon Sep 17 00:00:00 2001From: Wei Yang <[email protected]>
Date: Tue, 11 Jan 2022 09:45:25 +0100
Subject: [PATCH] memcg: do not tweak node inalloc_mem_cgroup_per_node_info
alloc_mem_cgroup_per_node_infois allocated for each possible node and this used to be a problem because not !node_online nodes didn't have appropriate data structure allocated. This has changed by "mm: handle uninitialized numa nodes gracefully" so we can drop the special casing here.Signed-off-by Wei Yang <[email protected]>Signed-off-by Michal Hocko <mhocko-IBi9RG/[email protected]>---
mm/memcontrol.c| 14 ++------------1 file changed, 2 insertions(+), 12 deletions(-)mm/memcontrol.c +0
-3@@ -5044,18 +5044,8 @@ struct mem_cgroup *mem_cgroup_from_id(unsigned short id)static int alloc_mem_cgroup_per_node_info (struct mem_cgroup *memcg,int node) {struct mem_cgroup_per_node *pn; -int tmp = node; -/* -* This routine is called against possible nodes.
Quoted 8 lines
mm/memcontrol.c struct mem_cgroup *mem_cgroup_from_id(unsigned short id) · line 5055
Quoted 6 lines
mm/memcontrol.c +0
-6-* But it's BUG to call kmalloc() against offline node. -* -* TODO: this routine can waste much memory for nodes which will -* never be onlined. It's better to use memory hotplug callback -* function. -*/ Do you think this TODO is not related to this change?
It is not really related but I am not sure how useful it is. Essentially any allocation that is per-possible node is in the same situation and if we really need to deal with large and sparse possible nodes masks.
If you want me to keep the TODO I will do it though.
Signature · 2 lines
Michal Hocko SUSE Labs
Quoted 3 lines · Wei Yang
Instead of use "-1", let's use
NUMA_NO_NODEfor consistency.Signed-off-by Wei Yang <[email protected]>
Quoted 21 lines
--- mm/memcontrol.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)mm/memcontrol.c +1
-1@@ -5054,7 +5054,7 @@ static int alloc_mem_cgroup_per_node_info(struct mem_cgroup *memcg, int node)* function. */ if (!node_state (node,N_NORMAL_MEMORY )) - tmp =-1 ; + tmp =NUMA_NO_NODE ; pn =kzalloc_node (sizeof (*pn),GFP_KERNEL , tmp);if (!pn)return 1 ;Signature · 1 line
2.33.1
Signature · 2 lines
Sincerely yours, Mike.
Re: [PATCH 2/4] mm/memcg: mem_cgroup_per_node is already set to 0 on allocation
In reply to Wei YangQuoted 4 lines · Wei Yang
kzalloc_node()would set data to 0, so it's not necessary to set it again.Signed-off-by Wei Yang <[email protected]>
Quoted 21 lines
--- mm/memcontrol.c | 2 -- 1 file changed, 2 deletions(-)mm/memcontrol.c +0
-2@@ -5067,8 +5067,6 @@ static int alloc_mem_cgroup_per_node_info(struct mem_cgroup *memcg, int node) }lruvec_init (&pn->lruvec); - pn->usage_in_excess =0 ; - pn->on_tree = false; pn->memcg = memcg; memcg->nodeinfo[node] = pn;Signature · 1 line
2.33.1
Signature · 2 lines
Sincerely yours, Mike.
Quoted 57 lines · Michal Hocko
Quoted 47 lines · Wei Yang
Quoted 5 lines · Michal Hocko
Quoted 4 lines · Wei Yang
Quoted 3 lines · Michal Hocko
Quoted 2 lines · Wei Yang
Instead of use "-1", let's use
NUMA_NO_NODEfor consistency.Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
Signed-off-by Wei Yang <[email protected]>I am not really sure this is worth it. After the merge window I plan to
post http://lkml.kernel.org/r/20211214100732.26335-1-mhocko-DgEjT+Ai2yi4UlQgPVntAg@public.gmane.orgGive me some time to understand it :-)
Just for the record, here is what I have put on top of that series:
Ok, I got what you try to resolve. I am ok with the following change except one point.
Quoted 29 lines
---
Quoted 1 line
From
b7195eba02fe6308a6927450f4630057c05e808eMon Sep 17 00:00:00 2001From: Wei Yang <[email protected]>
Date: Tue, 11 Jan 2022 09:45:25 +0100
Subject: [PATCH] memcg: do not tweak node inalloc_mem_cgroup_per_node_info
alloc_mem_cgroup_per_node_infois allocated for each possible node and this used to be a problem because not !node_online nodes didn't have appropriate data structure allocated. This has changed by "mm: handle uninitialized numa nodes gracefully" so we can drop the special casing here.Signed-off-by Wei Yang <[email protected]>Signed-off-by Michal Hocko <mhocko-IBi9RG/[email protected]>---
mm/memcontrol.c| 14 ++------------1 file changed, 2 insertions(+), 12 deletions(-)mm/memcontrol.c +0
-3@@ -5044,18 +5044,8 @@ struct mem_cgroup *mem_cgroup_from_id(unsigned short id)static int alloc_mem_cgroup_per_node_info (struct mem_cgroup *memcg,int node) {struct mem_cgroup_per_node *pn; -int tmp = node; -/* -* This routine is called against possible nodes. Quoted 8 lines
mm/memcontrol.c struct mem_cgroup *mem_cgroup_from_id(unsigned short id) · line 5055
Quoted 6 lines
mm/memcontrol.c +0
-6-* But it's BUG to call kmalloc() against offline node. -* -* TODO: this routine can waste much memory for nodes which will -* never be onlined. It's better to use memory hotplug callback -* function. -*/ Do you think this TODO is not related to this change?
Quoted 4 lines
It is not really related but I am not sure how useful it is. Essentially any allocation that is per-possible node is in the same situation and if we really need to deal with large and sparse possible nodes masks.
Sounds reasonable :-)
Quoted 5 lines
If you want me to keep the TODO I will do it though.
Signature · 2 lines
Michal Hocko SUSE Labs
Signature · 2 lines
Wei Yang Help you, Help me
Shakeel Butt
Reviewed-byQuoted 20 lines · Michal Hocko
Quoted 10 lines · Wei Yang
Quoted 7 lines · Michal Hocko
Quoted 3 lines · Wei Yang
Instead of use "-1", let's use
NUMA_NO_NODEfor consistency.Signed-off-by Wei Yang <[email protected]>I am not really sure this is worth it. After the merge window I plan to
post http://lkml.kernel.org/r/20211214100732.26335-1-mhocko-DgEjT+Ai2yi4UlQgPVntAg@public.gmane.orgGive me some time to understand it :-)
Just for the record, here is what I have put on top of that series:
---
Fromb7195eba02fe6308a6927450f4630057c05e808eMon Sep 17 00:00:00 2001
From: Wei Yang <[email protected]>
Date: Tue, 11 Jan 2022 09:45:25 +0100
Subject: [PATCH] memcg: do not tweak node inalloc_mem_cgroup_per_node_info
Quoted 8 lines
alloc_mem_cgroup_per_node_infois allocated for each possible node and this used to be a problem because not !node_online nodes didn't have appropriate data structure allocated. This has changed by "mm: handle uninitialized numa nodes gracefully" so we can drop the special casing here.Signed-off-by Wei Yang <[email protected]>Signed-off-by Michal Hocko <mhocko-IBi9RG/[email protected]>
Re: [PATCH 2/4] mm/memcg: mem_cgroup_per_node is already set to 0 on allocation
In reply to Wei YangQuoted 5 lines · Wei Yang
kzalloc_node()would set data to 0, so it's not necessary to set it again.Signed-off-by Wei Yang <[email protected]>
Re: [PATCH 3/4] mm/memcg: retrieve parent memcg from css.parent
In reply to Wei YangQuoted 8 lines · Wei Yang
The parent we get from
page_counteris correct, while this is two different hierarchy.Let's retrieve the parent memcg from css.parent just like
parent_cs(),blkcg_parent(), etc.Signed-off-by Wei Yang <[email protected]>
Hi, Andrew
Would you pick up this patch set, or prefer me to send a v2?
Quoted 22 lines · Wei Yang
Instead of use "-1", let's use
NUMA_NO_NODEfor consistency.Signed-off-by Wei Yang <[email protected]>---
mm/memcontrol.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)mm/memcontrol.c +1
-1@@ -5054,7 +5054,7 @@ static int alloc_mem_cgroup_per_node_info(struct mem_cgroup *memcg, int node)* function. */ if (!node_state (node,N_NORMAL_MEMORY )) - tmp =-1 ; + tmp =NUMA_NO_NODE ; pn =kzalloc_node (sizeof (*pn),GFP_KERNEL , tmp);if (!pn)return 1 ;Signature · 1 line
2.33.1
Signature · 2 lines
Wei Yang Help you, Help me
Andrew Morton
maintainerQuoted 4 lines · On Mon, 31 Jan 2022 01:47:42 +0000 Wei Yang…
Hi, Andrew
Would you pick up this patch set, or prefer me to send a v2?
It's unclear to me what's happening with [4/4]. At least a new changelog with more justification is expected?
So yes, please resend?
Quoted 10 lines · Andrew Morton
Quoted 4 lines · On Mon, 31 Jan 2022 01:47:42 +0000 Wei Yang…
Hi, Andrew
Would you pick up this patch set, or prefer me to send a v2?
It's unclear to me what's happening with [4/4]. At least a new changelog with more justification is expected?
As Michal and Roman suggested, this is not a hot-path. I would drop this one.
Quoted 1 line
So yes, please resend?
Sure.
Signature · 2 lines
Wei Yang Help you, Help me