From: Alexei Starovoitov <ast@plumgrid.com>
To: "Wangnan (F)" <wangnan0@huawei.com>,
He Kuang <hekuang@huawei.com>,
Peter Zijlstra <peterz@infradead.org>
Cc: rostedt@goodmis.org, masami.hiramatsu.pt@hitachi.com,
mingo@redhat.com, acme@redhat.com, jolsa@kernel.org,
namhyung@kernel.org, linux-kernel@vger.kernel.org,
pi3orama <pi3orama@163.com>
Subject: Re: [RFC PATCH 0/5] Make eBPF programs output data to perf event
Date: Thu, 02 Jul 2015 11:37:51 -0700 [thread overview]
Message-ID: <559584FF.2000500@plumgrid.com> (raw)
In-Reply-To: <55950356.3050507@huawei.com>
On 7/2/15 2:24 AM, Wangnan (F) wrote:
> Yes, by using perf_trace_buf_prepare() + perf_trace_buf_submit() in
> helper function and let bpf program always returns 0 we can make data
> collected by BPF programs output into samples, if following problems
> are solved:
>
> 1. In bpf program there's no way to get 'struct perf_event' or 'struct
> ftrace_event_call'. We have to deduce them through pt_regs:
>
> pt_regs -> ip -> kprobe -> struct trace_kprobe -> struct
> ftrace_event_call -> hlist_entry -> struct perf_event
yeah, going through hash table via get_kprobe() is not pretty.
How about using this_cpu_write(current_perf_event, ...) and using it
from the helper? bpf progs are non-preemptable and non-reentrable.
Also I think this helper would be more flexible if we can
allow passing sample_type into it.
Ideally from the program one could do something like:
bpf_event_output(buf, sizeof(buf), PERF_SAMPLE_CALLCHAIN);
which will prepare a sample with raw buf and callstack.
This way program can decide when and how send events to user space.
> 2. Even if we finally get 'struct perf_event', I'm not sure whether
> user really concern on it. If we really concern on all information
> output through perf_trace_buf_submit() like callstack and
> register, why not make bpf program return non-zero instead? But then
> we have to consider how to connect two samples together.
see my suggestion above. when sample_type was hard coded during event
creation it's a useful case on its own, but if we can make program to
provide this type dynamically, it will open whole new set of possibilities.
next prev parent reply other threads:[~2015-07-02 18:37 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-01 2:57 [RFC PATCH 0/5] Make eBPF programs output data to perf event He Kuang
2015-07-01 2:57 ` [RFC PATCH 1/5] bpf: Put perf_events check ahead of bpf prog He Kuang
2015-07-02 3:50 ` Alexei Starovoitov
2015-07-02 5:52 ` Wangnan (F)
2015-07-02 18:02 ` Alexei Starovoitov
2015-07-01 2:57 ` [RFC PATCH 2/5] perf/trace: Add perf extra percpu trace buffer He Kuang
2015-07-01 2:57 ` [RFC PATCH 3/5] tracing/kprobe: Separate inc recursion count out of perf_trace_buf_prepare He Kuang
2015-07-01 2:57 ` [RFC PATCH 4/5] bpf: Introduce function for outputing sample data to perf event He Kuang
2015-07-01 2:57 ` [RFC PATCH 5/5] tracing/kprobe: Combine extra trace buf into perf trace buf He Kuang
2015-07-01 5:44 ` [RFC PATCH 0/5] Make eBPF programs output data to perf event Peter Zijlstra
2015-07-01 6:21 ` Wangnan (F)
2015-07-01 11:58 ` Peter Zijlstra
2015-07-02 2:48 ` Alexei Starovoitov
2015-07-02 3:38 ` He Kuang
2015-07-02 3:52 ` Alexei Starovoitov
2015-07-02 9:24 ` Wangnan (F)
2015-07-02 18:37 ` Alexei Starovoitov [this message]
2015-07-02 9:31 ` Peter Zijlstra
2015-07-02 13:50 ` [RFC PATCH v2 0/4] " He Kuang
2015-07-02 13:50 ` [RFC PATCH v2 1/4] bpf: Put perf_events check ahead of bpf prog He Kuang
2015-07-02 18:41 ` Alexei Starovoitov
2015-07-02 13:50 ` [RFC PATCH v2 2/4] tracing/kprobe: Separate inc recursion count out of perf_trace_buf_prepare He Kuang
2015-07-02 13:50 ` [RFC PATCH v2 3/4] bpf: Introduce function for outputing data to perf event He Kuang
2015-07-02 13:50 ` [RFC PATCH v2 4/4] tracing/kprobe: Combine bpf output and perf event output He Kuang
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=559584FF.2000500@plumgrid.com \
--to=ast@plumgrid.com \
--cc=acme@redhat.com \
--cc=hekuang@huawei.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=masami.hiramatsu.pt@hitachi.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
--cc=pi3orama@163.com \
--cc=rostedt@goodmis.org \
--cc=wangnan0@huawei.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