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 <[email protected]>
---
 mm/memcontrol.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index ba107b12f314..23f37b129fc7 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -1568,6 +1568,30 @@ 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;
+       struct mem_cgroup *pos;
+       seqlock_t *lock;
+       int zone, node, i;
+       unsigned seq;
+
+       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];
+                               lock = &iter->last_visited_lock;
+
+                               write_seqlock(lock);
+                               pos = iter->last_visited;
+                               iter->last_visited = NULL;
+                               write_sequnlock(lock);
+                               }
+                       }
+               }
+       }
+
        /*
         * When a group in the hierarchy below root is destroyed, the
         * hierarchy iterator can no longer be trusted since it might
-- 
2.24.3

_______________________________________________
Devel mailing list
[email protected]
https://lists.openvz.org/mailman/listinfo/devel

Reply via email to