Skip to content

Commit

Permalink
perf tools: Use the "_stest" symbol to identify the kernel map when l…
Browse files Browse the repository at this point in the history
…oading kcore

The first symbol is not necessarily in the kernel text.  Instead of
using the first symbol, use the _stest symbol to identify the kernel map
when loading kcore.

This allows for the introduction of symbols to identify the x86_64 PTI
entry trampolines.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Joerg Roedel <joro@8bytes.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: x86@kernel.org
Link: http://lkml.kernel.org/r/1525866228-30321-6-git-send-email-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
  • Loading branch information
Adrian Hunter authored and Arnaldo Carvalho de Melo committed May 15, 2018
1 parent d8fc764 commit 5654997
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions tools/perf/util/symbol.c
Original file line number Diff line number Diff line change
Expand Up @@ -1149,7 +1149,7 @@ static int dso__load_kcore(struct dso *dso, struct map *map,
bool is_64_bit;
int err, fd;
char kcore_filename[PATH_MAX];
struct symbol *sym;
u64 stext;

if (!kmaps)
return -EINVAL;
Expand Down Expand Up @@ -1198,13 +1198,13 @@ static int dso__load_kcore(struct dso *dso, struct map *map,
old_map = next;
}

/* Find the kernel map using the first symbol */
sym = dso__first_symbol(dso);
list_for_each_entry(new_map, &md.maps, node) {
if (sym && sym->start >= new_map->start &&
sym->start < new_map->end) {
replacement_map = new_map;
break;
/* Find the kernel map using the '_stext' symbol */
if (!kallsyms__get_function_start(kallsyms_filename, "_stext", &stext)) {
list_for_each_entry(new_map, &md.maps, node) {
if (stext >= new_map->start && stext < new_map->end) {
replacement_map = new_map;
break;
}
}
}

Expand Down

0 comments on commit 5654997

Please sign in to comment.