All of lore.kernel.org
 help / color / mirror / Atom feed
* linux 4.4, perf & BPF, and bpf_perf_event_output
@ 2016-01-12  0:07 Brendan Gregg
  2016-01-12  2:36 ` Wangnan (F)
  0 siblings, 1 reply; 5+ messages in thread
From: Brendan Gregg @ 2016-01-12  0:07 UTC (permalink / raw)
  To: linux-perf-use., Alexei Starovoitov, Wang Nan

G'Day,

Congrats Wang Nan on the new perf bpf features in 4.4! I just
revisited where I was at with them now that it's official, and have a
couple of questions.

So I can run something like this:

---syncsnoop.c---
/* perf.data: default event record only; trace_pipe:
bpf_trace_printk() output */
#include <uapi/linux/bpf.h>
#include "bpf_helpers.h"

SEC("func=sys_sync")
int bpf_func__sys_sync(void *ctx)
{
    char fmt[] = "sync()\n";
    bpf_trace_printk(fmt, sizeof (fmt));
    return 1;
};

char _license[] SEC("license") = "GPL";
int _version SEC("version") = LINUX_VERSION_CODE;
------

With: perf record -a --clang-opt "-DLINUX_VERSION_CODE=0x40400"
--event syncsnoop.c sleep 5

And it works. I get PERF_RECORD_SAMPLE entries in perf.data, and my
custom strings in /sys/kernel/debug/tracing/trace_pipe.

Q1. Given bpf_trace_printk() & trace_pipe is a hack, is there a way
yet to print my custom strings to perf.data? Eg, something like
bpf_perf_event_output() to change the format string of the event.
Currently I just get:

# perf script
            sync 30207 [002]  2509.576984: perf_bpf_probe:func:
(ffffffff81221b20)
            sync 30209 [003]  2509.766632: perf_bpf_probe:func:
(ffffffff81221b20)
            sync 30229 [003]  2509.936299: perf_bpf_probe:func:
(ffffffff81221b20)
            sync 30230 [004]  2510.099059: perf_bpf_probe:func:
(ffffffff81221b20)
            sync 30231 [004]  2510.289351: perf_bpf_probe:func:
(ffffffff81221b20)

Q2. Apart from per-event strings, is there a way to emit the maps?
bpf-script-example.c populates a map, but I don't think it ends up in
perf.data. I think a common case would be to emit it once for the run.
Another common case would be to emit it once per second. Any way we
can do this? I did try bpf_perf_event_output(), but I don't think it
ended up in perf.data (at least, I don't see it using "perf script
-D").

thanks,

Brendan

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-01-13  2:54 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-01-12  0:07 linux 4.4, perf & BPF, and bpf_perf_event_output Brendan Gregg
2016-01-12  2:36 ` Wangnan (F)
2016-01-12 15:27   ` Arnaldo Carvalho de Melo
2016-01-12 20:56   ` Brendan Gregg
2016-01-13  2:54     ` Wangnan (F)

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.