Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

authored by

Anna-Maria Behnsen and committed by
Thomas Gleixner
b573c731 dbcdcb62

+31 -3
+20
include/trace/events/timer.h
··· 142 142 TP_ARGS(timer) 143 143 ); 144 144 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 + 145 165 #define decode_clockid(type) \ 146 166 __print_symbolic(type, \ 147 167 { CLOCK_REALTIME, "CLOCK_REALTIME" }, \
+11 -3
kernel/time/timer.c
··· 1950 1950 1951 1951 if (time_before_eq(nextevt, basej)) { 1952 1952 expires = basem; 1953 - base->is_idle = false; 1953 + if (base->is_idle) { 1954 + base->is_idle = false; 1955 + trace_timer_base_idle(false, base->cpu); 1956 + } 1954 1957 } else { 1955 1958 if (base->timers_pending) 1956 1959 expires = basem + (u64)(nextevt - basej) * TICK_NSEC; ··· 1964 1961 * logic is only maintained for the BASE_STD base, deferrable 1965 1962 * timers may still see large granularity skew (by design). 1966 1963 */ 1967 - if ((expires - basem) > TICK_NSEC) 1964 + if ((expires - basem) > TICK_NSEC && !base->is_idle) { 1968 1965 base->is_idle = true; 1966 + trace_timer_base_idle(true, base->cpu); 1967 + } 1969 1968 } 1970 1969 raw_spin_unlock(&base->lock); 1971 1970 ··· 1989 1984 * sending the IPI a few instructions smaller for the cost of taking 1990 1985 * the lock in the exit from idle path. 1991 1986 */ 1992 - base->is_idle = false; 1987 + if (base->is_idle) { 1988 + base->is_idle = false; 1989 + trace_timer_base_idle(false, smp_processor_id()); 1990 + } 1993 1991 } 1994 1992 #endif 1995 1993