aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorAdrian Hunter <adrian.hunter@intel.com>2014-01-29 09:14:44 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2014-01-31 15:21:54 -0500
commitd3b70220292c40d3b499797fd2f33f608fc35edb (patch)
treefd8198cd128aa99e87c73515a3330d57a097734c /tools
parentd9b62aba87a82939c73f451a166c7a21342350d6 (diff)
perf buildid-cache: Check relocation when checking for existing kcore
perf buildid-cache does not make another copy of kcore if the buildid and modules match an existing copy. That does not take into account the possibility that the kernel has been relocated. Extend the check to check if the reference relocation symbol matches too, otherwise do make a copy. Signed-off-by: Adrian Hunter <adrian.hunter@intel.com> Tested-by: Jiri Olsa <jolsa@redhat.com> Cc: David Ahern <dsahern@gmail.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Ingo Molnar <mingo@redhat.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Namhyung Kim <namhyung@gmail.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/1391004884-10334-10-git-send-email-adrian.hunter@intel.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/perf/builtin-buildid-cache.c33
1 files changed, 29 insertions, 4 deletions
diff --git a/tools/perf/builtin-buildid-cache.c b/tools/perf/builtin-buildid-cache.c
index cfede86161d8..b22dbb16f877 100644
--- a/tools/perf/builtin-buildid-cache.c
+++ b/tools/perf/builtin-buildid-cache.c
@@ -63,11 +63,35 @@ static int build_id_cache__kcore_dir(char *dir, size_t sz)
63 return 0; 63 return 0;
64} 64}
65 65
66static bool same_kallsyms_reloc(const char *from_dir, char *to_dir)
67{
68 char from[PATH_MAX];
69 char to[PATH_MAX];
70 const char *name;
71 u64 addr1 = 0, addr2 = 0;
72 int i;
73
74 scnprintf(from, sizeof(from), "%s/kallsyms", from_dir);
75 scnprintf(to, sizeof(to), "%s/kallsyms", to_dir);
76
77 for (i = 0; (name = ref_reloc_sym_names[i]) != NULL; i++) {
78 addr1 = kallsyms__get_function_start(from, name);
79 if (addr1)
80 break;
81 }
82
83 if (name)
84 addr2 = kallsyms__get_function_start(to, name);
85
86 return addr1 == addr2;
87}
88
66static int build_id_cache__kcore_existing(const char *from_dir, char *to_dir, 89static int build_id_cache__kcore_existing(const char *from_dir, char *to_dir,
67 size_t to_dir_sz) 90 size_t to_dir_sz)
68{ 91{
69 char from[PATH_MAX]; 92 char from[PATH_MAX];
70 char to[PATH_MAX]; 93 char to[PATH_MAX];
94 char to_subdir[PATH_MAX];
71 struct dirent *dent; 95 struct dirent *dent;
72 int ret = -1; 96 int ret = -1;
73 DIR *d; 97 DIR *d;
@@ -86,10 +110,11 @@ static int build_id_cache__kcore_existing(const char *from_dir, char *to_dir,
86 continue; 110 continue;
87 scnprintf(to, sizeof(to), "%s/%s/modules", to_dir, 111 scnprintf(to, sizeof(to), "%s/%s/modules", to_dir,
88 dent->d_name); 112 dent->d_name);
89 if (!compare_proc_modules(from, to)) { 113 scnprintf(to_subdir, sizeof(to_subdir), "%s/%s",
90 scnprintf(to, sizeof(to), "%s/%s", to_dir, 114 to_dir, dent->d_name);
91 dent->d_name); 115 if (!compare_proc_modules(from, to) &&
92 strlcpy(to_dir, to, to_dir_sz); 116 same_kallsyms_reloc(from_dir, to_subdir)) {
117 strlcpy(to_dir, to_subdir, to_dir_sz);
93 ret = 0; 118 ret = 0;
94 break; 119 break;
95 } 120 }