From b85940e9fff9236534a5800d849e906fa99ee2d7 Mon Sep 17 00:00:00 2001 From: Sooyong Suk Date: Thu, 24 Jul 2025 08:54:46 +0900 Subject: [PATCH] ANDROID: mm: add vendor hook to allow nonworkingset for gcma Gcma put page is only allowing workingset pages by default to increase cleancache hit ratio. On my device, the utilization ratio of the gcma area as cached pages is really low like almost zero. So I'd like to add a vendor hook to allow non-workingset pages when gcma usage is low. Bug: 433652944 Change-Id: I43a3900db416b2af6758d8b8905299eba0e38f39 Signed-off-by: Sooyong Suk --- drivers/android/vendor_hooks.c | 1 + include/trace/hooks/mm.h | 3 +++ mm/gcma.c | 8 +++++--- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index b3b8f473193e..8ab75d4316e2 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -581,6 +581,7 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_shrink_node); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_cpuset_fork); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_alloc_uid); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_free_user); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_gcma_cc_allow_nonworkingset); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_gcma_cc_store_page_bypass); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_gzvm_vcpu_exit_reason); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_gzvm_handle_demand_page_pre); diff --git a/include/trace/hooks/mm.h b/include/trace/hooks/mm.h index b348f20eaf0b..d5515ab486fc 100644 --- a/include/trace/hooks/mm.h +++ b/include/trace/hooks/mm.h @@ -540,6 +540,9 @@ DECLARE_HOOK(android_vh_filemap_add_folio, TP_PROTO(struct address_space *mapping, struct folio *folio, pgoff_t index), TP_ARGS(mapping, folio, index)); +DECLARE_HOOK(android_vh_gcma_cc_allow_nonworkingset, + TP_PROTO(bool *allow_nonworkingset), + TP_ARGS(allow_nonworkingset)); DECLARE_HOOK(android_vh_gcma_cc_store_page_bypass, TP_PROTO(bool *bypass), TP_ARGS(bypass)); diff --git a/mm/gcma.c b/mm/gcma.c index 6a2eef774f80..2542071165d1 100644 --- a/mm/gcma.c +++ b/mm/gcma.c @@ -752,6 +752,7 @@ static void gcma_cc_store_page(int hash_id, struct cleancache_filekey key, bool is_new = false; bool workingset = PageWorkingset(page); bool bypass = false; + bool allow_nonworkingset = false; trace_android_vh_gcma_cc_store_page_bypass(&bypass); if (bypass) @@ -767,10 +768,11 @@ static void gcma_cc_store_page(int hash_id, struct cleancache_filekey key, if (!gcma_fs) return; + trace_android_vh_gcma_cc_allow_nonworkingset(&allow_nonworkingset); find_inode: inode = find_and_get_gcma_inode(gcma_fs, &key); if (!inode) { - if (!workingset) + if (!workingset && !allow_nonworkingset) return; inode = add_gcma_inode(gcma_fs, &key); if (!IS_ERR(inode)) @@ -789,14 +791,14 @@ load_page: xa_lock(&inode->pages); g_page = xa_load(&inode->pages, offset); if (g_page) { - if (!workingset) { + if (!workingset && !allow_nonworkingset) { gcma_erase_page(inode, offset, g_page, true); goto out_unlock; } goto copy; } - if (!workingset) + if (!workingset && !allow_nonworkingset) goto out_unlock; g_page = gcma_alloc_page();