LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Ingo Molnar <mingo@kernel.org>
Cc: Clark Williams <williams@redhat.com>,
	linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org,
	Namhyung Kim <namhyung@kernel.org>, Jiri Olsa <jolsa@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	kernel-team@lge.com, Arnaldo Carvalho de Melo <acme@redhat.com>
Subject: [PATCH 01/12] perf machine: Set main kernel end address properly
Date: Wed, 25 Apr 2018 12:59:57 -0300	[thread overview]
Message-ID: <20180425160008.3407-2-acme@kernel.org> (raw)
In-Reply-To: <20180425160008.3407-1-acme@kernel.org>

From: Namhyung Kim <namhyung@kernel.org>

map_groups__fixup_end() was called to set the end addresses of kernel
and module maps.  But now since machine__create_modules() sets the end
address of modules properly, the only remaining piece is the kernel map.

We can set it with adjacent module's address directly instead of calling
map_groups__fixup_end().  If there's no module after the kernel map, the
end address will be ~0ULL.

Since it also changes the start address of the kernel map, it needs to
re-insert the map to the kmaps in order to keep a correct ordering.  Kim
reported that it caused problems on ARM64.

Reported-by: Kim Phillips <kim.phillips@arm.com>
Tested-by: Kim Phillips <kim.phillips@arm.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: kernel-team@lge.com
Link: http://lkml.kernel.org/r/20180419235915.GA19067@sejong
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/machine.c | 30 ++++++++++++++++++------------
 1 file changed, 18 insertions(+), 12 deletions(-)

diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index 2eca8478e24f..32d50492505d 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -1019,13 +1019,6 @@ int machine__load_vmlinux_path(struct machine *machine, enum map_type type)
 	return ret;
 }
 
-static void map_groups__fixup_end(struct map_groups *mg)
-{
-	int i;
-	for (i = 0; i < MAP__NR_TYPES; ++i)
-		__map_groups__fixup_end(mg, i);
-}
-
 static char *get_kernel_version(const char *root_dir)
 {
 	char version[PATH_MAX];
@@ -1233,6 +1226,7 @@ int machine__create_kernel_maps(struct machine *machine)
 {
 	struct dso *kernel = machine__get_kernel(machine);
 	const char *name = NULL;
+	struct map *map;
 	u64 addr = 0;
 	int ret;
 
@@ -1259,13 +1253,25 @@ int machine__create_kernel_maps(struct machine *machine)
 			machine__destroy_kernel_maps(machine);
 			return -1;
 		}
-		machine__set_kernel_mmap(machine, addr, 0);
+
+		/* we have a real start address now, so re-order the kmaps */
+		map = machine__kernel_map(machine);
+
+		map__get(map);
+		map_groups__remove(&machine->kmaps, map);
+
+		/* assume it's the last in the kmaps */
+		machine__set_kernel_mmap(machine, addr, ~0ULL);
+
+		map_groups__insert(&machine->kmaps, map);
+		map__put(map);
 	}
 
-	/*
-	 * Now that we have all the maps created, just set the ->end of them:
-	 */
-	map_groups__fixup_end(&machine->kmaps);
+	/* update end address of the kernel map using adjacent module address */
+	map = map__next(machine__kernel_map(machine));
+	if (map)
+		machine__set_kernel_mmap(machine, addr, map->start);
+
 	return 0;
 }
 
-- 
2.14.3

  reply	other threads:[~2018-04-25 16:04 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-25 15:59 [GIT PULL 00/12] perf/urgent fixes Arnaldo Carvalho de Melo
2018-04-25 15:59 ` Arnaldo Carvalho de Melo [this message]
2018-04-25 15:59 ` [PATCH 02/12] perf list: Remove s390 specific strcmp_cpuid_cmp function Arnaldo Carvalho de Melo
2018-04-25 15:59 ` [PATCH 03/12] perf test: Adapt test case record+probe_libc_inet_pton.sh for s390 Arnaldo Carvalho de Melo
2018-04-25 16:00 ` [PATCH 04/12] perf stat: Keep the / modifier separator in fallback Arnaldo Carvalho de Melo
2018-04-25 16:00 ` [PATCH 05/12] perf pmu: Fix pmu events parsing rule Arnaldo Carvalho de Melo
2018-05-03  8:25   ` Adrian Hunter
2018-05-03 10:37     ` Jiri Olsa
2018-05-03 11:38       ` Adrian Hunter
2018-05-03 11:47         ` Jiri Olsa
2018-05-04 16:02         ` Jiri Olsa
2018-05-06  3:43           ` Andi Kleen
2018-05-06 14:28             ` [PATCH] perf tools: Fix parser for empty pmu terms case Jiri Olsa
2018-05-06 16:34               ` Liang, Kan
2018-05-07  7:21               ` Adrian Hunter
2018-05-07  8:12                 ` Jiri Olsa
2018-05-07 15:04                   ` Arnaldo Carvalho de Melo
2018-05-07 18:37             ` [PATCH 05/12] perf pmu: Fix pmu events parsing rule Arnaldo Carvalho de Melo
2018-05-07 19:16               ` Jiri Olsa
2018-05-07 19:26                 ` Arnaldo Carvalho de Melo
2018-05-07 19:24               ` Arnaldo Carvalho de Melo
2018-05-07 19:42                 ` Jiri Olsa
2018-04-25 16:00 ` [PATCH 06/12] perf evsel: Disable write_backward for leader sampling group events Arnaldo Carvalho de Melo
2018-04-25 16:00 ` [PATCH 07/12] perf mem: Document incorrect and missing options Arnaldo Carvalho de Melo
2018-04-25 16:00 ` [PATCH 08/12] perf record: Fix s390 undefined record__auxtrace_init() return value Arnaldo Carvalho de Melo
2018-04-25 16:00 ` [PATCH 09/12] perf pmu: Fix core PMU alias list for X86 platform Arnaldo Carvalho de Melo
2018-04-25 16:00 ` [PATCH 10/12] perf stat: Print out hint for mixed PMU group error Arnaldo Carvalho de Melo
2018-04-25 16:00 ` [PATCH 11/12] perf evsel: Only fall back group read for leader Arnaldo Carvalho de Melo
2018-04-25 16:00 ` [PATCH 12/12] perf stat: Fix duplicate PMU name for interval print Arnaldo Carvalho de Melo
2018-04-26  5:33 ` [GIT PULL 00/12] perf/urgent fixes Ingo Molnar

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=20180425160008.3407-2-acme@kernel.org \
    --to=acme@kernel.org \
    --cc=acme@redhat.com \
    --cc=jolsa@kernel.org \
    --cc=kernel-team@lge.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=williams@redhat.com \
    --subject='Re: [PATCH 01/12] perf machine: Set main kernel end address properly' \
    /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

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).