Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1439659

Re: perf bpf examples

From Brendan Gregg <brendan.d.gregg@gmail.com>
Newsgroups linux.kernel
Subject Re: perf bpf examples
Date 2016-07-08 18:40 +0200
Message-ID <rSGYO-7fn-29@gated-at.bofh.it> (permalink)
References (2 earlier) <rSvqF-896-11@gated-at.bofh.it> <rSvqF-896-13@gated-at.bofh.it> <rSvqF-896-5@gated-at.bofh.it> <rSyRz-1NP-11@gated-at.bofh.it> <rSBw5-3D9-9@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Fri, Jul 8, 2016 at 3:46 AM, Wangnan (F) <wangnan0@huawei.com> wrote:
>
>
> On 2016/7/8 15:57, Brendan Gregg wrote:
>>
[...]
>> I mean just an -F99 that executes a BPF program on each sample. My
>> most common use for perf is:
>>
>> perf record -F 99 -a -g -- sleep 30
>> perf report (or perf script, for making flame graphs)
>>
>> But this uses perf.data as an intermediate file. With the recent
>> BPF_MAP_TYPE_STACK_TRACE, we could frequency count stack traces in
>> kernel context, and just dump a report. Much more efficient. And
>> improving a very common perf one-liner.
>
>
> You can't attach BPF script to samples other than kprobe and tracepoints.
> When you use 'perf record -F99 -a -g -- sleep 30', you are sampling on
> 'cycles:ppp' event. This is a hardware PMU event.

Sure, either cycles:ppp or cpu-clock (my Xen guests have no PMU,
sadly). But These are ultimately calling perf_swevent_hrtimer()/etc,
so I was wondering if someone was already looking at enhancing this
code to support BPF? Ie, BPF should be able to attach to kprobes,
uprobes, tracepoints, and timer-based samples.

> If we find a kprobe or tracepoint event which would be triggered 99 times
> in each second, we can utilize BPF_MAP_TYPE_STACK_TRACE and
> bpf_get_stackid().

Yes, that should be a workaround. It's annoying as some like
perf_swevent_hrtimer() can't be kprobed (inlined?), but I found
perf_misc_flags(struct pt_regs *regs) was called, but passing in that
regs to bpf_get_stackid() was returning "type=inv expected=ctx"
errors, despite casting. I'm guessing the BPF ctx type is special and
can't be casted, but need to dig more.

Brendan

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Re: perf bpf examples "Wangnan (F)" <wangnan0@huawei.com> - 2016-07-08 06:20 +0200
  Re: perf bpf examples Brendan Gregg <brendan.d.gregg@gmail.com> - 2016-07-08 10:00 +0200
    Re: perf bpf examples "Wangnan (F)" <wangnan0@huawei.com> - 2016-07-08 12:50 +0200
      Re: perf bpf examples Brendan Gregg <brendan.d.gregg@gmail.com> - 2016-07-08 18:40 +0200

csiph-web