[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190920193852.GI4865@kernel.org>
Date: Fri, 20 Sep 2019 16:38:52 -0300
From: Arnaldo Carvalho de Melo <arnaldo.melo@...il.com>
To: Steve MacLean <Steve.MacLean@...rosoft.com>
Cc: Peter Zijlstra <peterz@...radead.org>,
Ingo Molnar <mingo@...hat.com>,
Mark Rutland <mark.rutland@....com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Jiri Olsa <jolsa@...hat.com>,
Namhyung Kim <namhyung@...nel.org>,
Changbin Du <changbin.du@...el.com>,
Eric Saint-Etienne <eric.saint.etienne@...cle.com>,
John Keeping <john@...anate.com>,
Andi Kleen <ak@...ux.intel.com>,
Song Liu <songliubraving@...com>,
Davidlohr Bueso <dave@...olabs.net>,
Leo Yan <leo.yan@...aro.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
Brian Robbins <brianrob@...rosoft.com>,
Tom McDonald <Thomas.McDonald@...rosoft.com>,
John Salem <josalem@...rosoft.com>
Subject: Re: [PATCH] perf map: fix overlapped map handling
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@...rosoft.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
Powered by blists - more mailing lists