From 2f4537ba6c01c383ed9906916df5b6cee5eb0a4c Mon Sep 17 00:00:00 2001 From: Marcus Ma Date: Wed, 19 Mar 2025 10:02:16 +0800 Subject: [PATCH] ANDROID: vendor_hooks: Skip pages with high memory pressure in shrink_active_list The android_vh_folio_referenced_check_bypass hook reverse-maps and skips pages with high memory pressure in shrink_active_list, preferring to recycle them. This helps reduce memory pressure and improve system performance under high load. Bug: 404067669 Change-Id: Ic10edcef9761df774d6cf18544e7c044bf78d3ed Signed-off-by: Marcus Ma --- drivers/android/vendor_hooks.c | 1 + include/trace/hooks/vmscan.h | 3 +++ mm/vmscan.c | 2 ++ 3 files changed, 6 insertions(+) diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index d76fdab3b839..663121911094 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -474,3 +474,4 @@ 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); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_vprintk_store); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_folio_referenced_check_bypass); diff --git a/include/trace/hooks/vmscan.h b/include/trace/hooks/vmscan.h index fba2efaa294a..94303994f6d6 100644 --- a/include/trace/hooks/vmscan.h +++ b/include/trace/hooks/vmscan.h @@ -79,6 +79,9 @@ DECLARE_HOOK(android_vh_do_folio_trylock, DECLARE_HOOK(android_vh_page_referenced_check_bypass, TP_PROTO(struct folio *folio, unsigned long nr_to_scan, int lru, bool *bypass), TP_ARGS(folio, nr_to_scan, lru, bypass)); +DECLARE_HOOK(android_vh_folio_referenced_check_bypass, + TP_PROTO(struct folio *folio, s8 priority, unsigned long nr_to_scan, int lru, bool *bypass), + TP_ARGS(folio, priority, nr_to_scan, lru, bypass)); DECLARE_HOOK(android_vh_should_memcg_bypass, TP_PROTO(struct mem_cgroup *memcg, int priority, bool *bypass), TP_ARGS(memcg, priority, bypass)); diff --git a/mm/vmscan.c b/mm/vmscan.c index 432471847d37..9dbd8b1ae7a6 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -2709,6 +2709,8 @@ static void shrink_active_list(unsigned long nr_to_scan, } trace_android_vh_page_referenced_check_bypass(folio, nr_to_scan, lru, &bypass); + trace_android_vh_folio_referenced_check_bypass(folio, sc->priority, + nr_to_scan, lru, &bypass); if (bypass) goto skip_folio_referenced; trace_android_vh_folio_trylock_set(folio);