netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jiri Olsa <jolsa@redhat.com>
To: Song Liu <songliubraving@fb.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 20:44:49 +0100	[thread overview]
Message-ID: <20190122194449.GI27625@krava> (raw)
In-Reply-To: <CF447261-1B9C-423B-9508-60B32EAC4A5C@fb.com>

On Tue, Jan 22, 2019 at 07:24:43PM +0000, Song Liu wrote:
> 
> 
> > On Jan 22, 2019, at 11:15 AM, Jiri Olsa <jolsa@redhat.com> wrote:
> > 
> > On Tue, Jan 22, 2019 at 06:38:56PM +0000, Song Liu wrote:
> > 
> > SNIP
> > 
> >>>> 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? 
> > 
> > yep, looks good.. also don't forget to add the 'machine->id_hdr_size'
> > 
> > jirka
> 
> So we still need something like?
> 
> diff --git i/tools/perf/util/bpf-event.c w/tools/perf/util/bpf-event.c
> index 01e1dc1bb7fb..d7bf45485820 100644
> --- i/tools/perf/util/bpf-event.c
> +++ w/tools/perf/util/bpf-event.c
> @@ -4,6 +4,7 @@
>  #include <bpf/bpf.h>
>  #include <bpf/btf.h>
>  #include <linux/btf.h>
> +#include "machine.h"
>  #include "bpf-event.h"
>  #include "debug.h"
>  #include "symbol.h"
> @@ -187,7 +188,7 @@ static int perf_event__synthesize_one_bpf_prog(struct perf_tool *tool,
>                 *bpf_event = (struct bpf_event){
>                         .header = {
>                                 .type = PERF_RECORD_BPF_EVENT,
> -                               .size = sizeof(struct bpf_event),
> +                               .size = sizeof(struct bpf_event) + machine->id_hdr_size,
>                         },
>                         .type = PERF_BPF_EVENT_PROG_LOAD,
>                         .flags = 0,
> 
> Would you send the official patch? Or would you prefer me sending it?

plese send it, thanks

jirka

  reply	other threads:[~2019-01-22 19:44 UTC|newest]

Thread overview: 24+ 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-17 16:15 ` [PATCH v11 perf, bpf-next 2/9] sync tools/include/uapi/linux/perf_event.h 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-17 16:15 ` [PATCH v11 perf, bpf-next 4/9] sync tools/include/uapi/linux/perf_event.h 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-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-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
2019-01-22 19:15                 ` Jiri Olsa
2019-01-22 19:24                   ` Song Liu
2019-01-22 19:44                     ` Jiri Olsa [this message]
2019-01-24  9:49                     ` Arnaldo Carvalho de Melo
2019-01-17 16:15 ` [PATCH v11 perf, bpf-next 8/9] perf top: Synthesize BPF events for pre-existing " Song Liu
2019-01-17 16:15 ` [PATCH v11 perf, bpf-next 9/9] bpf: add module name [bpf] to ksymbols for bpf programs 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=20190122194449.GI27625@krava \
    --to=jolsa@redhat.com \
    --cc=Kernel-team@fb.com \
    --cc=acme@kernel.org \
    --cc=ast@kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=namhyung@kernel.org \
    --cc=netdev@vger.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;
as well as URLs for NNTP newsgroup(s).