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 <huangdezhi@hihonor.com>
This commit is contained in:
Dezhi Huang 2024-05-15 14:39:06 +08:00 committed by Treehugger Robot
parent 23f2a9f5f1
commit c7fcb9bf9a
3 changed files with 7 additions and 0 deletions

View File

@ -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);

View File

@ -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 */

View File

@ -92,6 +92,7 @@
#include "pgalloc-track.h"
#include "internal.h"
#include "swap.h"
#include <trace/hooks/mm.h>
#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