ANDROID: vendor_hooks: add hook to perform targeted memory management

Add vendor_hook trace_android_vh_should_fault_around, allow vendor modules
to skip the fault_around processing for less important processes.

Bug: 362663044
Bug: 337547131
Change-Id: I792dca2038f5ad7cba1d212ef95407244958609d
Signed-off-by: Dezhi Huang <huangdezhi@hihonor.com>
(cherry picked from commit 65ebb00fe7977348d5fcfa58985c29181f3ec173)
This commit is contained in:
Dezhi Huang
2024-04-28 16:12:21 +08:00
committed by Treehugger Robot
parent c105083ac6
commit 145b08312d
3 changed files with 10 additions and 0 deletions

View File

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

View File

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

View File

@@ -81,6 +81,7 @@
#include <linux/set_memory.h>
#include <trace/events/kmem.h>
#include <trace/hooks/mm.h>
#undef CREATE_TRACE_POINTS
#include <trace/hooks/mm.h>
@@ -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;
}