From 3503e439a98180e12e413c20d2e682392e87e237 Mon Sep 17 00:00:00 2001 From: Sooyong Suk Date: Wed, 9 Jul 2025 09:37:22 +0900 Subject: [PATCH] ANDROID: mm: add vendor hook to bypass gcma cleancache put page Cleancache put page operation is slower than just dropping file pages. So, I'd like to restrict gcma store page on some conditions. For example, direct reclaim contexts can bypass cleancache operation for better reclaim performance. Bug: 410432482 Change-Id: Ifc38b9b2912d1832dac5d2003ebd042683f78a1f Signed-off-by: Sooyong Suk --- drivers/android/vendor_hooks.c | 1 + include/trace/hooks/mm.h | 3 +++ mm/gcma.c | 5 +++++ 3 files changed, 9 insertions(+) diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index bbe3981ed032..590fc921b89f 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -578,6 +578,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_store_page_bypass); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_gzvm_vcpu_exit_reason); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_gzvm_handle_demand_page_pre); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_gzvm_handle_demand_page_post); diff --git a/include/trace/hooks/mm.h b/include/trace/hooks/mm.h index 86dfd82b2661..4cc08294d9b0 100644 --- a/include/trace/hooks/mm.h +++ b/include/trace/hooks/mm.h @@ -537,6 +537,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_store_page_bypass, + TP_PROTO(bool *bypass), + TP_ARGS(bypass)); #endif /* _TRACE_HOOK_MM_H */ /* This part must be outside protection */ diff --git a/mm/gcma.c b/mm/gcma.c index 503be698c844..6fc98f3e9c2d 100644 --- a/mm/gcma.c +++ b/mm/gcma.c @@ -13,6 +13,7 @@ #include #include #include +#include #include "gcma_sysfs.h" /* @@ -747,7 +748,11 @@ static void gcma_cc_store_page(int hash_id, struct cleancache_filekey key, void *src, *dst; bool is_new = false; bool workingset = PageWorkingset(page); + bool bypass = false; + trace_android_vh_gcma_cc_store_page_bypass(&bypass); + if (bypass) + return; /* * This cleancache function is called under irq disabled so every * locks in this function should take of the irq if they are