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: 397274634
Change-Id: I19d54c601e2ffc5de5ec2dafcd43fbdcdc84b0d2
Signed-off-by: zhanghui <zhanghui31@xiaomi.com>
(cherry picked from commit 2a0173a4773f377a208d79f1926ef08cdd20766a)
This commit is contained in:
zhanghui
2025-02-14 16:23:03 +08:00
committed by Carlos Llamas
parent 0c380917c7
commit 563c4f2322
2 changed files with 6 additions and 3 deletions

View File

@@ -351,9 +351,9 @@ DECLARE_HOOK(android_vh_filemap_read,
TP_PROTO(struct file *file, loff_t pos, size_t size),
TP_ARGS(file, pos, size));
DECLARE_HOOK(android_vh_filemap_map_pages,
TP_PROTO(struct file *file, pgoff_t first_pgoff,
TP_PROTO(struct file *file, pgoff_t orig_start_pgoff, pgoff_t first_pgoff,
pgoff_t last_pgoff, vm_fault_t ret),
TP_ARGS(file, first_pgoff, last_pgoff, ret));
TP_ARGS(file, orig_start_pgoff, first_pgoff, last_pgoff, ret));
DECLARE_HOOK(android_vh_page_cache_readahead_start,
TP_PROTO(struct file *file, pgoff_t pgoff,
unsigned int size, bool sync),

View File

@@ -3700,12 +3700,14 @@ vm_fault_t filemap_map_pages(struct vm_fault *vmf,
unsigned long rss = 0;
unsigned int nr_pages = 0, mmap_miss = 0, mmap_miss_saved, folio_type;
pgoff_t first_pgoff = 0;
pgoff_t orig_start_pgoff = start_pgoff;
rcu_read_lock();
folio = next_uptodate_folio(&xas, mapping, end_pgoff);
if (!folio)
goto out;
first_pgoff = xas.xa_index;
orig_start_pgoff = xas.xa_index;
if (filemap_map_pmd(vmf, folio, start_pgoff)) {
ret = VM_FAULT_NOPAGE;
@@ -3756,7 +3758,8 @@ out:
WRITE_ONCE(file->f_ra.mmap_miss, 0);
else
WRITE_ONCE(file->f_ra.mmap_miss, mmap_miss_saved - mmap_miss);
trace_android_vh_filemap_map_pages(file, first_pgoff, last_pgoff, ret);
trace_android_vh_filemap_map_pages(file, orig_start_pgoff,
first_pgoff, last_pgoff, ret);
return ret;
}