[Devel] [PATCH rh7 3/8] mm/mem_cgroup_iter: NULL-ify 'last_visited' for invalidated iterators
Konstantin Khorenko
khorenko at virtuozzo.com
Sat Feb 20 12:24:09 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 | 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
More information about the Devel
mailing list