Re: [PATCH] ftrace: add an fsync tracer

From: Mathieu Desnoyers
Date: Thu Nov 06 2008 - 16:53:38 EST


* Peter Zijlstra (peterz@xxxxxxxxxxxxx) wrote:
> On Thu, 2008-11-06 at 15:19 -0500, Frank Ch. Eigler wrote:
> > Arjan van de Ven <arjan@xxxxxxxxxxxxx> writes:
> >
> > > [...]
> > > what is the real need is
> > > 1) Have a trace point in the source
> > > 2) Associate a "formatting function" with that point
> > > (which basically transforms the trace parameters to, say, a string)
> > > 3) A way to turn the trace point on/off.
> >
> > For 1 and 2, it may be worth considering a plain trace_mark() in
> > do_sync(). The complication that makes this uglier than a one-liner
> > is d_path()'s buffer and error handling.
> >
> > {
> > char *buffer = kzalloc (4096, GFP_KERNEL);
> > trace_mark(fsync, "Process %s is calling fsync on %s\n",
> > current->comm,
> > ({char *err = d_path (...);
> > IS_ERR(err) ? "?" : err;}));
> > kfree (buffer);
> > }
> >
> > With a bit of extension on the marker front, the allocation could be
> > made conditional on the marker being enabled.
> >
> >
> > For 3, the kernel could merge a backend that connects arbitrary
> > markers to an ftrace (or whatever) buffer. Several compact prototypes
> > for the latter exist.
>
>
> I prefer we keep using trace points but do what jason has been proposing
> for a while, which is add a format and arg list to the trace point
> definition.
>
> Something like
>
> DEFINE_TRACE_FMT(sched_switch,
> TPPROTO(struct rq *rq, struct task_struct *prev,
> struct task_struct *next),
> TPARGS(rq, prev, next),
> TPFMT("%d to %d\n", prev->pid, next->pid));
>
> Which would be similar to attaching a trace_mark() to the trace point
> and can in these cases save a lot of lines of code.
>
> Both lttng and the ftrace event tracer can use these default text
> strings.
>
>

Argh. No, please. Doing this would end up exposing the inner kernel API
(the tracepoints) directly to userspace.

I've done an addition to the markers which does approximately the same.
It's in the -lttng tree now, I should post it soon.

A new marker type, trace_mark_tp() also takes a tracepoint name as
parameter. When the tracepoint is enabled, it also enables the
associated tracepoint. And it makes sure tracepoints are not exposed to
userspace.

Mathieu



--
Mathieu Desnoyers
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68
--
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/