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

tracing: Fix timer tracing

PowerTOP would like to be able to trace timers.

Unfortunately, the current timer tracing is not very useful: the
actual timer function is not recorded in the trace at the start
of timer execution.

Although this is recorded for timer "start" time (when it gets
armed), this is not useful; most timers get started early, and a
tracer like PowerTOP will never see this event, but will only
see the actual running of the timer.

This patch just adds the function to the timer tracing; I've
verified with PowerTOP that now it can get useful information
about timers.

Signed-off-by: Arjan van de Ven <arjan@linux.intel.com>
Cc: xiaoguangrong@cn.fujitsu.com
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: <stable@kernel.org> # .35.x, .34.x, .33.x
LKML-Reference: <4C6C5FA9.3000405@linux.intel.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>

authored by

Arjan van de Ven and committed by
Ingo Molnar
ede1b429 737480a0

+6 -2
+6 -2
include/trace/events/timer.h
··· 81 81 TP_STRUCT__entry( 82 82 __field( void *, timer ) 83 83 __field( unsigned long, now ) 84 + __field( void *, function) 84 85 ), 85 86 86 87 TP_fast_assign( 87 88 __entry->timer = timer; 88 89 __entry->now = jiffies; 90 + __entry->function = timer->function; 89 91 ), 90 92 91 - TP_printk("timer=%p now=%lu", __entry->timer, __entry->now) 93 + TP_printk("timer=%p function=%pf now=%lu", __entry->timer, __entry->function,__entry->now) 92 94 ); 93 95 94 96 /** ··· 202 200 TP_STRUCT__entry( 203 201 __field( void *, hrtimer ) 204 202 __field( s64, now ) 203 + __field( void *, function) 205 204 ), 206 205 207 206 TP_fast_assign( 208 207 __entry->hrtimer = hrtimer; 209 208 __entry->now = now->tv64; 209 + __entry->function = hrtimer->function; 210 210 ), 211 211 212 - TP_printk("hrtimer=%p now=%llu", __entry->hrtimer, 212 + TP_printk("hrtimer=%p function=%pf now=%llu", __entry->hrtimer, __entry->function, 213 213 (unsigned long long)ktime_to_ns((ktime_t) { .tv64 = __entry->now })) 214 214 ); 215 215