diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index 923ca2b2f953..a177b4fee436 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -276,6 +276,7 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_set_gfp_zone_flags); 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_should_fault_around); 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); diff --git a/include/trace/hooks/mm.h b/include/trace/hooks/mm.h index df7430211a09..90237954c83d 100644 --- a/include/trace/hooks/mm.h +++ b/include/trace/hooks/mm.h @@ -208,6 +208,9 @@ DECLARE_HOOK(android_vh_look_around, DECLARE_HOOK(android_vh_mm_alloc_pages_direct_reclaim_enter, TP_PROTO(unsigned int order), TP_ARGS(order)); +DECLARE_HOOK(android_vh_should_fault_around, + TP_PROTO(struct vm_fault *vmf, bool *should_around), + TP_ARGS(vmf, should_around)); DECLARE_HOOK(android_vh_mm_alloc_pages_direct_reclaim_exit, TP_PROTO(unsigned long did_some_progress, int retry_times), TP_ARGS(did_some_progress, retry_times)); diff --git a/mm/memory.c b/mm/memory.c index 90c90066b59a..551453be4b64 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -81,6 +81,7 @@ #include #include +#include #undef CREATE_TRACE_POINTS #include @@ -4663,6 +4664,7 @@ static vm_fault_t do_fault_around(struct vm_fault *vmf) /* Return true if we should do read fault-around, false otherwise */ static inline bool should_fault_around(struct vm_fault *vmf) { + bool should_around = true; /* No ->map_pages? No way to fault around... */ if (!vmf->vma->vm_ops->map_pages) return false; @@ -4670,6 +4672,10 @@ static inline bool should_fault_around(struct vm_fault *vmf) if (uffd_disable_fault_around(vmf->vma)) return false; + trace_android_vh_should_fault_around(vmf, &should_around); + if (!should_around) + return false; + return fault_around_bytes >> PAGE_SHIFT > 1; }