From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Song Liu <liu.song.a23@gmail.com>
Cc: David Ahern <dsahern@gmail.com>,
Alexei Starovoitov <alexei.starovoitov@gmail.com>,
Peter Zijlstra <peterz@infradead.org>,
Alexei Starovoitov <ast@kernel.org>,
Alexey Budankov <alexey.budankov@linux.intel.com>,
"David S . Miller" <davem@davemloft.net>,
Daniel Borkmann <daniel@iogearbox.net>,
Namhyung Kim <namhyung@kernel.org>, Jiri Olsa <jolsa@kernel.org>,
Networking <netdev@vger.kernel.org>,
kernel-team@fb.com
Subject: Re: [PATCH bpf-next 2/3] bpf: emit RECORD_MMAP events for bpf prog load/unload
Date: Wed, 17 Oct 2018 09:11:40 -0300 [thread overview]
Message-ID: <20181017121140.GA31465@kernel.org> (raw)
In-Reply-To: <CAPhsuW7zZE51ibma__y8SDVUU_YQMjGyHRhYDhBsuJF_b89h6g@mail.gmail.com>
Adding Alexey, Jiri and Namhyung as they worked/are working on
multithreading 'perf record'.
Em Tue, Oct 16, 2018 at 11:43:11PM -0700, Song Liu escreveu:
> On Tue, Oct 16, 2018 at 4:43 PM David Ahern <dsahern@gmail.com> wrote:
> > On 10/15/18 4:33 PM, Song Liu wrote:
> > > I am working with Alexei on the idea of fetching BPF program information via
> > > BPF_OBJ_GET_INFO_BY_FD cmd. I added PERF_RECORD_BPF_EVENT
> > > to perf_event_type, and dumped these events to perf event ring buffer.
> > > I found that perf will not process event until the end of perf-record:
> > > root@virt-test:~# ~/perf record -ag -- sleep 10
> > > ...... 10 seconds later
> > > [ perf record: Woken up 34 times to write data ]
> > > machine__process_bpf_event: prog_id 6 loaded
> > > machine__process_bpf_event: prog_id 6 unloaded
> > > [ perf record: Captured and wrote 9.337 MB perf.data (93178 samples) ]
> > > In this example, the bpf program was loaded and then unloaded in
> > > another terminal. When machine__process_bpf_event() processes
> > > the load event, the bpf program is already unloaded. Therefore,
> > > machine__process_bpf_event() will not be able to get information
> > > about the program via BPF_OBJ_GET_INFO_BY_FD cmd.
> > > To solve this problem, we will need to run BPF_OBJ_GET_INFO_BY_FD
> > > as soon as perf get the event from kernel. I looked around the perf
> > > code for a while. But I haven't found a good example where some
> > > events are processed before the end of perf-record. Could you
> > > please help me with this?
> > perf record does not process events as they are generated. Its sole job
> > is pushing data from the maps to a file as fast as possible meaning in
> > bulk based on current read and write locations.
> > Adding code to process events will add significant overhead to the
> > record command and will not really solve your race problem.
> I agree that processing events while recording has significant overhead.
> In this case, perf user space need to know details about the the jited BPF
> program. It is impossible to pass all these details to user space through
> the relatively stable ring_buffer API. Therefore, some processing of the
> data is necessary (get bpf prog_id from ring buffer, and then fetch program
> details via BPF_OBJ_GET_INFO_BY_FD.
> I have some idea on processing important data with relatively low overhead.
> Let me try implement it.
Well, you could have a separate thread processing just those kinds of
events, associate it with a dummy event where you only ask for
PERF_RECORD_BPF_EVENTs.
Here is how to setup the PERF_TYPE_SOFTWARE/PERF_COUNT_SW_DUMMY
perf_event_attr:
[root@seventh ~]# perf record -vv -e dummy sleep 01
------------------------------------------------------------
perf_event_attr:
type 1
size 112
config 0x9
{ sample_period, sample_freq } 4000
sample_type IP|TID|TIME|PERIOD
disabled 1
inherit 1
mmap 1
comm 1
freq 1
enable_on_exec 1
task 1
sample_id_all 1
exclude_guest 1
mmap2 1
comm_exec 1
------------------------------------------------------------
sys_perf_event_open: pid 12046 cpu 0 group_fd -1 flags 0x8 = 4
sys_perf_event_open: pid 12046 cpu 1 group_fd -1 flags 0x8 = 5
sys_perf_event_open: pid 12046 cpu 2 group_fd -1 flags 0x8 = 6
sys_perf_event_open: pid 12046 cpu 3 group_fd -1 flags 0x8 = 8
mmap size 528384B
perf event ring buffer mmapped per cpu
Synthesizing TSC conversion information
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.014 MB perf.data ]
[root@seventh ~]#
[root@seventh ~]# perf evlist -v
dummy: type: 1, size: 112, config: 0x9, { sample_period, sample_freq }: 4000, sample_type: IP|TID|TIME|PERIOD, disabled: 1, inherit: 1, mmap: 1, comm: 1, freq: 1, enable_on_exec: 1, task: 1, sample_id_all: 1, exclude_guest: 1, mmap2: 1, comm_exec: 1
[root@seventh ~]#
There is work ongoing in dumping one file per cpu and then, at post
processing time merging all those files to get ordering, so one more
file, for these VIP events, that require per-event processing would be
ordered at that time with all the other per-cpu files.
- Arnaldo
next prev parent reply other threads:[~2018-10-17 20:07 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-19 22:39 [PATCH bpf-next 0/3] perf, bpf: reveal invisible bpf programs Alexei Starovoitov
2018-09-19 22:39 ` [PATCH bpf-next 1/3] perf/core: introduce perf_event_mmap_bpf_prog Alexei Starovoitov
2018-09-19 23:30 ` Song Liu
2018-09-20 0:53 ` Alexei Starovoitov
2018-09-19 22:39 ` [PATCH bpf-next 2/3] bpf: emit RECORD_MMAP events for bpf prog load/unload Alexei Starovoitov
2018-09-19 23:44 ` Song Liu
2018-09-20 0:59 ` Alexei Starovoitov
2018-09-20 5:48 ` Song Liu
2018-09-20 8:44 ` Peter Zijlstra
2018-09-20 13:25 ` Arnaldo Carvalho de Melo
2018-09-20 13:56 ` Peter Zijlstra
2018-09-21 3:14 ` Alexei Starovoitov
2018-09-21 12:25 ` Arnaldo Carvalho de Melo
2018-09-21 13:55 ` Peter Zijlstra
2018-09-21 13:59 ` Peter Zijlstra
2018-09-21 22:13 ` Alexei Starovoitov
2018-10-15 23:33 ` Song Liu
2018-10-16 23:43 ` David Ahern
2018-10-17 6:43 ` Song Liu
2018-10-17 12:11 ` Arnaldo Carvalho de Melo [this message]
2018-10-17 12:50 ` Arnaldo Carvalho de Melo
2018-10-17 16:06 ` Song Liu
2018-11-02 1:08 ` Song Liu
2018-10-17 15:09 ` David Ahern
2018-10-17 16:18 ` Song Liu
2018-10-17 16:36 ` Alexei Starovoitov
2018-10-17 18:53 ` Arnaldo Carvalho de Melo
2018-10-17 19:08 ` Alexei Starovoitov
2018-10-17 21:31 ` Arnaldo Carvalho de Melo
2018-10-17 22:01 ` Alexei Starovoitov
2018-09-20 13:36 ` Peter Zijlstra
2018-09-19 22:39 ` [PATCH perf 3/3] tools/perf: recognize and process RECORD_MMAP events for bpf progs Alexei Starovoitov
2018-09-20 13:36 ` Arnaldo Carvalho de Melo
2018-09-20 14:05 ` Arnaldo Carvalho de Melo
2018-09-21 22:57 ` Song Liu
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=20181017121140.GA31465@kernel.org \
--to=acme@kernel.org \
--cc=alexei.starovoitov@gmail.com \
--cc=alexey.budankov@linux.intel.com \
--cc=ast@kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=dsahern@gmail.com \
--cc=jolsa@kernel.org \
--cc=kernel-team@fb.com \
--cc=liu.song.a23@gmail.com \
--cc=namhyung@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=peterz@infradead.org \
/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;
as well as URLs for NNTP newsgroup(s).