Re: [PATCH 1/2] perf: Add munmap callback

From: Peter Zijlstra
Date: Wed Oct 24 2018 - 20:23:33 EST


On Wed, Oct 24, 2018 at 12:30:52PM -0700, Stephane Eranian wrote:
> Hi,
>
> On Wed, Oct 24, 2018 at 8:12 AM <kan.liang@xxxxxxxxxxxxxxx> wrote:
> >
> > From: Kan Liang <kan.liang@xxxxxxxxxxxxxxx>
> >
> > To calculate the physical address, perf needs to walk the pages tables.
> > The related mapping may has already been removed from pages table in
> > some cases (e.g. large PEBS). The virtual address recorded in the first
> > PEBS records may already be unmapped before draining PEBS buffers.
> >
> > Add a munmap callback to notify the PMU of any unmapping, which only be
> > invoked when the munmap is implemented.
> >
> The need for this new record type extends beyond physical address conversions
> and PEBS. A long while ago, someone reported issues with symbolization related
> to perf lacking munmap tracking. It had to do with vma merging. I think the
> sequence of mmaps was as follows in the problematic case:
> 1. addr1 = mmap(8192);
> 2. munmap(addr1 + 4096, 4096)
> 3. addr2 = mmap(addr1+4096, 4096)
>
> If successful, that yields addr2 = addr1 + 4096 (could also get the
> same without forcing the address).

That is actually a different problem. And you're right, we never did fix
that.

I agree with you that Kan's Changelog is somewhat cryptic; it took me at
least 3 times reading and looking at what the patches actually do to
understand :/