From eaffa3e34155d13c4a2df6d44e46d8a046c2ea4c Mon Sep 17 00:00:00 2001 From: zhanghui Date: Fri, 14 Feb 2025 16:23:03 +0800 Subject: [PATCH] ANDROID: mm: add a new vendor hook in filemap_map_pages In the current vendor hook, if next_uptodate_folio returns NULL, the first_pgoff is set to zero, and the last_pgoff is set to start_pgoff. Therefore, the collection range is from 0 to the start_pgoff. |-----------|------------|-------------|------------------| 0 start_pgoff first_pgoff last_pgoff end_pgoff We want to collect the first_pgoff to last_pgoff, so we have to add a new vendor hook. Bug: 398130226 Change-Id: I19d54c601e2ffc5de5ec2dafcd43fbdcdc84b0d2 Signed-off-by: zhanghui --- drivers/android/vendor_hooks.c | 1 + include/trace/hooks/mm.h | 4 ++++ mm/filemap.c | 3 +++ 3 files changed, 8 insertions(+) diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index 27a420dce9a5..bddbde83c145 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -472,3 +472,4 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_mmc_attach_sd); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_sdhci_get_cd); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_mmc_gpio_cd_irqt); EXPORT_TRACEPOINT_SYMBOL_GPL(android_trigger_vendor_lmk_kill); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_filemap_map_pages_range); diff --git a/include/trace/hooks/mm.h b/include/trace/hooks/mm.h index 4f7bfc8bcb20..74b76878fe9d 100644 --- a/include/trace/hooks/mm.h +++ b/include/trace/hooks/mm.h @@ -298,6 +298,10 @@ DECLARE_HOOK(android_vh_alloc_flags_cma_adjust, DECLARE_HOOK(android_vh_rmqueue_cma_fallback, TP_PROTO(struct zone *zone, unsigned int order, struct page **page), TP_ARGS(zone, order, page)); +DECLARE_HOOK(android_vh_filemap_map_pages_range, + TP_PROTO(struct file *file, pgoff_t orig_start_pgoff, + pgoff_t last_pgoff, vm_fault_t ret), + TP_ARGS(file, orig_start_pgoff, last_pgoff, ret)); #endif /* _TRACE_HOOK_MM_H */ /* This part must be outside protection */ diff --git a/mm/filemap.c b/mm/filemap.c index 166889921dd7..2c7ee688aa20 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -3468,12 +3468,14 @@ vm_fault_t filemap_map_pages(struct vm_fault *vmf, unsigned int mmap_miss = READ_ONCE(file->f_ra.mmap_miss); vm_fault_t ret = 0; pgoff_t first_pgoff = 0; + pgoff_t orig_start_pgoff = start_pgoff; rcu_read_lock(); folio = first_map_page(mapping, &xas, end_pgoff); if (!folio) goto out; first_pgoff = xas.xa_index; + orig_start_pgoff = xas.xa_index; if (filemap_map_pmd(vmf, &folio->page)) { ret = VM_FAULT_NOPAGE; @@ -3530,6 +3532,7 @@ out: rcu_read_unlock(); WRITE_ONCE(file->f_ra.mmap_miss, mmap_miss); trace_android_vh_filemap_map_pages(file, first_pgoff, last_pgoff, ret); + trace_android_vh_filemap_map_pages_range(file, orig_start_pgoff, last_pgoff, ret); return ret; }