From 95e6a11201ab16ac37ac59c7b6981465b2f35048 Mon Sep 17 00:00:00 2001 From: Qianfeng Rong Date: Fri, 18 Apr 2025 11:09:06 +0800 Subject: [PATCH] ANDROID: vendor hooks: skip mem reclaim throttle to speed up mem alloc Allowing certain important threads to skip waiting and direct mem reclaim, speeding up mem allocation for critical processes. Bug: 411514531 Change-Id: I56506249bb5eda705185476c71eb4b9c7e3a3a55 Signed-off-by: Qianfeng Rong --- drivers/android/vendor_hooks.c | 1 + include/trace/hooks/vmscan.h | 3 +++ mm/vmscan.c | 5 +++++ 3 files changed, 9 insertions(+) diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index 0d8c43e1138e..60c943df0a42 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -478,6 +478,7 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_direct_reclaim_end); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_do_read_fault); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_alloc_pages_reclaim_start); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_alloc_pages_reclaim_cycle_end); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_throttle_direct_reclaim_bypass); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_bd_link_disk_holder); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_binder_new_ref); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_binder_del_ref); diff --git a/include/trace/hooks/vmscan.h b/include/trace/hooks/vmscan.h index 57d4a8afa7e3..a1be0fb3d3fa 100644 --- a/include/trace/hooks/vmscan.h +++ b/include/trace/hooks/vmscan.h @@ -98,6 +98,9 @@ DECLARE_HOOK(android_vh_direct_reclaim_begin, DECLARE_HOOK(android_vh_direct_reclaim_end, TP_PROTO(int prio), TP_ARGS(prio)); +DECLARE_HOOK(android_vh_throttle_direct_reclaim_bypass, + TP_PROTO(bool *bypass), + TP_ARGS(bypass)); #endif /* _TRACE_HOOK_VMSCAN_H */ /* This part must be outside protection */ diff --git a/mm/vmscan.c b/mm/vmscan.c index b3c02528b9ce..515919f8d719 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -6574,6 +6574,7 @@ static bool throttle_direct_reclaim(gfp_t gfp_mask, struct zonelist *zonelist, struct zoneref *z; struct zone *zone; pg_data_t *pgdat = NULL; + bool bypass = false; /* * Kernel threads should not be throttled as they may be indirectly @@ -6622,6 +6623,10 @@ static bool throttle_direct_reclaim(gfp_t gfp_mask, struct zonelist *zonelist, if (!pgdat) goto out; + trace_android_vh_throttle_direct_reclaim_bypass(&bypass); + if (bypass) + goto out; + /* Account for the throttling */ count_vm_event(PGSCAN_DIRECT_THROTTLE);