Skip to content

Commit cfe4cc3

Browse files
committed
tracing/timers: Add tracepoint for tracking timer base is_idle flag
JIRA: https://issues.redhat.com/browse/RHEL-33787 commit b573c73 Author: Anna-Maria Behnsen <anna-maria@linutronix.de> Date: Fri Dec 1 10:26:27 2023 +0100 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: Anna-Maria Behnsen <anna-maria@linutronix.de> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Frederic Weisbecker <frederic@kernel.org> Link: https://lore.kernel.org/r/20231201092654.34614-6-anna-maria@linutronix.de Signed-off-by: Phil Auld <pauld@redhat.com>
1 parent d8b5df8 commit cfe4cc3

File tree

2 files changed

+31
-3
lines changed

2 files changed

+31
-3
lines changed

include/trace/events/timer.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,26 @@ DEFINE_EVENT(timer_class, timer_cancel,
142142
TP_ARGS(timer)
143143
);
144144

145+
TRACE_EVENT(timer_base_idle,
146+
147+
TP_PROTO(bool is_idle, unsigned int cpu),
148+
149+
TP_ARGS(is_idle, cpu),
150+
151+
TP_STRUCT__entry(
152+
__field( bool, is_idle )
153+
__field( unsigned int, cpu )
154+
),
155+
156+
TP_fast_assign(
157+
__entry->is_idle = is_idle;
158+
__entry->cpu = cpu;
159+
),
160+
161+
TP_printk("is_idle=%d cpu=%d",
162+
__entry->is_idle, __entry->cpu)
163+
);
164+
145165
#define decode_clockid(type) \
146166
__print_symbolic(type, \
147167
{ CLOCK_REALTIME, "CLOCK_REALTIME" }, \

kernel/time/timer.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1897,7 +1897,10 @@ u64 get_next_timer_interrupt(unsigned long basej, u64 basem)
18971897

18981898
if (time_before_eq(nextevt, basej)) {
18991899
expires = basem;
1900-
base->is_idle = false;
1900+
if (base->is_idle) {
1901+
base->is_idle = false;
1902+
trace_timer_base_idle(false, base->cpu);
1903+
}
19011904
} else {
19021905
if (base->timers_pending)
19031906
expires = basem + (u64)(nextevt - basej) * TICK_NSEC;
@@ -1908,8 +1911,10 @@ u64 get_next_timer_interrupt(unsigned long basej, u64 basem)
19081911
* logic is only maintained for the BASE_STD base, deferrable
19091912
* timers may still see large granularity skew (by design).
19101913
*/
1911-
if ((expires - basem) > TICK_NSEC)
1914+
if ((expires - basem) > TICK_NSEC && !base->is_idle) {
19121915
base->is_idle = true;
1916+
trace_timer_base_idle(true, base->cpu);
1917+
}
19131918
}
19141919
raw_spin_unlock(&base->lock);
19151920

@@ -1931,7 +1936,10 @@ void timer_clear_idle(void)
19311936
* sending the IPI a few instructions smaller for the cost of taking
19321937
* the lock in the exit from idle path.
19331938
*/
1934-
base->is_idle = false;
1939+
if (base->is_idle) {
1940+
base->is_idle = false;
1941+
trace_timer_base_idle(false, smp_processor_id());
1942+
}
19351943
}
19361944
#endif
19371945

0 commit comments

Comments
 (0)