From 9789a88f4273089cad704a5ef219ea41882d5d55 Mon Sep 17 00:00:00 2001 From: Huang Yiwei Date: Fri, 29 Jan 2021 10:59:25 +0800 Subject: [PATCH] ANDROID: timer: Add vendor hook for timer calc index Since we're expecting timers more precisely in short period, add a vendor hook to calc_index when adding timers. Then we can modify the index this timer used to make it accurate. Bug: 178758017 Signed-off-by: Huang Yiwei Change-Id: Ie0e6493ae7ad53b0cc57eb1bbcf8a0a11f652828 --- drivers/android/vendor_hooks.c | 2 ++ include/trace/hooks/timer.h | 19 +++++++++++++++++++ kernel/time/timer.c | 3 +++ 3 files changed, 24 insertions(+) create mode 100644 include/trace/hooks/timer.h diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index b9f6772623a3..6a6d40bec073 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -31,6 +31,7 @@ #include #include #include +#include /* * Export tracepoints that act as a bare tracehook (ie: have no trace event @@ -137,3 +138,4 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_em_cpu_energy); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_cpu_up); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_cpu_down); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_sched_balance_rt); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_timer_calc_index); diff --git a/include/trace/hooks/timer.h b/include/trace/hooks/timer.h new file mode 100644 index 000000000000..174d958e4c31 --- /dev/null +++ b/include/trace/hooks/timer.h @@ -0,0 +1,19 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#undef TRACE_SYSTEM +#define TRACE_SYSTEM timer + +#define TRACE_INCLUDE_PATH trace/hooks + +#if !defined(_TRACE_HOOK_TIMER_H) || defined(TRACE_HEADER_MULTI_READ) +#define _TRACE_HOOK_TIMER_H + +#include +#include + +DECLARE_HOOK(android_vh_timer_calc_index, + TP_PROTO(unsigned int lvl, unsigned long *expires), + TP_ARGS(lvl, expires)); + +#endif /* _TRACE_HOOK_TIMER_H */ +/* This part must be outside protection */ +#include diff --git a/kernel/time/timer.c b/kernel/time/timer.c index 99d9bf8aed4c..9718e5a7bc1b 100644 --- a/kernel/time/timer.c +++ b/kernel/time/timer.c @@ -55,6 +55,8 @@ #define CREATE_TRACE_POINTS #include +#undef CREATE_TRACE_POINTS +#include EXPORT_TRACEPOINT_SYMBOL_GPL(hrtimer_expire_entry); EXPORT_TRACEPOINT_SYMBOL_GPL(hrtimer_expire_exit); @@ -505,6 +507,7 @@ static inline unsigned calc_index(unsigned long expires, unsigned lvl, * Round up with level granularity to prevent this. */ expires = (expires + LVL_GRAN(lvl)) >> LVL_SHIFT(lvl); + trace_android_vh_timer_calc_index(lvl, &expires); *bucket_expiry = expires << LVL_SHIFT(lvl); return LVL_OFFS(lvl) + (expires & LVL_MASK); }