From 891189b643600178d4736622b2ae2014bc951ea4 Mon Sep 17 00:00:00 2001 From: yipeng xiang Date: Wed, 22 Jan 2025 15:02:04 +0800 Subject: [PATCH] ANDROID: mm: create vendor hooks for mm proactive compact Add vendor hook to bypass compact_node if fragmentation score is tiny Bug: 391491611 Change-Id: I66df2bce09e08137e4812468e024fa24fcb97259 Signed-off-by: yipeng xiang --- drivers/android/vendor_hooks.c | 2 ++ include/trace/hooks/compaction.h | 17 +++++++++++++++++ mm/compaction.c | 2 ++ 3 files changed, 21 insertions(+) create mode 100644 include/trace/hooks/compaction.h diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index 6f2dc7fccaaf..b4d6efe84d3d 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -62,6 +62,7 @@ #include #include #include +#include #include @@ -313,6 +314,7 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_vmalloc_node_bypass); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_vfree_bypass); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_modify_scan_control); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_should_continue_reclaim); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_proactive_compact_wmark_high); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_async_psi_bypass); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_cma_alloc_retry); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_smaps_pte_entry); diff --git a/include/trace/hooks/compaction.h b/include/trace/hooks/compaction.h new file mode 100644 index 000000000000..6b72d649fe35 --- /dev/null +++ b/include/trace/hooks/compaction.h @@ -0,0 +1,17 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#undef TRACE_SYSTEM +#define TRACE_SYSTEM compaction + +#define TRACE_INCLUDE_PATH trace/hooks + +#if !defined(_TRACE_HOOK_COMPACTION_H) || defined(TRACE_HEADER_MULTI_READ) +#define _TRACE_HOOK_COMPACTION_H + +#include + +DECLARE_HOOK(android_vh_proactive_compact_wmark_high, + TP_PROTO(int *wmark_high), + TP_ARGS(wmark_high)); +#endif /* _TRACE_HOOK_COMPACTION_H */ +/* This part must be outside protection */ +#include diff --git a/mm/compaction.c b/mm/compaction.c index 1a5dc19584e9..af26ed222145 100644 --- a/mm/compaction.c +++ b/mm/compaction.c @@ -66,6 +66,7 @@ static inline bool is_via_compact_memory(int order) { return false; } #undef CREATE_TRACE_POINTS #include +#include #define block_start_pfn(pfn, order) round_down(pfn, 1UL << (order)) #define block_end_pfn(pfn, order) ALIGN((pfn) + 1, 1UL << (order)) @@ -2285,6 +2286,7 @@ static bool should_proactive_compact_node(pg_data_t *pgdat) return false; wmark_high = fragmentation_score_wmark(false); + trace_android_vh_proactive_compact_wmark_high(&wmark_high); return fragmentation_score_node(pgdat) > wmark_high; }