All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Song Liu <songliubraving@fb.com>
Cc: linux-kernel@vger.kernel.org, peterz@infradead.org,
	ast@kernel.org, daniel@iogearbox.net, kernel-team@fb.com,
	Arnaldo Carvalho de Melo <acme@redhat.com>
Subject: Re: [PATCH perf] perf tools: fix synthesized PERF_RECORD_KSYMBOL/BPF_EVENT
Date: Thu, 24 Jan 2019 10:49:46 +0100	[thread overview]
Message-ID: <20190124094946.GK14973@kernel.org> (raw)
In-Reply-To: <20190122210218.358664-1-songliubraving@fb.com>

Em Tue, Jan 22, 2019 at 01:02:18PM -0800, Song Liu escreveu:
> Added missing machine->id_hdr_size to event->header.size. Also fixed size
> of PERF_RECORD_KSYMBOL by removing extra bytes for name.

Ok, noticed this now, thanks,

- Arnaldo
 
> Fixes: 7b612e291a5a ("perf tools: Synthesize PERF_RECORD_* for loaded BPF programs")
> Cc: Peter Zijlstra <peterz@infradead.org>
> Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
> Suggested-by: Jiri Olsa <jolsa@kernel.org>
> Signed-off-by: Song Liu <songliubraving@fb.com>
> ---
>  tools/perf/util/bpf-event.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/perf/util/bpf-event.c b/tools/perf/util/bpf-event.c
> index 01e1dc1bb7fb..f610872812ef 100644
> --- a/tools/perf/util/bpf-event.c
> +++ b/tools/perf/util/bpf-event.c
> @@ -7,6 +7,7 @@
>  #include "bpf-event.h"
>  #include "debug.h"
>  #include "symbol.h"
> +#include "machine.h"
>  
>  #define ptr_to_u64(ptr)    ((__u64)(unsigned long)(ptr))
>  
> @@ -149,7 +150,7 @@ static int perf_event__synthesize_one_bpf_prog(struct perf_tool *tool,
>  		*ksymbol_event = (struct ksymbol_event){
>  			.header = {
>  				.type = PERF_RECORD_KSYMBOL,
> -				.size = sizeof(struct ksymbol_event),
> +				.size = offsetof(struct ksymbol_event, name),
>  			},
>  			.addr = prog_addrs[i],
>  			.len = prog_lens[i],
> @@ -178,6 +179,9 @@ static int perf_event__synthesize_one_bpf_prog(struct perf_tool *tool,
>  
>  		ksymbol_event->header.size += PERF_ALIGN(name_len + 1,
>  							 sizeof(u64));
> +
> +		memset(event + event->header.size, 0, machine->id_hdr_size);
> +		event->header.size += machine->id_hdr_size;
>  		err = perf_tool__process_synth_event(tool, event,
>  						     machine, process);
>  	}
> @@ -194,6 +198,8 @@ static int perf_event__synthesize_one_bpf_prog(struct perf_tool *tool,
>  			.id = info.id,
>  		};
>  		memcpy(bpf_event->tag, prog_tags[i], BPF_TAG_SIZE);
> +		memset(event + event->header.size, 0, machine->id_hdr_size);
> +		event->header.size += machine->id_hdr_size;
>  		err = perf_tool__process_synth_event(tool, event,
>  						     machine, process);
>  	}
> -- 
> 2.17.1

-- 

- Arnaldo

  reply	other threads:[~2019-01-24  9:49 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-22 21:02 [PATCH perf] perf tools: fix synthesized PERF_RECORD_KSYMBOL/BPF_EVENT Song Liu
2019-01-24  9:49 ` Arnaldo Carvalho de Melo [this message]
2019-01-24 10:29   ` Arnaldo Carvalho de Melo
2019-01-26 10:05 ` [tip:perf/core] perf bpf: Fix " 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=20190124094946.GK14973@kernel.org \
    --to=acme@kernel.org \
    --cc=acme@redhat.com \
    --cc=ast@kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=kernel-team@fb.com \
    --cc=linux-kernel@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.