Re: [RFC - beta][PATCH] tracing: Introduce TRACE_MARKER() no argument trace event
From: Frederic Weisbecker
Date: Thu Feb 13 2014 - 09:26:53 EST
On Fri, Feb 07, 2014 at 11:23:57AM -0500, Steven Rostedt wrote:
> A while back ago, Wolfgang (and others) have asked about the ability to
> add a trace event that recorder no data other than the fact that the
> trace event was hit.
>
> I've been reluctant to do so, but I noticed that one already exists in
> the iwlwifi tracepoints (iwlwifi_dev_irq) where it does a wasteful:
>
> /* TP_printk("") doesn't compile */
> TP_printk("%d", 0)
>
> The reason this is wasteful, is that there's a lot of code generated by
> the TRACE_EVENT() macros that end up basically being nops.
>
> I figured I would instead create a TRACE_MARKER(name, print) that would
> be something like:
>
> Added to tracepoint header:
>
> TRACE_MARKER(tpname, "Show this message");
>
> Then you have:
>
> trace_tpname();
>
> in the code.
>
> Notice that the tracepoint function (trace_<name>()) has no arguments.
> That's because the message is stored in the tracepoint (in one place)
> and is printed when the tracepoint is read. That is, the message isn't
> even recorded in the ring buffer.
>
> It still shows up in the tracepoint format file:
>
> name: tpname
> ID: 281
> format:
> field:unsigned short common_type; offset:0; size:2; signed:0;
> field:unsigned char common_flags; offset:2; size:1; signed:0;
> field:unsigned char common_preempt_count; offset:3; size:1; signed:0;
> field:int common_pid; offset:4; size:4; signed:1;
>
>
> print fmt: "Show this message"
>
> The TRACE_MARKER() is basically an optimized version of TRACE_EVENT()
> with no arguments. It can be enabled and disabled the same way as any
> other event, and stays within the system it was created in.
>
> Is this worth doing?
It sounds worth yeah. I've run into this situation multiple times where I had
to pass 0 instead of nothing on a tracepoint.
Now about the name, why not TRACE_EVENT_EMPTY?
Thanks.
--
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/