Skip to content

Commit 8a58a34

Browse files
KAGA-KOKOrostedt
authored andcommitted
timers: Make flags output in the timer_start tracepoint useful
The timer flags in the timer_start trace event contain lots of useful information, but the meaning is not clear in the trace output. Making tools rely on the bit positions is bad as they might change over time. Decode the flags in the print out. Tools can retrieve the bits and their meaning from the trace format file. Link: http://lkml.kernel.org/r/alpine.DEB.2.20.1702101639290.4036@nanos Requested-by: Arjan van de Ven <arjan@linux.intel.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
1 parent 1f9b354 commit 8a58a34

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

include/linux/timer.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ struct timer_list {
6666
#define TIMER_ARRAYSHIFT 22
6767
#define TIMER_ARRAYMASK 0xFFC00000
6868

69+
#define TIMER_TRACE_FLAGMASK (TIMER_MIGRATING | TIMER_DEFERRABLE | TIMER_PINNED | TIMER_IRQSAFE)
70+
6971
#define __TIMER_INITIALIZER(_function, _expires, _data, _flags) { \
7072
.entry = { .next = TIMER_ENTRY_STATIC }, \
7173
.function = (_function), \

include/trace/events/timer.h

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,13 @@ DEFINE_EVENT(timer_class, timer_init,
3636
TP_ARGS(timer)
3737
);
3838

39+
#define decode_timer_flags(flags) \
40+
__print_flags(flags, "|", \
41+
{ TIMER_MIGRATING, "M" }, \
42+
{ TIMER_DEFERRABLE, "D" }, \
43+
{ TIMER_PINNED, "P" }, \
44+
{ TIMER_IRQSAFE, "I" })
45+
3946
/**
4047
* timer_start - called when the timer is started
4148
* @timer: pointer to struct timer_list
@@ -65,9 +72,12 @@ TRACE_EVENT(timer_start,
6572
__entry->flags = flags;
6673
),
6774

68-
TP_printk("timer=%p function=%pf expires=%lu [timeout=%ld] flags=0x%08x",
75+
TP_printk("timer=%p function=%pf expires=%lu [timeout=%ld] cpu=%u idx=%u flags=%s",
6976
__entry->timer, __entry->function, __entry->expires,
70-
(long)__entry->expires - __entry->now, __entry->flags)
77+
(long)__entry->expires - __entry->now,
78+
__entry->flags & TIMER_CPUMASK,
79+
__entry->flags >> TIMER_ARRAYSHIFT,
80+
decode_timer_flags(__entry->flags & TIMER_TRACE_FLAGMASK))
7181
);
7282

7383
/**

0 commit comments

Comments
 (0)