From: Song Liu <songliubraving@fb.com>
To: Jiri Olsa <jolsa@redhat.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>,
Jiri Olsa <jolsa@kernel.org>, Namhyung Kim <namhyung@kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
"peterz@infradead.org" <peterz@infradead.org>,
"ast@kernel.org" <ast@kernel.org>,
"daniel@iogearbox.net" <daniel@iogearbox.net>,
Kernel Team <Kernel-team@fb.com>
Subject: Re: [PATCH v11 perf, bpf-next 7/9] perf tools: synthesize PERF_RECORD_* for loaded BPF programs
Date: Tue, 22 Jan 2019 18:38:56 +0000 [thread overview]
Message-ID: <101BF88D-2DA4-4B54-A710-D0641C427136@fb.com> (raw)
In-Reply-To: <20190122152145.GG27625@krava>
> On Jan 22, 2019, at 7:21 AM, Jiri Olsa <jolsa@redhat.com> wrote:
>
> On Tue, Jan 22, 2019 at 12:58:05PM -0200, Arnaldo Carvalho de Melo wrote:
>> Em Tue, Jan 22, 2019 at 03:51:19PM +0100, Jiri Olsa escreveu:
>>> On Tue, Jan 22, 2019 at 12:31:17PM -0200, Arnaldo Carvalho de Melo wrote:
>>>> Em Tue, Jan 22, 2019 at 12:13:20PM -0200, Arnaldo Carvalho de Melo escreveu:
>>>>> Em Fri, Jan 18, 2019 at 11:46:55AM -0300, Arnaldo Carvalho de Melo escreveu:
>>>>>> Em Thu, Jan 17, 2019 at 08:15:19AM -0800, Song Liu escreveu:
>>>>>>> This patch synthesize PERF_RECORD_KSYMBOL and PERF_RECORD_BPF_EVENT for
>>>>>>> BPF programs loaded before perf-record. This is achieved by gathering
>>>>>>> information about all BPF programs via sys_bpf.
>>>>>>
>>>>>> Ditto
>>>>>
>>>>> This is breaking 'perf sched', see below, the fix seems trivial:
>>>>>
>>>>> [root@quaco ~]# perf sched record -a sleep 2
>>>>> [ perf record: Woken up 1 times to write data ]
>>>>> 0x5b60 [0x138]: failed to process type: 17
>>>>> [ perf record: Captured and wrote 1.539 MB perf.data ]
>>>>> [root@quaco ~]# perf sched lat
>>>>> 0x5b60 [0x138]: failed to process type: 17
>>>>> Failed to process events, error -22
>>>>> [root@quaco ~]#
>>>>
>>>> So:
>>>>
>>>> perf_session__process_event (event->header.type = 17 (PERF_RECORD_KSYMBOL)
>>>> if (tool->ordered_events)
>>>> ret = perf_evlist__parse_sample_timestamp(evlist, event, ×tamp);
>>>> if (ret && ret != -1)
>>>> return ret;
>>>>
>>>> So it returns here with -EFAULT, i.e. this is failing:
>>>>
>>>> int perf_evlist__parse_sample_timestamp(struct perf_evlist *evlist,
>>>> union perf_event *event,
>>>> u64 *timestamp)
>>>> {
>>>> struct perf_evsel *evsel = perf_evlist__event2evsel(evlist, event);
>>>>
>>>> if (!evsel)
>>>> return -EFAULT;
>>>> return perf_evsel__parse_sample_timestamp(evsel, event, timestamp);
>>>> }
>>>>
>>>> It isn't mapping the event ID it finds back to an evsel.. Jiri, ideas?
>>>>
>>>> This is happening so far only for 'perf sched', perf record with two
>>>> events works.
>>>
>>> I saw also perf mem failing because of this.. will check
>>
>> Right, seems something with the synthesizing of existing bpf progs,
>> which always there are some nowadays, for instance, on this fedora29
>> system:
>>
>> [root@quaco tmp]# bpftool prog
>> 13: cgroup_skb tag 7be49e3934a125ba gpl
>> loaded_at 2019-01-21T13:30:27-0200 uid 0
>> xlated 296B jited 229B memlock 4096B map_ids 13,14
>> 14: cgroup_skb tag 2a142ef67aaad174 gpl
>> loaded_at 2019-01-21T13:30:27-0200 uid 0
>> xlated 296B jited 229B memlock 4096B map_ids 13,14
>> 15: cgroup_skb tag 7be49e3934a125ba gpl
>> loaded_at 2019-01-21T13:30:27-0200 uid 0
>> xlated 296B jited 229B memlock 4096B map_ids 15,16
>> 16: cgroup_skb tag 2a142ef67aaad174 gpl
>> loaded_at 2019-01-21T13:30:27-0200 uid 0
>> xlated 296B jited 229B memlock 4096B map_ids 15,16
>> 17: cgroup_skb tag 7be49e3934a125ba gpl
>> loaded_at 2019-01-21T13:30:29-0200 uid 0
>> xlated 296B jited 229B memlock 4096B map_ids 17,18
>> 18: cgroup_skb tag 2a142ef67aaad174 gpl
>> loaded_at 2019-01-21T13:30:29-0200 uid 0
>> xlated 296B jited 229B memlock 4096B map_ids 17,18
>> 21: cgroup_skb tag 7be49e3934a125ba gpl
>> loaded_at 2019-01-21T13:30:29-0200 uid 0
>> xlated 296B jited 229B memlock 4096B map_ids 21,22
>> 22: cgroup_skb tag 2a142ef67aaad174 gpl
>> loaded_at 2019-01-21T13:30:29-0200 uid 0
>> xlated 296B jited 229B memlock 4096B map_ids 21,22
>> [root@quaco tmp]#
>>
>> When with a bunch of tracepoints, that is what 'perf mem', 'perf kmem',
>> 'perf sched', etc does, it ends up failing here:
>>
>> ret = perf_evlist__parse_sample_timestamp(evlist, event, ×tamp);
>>
>> So it is not passed to
>>
>> ret = perf_session__queue_event(session, event, timestamp, file_offset);
>>
>> in perf_session__process_event, this happens right when processing
>> buildids in 'perf record', and also in 'perf report', so that is
>> something badly synthesized that hits perf.data for PERF_RECORD_KSYMBOL.
>
> it's reproducible with simple:
> perf record -e cycles,instructions ls
>
> as you said on irc, it's the machine->id_hdr_size size missing
> there's one more glitch, attached patch fixes that for me
> you can't use sizeof(struct ksymbol_event), because it includes
> the name as well.. which screws the size
>
> but I don't know that code that much.. might be still something
> missing
>
> jirka
Hi Arnaldo and Jiri,
Thanks for catching and fixing the bug.
I guess the following is OK?
*bpf_event = (struct bpf_event){
.header = {
.type = PERF_RECORD_BPF_EVENT,
.size = sizeof(struct bpf_event),
},
.type = PERF_BPF_EVENT_PROG_LOAD,
.flags = 0,
.id = info.id,
};
as struct bpf_event doesn't have variable length name:
struct bpf_event {
struct perf_event_header header;
u16 type;
u16 flags;
u32 id;
/* for bpf_prog types */
u8 tag[BPF_TAG_SIZE]; // prog tag
};
Or we need similar fix?
Song
next prev parent reply other threads:[~2019-01-22 18:45 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-17 16:15 [PATCH v11 perf, bpf-next 0/9] reveal invisible bpf programs Song Liu
2019-01-17 16:15 ` [PATCH v11 perf, bpf-next 1/9] perf, bpf: Introduce PERF_RECORD_KSYMBOL Song Liu
2019-01-22 10:18 ` [tip:perf/core] " tip-bot for Song Liu
2019-01-17 16:15 ` [PATCH v11 perf, bpf-next 2/9] sync tools/include/uapi/linux/perf_event.h Song Liu
2019-01-22 10:18 ` [tip:perf/core] tools headers uapi: Sync tools/include/uapi/linux/perf_event.h tip-bot for Song Liu
2019-01-17 16:15 ` [PATCH v11 perf, bpf-next 3/9] perf, bpf: introduce PERF_RECORD_BPF_EVENT Song Liu
2019-01-22 10:19 ` [tip:perf/core] perf, bpf: Introduce PERF_RECORD_BPF_EVENT tip-bot for Song Liu
2019-01-17 16:15 ` [PATCH v11 perf, bpf-next 4/9] sync tools/include/uapi/linux/perf_event.h Song Liu
2019-01-22 10:20 ` [tip:perf/core] tools headers uapi: Sync tools/include/uapi/linux/perf_event.h tip-bot for Song Liu
2019-01-17 16:15 ` [PATCH v11 perf, bpf-next 5/9] perf util: handle PERF_RECORD_KSYMBOL Song Liu
2019-01-18 14:45 ` Arnaldo Carvalho de Melo
2019-01-22 10:20 ` [tip:perf/core] perf tools: Handle PERF_RECORD_KSYMBOL tip-bot for Song Liu
2019-01-17 16:15 ` [PATCH v11 perf, bpf-next 6/9] perf util: handle PERF_RECORD_BPF_EVENT Song Liu
2019-01-18 14:46 ` Arnaldo Carvalho de Melo
2019-01-22 10:21 ` [tip:perf/core] perf tools: Handle PERF_RECORD_BPF_EVENT tip-bot for Song Liu
2019-01-17 16:15 ` [PATCH v11 perf, bpf-next 7/9] perf tools: synthesize PERF_RECORD_* for loaded BPF programs Song Liu
2019-01-18 14:46 ` Arnaldo Carvalho de Melo
2019-01-22 14:13 ` Arnaldo Carvalho de Melo
2019-01-22 14:31 ` Arnaldo Carvalho de Melo
2019-01-22 14:48 ` Arnaldo Carvalho de Melo
2019-01-22 14:51 ` Jiri Olsa
2019-01-22 14:58 ` Arnaldo Carvalho de Melo
2019-01-22 15:21 ` Jiri Olsa
2019-01-22 18:38 ` Song Liu [this message]
2019-01-22 19:15 ` Jiri Olsa
2019-01-22 19:24 ` Song Liu
2019-01-22 19:44 ` Jiri Olsa
2019-01-24 9:49 ` Arnaldo Carvalho de Melo
2019-01-22 10:22 ` [tip:perf/core] perf tools: Synthesize " tip-bot for Song Liu
2019-01-17 16:15 ` [PATCH v11 perf, bpf-next 8/9] perf top: Synthesize BPF events for pre-existing " Song Liu
2019-01-22 10:22 ` [tip:perf/core] " tip-bot for Arnaldo Carvalho de Melo
2019-01-17 16:15 ` [PATCH v11 perf, bpf-next 9/9] bpf: add module name [bpf] to ksymbols for bpf programs Song Liu
2019-01-22 10:23 ` [tip:perf/core] bpf: Add " tip-bot for 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=101BF88D-2DA4-4B54-A710-D0641C427136@fb.com \
--to=songliubraving@fb.com \
--cc=Kernel-team@fb.com \
--cc=acme@kernel.org \
--cc=ast@kernel.org \
--cc=daniel@iogearbox.net \
--cc=jolsa@kernel.org \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--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
all inboxes | Powered by JetHome®