[PATCH 4/9] nohz: Use enum code for tick stop failure tracing message

From: Frederic Weisbecker
Date: Mon Dec 14 2015 - 13:40:40 EST


It makes nohz tracing more lightweight, standard and easier to parse.

Examples:

user_loop-2904 [007] d..1 517.701126: tick_stop: success=1 dependency=NONE
user_loop-2904 [007] dn.1 518.021181: tick_stop: success=0 dependency=SCHED
posix_timers-6142 [007] d..1 1739.027400: tick_stop: success=0 dependency=POSIX_TIMER
user_loop-5463 [007] dN.1 1185.931939: tick_stop: success=0 dependency=PERF_EVENTS

Suggested-by: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
Cc: Christoph Lameter <cl@xxxxxxxxx>
Cc: Chris Metcalf <cmetcalf@xxxxxxxxxx>
Cc: Ingo Molnar <mingo@xxxxxxxxxx>
Cc: Luiz Capitulino <lcapitulino@xxxxxxxxxx>
Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
Cc: Rik van Riel <riel@xxxxxxxxxx>
Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
Cc: Viresh Kumar <viresh.kumar@xxxxxxxxxx>
Signed-off-by: Frederic Weisbecker <fweisbec@xxxxxxxxx>
---
include/linux/tick.h | 1 +
include/trace/events/timer.h | 36 +++++++++++++++++++++++++++++++-----
kernel/time/tick-sched.c | 18 +++++++++---------
3 files changed, 41 insertions(+), 14 deletions(-)

diff --git a/include/linux/tick.h b/include/linux/tick.h
index 56c660e..6d09dc1 100644
--- a/include/linux/tick.h
+++ b/include/linux/tick.h
@@ -104,6 +104,7 @@ enum tick_dependency_bit {
TICK_CLOCK_UNSTABLE_BIT = 3
};

+#define TICK_NONE_MASK 0
#define TICK_POSIX_TIMER_MASK (1 << TICK_POSIX_TIMER_BIT)
#define TICK_PERF_EVENTS_MASK (1 << TICK_PERF_EVENTS_BIT)
#define TICK_SCHED_MASK (1 << TICK_SCHED_BIT)
diff --git a/include/trace/events/timer.h b/include/trace/events/timer.h
index 073b9ac..2868fa5 100644
--- a/include/trace/events/timer.h
+++ b/include/trace/events/timer.h
@@ -328,23 +328,49 @@ TRACE_EVENT(itimer_expire,
);

#ifdef CONFIG_NO_HZ_COMMON
+
+#define TICK_DEP_NAMES \
+ tick_dep_name(NONE) \
+ tick_dep_name(POSIX_TIMER) \
+ tick_dep_name(PERF_EVENTS) \
+ tick_dep_name(SCHED) \
+ tick_dep_name_end(CLOCK_UNSTABLE)
+
+#undef tick_dep_name
+#undef tick_dep_name_end
+
+#define tick_dep_name(sdep) TRACE_DEFINE_ENUM(TICK_##sdep##_MASK);
+#define tick_dep_name_end(sdep) TRACE_DEFINE_ENUM(TICK_##sdep##_MASK);
+
+TICK_DEP_NAMES
+
+#undef tick_dep_name
+#undef tick_dep_name_end
+
+#define tick_dep_name(sdep) { TICK_##sdep##_MASK, #sdep },
+#define tick_dep_name_end(sdep) { TICK_##sdep##_MASK, #sdep }
+
+#define show_tick_dep_name(val) \
+ __print_symbolic(val, TICK_DEP_NAMES)
+
TRACE_EVENT(tick_stop,

- TP_PROTO(int success, char *error_msg),
+ TP_PROTO(int success, int dependency),

- TP_ARGS(success, error_msg),
+ TP_ARGS(success, dependency),

TP_STRUCT__entry(
__field( int , success )
- __string( msg, error_msg )
+ __field( int , dependency )
),

TP_fast_assign(
__entry->success = success;
- __assign_str(msg, error_msg);
+ __entry->dependency = dependency;
),

- TP_printk("success=%s msg=%s", __entry->success ? "yes" : "no", __get_str(msg))
+ TP_printk("success=%d dependency=%s", __entry->success, \
+ show_tick_dep_name(__entry->dependency))
);
#endif

diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c
index 093b807..b3bd5c4 100644
--- a/kernel/time/tick-sched.c
+++ b/kernel/time/tick-sched.c
@@ -161,22 +161,22 @@ static unsigned long tick_dependency;
static void trace_tick_dependency(unsigned long dep)
{
if (dep & TICK_POSIX_TIMER_MASK) {
- trace_tick_stop(0, "posix timers running\n");
+ trace_tick_stop(0, TICK_POSIX_TIMER_MASK);
return;
}

if (dep & TICK_PERF_EVENTS_MASK) {
- trace_tick_stop(0, "perf events running\n");
+ trace_tick_stop(0, TICK_PERF_EVENTS_MASK);
return;
}

if (dep & TICK_SCHED_MASK) {
- trace_tick_stop(0, "more than 1 task in runqueue\n");
+ trace_tick_stop(0, TICK_SCHED_MASK);
return;
}

if (dep & TICK_CLOCK_UNSTABLE_MASK)
- trace_tick_stop(0, "unstable sched clock\n");
+ trace_tick_stop(0, TICK_CLOCK_UNSTABLE_MASK);
}

static bool can_stop_full_tick(struct tick_sched *ts)
@@ -204,17 +204,17 @@ static bool can_stop_full_tick(struct tick_sched *ts)
}

if (!sched_can_stop_tick()) {
- trace_tick_stop(0, "more than 1 task in runqueue\n");
+ trace_tick_stop(0, TICK_SCHED_MASK);
return false;
}

if (!posix_cpu_timers_can_stop_tick(current)) {
- trace_tick_stop(0, "posix timers running\n");
+ trace_tick_stop(0, TICK_POSIX_TIMER_MASK);
return false;
}

if (!perf_event_can_stop_tick()) {
- trace_tick_stop(0, "perf events running\n");
+ trace_tick_stop(0, TICK_PERF_EVENTS_MASK);
return false;
}

@@ -226,7 +226,7 @@ static bool can_stop_full_tick(struct tick_sched *ts)
* sched_clock_stable is set.
*/
if (!sched_clock_stable()) {
- trace_tick_stop(0, "unstable sched clock\n");
+ trace_tick_stop(0, TICK_CLOCK_UNSTABLE_MASK);
/*
* Don't allow the user to think they can get
* full NO_HZ with this machine.
@@ -803,7 +803,7 @@ static ktime_t tick_nohz_stop_sched_tick(struct tick_sched *ts,

ts->last_tick = hrtimer_get_expires(&ts->sched_timer);
ts->tick_stopped = 1;
- trace_tick_stop(1, " ");
+ trace_tick_stop(1, TICK_NONE_MASK);
}

/*
--
2.6.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/