Re: [PATCH 16/26] perf tools: Synthesize modules with mmap3

Jiri Olsa
2020-09-16T08:20:40Z

On Tue, Sep 15, 2020 at 01:17:44PM -0700, Ian Rogers wrote:

SNIP

> > > /*
> > > * 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" ?

ah right, will check on that

thanks,
jirka