[rh7,v4,8/9] mm/mem_cgroup_iter: Cleanup mem_cgroup_iter_load()

Submitted by Konstantin Khorenko on Feb. 24, 2021, 6:55 p.m.

Details

Message ID 20210224185541.862-9-khorenko@virtuozzo.com
State New
Series "mm/mem_cgroup_iter: Reduce the number of iterator restarts upon cgroup removals"
Headers show

Commit Message

Konstantin Khorenko Feb. 24, 2021, 6:55 p.m.
No functional changes here.

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

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

Patch hide | download patch | download mbox

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index cdb7f6f4c994..3e8607c62035 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;
 }