From 5c06e6f0f8166dc95a38edc3999598644df34624 Mon Sep 17 00:00:00 2001 From: "qinglin.li" Date: Fri, 3 Jan 2025 18:48:22 +0800 Subject: [PATCH] ANDROID: vendor_hooks: add vendor hook in __alloc_pages() By this vh, so that we can record page information and add custom optimisations such as cma. Bug: 387438223 Bug: 305868227 Change-Id: I6d20dc96f864202ea0ca236c82337f385a9054f6 Signed-off-by: qinglin.li --- drivers/android/vendor_hooks.c | 1 + include/trace/hooks/mm.h | 5 +++++ mm/page_alloc.c | 1 + 3 files changed, 7 insertions(+) diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index b35327eeb020..c31de25c5771 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -210,3 +210,4 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_flush_wq_wait_finish); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_flush_work_wait_start); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_flush_work_wait_finish); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_enable_thermal_genl_check); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_alloc_pages_entry); diff --git a/include/trace/hooks/mm.h b/include/trace/hooks/mm.h index 7899ea20b20a..a0ce1350fb7b 100644 --- a/include/trace/hooks/mm.h +++ b/include/trace/hooks/mm.h @@ -78,6 +78,11 @@ DECLARE_HOOK(android_vh_kmalloc_large_alloced, DECLARE_RESTRICTED_HOOK(android_rvh_ctl_dirty_rate, TP_PROTO(struct inode *inode), TP_ARGS(inode), 1); + +DECLARE_HOOK(android_vh_alloc_pages_entry, + TP_PROTO(gfp_t *gfp, unsigned int order, int preferred_nid, + nodemask_t *nodemask), + TP_ARGS(gfp, order, preferred_nid, nodemask)); #endif /* _TRACE_HOOK_MM_H */ /* This part must be outside protection */ diff --git a/mm/page_alloc.c b/mm/page_alloc.c index b13c7f486b44..a821316fa5c7 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -4735,6 +4735,7 @@ struct page *__alloc_pages_noprof(gfp_t gfp, unsigned int order, gfp_t alloc_gfp; /* The gfp_t that was actually used for allocation */ struct alloc_context ac = { }; + trace_android_vh_alloc_pages_entry(&gfp, order, preferred_nid, nodemask); /* * There are several places where we assume that the order value is sane * so bail out early if the request is out of bound.