Skip to contentSkip to conversation

mm, memcg: Bypass high reclaim iteration for cgroup hierarchy root

PATCH Applied Chris Down 3 participants 3 messages Mar 12, 2020 – Apr 2, 2020

Subsystems (3)
lore
Share & tools
lore

Chris Down

author
#0 lore raw

PATCH 1/1 mm, memcg: Bypass high reclaim iteration for cgroup hierarchy root

The root of the hierarchy cannot have high set, so we will never reclaim based on it. This makes that clearer and avoids another entry.

---
 mm/memcontrol.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
mm/memcontrol.c +2 -1
index 63bb6a2aab81..ab9d24a657b9 100644
@@ -2232,7 +2232,8 @@ static void reclaim_high(struct mem_cgroup *memcg,
 			continue;
 		memcg_memory_event(memcg, MEMCG_HIGH);
 		try_to_free_mem_cgroup_pages(memcg, nr_pages, gfp_mask, true);
-	} while ((memcg = parent_mem_cgroup(memcg)));
+	} while ((memcg = parent_mem_cgroup(memcg)) &&
+		 !mem_cgroup_is_root(memcg));
 }
 
 static void high_work_func(struct work_struct *work)
Signature · 1 line
2.25.1
maintainer
#1 lore raw
Quoted 8 lines · On Thu, 12 Mar 2020 16:41:37 +0000 Chris Down…

The root of the hierarchy cannot have high set, so we will never reclaim based on it. This makes that clearer and avoids another entry.

...

mm/memcontrol.c static void reclaim_high(struct mem_cgroup *memcg, · line 2239

Quoted 9 lines
mm/memcontrol.c +2 -1
@@ -2232,7 +2232,8 @@ static void reclaim_high(struct mem_cgroup *memcg,
 			continue;
 		memcg_memory_event(memcg, MEMCG_HIGH);
 		try_to_free_mem_cgroup_pages(memcg, nr_pages, gfp_mask, true);
-	} while ((memcg = parent_mem_cgroup(memcg)));
+	} while ((memcg = parent_mem_cgroup(memcg)) &&
+		 !mem_cgroup_is_root(memcg));
 }
 
 static void high_work_func(struct work_struct *work)

Does someone have time to review this one?

Thanks.

maintainer Acked-by on v1 1/1
#2 lore raw
In reply to Chris Down
Quoted 11 lines · Chris Down

The root of the hierarchy cannot have high set, so we will never reclaim based on it. This makes that clearer and avoids another entry.

This makes sense, memory.high doesn't exist on the root.

And the mem_cgroup_is_root() check, a simple pointer comparison, is cheaper than reading the page_counter atomic and memcg->high (which we already know to be PAGE_COUNTER_MAX).