ANDROID: vendor_hooks: add hook to optimize the madvise processing flow

Add vendor_hook trace_android_vh_process_madvise_begin, allow vendor modules
to mark the start of the madvise processing.
Add vendor_hook trace_android_vh_process_madvise_iter, allow vendor modules
to document the state during the iteration of madvise processing and allow us
to intervene in the loop based on the state of the process.

Bug: 337591184
Change-Id: I8cca4818de19c5823e2821ce9b5b0903cbee3281
Signed-off-by: Dezhi Huang <huangdezhi@hihonor.com>
This commit is contained in:
Dezhi Huang 2024-04-28 17:04:10 +08:00 committed by Suren Baghdasaryan
parent d974a8b61d
commit 0517467c26
3 changed files with 12 additions and 0 deletions

View File

@ -238,6 +238,8 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_irqs_disable);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_irqs_enable);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_is_fpsimd_save);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_slab_folio_alloced);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_process_madvise_begin);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_process_madvise_iter);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_kmalloc_large_alloced);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_tune_swappiness);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_sched_show_task);

View File

@ -54,6 +54,12 @@ DECLARE_HOOK(android_vh_si_meminfo_adjust,
DECLARE_HOOK(android_vh_slab_folio_alloced,
TP_PROTO(unsigned int order, gfp_t flags),
TP_ARGS(order, flags));
DECLARE_HOOK(android_vh_process_madvise_begin,
TP_PROTO(struct task_struct *task, int behavior),
TP_ARGS(task, behavior));
DECLARE_HOOK(android_vh_process_madvise_iter,
TP_PROTO(struct task_struct *task, int behavior, ssize_t *ret),
TP_ARGS(task, behavior, ret));
DECLARE_HOOK(android_vh_kmalloc_large_alloced,
TP_PROTO(struct page *page, unsigned int order, gfp_t flags),
TP_ARGS(page, order, flags));

View File

@ -1591,8 +1591,12 @@ SYSCALL_DEFINE5(process_madvise, int, pidfd, const struct iovec __user *, vec,
}
total_len = iov_iter_count(&iter);
trace_android_vh_process_madvise_begin(task, behavior);
while (iov_iter_count(&iter)) {
trace_android_vh_process_madvise_iter(task, behavior, &ret);
if (ret < 0)
break;
ret = do_madvise(mm, (unsigned long)iter_iov_addr(&iter),
iter_iov_len(&iter), behavior);
if (ret < 0)