Skip to contentSkip to conversation

mm/memcg: non-hierarchical mode is deprecated

PATCH Applied Wei Yang 4 participants 7 messages Apr 3, 2022 – Apr 5, 2022

Subsystems (3)
lore
Share & tools
lore

Wei Yang

author
#0 lore raw

PATCH 1/1 mm/memcg: non-hierarchical mode is deprecated

After commit bef8620cd8e0 ("mm: memcg: deprecate the non-hierarchical mode"), we won't have a NULL parent except root_mem_cgroup. And this case is handled when (memcg == root).

CC Roman Gushchin <[email protected]>
CC Johannes Weiner <[email protected]>
---
 mm/memcontrol.c | 3 ---
 1 file changed, 3 deletions(-)
mm/memcontrol.c +0 -3
index 2cd8bfdec379..3ceb9b8592b1 100644
@@ -6587,9 +6587,6 @@ void mem_cgroup_calculate_protection(struct mem_cgroup *root,
 		return;
 
 	parent = parent_mem_cgroup(memcg);
-	/* No parent means a non-hierarchical mode on v1 memcg */
-	if (!parent)
-		return;
 
 	if (parent == root) {
 		memcg->memory.emin = READ_ONCE(memcg->memory.min);
Signature · 1 line
2.33.1
Acked-by on v1 1/1
#1 lore raw
Quoted 7 lines · Wei Yang

After commit bef8620cd8e0 ("mm: memcg: deprecate the non-hierarchical mode"), we won't have a NULL parent except root_mem_cgroup. And this case is handled when (memcg == root).

CC Roman Gushchin <[email protected]>
CC Johannes Weiner <[email protected]>

Thanks!

Quoted 20 lines
---
 mm/memcontrol.c | 3 ---
 1 file changed, 3 deletions(-)
mm/memcontrol.c +0 -3
index 2cd8bfdec379..3ceb9b8592b1 100644
@@ -6587,9 +6587,6 @@ void mem_cgroup_calculate_protection(struct mem_cgroup *root,
 		return;
 
 	parent = parent_mem_cgroup(memcg);
-	/* No parent means a non-hierarchical mode on v1 memcg */
-	if (!parent)
-		return;
 
 	if (parent == root) {
 		memcg->memory.emin = READ_ONCE(memcg->memory.min);
Signature · 1 line
2.33.1
Signature · 2 lines
Michal Hocko
SUSE Labs
author
#2 lore raw
Quoted 5 lines · Michal Hocko
Quoted 4 lines · Wei Yang

After commit bef8620cd8e0 ("mm: memcg: deprecate the non-hierarchical mode"), we won't have a NULL parent except root_mem_cgroup. And this case is handled when (memcg == root).

Quoted 7 lines
Quoted 3 lines
CC Roman Gushchin <[email protected]>
CC Johannes Weiner <[email protected]>

Thanks!

Thanks for the ack. When reading the code, I found one redundant check in shrink_node_memcgs().

shrink_node_memcgs
mem_cgroup_below_min
mem_cgroup_supports_protection
mem_cgroup_below_low
mem_cgroup_supports_protection

I am not sure it worthwhile to take it out.

shrink_node_memcgs
mem_cgroup_supports_protection
mem_cgroup_below_min
mem_cgroup_below_low

Look forward your opinion.

Signature · 2 lines
Wei Yang
Help you, Help me
#3 lore raw
Quoted 23 lines · Wei Yang
Quoted 5 lines · Michal Hocko
Quoted 4 lines · Wei Yang

After commit bef8620cd8e0 ("mm: memcg: deprecate the non-hierarchical mode"), we won't have a NULL parent except root_mem_cgroup. And this case is handled when (memcg == root).

Quoted 7 lines
Quoted 3 lines
CC Roman Gushchin <[email protected]>
CC Johannes Weiner <[email protected]>

Thanks!

Thanks for the ack. When reading the code, I found one redundant check in shrink_node_memcgs().

shrink_node_memcgs
mem_cgroup_below_min
mem_cgroup_supports_protection
mem_cgroup_below_low
mem_cgroup_supports_protection

Quoted 8 lines

I am not sure it worthwhile to take it out.

shrink_node_memcgs
mem_cgroup_supports_protection
mem_cgroup_below_min
mem_cgroup_below_low

Look forward your opinion.

I guess you refer to mem_cgroup_is_root check in mem_cgroup_supports_protection, right?

You are right that the check is not really required because e{min,low} should always stay at 0 for the root memcg AFAICS. On the other hand the check is not in any hot path and it really adds clarity here because protection is not really supported on the root memcg. So I am not this is an overall win.

Signature · 2 lines
Michal Hocko
SUSE Labs
author
#4 lore raw
Quoted 33 lines · Michal Hocko
Quoted 23 lines · Wei Yang
Quoted 5 lines · Michal Hocko
Quoted 4 lines · Wei Yang

After commit bef8620cd8e0 ("mm: memcg: deprecate the non-hierarchical mode"), we won't have a NULL parent except root_mem_cgroup. And this case is handled when (memcg == root).

Quoted 7 lines
Quoted 3 lines
CC Roman Gushchin <[email protected]>
CC Johannes Weiner <[email protected]>

Thanks!

Thanks for the ack. When reading the code, I found one redundant check in shrink_node_memcgs().

shrink_node_memcgs
mem_cgroup_below_min
mem_cgroup_supports_protection
mem_cgroup_below_low
mem_cgroup_supports_protection

Quoted 8 lines

I am not sure it worthwhile to take it out.

shrink_node_memcgs
mem_cgroup_supports_protection
mem_cgroup_below_min
mem_cgroup_below_low

Look forward your opinion.

Quoted 8 lines

I guess you refer to mem_cgroup_is_root check in mem_cgroup_supports_protection, right?

You are right that the check is not really required because e{min,low} should always stay at 0 for the root memcg AFAICS. On the other hand the check is not in any hot path and it really adds clarity here because protection is not really supported on the root memcg. So I am not this is an overall win.

Agree.

Quoted 3 lines
Signature · 2 lines
Michal Hocko
SUSE Labs
Signature · 2 lines
Wei Yang
Help you, Help me
maintainer Reviewed-by on v1 1/1
#5 lore raw
In reply to Wei Yang
Quoted 7 lines · Wei Yang

After commit bef8620cd8e0 ("mm: memcg: deprecate the non-hierarchical mode"), we won't have a NULL parent except root_mem_cgroup. And this case is handled when (memcg == root).

CC Roman Gushchin <[email protected]>
CC Johannes Weiner <[email protected]>

Thanks!

Quoted 21 lines
---
 mm/memcontrol.c | 3 ---
 1 file changed, 3 deletions(-)
mm/memcontrol.c +0 -3
index 2cd8bfdec379..3ceb9b8592b1 100644
@@ -6587,9 +6587,6 @@ void mem_cgroup_calculate_protection(struct mem_cgroup *root,
 		return;
 
 	parent = parent_mem_cgroup(memcg);
-	/* No parent means a non-hierarchical mode on v1 memcg */
-	if (!parent)
-		return;
 
 	if (parent == root) {
 		memcg->memory.emin = READ_ONCE(memcg->memory.min);
Signature · 1 line
2.33.1