ANDROID: mm/readahead: add for bypass high order allocation

EROFS supports large folios on kernel-6.12 which enable high order
allocation with direct_reclaim flags. This might increase the latency
on UX task with filemap_fault(). Add a vendor hook here to bypass
unnecessary allocation in certain scenarios.

Bug: 430753566
Change-Id: I0f11b059a06d1e839aed51dc9b41f1a312eec048
Signed-off-by: Hailong Liu <hailong.liu@oppo.com>
This commit is contained in:
Hailong Liu
2025-07-11 09:23:30 +08:00
committed by Juan Yescas
parent 659d7bb454
commit 6222007a04
3 changed files with 11 additions and 0 deletions

View File

@@ -461,6 +461,7 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_filemap_map_pages);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_try_alloc_pages_gfp);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_page_cache_readahead_start);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_page_cache_readahead_end);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_page_cache_ra_order_bypass);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_filemap_fault_start);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_filemap_fault_end);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_dma_heap_buffer_alloc_start);

View File

@@ -376,6 +376,10 @@ DECLARE_HOOK(android_vh_page_cache_readahead_start,
DECLARE_HOOK(android_vh_page_cache_readahead_end,
TP_PROTO(struct file *file, pgoff_t pgoff),
TP_ARGS(file, pgoff));
DECLARE_HOOK(android_vh_page_cache_ra_order_bypass,
TP_PROTO(struct readahead_control *ractl, struct file_ra_state *ra,
int new_order, gfp_t *gfp, bool *bypass),
TP_ARGS(ractl, ra, new_order, gfp, bypass));
DECLARE_HOOK(android_vh_filemap_fault_start,
TP_PROTO(struct file *file, pgoff_t pgoff),
TP_ARGS(file, pgoff));

View File

@@ -472,6 +472,7 @@ void page_cache_ra_order(struct readahead_control *ractl,
int err = 0;
gfp_t gfp = readahead_gfp_mask(mapping);
unsigned int min_ra_size = max(4, mapping_min_folio_nrpages(mapping));
bool bypass = false;
/*
* Fallback when size < min_nrpages as each folio should be
@@ -480,6 +481,11 @@ void page_cache_ra_order(struct readahead_control *ractl,
if (!mapping_large_folio_support(mapping) || ra->size < min_ra_size)
goto fallback;
trace_android_vh_page_cache_ra_order_bypass(ractl, ra, new_order, &gfp,
&bypass);
if (bypass)
goto fallback;
limit = min(limit, index + ra->size - 1);
if (new_order < mapping_max_folio_order(mapping))