Re: [patch] trace: Add user-space event tracing/injection

From: Frederic Weisbecker
Date: Wed Nov 17 2010 - 08:10:49 EST


On Wed, Nov 17, 2010 at 01:29:54PM +0100, Peter Zijlstra wrote:
> On Wed, 2010-11-17 at 13:07 +0100, Ingo Molnar wrote:
>
> > Subject: trace: Add user-space event tracing/injection
> > From: Ingo Molnar <mingo@xxxxxxx>
> > Date: Wed Nov 17 10:11:53 CET 2010
> >
> > This feature (suggested by Darren Hart and Pekka Engberg) allows user-space
> > programs to print trace events in a very simple and self-contained way:
> >
> > #include <sys/prctl.h>
> > #include <string.h>
> >
> > #define PR_TASK_PERF_USER_TRACE 35
> >
> > int main(void)
> > {
> > char *msg = "Hello World!\n";
> >
> > prctl(PR_TASK_PERF_USER_TRACE, msg, strlen(msg));
> >
> > return 0;
> > }
> >
> > These show up in 'trace' output as:
> >
> > $ trace report
> > #
> > # trace events of 'sleep 1':
> > #
> > testit/ 6006 ( 0.002 ms): <"Hello World!">
> > testit/ 6006 ( 0.002 ms): <"Hello World!">
> >
> > Suggested-by: Darren Hart <dvhart@xxxxxxxxxxxxxxx>
> > Suggested-by: Pekka Enberg <penberg@xxxxxxxxxx>
> > Signed-off-by: Ingo Molnar <mingo@xxxxxxx>
>
> I really dislike abusing prctl(), I understand your reasons, but it
> still sucks.
>
> Also, the naming doesn't work, you've implemented a trace event, that's
> got nothing to do with perf, so the PR_TASK_PERF_ prefix is incorrect.


Why not using write() on the perf event fd?
So that you don't only limit to a custom new simple event (which should
match most needs) but you can also inject whatever existing event you like.

--
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/