Commit b573c731 authored by Anna-Maria Behnsen's avatar Anna-Maria Behnsen Committed by Thomas Gleixner

tracing/timers: Add tracepoint for tracking timer base is_idle flag

When debugging timer code the timer tracepoints are very important. There
is no tracepoint when the is_idle flag of the timer base changes. Instead
of always adding manually trace_printk(), add tracepoints which can be
easily enabled whenever required.
Signed-off-by: default avatarAnna-Maria Behnsen <anna-maria@linutronix.de>
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
Reviewed-by: default avatarFrederic Weisbecker <frederic@kernel.org>
Link: https://lore.kernel.org/r/20231201092654.34614-6-anna-maria@linutronix.de
parent dbcdcb62
...@@ -142,6 +142,26 @@ DEFINE_EVENT(timer_class, timer_cancel, ...@@ -142,6 +142,26 @@ DEFINE_EVENT(timer_class, timer_cancel,
TP_ARGS(timer) TP_ARGS(timer)
); );
TRACE_EVENT(timer_base_idle,
TP_PROTO(bool is_idle, unsigned int cpu),
TP_ARGS(is_idle, cpu),
TP_STRUCT__entry(
__field( bool, is_idle )
__field( unsigned int, cpu )
),
TP_fast_assign(
__entry->is_idle = is_idle;
__entry->cpu = cpu;
),
TP_printk("is_idle=%d cpu=%d",
__entry->is_idle, __entry->cpu)
);
#define decode_clockid(type) \ #define decode_clockid(type) \
__print_symbolic(type, \ __print_symbolic(type, \
{ CLOCK_REALTIME, "CLOCK_REALTIME" }, \ { CLOCK_REALTIME, "CLOCK_REALTIME" }, \
......
...@@ -1950,7 +1950,10 @@ u64 get_next_timer_interrupt(unsigned long basej, u64 basem) ...@@ -1950,7 +1950,10 @@ u64 get_next_timer_interrupt(unsigned long basej, u64 basem)
if (time_before_eq(nextevt, basej)) { if (time_before_eq(nextevt, basej)) {
expires = basem; expires = basem;
if (base->is_idle) {
base->is_idle = false; base->is_idle = false;
trace_timer_base_idle(false, base->cpu);
}
} else { } else {
if (base->timers_pending) if (base->timers_pending)
expires = basem + (u64)(nextevt - basej) * TICK_NSEC; expires = basem + (u64)(nextevt - basej) * TICK_NSEC;
...@@ -1961,8 +1964,10 @@ u64 get_next_timer_interrupt(unsigned long basej, u64 basem) ...@@ -1961,8 +1964,10 @@ u64 get_next_timer_interrupt(unsigned long basej, u64 basem)
* logic is only maintained for the BASE_STD base, deferrable * logic is only maintained for the BASE_STD base, deferrable
* timers may still see large granularity skew (by design). * timers may still see large granularity skew (by design).
*/ */
if ((expires - basem) > TICK_NSEC) if ((expires - basem) > TICK_NSEC && !base->is_idle) {
base->is_idle = true; base->is_idle = true;
trace_timer_base_idle(true, base->cpu);
}
} }
raw_spin_unlock(&base->lock); raw_spin_unlock(&base->lock);
...@@ -1984,7 +1989,10 @@ void timer_clear_idle(void) ...@@ -1984,7 +1989,10 @@ void timer_clear_idle(void)
* sending the IPI a few instructions smaller for the cost of taking * sending the IPI a few instructions smaller for the cost of taking
* the lock in the exit from idle path. * the lock in the exit from idle path.
*/ */
if (base->is_idle) {
base->is_idle = false; base->is_idle = false;
trace_timer_base_idle(false, smp_processor_id());
}
} }
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment