[Devel] [PATCH rh7 v4 3/9] mm/mem_cgroup_iter: Make 'iter->last_visited' a bit more stable
Konstantin Khorenko
khorenko at virtuozzo.com
Wed Feb 24 21:55:35 MSK 2021
In fact this patch does not change the logic, but after it
we can state that iter->last_visited _always_ contains valid
pointer until the iter is "break-ed".
Why? Because 'last_visited' is always assigned in _update()
to the memcg which has passed css_tryget(), so css won't be
ever offlined (and moreover - destroyed) until we css_put() it.
And if now we call css_put() after iter->last_visited is
assigned a new cgroup, the only case when 'last_visited' may
contain invalid entry is "break-ed" mem_cgroup_iter().
https://jira.sw.ru/browse/PSBM-123655
Signed-off-by: Konstantin Khorenko <khorenko at virtuozzo.com>
---
mm/memcontrol.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index d3a35a13ae4d..8040f09425bf 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -1614,9 +1614,6 @@ static void mem_cgroup_iter_update(struct mem_cgroup_reclaim_iter *iter,
struct mem_cgroup *root,
int sequence)
{
- /* root reference counting symmetric to mem_cgroup_iter_load */
- if (last_visited && last_visited != root)
- css_put(&last_visited->css);
/*
* We store the sequence count from the time @last_visited was
* loaded successfully instead of rereading it here so that we
@@ -1626,6 +1623,10 @@ static void mem_cgroup_iter_update(struct mem_cgroup_reclaim_iter *iter,
iter->last_visited = new_position;
smp_wmb();
iter->last_dead_count = sequence;
+
+ /* root reference counting symmetric to mem_cgroup_iter_load */
+ if (last_visited && last_visited != root)
+ css_put(&last_visited->css);
}
/**
--
2.24.3
More information about the Devel
mailing list