[Devel] [PATCH rh7 v5 8/9] mm/mem_cgroup_iter: Cleanup mem_cgroup_iter_load()

Konstantin Khorenko khorenko at virtuozzo.com
Fri Feb 26 17:26:04 MSK 2021


No functional changes here.

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

Signed-off-by: Konstantin Khorenko <khorenko at virtuozzo.com>
Reviewed-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
 mm/memcontrol.c | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 3affd9931d77..d900d1a23b53 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -1653,18 +1653,17 @@ 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.
 	 */
-		position = rcu_dereference(iter->last_visited);
+	position = rcu_dereference(iter->last_visited);
+
+	/*
+	 * 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