diff options
author | Jiri Olsa <jolsa@kernel.org> | 2018-08-17 05:48:08 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2018-08-20 07:54:59 -0400 |
commit | dde755a90e98a1c57f6a92d1a79bc5554024065c (patch) | |
tree | 68c03125b2b87d807a98da6b4a020dd310af1ee3 /tools | |
parent | 2af5247530e073f4146d74ecd96cf64c953c001c (diff) |
perf tools: Use compression id in decompress_kmodule()
Once we parsed out the compression ID, we dont need to iterate all
available compressions and we can call it directly.
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Michael Petlan <mpetlan@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20180817094813.15086-9-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/util/dso.c | 24 |
1 files changed, 3 insertions, 21 deletions
diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c index d875e6956a3e..54bfe1f4762f 100644 --- a/tools/perf/util/dso.c +++ b/tools/perf/util/dso.c | |||
@@ -244,18 +244,6 @@ bool is_kernel_module(const char *pathname, int cpumode) | |||
244 | return m.kmod; | 244 | return m.kmod; |
245 | } | 245 | } |
246 | 246 | ||
247 | static bool decompress_to_file(const char *ext, const char *filename, int output_fd) | ||
248 | { | ||
249 | unsigned i; | ||
250 | |||
251 | for (i = 0; compressions[i].fmt; i++) { | ||
252 | if (!strcmp(ext, compressions[i].fmt)) | ||
253 | return !compressions[i].decompress(filename, | ||
254 | output_fd); | ||
255 | } | ||
256 | return false; | ||
257 | } | ||
258 | |||
259 | bool dso__needs_decompress(struct dso *dso) | 247 | bool dso__needs_decompress(struct dso *dso) |
260 | { | 248 | { |
261 | return dso->symtab_type == DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE_COMP || | 249 | return dso->symtab_type == DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE_COMP || |
@@ -265,31 +253,25 @@ bool dso__needs_decompress(struct dso *dso) | |||
265 | static int decompress_kmodule(struct dso *dso, const char *name, char *tmpbuf) | 253 | static int decompress_kmodule(struct dso *dso, const char *name, char *tmpbuf) |
266 | { | 254 | { |
267 | int fd = -1; | 255 | int fd = -1; |
268 | struct kmod_path m; | ||
269 | 256 | ||
270 | if (!dso__needs_decompress(dso)) | 257 | if (!dso__needs_decompress(dso)) |
271 | return -1; | 258 | return -1; |
272 | 259 | ||
273 | if (kmod_path__parse_ext(&m, dso->long_name)) | 260 | if (dso->comp == COMP_ID__NONE) |
274 | return -1; | 261 | return -1; |
275 | 262 | ||
276 | if (!m.comp) | ||
277 | goto out; | ||
278 | |||
279 | fd = mkstemp(tmpbuf); | 263 | fd = mkstemp(tmpbuf); |
280 | if (fd < 0) { | 264 | if (fd < 0) { |
281 | dso->load_errno = errno; | 265 | dso->load_errno = errno; |
282 | goto out; | 266 | return -1; |
283 | } | 267 | } |
284 | 268 | ||
285 | if (!decompress_to_file(m.ext, name, fd)) { | 269 | if (compressions[dso->comp].decompress(name, fd)) { |
286 | dso->load_errno = DSO_LOAD_ERRNO__DECOMPRESSION_FAILURE; | 270 | dso->load_errno = DSO_LOAD_ERRNO__DECOMPRESSION_FAILURE; |
287 | close(fd); | 271 | close(fd); |
288 | fd = -1; | 272 | fd = -1; |
289 | } | 273 | } |
290 | 274 | ||
291 | out: | ||
292 | free(m.ext); | ||
293 | return fd; | 275 | return fd; |
294 | } | 276 | } |
295 | 277 | ||