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_pages_exit(enum *compact result)

Bug: 301044280

Change-Id: I4c3f94e77eb2b16ba154ba88a9f75095536de916
Signed-off-by: John Hsu <john.hsu@mediatek.com>
This commit is contained in:
JohnHsu 2023-09-25 14:08:53 +08:00
parent 4e10001b7c
commit 5c2855fbce
3 changed files with 27 additions and 2 deletions

View File

@ -67,7 +67,7 @@
#include <trace/hooks/psi.h>
#include <trace/hooks/bl_hib.h>
#include <trace/hooks/regmap.h>
#include <trace/hooks/compaction.h>
/*
* Export tracepoints that act as a bare tracehook (ie: have no trace event
* associated with them) to allow external modules to probe them.
@ -335,3 +335,5 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_binder_transaction_received);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_free_oem_binder_struct);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_binder_special_task);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_binder_free_buf);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_compaction_exit);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_compaction_try_to_compact_pages_exit);

View File

@ -0,0 +1,20 @@
#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 <trace/hooks/vendor_hooks.h>
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_pages_exit,
TP_PROTO(enum compact_result *compact_result),
TP_ARGS(compact_result));
#endif /* _TRACE_HOOK_COMPACTION_H */
/* This part must be outside protection */
#include <trace/define_trace.h>

View File

@ -49,6 +49,8 @@ static inline void count_compact_events(enum vm_event_item item, long delta)
#define CREATE_TRACE_POINTS
#include <trace/events/compaction.h>
#undef CREATE_TRACE_POINTS
#include <trace/hooks/compaction.h>
#define block_start_pfn(pfn, order) round_down(pfn, 1UL << (order))
#define block_end_pfn(pfn, order) ALIGN((pfn) + 1, 1UL << (order))
@ -2655,7 +2657,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_pages_exit(&rc);
return rc;
}
@ -2902,6 +2904,7 @@ static void kcompactd_do_work(pg_data_t *pgdat)
VM_BUG_ON(!list_empty(&cc.freepages));
VM_BUG_ON(!list_empty(&cc.migratepages));
}
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