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 <zhanghui31@xiaomi.com>
This commit is contained in:
zhanghui
2025-02-14 16:23:03 +08:00
committed by Treehugger Robot
parent fa3cc11118
commit eaffa3e341
3 changed files with 8 additions and 0 deletions

View File

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

View File

@@ -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 */

View File

@@ -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;
}