[Devel] [PATCH rh7 7/8] mm/mem_cgroup_iter: Cleanup mem_cgroup_iter_load()
Konstantin Khorenko
khorenko at virtuozzo.com
Sat Feb 20 12:24:13 MSK 2021
No functional changes here.
https://jira.sw.ru/browse/PSBM-123655
Signed-off-by: Konstantin Khorenko <khorenko at virtuozzo.com>
---
mm/memcontrol.c | 25 +++++++++++--------------
1 file changed, 11 insertions(+), 14 deletions(-)
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 39b3350eddf9..62bc824adb53 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -1646,23 +1646,20 @@ mem_cgroup_iter_load(struct mem_cgroup_reclaim_iter *iter,
* offlining. The RCU lock ensures the object won't be
* released, tryget will fail if we lost the race.
*/
-retry:
- seq = read_seqbegin(&iter->last_visited_lock);
+ do {
+ seq = read_seqbegin(&iter->last_visited_lock);
position = READ_ONCE(iter->last_visited);
+ } while (read_seqretry(&iter->last_visited_lock, seq));
- if (read_seqretry(&iter->last_visited_lock, seq))
- goto retry;
+ /*
+ * We cannot take a reference to root because we might race
+ * with root removal and returning NULL would end up in
+ * an endless loop on the iterator user level when root
+ * would be returned all the time.
+ */
+ if (position && position != root && !css_tryget(&position->css))
+ position = NULL;
- /*
- * We cannot take a reference to root because we might race
- * with root removal and returning NULL would end up in
- * an endless loop on the iterator user level when root
- * would be returned all the time.
- */
- if (position && position != root &&
- !css_tryget(&position->css))
-
- position = NULL;
return position;
}
--
2.24.3
More information about the Devel
mailing list