lkml.org 
[lkml]   [2020]   [Sep]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH 16/26] perf tools: Synthesize modules with mmap3
On Mon, Sep 14, 2020 at 9:08 AM Arnaldo Carvalho de Melo
<acme@kernel.org> wrote:
>
> Em Sun, Sep 13, 2020 at 11:03:03PM +0200, Jiri Olsa escreveu:
> > Synthesizing modules with mmap3 events so we can
> > get build id data for module's maps as well.
>
> Ditto as for 15/26
>
> > Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> > ---
> > tools/perf/util/synthetic-events.c | 37 +++++++++++++++++++-----------
> > 1 file changed, 24 insertions(+), 13 deletions(-)
> >
> > diff --git a/tools/perf/util/synthetic-events.c b/tools/perf/util/synthetic-events.c
> > index bd6e7b84283d..6bd2423ce2f3 100644
> > --- a/tools/perf/util/synthetic-events.c
> > +++ b/tools/perf/util/synthetic-events.c
> > @@ -605,7 +605,7 @@ int perf_event__synthesize_modules(struct perf_tool *tool, perf_event__handler_t
> > int rc = 0;
> > struct map *pos;
> > struct maps *maps = machine__kernel_maps(machine);
> > - union perf_event *event = zalloc((sizeof(event->mmap) +
> > + union perf_event *event = zalloc((sizeof(event->mmap3) +
> > machine->id_hdr_size));
> > if (event == NULL) {
> > pr_debug("Not enough memory synthesizing mmap event "
> > @@ -613,8 +613,6 @@ int perf_event__synthesize_modules(struct perf_tool *tool, perf_event__handler_t
> > return -1;
> > }
> >
> > - event->header.type = PERF_RECORD_MMAP;
> > -
> > /*
> > * kernel uses 0 for user space maps, see kernel/perf_event.c
> > * __perf_event_mmap
> > @@ -631,17 +629,30 @@ int perf_event__synthesize_modules(struct perf_tool *tool, perf_event__handler_t
> > continue;
> >
> > size = PERF_ALIGN(pos->dso->long_name_len + 1, sizeof(u64));
> > - event->mmap.header.type = PERF_RECORD_MMAP;
> > - event->mmap.header.size = (sizeof(event->mmap) -
> > - (sizeof(event->mmap.filename) - size));
> > - memset(event->mmap.filename + size, 0, machine->id_hdr_size);
> > - event->mmap.header.size += machine->id_hdr_size;
> > - event->mmap.start = pos->start;
> > - event->mmap.len = pos->end - pos->start;
> > - event->mmap.pid = machine->pid;
> > -
> > - memcpy(event->mmap.filename, pos->dso->long_name,
> > + event->mmap3.header.type = PERF_RECORD_MMAP3;
> > + event->mmap3.header.size = (sizeof(event->mmap3) -
> > + (sizeof(event->mmap3.filename) - size));
> > + memset(event->mmap3.filename + size, 0, machine->id_hdr_size);
> > + event->mmap3.header.size += machine->id_hdr_size;
> > + event->mmap3.start = pos->start;
> > + event->mmap3.len = pos->end - pos->start;
> > + event->mmap3.pid = machine->pid;
> > +
> > + memcpy(event->mmap3.filename, pos->dso->long_name,
> > pos->dso->long_name_len + 1);
> > +
> > + rc = filename__read_build_id(event->mmap3.filename, event->mmap3.buildid,
> > + BUILD_ID_SIZE);
> > + if (rc != BUILD_ID_SIZE) {

IIRC BUILD_ID_SIZE is 20 bytes which is the correct size for SHA-1. A
build ID may be 128-bits (16 bytes) if md5 or uuid hashes are used.
Should this test just be "> 0" ?

Thanks,
Ian

> > + if (event->mmap3.filename[0] == '/') {
> > + pr_debug2("Failed to read build ID for %s\n",
> > + event->mmap3.filename);
> > + }
> > + memset(event->mmap3.buildid, 0x0, sizeof(event->mmap3.buildid));
> > + }
> > +
> > + rc = 0;
> > +
> > if (perf_tool__process_synth_event(tool, event, machine, process) != 0) {
> > rc = -1;
> > break;
> > --
> > 2.26.2
> >
>
> --
>
> - Arnaldo

\
 
 \ /
  Last update: 2020-09-16 00:10    [W:0.118 / U:2.716 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site