[Devel] [PATCH RHEL9 COMMIT] memcg: Add a comment on using page_memcg() in cleancache code
Konstantin Khorenko
khorenko at virtuozzo.com
Wed Oct 20 18:10:27 MSK 2021
The commit is pushed to "branch-rh9-5.14.vz9.1.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh9-5.14.0-4.vz9.10.13
------>
commit ef37d176e210c32a23e65236d3086e34a7f762ed
Author: Nikita Yushchenko <nikita.yushchenko at virtuozzo.com>
Date: Wed Oct 20 18:07:51 2021 +0300
memcg: Add a comment on using page_memcg() in cleancache code
To_merge: e94505ccca99 ("memcg: allow to disable cleancache per memcg")
Signed-off-by: Nikita Yushchenko <nikita.yushchenko at virtuozzo.com>
---
mm/memcontrol.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index f63f998ceccb..19a5638ce1dc 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -1322,6 +1322,16 @@ bool mem_cgroup_cleancache_disabled(struct page *page)
if (mem_cgroup_disabled())
return false;
+ /*
+ * On all paths to mem_cgroup_cleancache_disabled(), the page in
+ * question is locked. Calls go from __delete_from_page_cache() or
+ * from delete_from_page_cache_batch(), in both cases page lock is
+ * mandatory.
+ *
+ * Per comment in the documentation of page_memcg(), holding page lock
+ * guarantees stability of the value returned from page_memcg().
+ * Thus using page_memcg() is safe, rcu is not needed.
+ */
memcg = page_memcg(page);
return memcg && memcg->cleancache_disabled;
}
More information about the Devel
mailing list