From c7fcb9bf9aaee38025c43516f8f655acc23bc108 Mon Sep 17 00:00:00 2001 From: Dezhi Huang Date: Wed, 15 May 2024 14:39:06 +0800 Subject: [PATCH] ANDROID: add vendor hook in do_read_fault to tune fault_around_bytes with this vendor_hook, oem can dynamically adjust fault_around_bytes to balance memory usage and performance Bug: 340749845 Change-Id: I429f4302caf44a769696ccec84e9cc13ea8892ea Signed-off-by: Dezhi Huang --- drivers/android/vendor_hooks.c | 1 + include/trace/hooks/mm.h | 3 +++ mm/memory.c | 3 +++ 3 files changed, 7 insertions(+) diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index 675646d924e7..ff9a0a78977a 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -275,6 +275,7 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_set_readahead_gfp_mask); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_alter_mutex_list_add); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_mutex_unlock_slowpath); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_rwsem_wake_finish); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_tune_fault_around_bytes); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_adjust_alloc_flags); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_adjust_kvmalloc_flags); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_binder_looper_state_registered); diff --git a/include/trace/hooks/mm.h b/include/trace/hooks/mm.h index 28dcf14b9d72..73a544af12b7 100644 --- a/include/trace/hooks/mm.h +++ b/include/trace/hooks/mm.h @@ -208,6 +208,9 @@ DECLARE_HOOK(android_vh_slab_folio_alloced, DECLARE_HOOK(android_vh_kmalloc_large_alloced, TP_PROTO(struct page *page, unsigned int order, gfp_t flags), TP_ARGS(page, order, flags)); +DECLARE_HOOK(android_vh_tune_fault_around_bytes, + TP_PROTO(unsigned long *fault_around_bytes), + TP_ARGS(fault_around_bytes)); #endif /* _TRACE_HOOK_MM_H */ /* This part must be outside protection */ diff --git a/mm/memory.c b/mm/memory.c index 66cbb29cd444..ffbf374a787d 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -92,6 +92,7 @@ #include "pgalloc-track.h" #include "internal.h" #include "swap.h" +#include #if defined(LAST_CPUPID_NOT_IN_PAGE_FLAGS) && !defined(CONFIG_COMPILE_TEST) #warning Unfortunate NUMA and NUMA Balancing config, growing page-frame for last_cpupid. @@ -4645,6 +4646,8 @@ static vm_fault_t do_read_fault(struct vm_fault *vmf) { vm_fault_t ret = 0; + trace_android_vh_tune_fault_around_bytes(&fault_around_bytes); + /* * Let's call ->map_pages() first and use ->fault() as fallback * if page by the offset is not ready to be mapped (cold cache or