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();