ANDROID: vendor_hooks: add hooks for adjust kvmalloc_node alloc_flags

since we can't control all kvmalloc_node callsite's gfp_flags, we add
a vendor hook in kvmalloc_node to tune the reclaim behavior for some
really high-order allocation

Bug: 300857012

Change-Id: I5f0c4c2921d204289911704e3a205f6a1dc50d04
Signed-off-by: liwei <liwei1234@oppo.com>
This commit is contained in:
liwei 2023-10-25 09:45:04 +08:00 committed by Suren Baghdasaryan
parent fef66e8544
commit 71f3b61ee4
3 changed files with 6 additions and 1 deletions

View file

@ -255,6 +255,7 @@ 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_adjust_alloc_flags);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_adjust_kvmalloc_flags);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_binder_looper_state_registered);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_binder_thread_read);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_binder_free_proc);

View file

@ -168,6 +168,9 @@ struct oom_control;
DECLARE_HOOK(android_vh_mm_alloc_pages_may_oom_exit,
TP_PROTO(struct oom_control *oc, unsigned long did_some_progress),
TP_ARGS(oc, did_some_progress));
DECLARE_HOOK(android_vh_adjust_kvmalloc_flags,
TP_PROTO(unsigned int order, gfp_t *alloc_flags),
TP_ARGS(order, alloc_flags));
#endif /* _TRACE_HOOK_MM_H */
/* This part must be outside protection */

View file

@ -25,7 +25,7 @@
#include <linux/compat.h>
#include <linux/uaccess.h>
#include <trace/hooks/mm.h>
#include "internal.h"
#include "swap.h"
@ -582,6 +582,7 @@ void *kvmalloc_node(size_t size, gfp_t flags, int node)
/* nofail semantic is implemented by the vmalloc fallback */
kmalloc_flags &= ~__GFP_NOFAIL;
}
trace_android_vh_adjust_kvmalloc_flags(get_order(size), &kmalloc_flags);
ret = kmalloc_node(size, kmalloc_flags, node);