[PATCH v2 08/37] tracing: hrtimer: Print hrtimer mode in hrtimer_start tracepoint

Anna-Maria Gleixner
2017-10-22T21:43:10Z

[-- Attachment #1: tracing--hrtimer--Print-hrtimer-mode-in-hrtimer_start-tracepoint.patch --]
[-- Type: text/plain, Size: 3350 bytes --]

The hrtimer_start tracepoint lacks the mode information. The mode is
important because consecutive starts can switch from ABS to REL or from
PINNED to non PINNED.

Add the mode information.

Signed-off-by: Anna-Maria Gleixner <anna-maria@linutronix.de>
---
include/trace/events/timer.h | 13 ++++++++-----
kernel/time/hrtimer.c | 16 +++++++++-------
2 files changed, 17 insertions(+), 12 deletions(-)

--- a/include/trace/events/timer.h
+++ b/include/trace/events/timer.h
@@ -185,15 +185,16 @@ TRACE_EVENT(hrtimer_init,
*/
TRACE_EVENT(hrtimer_start,

- TP_PROTO(struct hrtimer *hrtimer),
+ TP_PROTO(struct hrtimer *hrtimer, enum hrtimer_mode mode),

- TP_ARGS(hrtimer),
+ TP_ARGS(hrtimer, mode),

TP_STRUCT__entry(
__field( void *, hrtimer )
__field( void *, function )
__field( s64, expires )
__field( s64, softexpires )
+ __field( enum hrtimer_mode, mode )
),

TP_fast_assign(
@@ -201,12 +202,14 @@ TRACE_EVENT(hrtimer_start,
__entry->function = hrtimer->function;
__entry->expires = hrtimer_get_expires(hrtimer);
__entry->softexpires = hrtimer_get_softexpires(hrtimer);
+ __entry->mode = mode;
),

- TP_printk("hrtimer=%p function=%pf expires=%llu softexpires=%llu",
- __entry->hrtimer, __entry->function,
+ TP_printk("hrtimer=%p function=%pf expires=%llu softexpires=%llu "
+ "mode=%s", __entry->hrtimer, __entry->function,
(unsigned long long) __entry->expires,
- (unsigned long long) __entry->softexpires)
+ (unsigned long long) __entry->softexpires,
+ decode_hrtimer_mode(__entry->mode))
);

/**
--- a/kernel/time/hrtimer.c
+++ b/kernel/time/hrtimer.c
@@ -442,10 +442,11 @@ debug_init(struct hrtimer *timer, clocki
trace_hrtimer_init(timer, clockid, mode);
}

-static inline void debug_activate(struct hrtimer *timer)
+static inline void debug_activate(struct hrtimer *timer,
+ enum hrtimer_mode mode)
{
debug_hrtimer_activate(timer);
- trace_hrtimer_start(timer);
+ trace_hrtimer_start(timer, mode);
}

static inline void debug_deactivate(struct hrtimer *timer)
@@ -837,9 +838,10 @@ EXPORT_SYMBOL_GPL(hrtimer_forward);
* Returns 1 when the new timer is the leftmost timer in the tree.
*/
static int enqueue_hrtimer(struct hrtimer *timer,
- struct hrtimer_clock_base *base)
+ struct hrtimer_clock_base *base,
+ enum hrtimer_mode mode)
{
- debug_activate(timer);
+ debug_activate(timer, mode);

base->cpu_base->active_bases |= 1 << base->index;

@@ -962,7 +964,7 @@ void hrtimer_start_range_ns(struct hrtim
/* Switch the timer base, if necessary: */
new_base = switch_hrtimer_base(timer, base, mode & HRTIMER_MODE_PINNED);

- leftmost = enqueue_hrtimer(timer, new_base);
+ leftmost = enqueue_hrtimer(timer, new_base, mode);
if (!leftmost)
goto unlock;

@@ -1231,7 +1233,7 @@ static void __run_hrtimer(struct hrtimer
*/
if (restart != HRTIMER_NORESTART &&
!(timer->state & HRTIMER_STATE_ENQUEUED))
- enqueue_hrtimer(timer, base);
+ enqueue_hrtimer(timer, base, HRTIMER_MODE_ABS);

/*
* Separate the ->running assignment from the ->state assignment.
@@ -1630,7 +1632,7 @@ static void migrate_hrtimer_list(struct
* sort out already expired timers and reprogram the
* event device.
*/
- enqueue_hrtimer(timer, new_base);
+ enqueue_hrtimer(timer, new_base, HRTIMER_MODE_ABS);
}
}