Re: [PATCH] perf tools: Add sample types for bpf-output event
From: Arnaldo Carvalho de Melo
Date: Fri Apr 01 2016 - 11:20:14 EST
Em Fri, Apr 01, 2016 at 12:16:10PM -0300, Arnaldo Carvalho de Melo escreveu:
> Perhaps, to make all more familiar we could even define equivalents to
> stdio.h functions like puts, printf, fputs, etc, that would send to this
> bpf-output based "stdout" "channel", then the above would end up being:
>
> func(void *ctx, int type)
> {
> char err_str[] = "BAD %d\n";
> int err;
>
> err = puts("Raise a BPF event!");
> if (err)
> trace_printk(err_str, sizeof(err_str), err);
> return 1;
> }
>
> This trace_printk() in turn could become error() (glibc's error.h header), i.e.
> the error mechanism would use the equivalent to userland's "syslog", i.e.
> trace_printk :-)
>
> In general trying to make BPF C scriptlets fed via perf to be as compact as
> possible, hiding all these details while allowing them to be used, if desired.
One extra possibility would be that it would look so much like a user
space C program that we could test it without loading it to the kernel,
with just building it with a different header and feeding it data as it
would get inside the kernel :-)
- Arnaldo