Skip to content

Commit 0a7e6d1

Browse files
namhyungacmel
authored andcommitted
perf tools: Check recorded kernel version when finding vmlinux
Currently vmlinux_path__init() only tries to find vmlinux file from current directory, /boot and some canonical directories with version number of the running kernel. This can be a problem when reporting old data recorded on a kernel version not running currently. We can use --symfs option for this but it's annoying for user to do it always. As we already have the info in the perf.data file, it can be changed to use it for the search automatically. Before: $ perf report ... # Samples: 4K of event 'cpu-clock' # Event count (approx.): 1067250000 # # Overhead Command Shared Object Symbol # ........ .......... ................. .............................. 71.87% swapper [kernel.kallsyms] [k] recover_probed_instruction After: # Overhead Command Shared Object Symbol # ........ .......... ................. .................... 71.87% swapper [kernel.kallsyms] [k] native_safe_halt This requires to change signature of symbol__init() to receive struct perf_session_env *. Reported-by: Minchan Kim <minchan@kernel.org> Signed-off-by: Namhyung Kim <namhyung@kernel.org> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: David Ahern <dsahern@gmail.com> Cc: Ingo Molnar <mingo@kernel.org> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> Cc: Minchan Kim <minchan@kernel.org> Cc: Namhyung Kim <namhyung.kim@lge.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/r/1407825645-24586-14-git-send-email-namhyung@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent cb2ffae commit 0a7e6d1

19 files changed

Lines changed: 39 additions & 30 deletions

‎tools/perf/builtin-annotate.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ int cmd_annotate(int argc, const char **argv, const char *prefix __maybe_unused)
345345
symbol_conf.priv_size = sizeof(struct annotation);
346346
symbol_conf.try_vmlinux_path = true;
347347

348-
ret = symbol__init();
348+
ret = symbol__init(&annotate.session->header.env);
349349
if (ret < 0)
350350
goto out_delete;
351351

‎tools/perf/builtin-buildid-cache.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ int cmd_buildid_cache(int argc, const char **argv,
329329
return -1;
330330
}
331331

332-
if (symbol__init() < 0)
332+
if (symbol__init(session ? &session->header.env : NULL) < 0)
333333
goto out;
334334

335335
setup_pager();

‎tools/perf/builtin-diff.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1143,7 +1143,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix __maybe_unused)
11431143

11441144
argc = parse_options(argc, argv, options, diff_usage, 0);
11451145

1146-
if (symbol__init() < 0)
1146+
if (symbol__init(NULL) < 0)
11471147
return -1;
11481148

11491149
if (data_init(argc, argv) < 0)

‎tools/perf/builtin-inject.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ int cmd_inject(int argc, const char **argv, const char *prefix __maybe_unused)
462462
if (inject.session == NULL)
463463
return -ENOMEM;
464464

465-
if (symbol__init() < 0)
465+
if (symbol__init(&inject.session->header.env) < 0)
466466
return -1;
467467

468468
ret = __cmd_inject(&inject);

‎tools/perf/builtin-kmem.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -692,15 +692,15 @@ int cmd_kmem(int argc, const char **argv, const char *prefix __maybe_unused)
692692
usage_with_options(kmem_usage, kmem_options);
693693

694694
if (!strncmp(argv[0], "rec", 3)) {
695-
symbol__init();
695+
symbol__init(NULL);
696696
return __cmd_record(argc, argv);
697697
}
698698

699699
session = perf_session__new(&file, false, &perf_kmem);
700700
if (session == NULL)
701701
return -ENOMEM;
702702

703-
symbol__init();
703+
symbol__init(&session->header.env);
704704

705705
if (!strcmp(argv[0], "stat")) {
706706
if (cpu__setup_cpunode_map())

‎tools/perf/builtin-kvm.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1064,7 +1064,7 @@ static int read_events(struct perf_kvm_stat *kvm)
10641064
return -EINVAL;
10651065
}
10661066

1067-
symbol__init();
1067+
symbol__init(&kvm->session->header.env);
10681068

10691069
if (!perf_session__has_traces(kvm->session, "kvm record"))
10701070
return -EINVAL;
@@ -1314,7 +1314,7 @@ static int kvm_events_live(struct perf_kvm_stat *kvm,
13141314
kvm->opts.target.uid_str = NULL;
13151315
kvm->opts.target.uid = UINT_MAX;
13161316

1317-
symbol__init();
1317+
symbol__init(NULL);
13181318
disable_buildid_cache();
13191319

13201320
use_browser = 0;

‎tools/perf/builtin-lock.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -865,7 +865,7 @@ static int __cmd_report(bool display_info)
865865
return -ENOMEM;
866866
}
867867

868-
symbol__init();
868+
symbol__init(&session->header.env);
869869

870870
if (!perf_session__has_traces(session, "lock record"))
871871
goto out_delete;

‎tools/perf/builtin-mem.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ static int report_raw_events(struct perf_mem *mem)
133133
goto out_delete;
134134
}
135135

136-
if (symbol__init() < 0)
136+
if (symbol__init(&session->header.env) < 0)
137137
return -1;
138138

139139
printf("# PID, TID, IP, ADDR, LOCAL WEIGHT, DSRC, SYMBOL\n");

‎tools/perf/builtin-record.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -908,7 +908,7 @@ int cmd_record(int argc, const char **argv, const char *prefix __maybe_unused)
908908
usage_with_options(record_usage, record_options);
909909
}
910910

911-
symbol__init();
911+
symbol__init(NULL);
912912

913913
if (symbol_conf.kptr_restrict)
914914
pr_warning(

‎tools/perf/builtin-report.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -798,7 +798,7 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused)
798798
}
799799
}
800800

801-
if (symbol__init() < 0)
801+
if (symbol__init(&session->header.env) < 0)
802802
goto error;
803803

804804
if (argc) {

0 commit comments

Comments
 (0)