From: Yonghong Song <yhs@fb.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Daniel Xu <dxu@dxuuu.xyz>,
"bpf@vger.kernel.org" <bpf@vger.kernel.org>,
Song Liu <songliubraving@fb.com>,
Andrii Nakryiko <andriin@fb.com>,
"mingo@redhat.com" <mingo@redhat.com>,
"acme@kernel.org" <acme@kernel.org>,
Alexei Starovoitov <ast@fb.com>,
"alexander.shishkin@linux.intel.com"
<alexander.shishkin@linux.intel.com>,
"jolsa@redhat.com" <jolsa@redhat.com>,
"namhyung@kernel.org" <namhyung@kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Kernel Team <Kernel-team@fb.com>,
"Arnaldo Carvalho de Melo" <acme@redhat.com>
Subject: Re: [PATCH v3 bpf-next 1/4] tracing/probe: Add PERF_EVENT_IOC_QUERY_PROBE ioctl
Date: Wed, 21 Aug 2019 18:43:49 +0000 [thread overview]
Message-ID: <5ecdcd72-255d-26d1-baf3-dc64498753c2@fb.com> (raw)
In-Reply-To: <20190821183155.GE2349@hirez.programming.kicks-ass.net>
On 8/21/19 11:31 AM, Peter Zijlstra wrote:
> On Wed, Aug 21, 2019 at 04:54:47PM +0000, Yonghong Song wrote:
>> Currently, in kernel/trace/bpf_trace.c, we have
>>
>> unsigned int trace_call_bpf(struct trace_event_call *call, void *ctx)
>> {
>> unsigned int ret;
>>
>> if (in_nmi()) /* not supported yet */
>> return 1;
>>
>> preempt_disable();
>>
>> if (unlikely(__this_cpu_inc_return(bpf_prog_active) != 1)) {
>
> Yes, I'm aware of that.
>
>> In the above, the events with bpf program attached will be missed
>> if the context is nmi interrupt, or if some recursion happens even with
>> the same or different bpf programs.
>> In case of recursion, the events will not be sent to ring buffer.
>
> And while that is significantly worse than what ftrace/perf have, it is
> fundamentally the same thing.
>
> perf allows (and iirc ftrace does too) 4 nested context per CPU
> (task,softirq,irq,nmi) but any recursion within those context and we
> drop stuff.
>
> The BPF stuff is just more eager to drop things on the floor, but it is
> fundamentally the same.
>
>> A lot of bpf-based tracing programs uses maps to communicate and
>> do not allocate ring buffer at all.
>
> So extending PERF_RECORD_LOST doesn't work. But PERF_FORMAT_LOST might
> still work fine; but you get to implement it for all software events.
Could you give more specifics about PERF_FORMAT_LOST? Googling
"PERF_FORMAT_LOST" only yields two emails which we are discussing here :-(
>
>> Maybe we can still use ioctl based approach which is light weighted
>> compared to ring buffer approach? If a fd has bpf attached, nhit/nmisses
>> means the kprobe is processed by bpf program or not.
>
> There is nothing kprobe specific here. Kprobes just appear to be the
> only one actually accounting the recursion cases, but everyone has
> them.
Sorry to be specific, kprobe is just an example, I actually refers to
any perf event where bpf can attach to, which theoretically are any
perf events which can be opened with "perf_event_open" syscall although
some of them (e.g., software events?) may not have bpf running hooks yet.
>
>> Currently, for debugfs, the nhit/nmisses info is exposed at
>> {k|u}probe_profile. Alternative, we could expose the nhit/nmisses
>> in /proc/self/fdinfo/<fd>. User can query this interface to
>> get numbers.
>
> No, we're not adding stuff to procfs for this.
No problem. Just a suggestion.
next prev parent reply other threads:[~2019-08-21 18:44 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-16 22:31 [PATCH v3 bpf-next 0/4] tracing/probe: Add PERF_EVENT_IOC_QUERY_PROBE Daniel Xu
2019-08-16 22:31 ` [PATCH v3 bpf-next 1/4] tracing/probe: Add PERF_EVENT_IOC_QUERY_PROBE ioctl Daniel Xu
2019-08-19 18:22 ` kbuild test robot
2019-08-20 1:26 ` Alexei Starovoitov
2019-08-20 2:34 ` Daniel Xu
2019-08-20 2:52 ` Alexei Starovoitov
2019-08-20 2:04 ` kbuild test robot
2019-08-20 14:45 ` Peter Zijlstra
2019-08-20 17:58 ` Daniel Xu
2019-08-21 11:08 ` Peter Zijlstra
2019-08-21 16:54 ` Yonghong Song
2019-08-21 18:31 ` Peter Zijlstra
2019-08-21 18:43 ` Yonghong Song [this message]
2019-08-21 20:04 ` Arnaldo Carvalho de Melo
2019-08-22 7:47 ` Peter Zijlstra
2019-08-22 7:54 ` Song Liu
2019-08-22 9:05 ` Peter Zijlstra
2019-08-22 21:08 ` Daniel Xu
2019-08-21 20:07 ` Arnaldo Carvalho de Melo
2019-08-21 22:10 ` Yonghong Song
2019-08-16 22:31 ` [PATCH v3 bpf-next 2/4] libbpf: Add helpers to extract perf fd from bpf_link Daniel Xu
2019-08-19 17:45 ` Andrii Nakryiko
2019-08-19 21:30 ` Daniel Xu
2019-08-16 22:31 ` [PATCH v3 bpf-next 3/4] tracing/probe: Sync perf_event.h to tools Daniel Xu
2019-08-16 22:31 ` [PATCH v3 bpf-next 4/4] tracing/probe: Add self test for PERF_EVENT_IOC_QUERY_PROBE Daniel Xu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5ecdcd72-255d-26d1-baf3-dc64498753c2@fb.com \
--to=yhs@fb.com \
--cc=Kernel-team@fb.com \
--cc=acme@kernel.org \
--cc=acme@redhat.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=andriin@fb.com \
--cc=ast@fb.com \
--cc=bpf@vger.kernel.org \
--cc=dxu@dxuuu.xyz \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
--cc=songliubraving@fb.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox