Re: [PATCH 1/2] perf: Add munmap callback
From: Stephane Eranian
Date: Wed Oct 24 2018 - 20:26:14 EST
On Wed, Oct 24, 2018 at 5:23 PM Peter Zijlstra <peterz@xxxxxxxxxxxxx> wrote:
>
> 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.
>
it is a different problem but the solution is the same: PERF_RECORD_UNMAP!
That's why I mentioned it here. To show that this is needed for more
than one reason ;-)
> 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 :/