aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf
diff options
context:
space:
mode:
authorNamhyung Kim <namhyung@kernel.org>2014-08-12 02:40:45 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2014-08-13 15:42:21 -0400
commit0a7e6d1b6844bec2d6817615a693c7fce447b80d (patch)
tree5bdb9ce67fa5b7c301c16e817f9b1d803a44374c /tools/perf
parentcb2ffae241cfdd6d90acb7ec5f52ad8401885dd2 (diff)
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>
Diffstat (limited to 'tools/perf')
-rw-r--r--tools/perf/builtin-annotate.c2
-rw-r--r--tools/perf/builtin-buildid-cache.c2
-rw-r--r--tools/perf/builtin-diff.c2
-rw-r--r--tools/perf/builtin-inject.c2
-rw-r--r--tools/perf/builtin-kmem.c4
-rw-r--r--tools/perf/builtin-kvm.c4
-rw-r--r--tools/perf/builtin-lock.c2
-rw-r--r--tools/perf/builtin-mem.c2
-rw-r--r--tools/perf/builtin-record.c2
-rw-r--r--tools/perf/builtin-report.c2
-rw-r--r--tools/perf/builtin-sched.c2
-rw-r--r--tools/perf/builtin-script.c2
-rw-r--r--tools/perf/builtin-timechart.c2
-rw-r--r--tools/perf/builtin-top.c2
-rw-r--r--tools/perf/builtin-trace.c4
-rw-r--r--tools/perf/tests/builtin-test.c2
-rw-r--r--tools/perf/util/probe-event.c2
-rw-r--r--tools/perf/util/symbol.c26
-rw-r--r--tools/perf/util/symbol.h3
19 files changed, 39 insertions, 30 deletions
diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index c0464dc38057..d4da6929597f 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -345,7 +345,7 @@ int cmd_annotate(int argc, const char **argv, const char *prefix __maybe_unused)
345 symbol_conf.priv_size = sizeof(struct annotation); 345 symbol_conf.priv_size = sizeof(struct annotation);
346 symbol_conf.try_vmlinux_path = true; 346 symbol_conf.try_vmlinux_path = true;
347 347
348 ret = symbol__init(); 348 ret = symbol__init(&annotate.session->header.env);
349 if (ret < 0) 349 if (ret < 0)
350 goto out_delete; 350 goto out_delete;
351 351
diff --git a/tools/perf/builtin-buildid-cache.c b/tools/perf/builtin-buildid-cache.c
index d91bfa6632e8..ac5838e0b1bd 100644
--- a/tools/perf/builtin-buildid-cache.c
+++ b/tools/perf/builtin-buildid-cache.c
@@ -329,7 +329,7 @@ int cmd_buildid_cache(int argc, const char **argv,
329 return -1; 329 return -1;
330 } 330 }
331 331
332 if (symbol__init() < 0) 332 if (symbol__init(session ? &session->header.env : NULL) < 0)
333 goto out; 333 goto out;
334 334
335 setup_pager(); 335 setup_pager();
diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c
index c10cc44bae19..190d0b6b28cc 100644
--- a/tools/perf/builtin-diff.c
+++ b/tools/perf/builtin-diff.c
@@ -1143,7 +1143,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix __maybe_unused)
1143 1143
1144 argc = parse_options(argc, argv, options, diff_usage, 0); 1144 argc = parse_options(argc, argv, options, diff_usage, 0);
1145 1145
1146 if (symbol__init() < 0) 1146 if (symbol__init(NULL) < 0)
1147 return -1; 1147 return -1;
1148 1148
1149 if (data_init(argc, argv) < 0) 1149 if (data_init(argc, argv) < 0)
diff --git a/tools/perf/builtin-inject.c b/tools/perf/builtin-inject.c
index 18eaefd3cd0c..3a62b6b3c8fd 100644
--- a/tools/perf/builtin-inject.c
+++ b/tools/perf/builtin-inject.c
@@ -462,7 +462,7 @@ int cmd_inject(int argc, const char **argv, const char *prefix __maybe_unused)
462 if (inject.session == NULL) 462 if (inject.session == NULL)
463 return -ENOMEM; 463 return -ENOMEM;
464 464
465 if (symbol__init() < 0) 465 if (symbol__init(&inject.session->header.env) < 0)
466 return -1; 466 return -1;
467 467
468 ret = __cmd_inject(&inject); 468 ret = __cmd_inject(&inject);
diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c
index 349d9b46098e..23762187a219 100644
--- a/tools/perf/builtin-kmem.c
+++ b/tools/perf/builtin-kmem.c
@@ -692,7 +692,7 @@ int cmd_kmem(int argc, const char **argv, const char *prefix __maybe_unused)
692 usage_with_options(kmem_usage, kmem_options); 692 usage_with_options(kmem_usage, kmem_options);
693 693
694 if (!strncmp(argv[0], "rec", 3)) { 694 if (!strncmp(argv[0], "rec", 3)) {
695 symbol__init(); 695 symbol__init(NULL);
696 return __cmd_record(argc, argv); 696 return __cmd_record(argc, argv);
697 } 697 }
698 698
@@ -700,7 +700,7 @@ int cmd_kmem(int argc, const char **argv, const char *prefix __maybe_unused)
700 if (session == NULL) 700 if (session == NULL)
701 return -ENOMEM; 701 return -ENOMEM;
702 702
703 symbol__init(); 703 symbol__init(&session->header.env);
704 704
705 if (!strcmp(argv[0], "stat")) { 705 if (!strcmp(argv[0], "stat")) {
706 if (cpu__setup_cpunode_map()) 706 if (cpu__setup_cpunode_map())
diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c
index 7f2b55513863..14d03edc81c2 100644
--- a/tools/perf/builtin-kvm.c
+++ b/tools/perf/builtin-kvm.c
@@ -1064,7 +1064,7 @@ static int read_events(struct perf_kvm_stat *kvm)
1064 return -EINVAL; 1064 return -EINVAL;
1065 } 1065 }
1066 1066
1067 symbol__init(); 1067 symbol__init(&kvm->session->header.env);
1068 1068
1069 if (!perf_session__has_traces(kvm->session, "kvm record")) 1069 if (!perf_session__has_traces(kvm->session, "kvm record"))
1070 return -EINVAL; 1070 return -EINVAL;
@@ -1314,7 +1314,7 @@ static int kvm_events_live(struct perf_kvm_stat *kvm,
1314 kvm->opts.target.uid_str = NULL; 1314 kvm->opts.target.uid_str = NULL;
1315 kvm->opts.target.uid = UINT_MAX; 1315 kvm->opts.target.uid = UINT_MAX;
1316 1316
1317 symbol__init(); 1317 symbol__init(NULL);
1318 disable_buildid_cache(); 1318 disable_buildid_cache();
1319 1319
1320 use_browser = 0; 1320 use_browser = 0;
diff --git a/tools/perf/builtin-lock.c b/tools/perf/builtin-lock.c
index d73580b39908..92790ed7af45 100644
--- a/tools/perf/builtin-lock.c
+++ b/tools/perf/builtin-lock.c
@@ -865,7 +865,7 @@ static int __cmd_report(bool display_info)
865 return -ENOMEM; 865 return -ENOMEM;
866 } 866 }
867 867
868 symbol__init(); 868 symbol__init(&session->header.env);
869 869
870 if (!perf_session__has_traces(session, "lock record")) 870 if (!perf_session__has_traces(session, "lock record"))
871 goto out_delete; 871 goto out_delete;
diff --git a/tools/perf/builtin-mem.c b/tools/perf/builtin-mem.c
index 80e57c84adef..8b4a87fe3858 100644
--- a/tools/perf/builtin-mem.c
+++ b/tools/perf/builtin-mem.c
@@ -133,7 +133,7 @@ static int report_raw_events(struct perf_mem *mem)
133 goto out_delete; 133 goto out_delete;
134 } 134 }
135 135
136 if (symbol__init() < 0) 136 if (symbol__init(&session->header.env) < 0)
137 return -1; 137 return -1;
138 138
139 printf("# PID, TID, IP, ADDR, LOCAL WEIGHT, DSRC, SYMBOL\n"); 139 printf("# PID, TID, IP, ADDR, LOCAL WEIGHT, DSRC, SYMBOL\n");
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index ca0251e8470d..4db670d4b8da 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -908,7 +908,7 @@ int cmd_record(int argc, const char **argv, const char *prefix __maybe_unused)
908 usage_with_options(record_usage, record_options); 908 usage_with_options(record_usage, record_options);
909 } 909 }
910 910
911 symbol__init(); 911 symbol__init(NULL);
912 912
913 if (symbol_conf.kptr_restrict) 913 if (symbol_conf.kptr_restrict)
914 pr_warning( 914 pr_warning(
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 041e93da13e4..b9e0fcac4d71 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -798,7 +798,7 @@ repeat:
798 } 798 }
799 } 799 }
800 800
801 if (symbol__init() < 0) 801 if (symbol__init(&session->header.env) < 0)
802 goto error; 802 goto error;
803 803
804 if (argc) { 804 if (argc) {
diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
index dcd9ebf5a7df..f5874a27b346 100644
--- a/tools/perf/builtin-sched.c
+++ b/tools/perf/builtin-sched.c
@@ -1462,7 +1462,7 @@ static int perf_sched__read_events(struct perf_sched *sched,
1462 return -1; 1462 return -1;
1463 } 1463 }
1464 1464
1465 symbol__init(); 1465 symbol__init(&session->header.env);
1466 1466
1467 if (perf_session__set_tracepoints_handlers(session, handlers)) 1467 if (perf_session__set_tracepoints_handlers(session, handlers))
1468 goto out_delete; 1468 goto out_delete;
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index 9ca7a2d03f17..37d2b608d388 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -1732,7 +1732,7 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused)
1732 goto out_delete; 1732 goto out_delete;
1733 } 1733 }
1734 1734
1735 if (symbol__init() < 0) 1735 if (symbol__init(&session->header.env) < 0)
1736 goto out_delete; 1736 goto out_delete;
1737 1737
1738 script.session = session; 1738 script.session = session;
diff --git a/tools/perf/builtin-timechart.c b/tools/perf/builtin-timechart.c
index df3b1c5ae7b9..48eea6cd2f5b 100644
--- a/tools/perf/builtin-timechart.c
+++ b/tools/perf/builtin-timechart.c
@@ -1607,7 +1607,7 @@ static int __cmd_timechart(struct timechart *tchart, const char *output_name)
1607 if (session == NULL) 1607 if (session == NULL)
1608 return -ENOMEM; 1608 return -ENOMEM;
1609 1609
1610 symbol__init(); 1610 symbol__init(&session->header.env);
1611 1611
1612 (void)perf_header__process_sections(&session->header, 1612 (void)perf_header__process_sections(&session->header,
1613 perf_data_file__fd(session->file), 1613 perf_data_file__fd(session->file),
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 0ab3ea7f7525..4b0e15c2b2a8 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -1234,7 +1234,7 @@ int cmd_top(int argc, const char **argv, const char *prefix __maybe_unused)
1234 symbol_conf.priv_size = sizeof(struct annotation); 1234 symbol_conf.priv_size = sizeof(struct annotation);
1235 1235
1236 symbol_conf.try_vmlinux_path = (symbol_conf.vmlinux_name == NULL); 1236 symbol_conf.try_vmlinux_path = (symbol_conf.vmlinux_name == NULL);
1237 if (symbol__init() < 0) 1237 if (symbol__init(NULL) < 0)
1238 return -1; 1238 return -1;
1239 1239
1240 sort__setup_elide(stdout); 1240 sort__setup_elide(stdout);
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index 8a83bd835327..d080b9cf0354 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -1411,7 +1411,7 @@ static int trace__tool_process(struct perf_tool *tool,
1411 1411
1412static int trace__symbols_init(struct trace *trace, struct perf_evlist *evlist) 1412static int trace__symbols_init(struct trace *trace, struct perf_evlist *evlist)
1413{ 1413{
1414 int err = symbol__init(); 1414 int err = symbol__init(NULL);
1415 1415
1416 if (err) 1416 if (err)
1417 return err; 1417 return err;
@@ -2245,7 +2245,7 @@ static int trace__replay(struct trace *trace)
2245 if (session == NULL) 2245 if (session == NULL)
2246 return -ENOMEM; 2246 return -ENOMEM;
2247 2247
2248 if (symbol__init() < 0) 2248 if (symbol__init(&session->header.env) < 0)
2249 goto out; 2249 goto out;
2250 2250
2251 trace->host = &session->machines.host; 2251 trace->host = &session->machines.host;
diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c
index 6f8b01bc6033..c6796d22423a 100644
--- a/tools/perf/tests/builtin-test.c
+++ b/tools/perf/tests/builtin-test.c
@@ -297,7 +297,7 @@ int cmd_test(int argc, const char **argv, const char *prefix __maybe_unused)
297 symbol_conf.sort_by_name = true; 297 symbol_conf.sort_by_name = true;
298 symbol_conf.try_vmlinux_path = true; 298 symbol_conf.try_vmlinux_path = true;
299 299
300 if (symbol__init() < 0) 300 if (symbol__init(NULL) < 0)
301 return -1; 301 return -1;
302 302
303 if (skip != NULL) 303 if (skip != NULL)
diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index 443225cb62f7..784ea42ad8cb 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -79,7 +79,7 @@ static int init_symbol_maps(bool user_only)
79 int ret; 79 int ret;
80 80
81 symbol_conf.sort_by_name = true; 81 symbol_conf.sort_by_name = true;
82 ret = symbol__init(); 82 ret = symbol__init(NULL);
83 if (ret < 0) { 83 if (ret < 0) {
84 pr_debug("Failed to init symbol map.\n"); 84 pr_debug("Failed to init symbol map.\n");
85 goto out; 85 goto out;
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index 009a9d064f11..ac098a3c2a31 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -15,6 +15,7 @@
15#include "machine.h" 15#include "machine.h"
16#include "symbol.h" 16#include "symbol.h"
17#include "strlist.h" 17#include "strlist.h"
18#include "header.h"
18 19
19#include <elf.h> 20#include <elf.h>
20#include <limits.h> 21#include <limits.h>
@@ -1749,10 +1750,11 @@ static void vmlinux_path__exit(void)
1749 zfree(&vmlinux_path); 1750 zfree(&vmlinux_path);
1750} 1751}
1751 1752
1752static int vmlinux_path__init(void) 1753static int vmlinux_path__init(struct perf_session_env *env)
1753{ 1754{
1754 struct utsname uts; 1755 struct utsname uts;
1755 char bf[PATH_MAX]; 1756 char bf[PATH_MAX];
1757 char *kernel_version;
1756 1758
1757 vmlinux_path = malloc(sizeof(char *) * 5); 1759 vmlinux_path = malloc(sizeof(char *) * 5);
1758 if (vmlinux_path == NULL) 1760 if (vmlinux_path == NULL)
@@ -1767,25 +1769,31 @@ static int vmlinux_path__init(void)
1767 goto out_fail; 1769 goto out_fail;
1768 ++vmlinux_path__nr_entries; 1770 ++vmlinux_path__nr_entries;
1769 1771
1770 /* only try running kernel version if no symfs was given */ 1772 /* only try kernel version if no symfs was given */
1771 if (symbol_conf.symfs[0] != 0) 1773 if (symbol_conf.symfs[0] != 0)
1772 return 0; 1774 return 0;
1773 1775
1774 if (uname(&uts) < 0) 1776 if (env) {
1775 goto out_fail; 1777 kernel_version = env->os_release;
1778 } else {
1779 if (uname(&uts) < 0)
1780 goto out_fail;
1781
1782 kernel_version = uts.release;
1783 }
1776 1784
1777 snprintf(bf, sizeof(bf), "/boot/vmlinux-%s", uts.release); 1785 snprintf(bf, sizeof(bf), "/boot/vmlinux-%s", kernel_version);
1778 vmlinux_path[vmlinux_path__nr_entries] = strdup(bf); 1786 vmlinux_path[vmlinux_path__nr_entries] = strdup(bf);
1779 if (vmlinux_path[vmlinux_path__nr_entries] == NULL) 1787 if (vmlinux_path[vmlinux_path__nr_entries] == NULL)
1780 goto out_fail; 1788 goto out_fail;
1781 ++vmlinux_path__nr_entries; 1789 ++vmlinux_path__nr_entries;
1782 snprintf(bf, sizeof(bf), "/lib/modules/%s/build/vmlinux", uts.release); 1790 snprintf(bf, sizeof(bf), "/lib/modules/%s/build/vmlinux", kernel_version);
1783 vmlinux_path[vmlinux_path__nr_entries] = strdup(bf); 1791 vmlinux_path[vmlinux_path__nr_entries] = strdup(bf);
1784 if (vmlinux_path[vmlinux_path__nr_entries] == NULL) 1792 if (vmlinux_path[vmlinux_path__nr_entries] == NULL)
1785 goto out_fail; 1793 goto out_fail;
1786 ++vmlinux_path__nr_entries; 1794 ++vmlinux_path__nr_entries;
1787 snprintf(bf, sizeof(bf), "/usr/lib/debug/lib/modules/%s/vmlinux", 1795 snprintf(bf, sizeof(bf), "/usr/lib/debug/lib/modules/%s/vmlinux",
1788 uts.release); 1796 kernel_version);
1789 vmlinux_path[vmlinux_path__nr_entries] = strdup(bf); 1797 vmlinux_path[vmlinux_path__nr_entries] = strdup(bf);
1790 if (vmlinux_path[vmlinux_path__nr_entries] == NULL) 1798 if (vmlinux_path[vmlinux_path__nr_entries] == NULL)
1791 goto out_fail; 1799 goto out_fail;
@@ -1831,7 +1839,7 @@ static bool symbol__read_kptr_restrict(void)
1831 return value; 1839 return value;
1832} 1840}
1833 1841
1834int symbol__init(void) 1842int symbol__init(struct perf_session_env *env)
1835{ 1843{
1836 const char *symfs; 1844 const char *symfs;
1837 1845
@@ -1846,7 +1854,7 @@ int symbol__init(void)
1846 symbol_conf.priv_size += (sizeof(struct symbol_name_rb_node) - 1854 symbol_conf.priv_size += (sizeof(struct symbol_name_rb_node) -
1847 sizeof(struct symbol)); 1855 sizeof(struct symbol));
1848 1856
1849 if (symbol_conf.try_vmlinux_path && vmlinux_path__init() < 0) 1857 if (symbol_conf.try_vmlinux_path && vmlinux_path__init(env) < 0)
1850 return -1; 1858 return -1;
1851 1859
1852 if (symbol_conf.field_sep && *symbol_conf.field_sep == '.') { 1860 if (symbol_conf.field_sep && *symbol_conf.field_sep == '.') {
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h
index 196b29104276..b95e3a36d654 100644
--- a/tools/perf/util/symbol.h
+++ b/tools/perf/util/symbol.h
@@ -262,7 +262,8 @@ int modules__parse(const char *filename, void *arg,
262int filename__read_debuglink(const char *filename, char *debuglink, 262int filename__read_debuglink(const char *filename, char *debuglink,
263 size_t size); 263 size_t size);
264 264
265int symbol__init(void); 265struct perf_session_env;
266int symbol__init(struct perf_session_env *env);
266void symbol__exit(void); 267void symbol__exit(void);
267void symbol__elf_init(void); 268void symbol__elf_init(void);
268struct symbol *symbol__new(u64 start, u64 len, u8 binding, const char *name); 269struct symbol *symbol__new(u64 start, u64 len, u8 binding, const char *name);