Re: [PATCH] staging: tracing/kprobe: filter kprobe based perf event

From: Alexei Starovoitov
Date: Wed Sep 18 2019 - 10:32:42 EST


On Wed, Sep 18, 2019 at 05:51:10AM +0000, Yonghong Song wrote:
>
> Adding cc to bpf@xxxxxxxxxxxxxxx mailing list since this is really
> bpf related.
>
> On 9/17/19 10:24 PM, jinshan.xiong@xxxxxxxxx wrote:
> > From: Jinshan Xiong <jinshan.xiong@xxxxxxxxx>
> >
> > Invoking bpf program only if kprobe based perf_event has been added into
> > the percpu list. This is essential to make event tracing for cgroup to work
> > properly.
>
> The issue actually exists for bpf programs with kprobe, uprobe,
> tracepoint and trace_syscall_enter/exit.
>
> In all these places, bpf program is called regardless of
> whether there are perf events or not on this cpu.
> This provides bpf programs more opportunities to see
> the events. I guess this is by design.
> Alexei/Daniel, could you clarify?

Yes. It is by design.
When bpf is attached to kprobe it will fire on all cpus.
Per-cpu or per-task or per-cgroup filtering is already done
inside bpf programs.
We cannot make this change now it will break all users.