From 9d4b553252eae4c6e4853695a639cb32a4a61400 Mon Sep 17 00:00:00 2001 From: Bing Han Date: Mon, 30 May 2022 14:42:44 +0800 Subject: [PATCH] ANDROID: vendor_hook: Add hook in wp_page_copy() android_vh_cow_user_page: when copy a page to a new page, set the status that whether the new page should be reclaimed to a specified swap location, according to the information of vm_fault. Bug: 234214858 Signed-off-by: Bing Han Change-Id: Ie445c7b034ca176ec1e8fd1cd67c88581bf9ddf4 --- drivers/android/vendor_hooks.c | 1 + include/trace/hooks/mm.h | 3 +++ mm/memory.c | 2 ++ 3 files changed, 6 insertions(+) diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index 63acb55e9642..ab0cad1ce365 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -407,6 +407,7 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_handle_tlb_conf); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_shrink_node_memcgs); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_ra_tuning_max_page); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_tune_memcg_scan_type); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_cow_user_page); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_page_isolated_for_reclaim); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_inactive_is_low); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_snapshot_refaults); diff --git a/include/trace/hooks/mm.h b/include/trace/hooks/mm.h index 37f09cdeba9a..68999767a530 100644 --- a/include/trace/hooks/mm.h +++ b/include/trace/hooks/mm.h @@ -149,6 +149,9 @@ DECLARE_HOOK(android_vh_subpage_dma_contig_alloc, DECLARE_HOOK(android_vh_ra_tuning_max_page, TP_PROTO(struct readahead_control *ractl, unsigned long *max_page), TP_ARGS(ractl, max_page)); +DECLARE_HOOK(android_vh_cow_user_page, + TP_PROTO(struct vm_fault *vmf, struct page *page), + TP_ARGS(vmf, page)); DECLARE_HOOK(android_vh_page_isolated_for_reclaim, TP_PROTO(struct mm_struct *mm, struct page *page), TP_ARGS(mm, page)); diff --git a/mm/memory.c b/mm/memory.c index 5243236f018b..df32008d7c16 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -86,6 +86,7 @@ #include "pgalloc-track.h" #include "internal.h" +#include #define CREATE_TRACE_POINTS #include @@ -3141,6 +3142,7 @@ static vm_fault_t wp_page_copy(struct vm_fault *vmf) put_page(old_page); return 0; } + trace_android_vh_cow_user_page(vmf, new_page); } if (mem_cgroup_charge(new_page, mm, GFP_KERNEL))