From c90ae2df480a219a760f391c60dbbca984b461e3 Mon Sep 17 00:00:00 2001 From: JohnHsu Date: Mon, 25 Sep 2023 14:08:53 +0800 Subject: [PATCH] ANDROID: mm: Add vendor hook for compact pages work. To monitor the efficiency of each action about compaction. Add the vendor_hook function and call it in kcompactd_do_work() and try_to_compact_pages() ANDROID vendor hook android_vh_compaction_exit(int, int, const int) android_vh_compaction_try_to_compact_exit(enum *compact result) Bug: 301044280 Bug: 330661608 Bug: 411525596 Change-Id: I4c3f94e77eb2b16ba154ba88a9f75095536de916 Signed-off-by: John Hsu Signed-off-by: Chinwen Chang --- drivers/android/vendor_hooks.c | 2 ++ include/trace/hooks/compaction.h | 7 +++++++ mm/compaction.c | 3 ++- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index c447840b88f5..4d2442193033 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -496,3 +496,5 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_clear_rwsem_reader_owned); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_record_rwsem_writer_owned); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_clear_rwsem_writer_owned); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_rwsem_read_trylock_failed); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_compaction_exit); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_compaction_try_to_compact_exit); diff --git a/include/trace/hooks/compaction.h b/include/trace/hooks/compaction.h index 6b72d649fe35..c22b22386be8 100644 --- a/include/trace/hooks/compaction.h +++ b/include/trace/hooks/compaction.h @@ -12,6 +12,13 @@ DECLARE_HOOK(android_vh_proactive_compact_wmark_high, TP_PROTO(int *wmark_high), TP_ARGS(wmark_high)); +DECLARE_HOOK(android_vh_compaction_exit, + TP_PROTO(int node_id, int order, const int highest_zoneidx), + TP_ARGS(node_id, order, highest_zoneidx)); +enum compact_result; +DECLARE_HOOK(android_vh_compaction_try_to_compact_exit, + TP_PROTO(enum compact_result *compact_result), + TP_ARGS(compact_result)); #endif /* _TRACE_HOOK_COMPACTION_H */ /* This part must be outside protection */ #include diff --git a/mm/compaction.c b/mm/compaction.c index 66c29ed624fe..c6acec0b1a04 100644 --- a/mm/compaction.c +++ b/mm/compaction.c @@ -2896,7 +2896,7 @@ enum compact_result try_to_compact_pages(gfp_t gfp_mask, unsigned int order, || fatal_signal_pending(current)) break; } - + trace_android_vh_compaction_try_to_compact_exit(&rc); return rc; } @@ -3166,6 +3166,7 @@ static void kcompactd_do_work(pg_data_t *pgdat) count_compact_events(KCOMPACTD_FREE_SCANNED, cc.total_free_scanned); } + trace_android_vh_compaction_exit(pgdat->node_id, cc.order, cc.highest_zoneidx); /* * Regardless of success, we are done until woken up next. But remember