Re: [PATCH v4 2/3] tracing: Add trace_irqsoff tracepoints

From: Steven Rostedt
Date: Tue Aug 30 2016 - 10:09:08 EST


On Tue, 30 Aug 2016 15:58:43 +0530
Binoy Jayan <binoy.jayan@xxxxxxxxxx> wrote:

> This work is based on work by Daniel Wagner. A few tracepoints are added
> at the end of the critical section. With the hist trigger in place, the
> hist trigger plots may be generated, with per-cpu breakdown of events
> captured. It is based on linux kernel's event infrastructure.
>
> The following filter(s) may be used
>
> 'hist:key=latency.log2:val=hitcount:sort=latency'
> 'hist:key=ltype,latency:val=hitcount:sort=latency if cpu==1'
> 'hist:key=ltype:val=latency:sort=ltype if ltype==0 && cpu==2'
>
> Where ltype is
> 0: IRQSOFF latency
> 1: PREEMPTOFF Latency
> 2: Critical Timings
>
> This captures only the latencies introduced by disabled irqs and
> preemption. Additional per process data has to be captured to calculate
> the effective latencies introduced for individual processes.
>
> Initial work - latency.patch
>
> [1] https://git.kernel.org/cgit/linux/kernel/git/rt/linux-stable-rt.git/commit/?h=v3.14-rt-rebase&id=56d50cc34943bbba12b8c5942ee1ae3b29f73acb
>
> Signed-off-by: Binoy Jayan <binoy.jayan@xxxxxxxxxx>
> ---
> include/trace/events/latency.h | 35 +++++++++++++++++++++++++++++++++++
> kernel/trace/trace_irqsoff.c | 42 ++++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 77 insertions(+)
> create mode 100644 include/trace/events/latency.h
>
> diff --git a/include/trace/events/latency.h b/include/trace/events/latency.h
> new file mode 100644
> index 0000000..e89be12
> --- /dev/null
> +++ b/include/trace/events/latency.h
> @@ -0,0 +1,35 @@
> +#undef TRACE_SYSTEM
> +#define TRACE_SYSTEM latency
> +
> +#if !defined(_TRACE_HIST_H) || defined(TRACE_HEADER_MULTI_READ)
> +#define _TRACE_HIST_H
> +
> +#include <linux/tracepoint.h>
> +
> +DECLARE_EVENT_CLASS(latency_template,
> + TP_PROTO(int ltype, cycles_t latency),
> +
> + TP_ARGS(ltype, latency),
> +
> + TP_STRUCT__entry(
> + __field(int, ltype)
> + __field(cycles_t, latency)
> + ),
> +
> + TP_fast_assign(
> + __entry->ltype = ltype;
> + __entry->latency = latency;
> + ),
> +
> + TP_printk("ltype=%d, latency=%lu",
> + __entry->ltype, (unsigned long) __entry->latency)

The print of ltype should be text and not a number. Well, you could
have both text and a number, but a number is useless for those looking
at traces.

There's infrastructure to do this, see __print_symbolic() and
TRACE_DEFINE_ENUM().

-- Steve

> +);
> +
> +DEFINE_EVENT(latency_template, latency_preempt,
> + TP_PROTO(int ltype, cycles_t latency),
> + TP_ARGS(ltype, latency));
> +
> +#endif /* _TRACE_HIST_H */
> +