From 50148ce2498ac7749ac692e7beae2c4224b45a1e Mon Sep 17 00:00:00 2001 From: Bing Han Date: Tue, 28 Jun 2022 13:59:34 +0800 Subject: [PATCH] ANDROID: vendor_hook: Add hook in do_swap_page() android_vh_swapin_add_anon_rmap: after add pte mapping to an anonymous page durning do_swap_page, update the status that whether this page need to be reclaimed to a swap location, according to the information of vm_fault. Bug: 234214858 Signed-off-by: Bing Han Change-Id: I8a2d603102c315323817e6c9366db9b0da878344 --- drivers/android/vendor_hooks.c | 1 + include/trace/hooks/mm.h | 3 +++ mm/memory.c | 1 + 3 files changed, 5 insertions(+) diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index ab0cad1ce365..956e8594bf3d 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -408,6 +408,7 @@ 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_swapin_add_anon_rmap); 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 68999767a530..6b4d778ad2de 100644 --- a/include/trace/hooks/mm.h +++ b/include/trace/hooks/mm.h @@ -152,6 +152,9 @@ DECLARE_HOOK(android_vh_ra_tuning_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_swapin_add_anon_rmap, + 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 df32008d7c16..6ba58a781626 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -3784,6 +3784,7 @@ vm_fault_t do_swap_page(struct vm_fault *vmf) do_page_add_anon_rmap(page, vma, vmf->address, exclusive); } + trace_android_vh_swapin_add_anon_rmap(vmf, page); swap_free(entry); if (mem_cgroup_swap_full(page) || (vmf->vma_flags & VM_LOCKED) || PageMlocked(page))