RE: [PATCH v3] perf inject --jit: Remove //anon mmap events

From: Steve MacLean
Date: Sat Nov 09 2019 - 11:49:46 EST


> > While a JIT is jitting code it will eventually need to commit more
> > pages and change these pages to executable permissions.
> >
> > Typically the JIT will want these colocated to minimize branch displacements.
> >
> > The kernel will coalesce these anonymous mapping with identical
> > permissions before sending an MMAP event for the new pages. This means
> > the mmap event for the new pages will include the older pages.
> >
> > These anonymous mmap events will obscure the jitdump injected pseudo events.
> > This means that the jitdump generated symbols, machine code, debugging
> > info, and unwind info will no longer be used.
> >
> > Observations:
> >
> > When a process emits a jit dump marker and a jitdump file, the
> > perf-xxx.map file represents inferior information which has been
> > superceded by the jitdump jit-xxx.dump file.
> >
> > Further the '//anon*' mmap events are only required for the legacy
> > perf-xxx.map mapping.
> >
> > When attaching to an existing process, the synthetic anon map events
> > are given a time stamp of -1. These should not obscure the jitdump
> > events which have an actual time.
> >
> > Summary:
> >
> > Use thread->priv to store whether a jitdump file has been processed
>
> I'm ok wih the implementation but not sure about the described JIT/mmap logic, Stephane?
>
> jirka

The kernel only seems to coalesce the anonymous mappings when the allocations grow beyond 64K. It may not affect JITs for smaller sets of JITted code. I would guess a javascript JIT engine might not hit this type of problem often.

@Stephane Eranian could you comment.

@Jiri Olsa I am happy to expand the explanation if it would be helpful.