From 01680ae117e650bbc7b4c2714165218e019efebe Mon Sep 17 00:00:00 2001 From: Bing Han Date: Sat, 11 Jun 2022 18:24:07 +0800 Subject: [PATCH] ANDROID: vendor_hook: Add hook in __free_pages() Provide a vendor hook android_vh_free_pages to clear the information in struct page_ext, when the page is freed. Bug: 234214858 Signed-off-by: Bing Han Change-Id: Iac8e3a72f59f8d3ae16dbc93d94034fe4b627d61 --- drivers/android/vendor_hooks.c | 1 + include/trace/hooks/mm.h | 3 +++ mm/page_alloc.c | 1 + 3 files changed, 5 insertions(+) diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index b35324b886c0..a6c589b266da 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -429,3 +429,4 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_unuse_swap_page); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_init_swap_info_struct); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_si_swapinfo); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_alloc_si); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_free_pages); diff --git a/include/trace/hooks/mm.h b/include/trace/hooks/mm.h index ae93f1916273..91d9172c6b4a 100644 --- a/include/trace/hooks/mm.h +++ b/include/trace/hooks/mm.h @@ -212,6 +212,9 @@ DECLARE_HOOK(android_vh_si_swapinfo, DECLARE_HOOK(android_vh_alloc_si, TP_PROTO(struct swap_info_struct **p, bool *skip), TP_ARGS(p, skip)); +DECLARE_HOOK(android_vh_free_pages, + TP_PROTO(struct page *page, unsigned int order), + TP_ARGS(page, order)); /* macro versions of hooks are no longer required */ #endif /* _TRACE_HOOK_MM_H */ diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 9209be35258a..27b18887bf5f 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -5180,6 +5180,7 @@ static inline void free_the_page(struct page *page, unsigned int order) void __free_pages(struct page *page, unsigned int order) { + trace_android_vh_free_pages(page, order); if (put_page_testzero(page)) free_the_page(page, order); else if (!PageHead(page))