linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <arnaldo.melo@gmail.com>
To: Steve MacLean <Steve.MacLean@microsoft.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>,
	Mark Rutland <mark.rutland@arm.com>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Jiri Olsa <jolsa@redhat.com>, Namhyung Kim <namhyung@kernel.org>,
	Changbin Du <changbin.du@intel.com>,
	Eric Saint-Etienne <eric.saint.etienne@oracle.com>,
	John Keeping <john@metanate.com>, Andi Kleen <ak@linux.intel.com>,
	Song Liu <songliubraving@fb.com>,
	Davidlohr Bueso <dave@stgolabs.net>, Leo Yan <leo.yan@linaro.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Brian Robbins <brianrob@microsoft.com>,
	Tom McDonald <Thomas.McDonald@microsoft.com>,
	John Salem <josalem@microsoft.com>
Subject: Re: [PATCH] perf map: fix overlapped map handling
Date: Fri, 20 Sep 2019 16:38:52 -0300	[thread overview]
Message-ID: <20190920193852.GI4865@kernel.org> (raw)
In-Reply-To: <BN8PR21MB136261C1A4BB2C884F10FCECF7880@BN8PR21MB1362.namprd21.prod.outlook.com>

Em Fri, Sep 20, 2019 at 07:20:18PM +0000, Steve MacLean escreveu:
> Whenever an mmap/mmap2 event occurs, the map tree must be updated to add a new
> entry. If a new map overlaps a previous map, the overlapped section of the
> previous map is effectively unmapped, but the non-overlapping sections are
> still valid.
> 
> maps__fixup_overlappings() is responsible for creating any new map entries from
> the previously overlapped map. It optionally creates a before and an after map.
> 
> When creating the after map the existing code failed to adjust the map.pgoff.
> This meant the new after map would incorrectly calculate the file offset
> for the ip. This results in incorrect symbol name resolution for any ip in the
> after region.
> 
> Make maps__fixup_overlappings() correctly populate map.pgoff.
> 
> Add an assert that new mapping matches old mapping at the beginning of
> the after map.
> 
> Signed-off-by: Steve MacLean <Steve.MacLean@Microsoft.com>
> ---
>  tools/perf/util/map.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c
> index 5b83ed1..73870d7 100644
> --- a/tools/perf/util/map.c
> +++ b/tools/perf/util/map.c
> @@ -1,5 +1,6 @@
>  // SPDX-License-Identifier: GPL-2.0
>  #include "symbol.h"
> +#include <assert.h>
>  #include <errno.h>
>  #include <inttypes.h>
>  #include <limits.h>
> @@ -850,6 +851,8 @@ static int maps__fixup_overlappings(struct maps *maps, struct map *map, FILE *fp
>  			}
>  
>  			after->start = map->end;
> +			after->pgoff = pos->map_ip(pos, map->end);

So is this equivalent to what __split_vma() does in the kernel, i.e.:

        if (new_below)
                new->vm_end = addr;
        else {
                new->vm_start = addr;
                new->vm_pgoff += ((addr - vma->vm_start) >> PAGE_SHIFT);
        }

where new->vm_pgoff starts equal to the vm_pgoff of the mmap being
split?

- Arnaldo

> +			assert(pos->map_ip(pos, map->end) == after->map_ip(after, map->end));



>  			__map_groups__insert(pos->groups, after);
>  			if (verbose >= 2 && !use_browser)
>  				map__fprintf(after, fp);
> -- 
> 2.7.4

-- 

- Arnaldo

  reply	other threads:[~2019-09-20 19:38 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-20 19:20 [PATCH] perf map: fix overlapped map handling Steve MacLean
2019-09-20 19:38 ` Arnaldo Carvalho de Melo [this message]
2019-09-20 21:46   ` Steve MacLean
2019-09-27 15:35     ` Arnaldo Carvalho de Melo
2019-09-28  1:32       ` Steve MacLean

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190920193852.GI4865@kernel.org \
    --to=arnaldo.melo@gmail.com \
    --cc=Steve.MacLean@microsoft.com \
    --cc=Thomas.McDonald@microsoft.com \
    --cc=ak@linux.intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=brianrob@microsoft.com \
    --cc=changbin.du@intel.com \
    --cc=dave@stgolabs.net \
    --cc=eric.saint.etienne@oracle.com \
    --cc=john@metanate.com \
    --cc=jolsa@redhat.com \
    --cc=josalem@microsoft.com \
    --cc=leo.yan@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=songliubraving@fb.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).