[Devel] [PATCH rh7 8/8] mm/mem_cgroup_iter: Drop dead_count related infrastructure

Konstantin Khorenko khorenko at virtuozzo.com
Sat Feb 20 12:24:14 MSK 2021


As we now have stable and reliable iter->last_visited,
don't need to save/compare number of destroyed cgroups.

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

Signed-off-by: Konstantin Khorenko <khorenko at virtuozzo.com>
---
 mm/memcontrol.c | 22 ++++------------------
 1 file changed, 4 insertions(+), 18 deletions(-)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 62bc824adb53..73c0232e6303 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -196,7 +196,6 @@ struct mem_cgroup_reclaim_iter {
 	 * If stored memcg is destroyed, the field is wiped.
 	 */
 	struct mem_cgroup *last_visited;
-	unsigned long last_dead_count;
 	seqlock_t last_visited_lock;
 
 	/* scan generation, increased every round-trip */
@@ -403,7 +402,6 @@ struct mem_cgroup {
 	spinlock_t pcp_counter_lock;
 	atomic_long_t	oom;
 
-	atomic_t	dead_count;
 #if defined(CONFIG_MEMCG_KMEM) && defined(CONFIG_INET)
 	struct tcp_memcontrol tcp_mem;
 	struct udp_memcontrol udp_mem;
@@ -1621,19 +1619,11 @@ static void mem_cgroup_iter_invalidate(struct mem_cgroup *root,
 			}
 		}
 	}
-
-	/*
-	 * When a group in the hierarchy below root is destroyed, the
-	 * hierarchy iterator can no longer be trusted since it might
-	 * have pointed to the destroyed group.  Invalidate it.
-	 */
-	atomic_inc(&root->dead_count);
 }
 
 static struct mem_cgroup *
 mem_cgroup_iter_load(struct mem_cgroup_reclaim_iter *iter,
-		     struct mem_cgroup *root,
-		     int *sequence)
+		     struct mem_cgroup *root)
 {
 	struct mem_cgroup *position;
 	unsigned seq;
@@ -1666,8 +1656,7 @@ mem_cgroup_iter_load(struct mem_cgroup_reclaim_iter *iter,
 static void mem_cgroup_iter_update(struct mem_cgroup_reclaim_iter *iter,
 				   struct mem_cgroup *last_visited,
 				   struct mem_cgroup *new_position,
-				   struct mem_cgroup *root,
-				   int sequence)
+				   struct mem_cgroup *root)
 {
 	/*
 	 * The position saved in 'last_visited' is always valid.
@@ -1676,7 +1665,6 @@ static void mem_cgroup_iter_update(struct mem_cgroup_reclaim_iter *iter,
 	 */
 	write_seqlock(&iter->last_visited_lock);
 	iter->last_visited = new_position;
-	iter->last_dead_count = sequence;
 	write_sequnlock(&iter->last_visited_lock);
 
 	/* root reference counting symmetric to mem_cgroup_iter_load */
@@ -1726,7 +1714,6 @@ struct mem_cgroup *mem_cgroup_iter(struct mem_cgroup *root,
 	rcu_read_lock();
 	while (!memcg) {
 		struct mem_cgroup_reclaim_iter *uninitialized_var(iter);
-		int uninitialized_var(seq);
 
 		if (reclaim) {
 			int nid = zone_to_nid(reclaim->zone);
@@ -1742,14 +1729,13 @@ struct mem_cgroup *mem_cgroup_iter(struct mem_cgroup *root,
 				goto out_unlock;
 			}
 
-			last_visited = mem_cgroup_iter_load(iter, root, &seq);
+			last_visited = mem_cgroup_iter_load(iter, root);
 		}
 
 		memcg = __mem_cgroup_iter_next(root, last_visited);
 
 		if (reclaim) {
-			mem_cgroup_iter_update(iter, last_visited, memcg, root,
-					seq);
+			mem_cgroup_iter_update(iter, last_visited, memcg, root);
 
 			if (!memcg)
 				iter->generation++;
-- 
2.24.3



More information about the Devel mailing list