[Devel] [PATCH rh7 v2 05/10] mm/mem_cgroup_iter: NULL-ify 'last_visited' for invalidated iterators

Konstantin Khorenko khorenko at virtuozzo.com
Wed Feb 24 13:48:00 MSK 2021


Our target is to invalidate only those iterators which have our
dying memcg as 'last_visited' and put NULL there instead.

As the first step let's put NULL to all iterators'
'last_visited' we are invalidating.

https://jira.sw.ru/browse/PSBM-123655

Signed-off-by: Konstantin Khorenko <khorenko at virtuozzo.com>
---
 mm/memcontrol.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 2f1dfb0de524..c56d68d12c24 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -1567,6 +1567,22 @@ static struct mem_cgroup *__mem_cgroup_iter_next(struct mem_cgroup *root,
 
 static void mem_cgroup_iter_invalidate(struct mem_cgroup *root)
 {
+	struct mem_cgroup_reclaim_iter *iter;
+	struct mem_cgroup_per_zone *mz;
+	int zone, node, i;
+
+	for_each_node(node) {
+		for (zone = 0; zone < MAX_NR_ZONES; zone++) {
+			mz = mem_cgroup_zoneinfo(root, node, zone);
+
+			for (i = 0; i < ARRAY_SIZE(mz->reclaim_iter); i++) {
+				iter = &mz->reclaim_iter[i];
+				rcu_assign_pointer(iter->last_visited, NULL);
+				}
+			}
+		}
+	}
+
 	/*
 	 * When a group in the hierarchy below root is destroyed, the
 	 * hierarchy iterator can no longer be trusted since it might
-- 
2.24.3



More information about the Devel mailing list