[PATCH v3 48/49] mm: shrinker: hold write lock to reparent shrinker nr_deferred
Qi Zheng
zhengqi.arch at bytedance.com
Thu Jul 27 08:05:01 UTC 2023
For now, reparent_shrinker_deferred() is the only holder of read lock of
shrinker_rwsem. And it already holds the global cgroup_mutex, so it will
not be called in parallel.
Therefore, in order to convert shrinker_rwsem to shrinker_mutex later,
here we change to hold the write lock of shrinker_rwsem to reparent.
Signed-off-by: Qi Zheng <zhengqi.arch at bytedance.com>
---
mm/shrinker.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/mm/shrinker.c b/mm/shrinker.c
index fee6f62904fb..a12dede5d21f 100644
--- a/mm/shrinker.c
+++ b/mm/shrinker.c
@@ -299,7 +299,7 @@ void reparent_shrinker_deferred(struct mem_cgroup *memcg)
parent = root_mem_cgroup;
/* Prevent from concurrent shrinker_info expand */
- down_read(&shrinker_rwsem);
+ down_write(&shrinker_rwsem);
for_each_node(nid) {
child_info = shrinker_info_protected(memcg, nid);
parent_info = shrinker_info_protected(parent, nid);
@@ -312,7 +312,7 @@ void reparent_shrinker_deferred(struct mem_cgroup *memcg)
}
}
}
- up_read(&shrinker_rwsem);
+ up_write(&shrinker_rwsem);
}
#else
static int shrinker_memcg_alloc(struct shrinker *shrinker)
--
2.30.2
More information about the dri-devel
mailing list