Commit eeb49845425375481f14c0e5721f88242642e88e
Committed by
Arnaldo Carvalho de Melo
1 parent
a3d4fd7a2d
Exists in
smarc-l5.0.0_1.0.0-ga
and in
5 other branches
perf buildid-cache: Add --update option
When adding vmlinux file to build-id cache, it'd be fail since kallsyms dso with a same build-id was already added by perf record. So one needs to remove the kallsyms first to add vmlinux into the cache. Add --update option for doing it at once. Signed-off-by: Namhyung Kim <namhyung@kernel.org> Cc: Andi Kleen <andi@firstfloor.org> Cc: Borislav Petkov <bp@alien8.de> Cc: Ingo Molnar <mingo@kernel.org> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Pekka Enberg <penberg@kernel.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Link: http://lkml.kernel.org/r/1360227734-375-5-git-send-email-namhyung@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Showing 2 changed files with 53 additions and 1 deletions Side-by-side Diff
tools/perf/Documentation/perf-buildid-cache.txt
... | ... | @@ -27,6 +27,10 @@ |
27 | 27 | -M:: |
28 | 28 | --missing=:: |
29 | 29 | List missing build ids in the cache for the specified file. |
30 | +-u:: | |
31 | +--update:: | |
32 | + Update specified file of the cache. It can be used to update kallsyms | |
33 | + kernel dso to vmlinux in order to support annotation. | |
30 | 34 | -v:: |
31 | 35 | --verbose:: |
32 | 36 | Be more verbose. |
tools/perf/builtin-buildid-cache.c
... | ... | @@ -93,6 +93,32 @@ |
93 | 93 | return 0; |
94 | 94 | } |
95 | 95 | |
96 | +static int build_id_cache__update_file(const char *filename, | |
97 | + const char *debugdir) | |
98 | +{ | |
99 | + u8 build_id[BUILD_ID_SIZE]; | |
100 | + char sbuild_id[BUILD_ID_SIZE * 2 + 1]; | |
101 | + | |
102 | + int err; | |
103 | + | |
104 | + if (filename__read_build_id(filename, &build_id, sizeof(build_id)) < 0) { | |
105 | + pr_debug("Couldn't read a build-id in %s\n", filename); | |
106 | + return -1; | |
107 | + } | |
108 | + | |
109 | + build_id__sprintf(build_id, sizeof(build_id), sbuild_id); | |
110 | + err = build_id_cache__remove_s(sbuild_id, debugdir); | |
111 | + if (!err) { | |
112 | + err = build_id_cache__add_s(sbuild_id, debugdir, filename, | |
113 | + false, false); | |
114 | + } | |
115 | + if (verbose) | |
116 | + pr_info("Updating %s %s: %s\n", sbuild_id, filename, | |
117 | + err ? "FAIL" : "Ok"); | |
118 | + | |
119 | + return err; | |
120 | +} | |
121 | + | |
96 | 122 | int cmd_buildid_cache(int argc, const char **argv, |
97 | 123 | const char *prefix __maybe_unused) |
98 | 124 | { |
... | ... | @@ -103,7 +129,9 @@ |
103 | 129 | char debugdir[PATH_MAX]; |
104 | 130 | char const *add_name_list_str = NULL, |
105 | 131 | *remove_name_list_str = NULL, |
106 | - *missing_filename = NULL; | |
132 | + *missing_filename = NULL, | |
133 | + *update_name_list_str = NULL; | |
134 | + | |
107 | 135 | const struct option buildid_cache_options[] = { |
108 | 136 | OPT_STRING('a', "add", &add_name_list_str, |
109 | 137 | "file list", "file(s) to add"), |
... | ... | @@ -112,6 +140,8 @@ |
112 | 140 | OPT_STRING('M', "missing", &missing_filename, "file", |
113 | 141 | "to find missing build ids in the cache"), |
114 | 142 | OPT_BOOLEAN('f', "force", &force, "don't complain, do it"), |
143 | + OPT_STRING('u', "update", &update_name_list_str, "file list", | |
144 | + "file(s) to update"), | |
115 | 145 | OPT_INCR('v', "verbose", &verbose, "be more verbose"), |
116 | 146 | OPT_END() |
117 | 147 | }; |
... | ... | @@ -168,6 +198,24 @@ |
168 | 198 | |
169 | 199 | if (missing_filename) |
170 | 200 | ret = build_id_cache__fprintf_missing(missing_filename, force, stdout); |
201 | + | |
202 | + if (update_name_list_str) { | |
203 | + list = strlist__new(true, update_name_list_str); | |
204 | + if (list) { | |
205 | + strlist__for_each(pos, list) | |
206 | + if (build_id_cache__update_file(pos->s, debugdir)) { | |
207 | + if (errno == ENOENT) { | |
208 | + pr_debug("%s wasn't in the cache\n", | |
209 | + pos->s); | |
210 | + continue; | |
211 | + } | |
212 | + pr_warning("Couldn't update %s: %s\n", | |
213 | + pos->s, strerror(errno)); | |
214 | + } | |
215 | + | |
216 | + strlist__delete(list); | |
217 | + } | |
218 | + } | |
171 | 219 | |
172 | 220 | return ret; |
173 | 221 | } |