diff options
| author | Jiri Olsa <jolsa@kernel.org> | 2018-08-17 05:48:06 -0400 |
|---|---|---|
| committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2018-08-20 07:54:59 -0400 |
| commit | 4b838b0db4e9cb3892b181ea9adc13cefb90d210 (patch) | |
| tree | 30c2e4514dc4799cb1f8ecf702afb8e8aa59539f /tools | |
| parent | e1e139463db363a253296b431e61519d8809e386 (diff) | |
perf tools: Add compression id into 'struct kmod_path'
Store a decompression ID in 'struct kmod_path', so it can be later
stored in 'struct dso'.
Switch 'struct kmod_path's 'comp' from 'bool' to 'int' to return the
compressions array index. Add 0 index item into compressions array, so
that the comp usage stays as it was: 0 - no compression, != 0
compression index.
Update the kmod_path tests.
Committer notes:
Use a designated initializer + terminating comma, e.g. { .fmt = NULL, }, to fix
the build in several distros:
centos:6: util/dso.c:201: error: missing initializer
centos:6: util/dso.c:201: error: (near initialization for 'compressions[0].decompress')
debian:9: util/dso.c:201:24: error: missing field 'decompress' initializer [-Werror,-Wmissing-field-initializers]
fedora:25: util/dso.c:201:24: error: missing field 'decompress' initializer [-Werror,-Wmissing-field-initializers]
fedora:26: util/dso.c:201:24: error: missing field 'decompress' initializer [-Werror,-Wmissing-field-initializers]
fedora:27: util/dso.c:201:24: error: missing field 'decompress' initializer [-Werror,-Wmissing-field-initializers]
oraclelinux:6: util/dso.c:201: error: missing initializer
oraclelinux:6: util/dso.c:201: error: (near initialization for 'compressions[0].decompress')
ubuntu:12.04.5: util/dso.c:201:2: error: missing initializer [-Werror=missing-field-initializers]
ubuntu:12.04.5: util/dso.c:201:2: error: (near initialization for 'compressions[0].decompress') [-Werror=missing-field-initializers]
ubuntu:16.04: util/dso.c:201:24: error: missing field 'decompress' initializer [-Werror,-Wmissing-field-initializers]
ubuntu:16.10: util/dso.c:201:24: error: missing field 'decompress' initializer [-Werror,-Wmissing-field-initializers]
ubuntu:16.10: util/dso.c:201:24: error: missing field 'decompress' initializer [-Werror,-Wmissing-field-initializers]
ubuntu:17.10: util/dso.c:201:24: error: missing field 'decompress' initializer [-Werror,-Wmissing-field-initializers]
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-7-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/perf/tests/kmod-path.c | 42 | ||||
| -rw-r--r-- | tools/perf/util/dso.c | 18 | ||||
| -rw-r--r-- | tools/perf/util/dso.h | 2 |
3 files changed, 33 insertions, 29 deletions
diff --git a/tools/perf/tests/kmod-path.c b/tools/perf/tests/kmod-path.c index 148dd31cc201..f92f78f683ea 100644 --- a/tools/perf/tests/kmod-path.c +++ b/tools/perf/tests/kmod-path.c | |||
| @@ -6,7 +6,7 @@ | |||
| 6 | #include "debug.h" | 6 | #include "debug.h" |
| 7 | 7 | ||
| 8 | static int test(const char *path, bool alloc_name, bool alloc_ext, | 8 | static int test(const char *path, bool alloc_name, bool alloc_ext, |
| 9 | bool kmod, bool comp, const char *name, const char *ext) | 9 | bool kmod, int comp, const char *name, const char *ext) |
| 10 | { | 10 | { |
| 11 | struct kmod_path m; | 11 | struct kmod_path m; |
| 12 | 12 | ||
| @@ -54,47 +54,47 @@ static int test_is_kernel_module(const char *path, int cpumode, bool expect) | |||
| 54 | int test__kmod_path__parse(struct test *t __maybe_unused, int subtest __maybe_unused) | 54 | int test__kmod_path__parse(struct test *t __maybe_unused, int subtest __maybe_unused) |
| 55 | { | 55 | { |
| 56 | /* path alloc_name alloc_ext kmod comp name ext */ | 56 | /* path alloc_name alloc_ext kmod comp name ext */ |
| 57 | T("/xxxx/xxxx/x-x.ko", true , true , true, false, "[x_x]", NULL); | 57 | T("/xxxx/xxxx/x-x.ko", true , true , true, 0 , "[x_x]", NULL); |
| 58 | T("/xxxx/xxxx/x-x.ko", false , true , true, false, NULL , NULL); | 58 | T("/xxxx/xxxx/x-x.ko", false , true , true, 0 , NULL , NULL); |
| 59 | T("/xxxx/xxxx/x-x.ko", true , false , true, false, "[x_x]", NULL); | 59 | T("/xxxx/xxxx/x-x.ko", true , false , true, 0 , "[x_x]", NULL); |
| 60 | T("/xxxx/xxxx/x-x.ko", false , false , true, false, NULL , NULL); | 60 | T("/xxxx/xxxx/x-x.ko", false , false , true, 0 , NULL , NULL); |
| 61 | M("/xxxx/xxxx/x-x.ko", PERF_RECORD_MISC_CPUMODE_UNKNOWN, true); | 61 | M("/xxxx/xxxx/x-x.ko", PERF_RECORD_MISC_CPUMODE_UNKNOWN, true); |
| 62 | M("/xxxx/xxxx/x-x.ko", PERF_RECORD_MISC_KERNEL, true); | 62 | M("/xxxx/xxxx/x-x.ko", PERF_RECORD_MISC_KERNEL, true); |
| 63 | M("/xxxx/xxxx/x-x.ko", PERF_RECORD_MISC_USER, false); | 63 | M("/xxxx/xxxx/x-x.ko", PERF_RECORD_MISC_USER, false); |
| 64 | 64 | ||
| 65 | #ifdef HAVE_ZLIB_SUPPORT | 65 | #ifdef HAVE_ZLIB_SUPPORT |
| 66 | /* path alloc_name alloc_ext kmod comp name ext */ | 66 | /* path alloc_name alloc_ext kmod comp name ext */ |
| 67 | T("/xxxx/xxxx/x.ko.gz", true , true , true, true, "[x]", "gz"); | 67 | T("/xxxx/xxxx/x.ko.gz", true , true , true, 1 , "[x]", "gz"); |
| 68 | T("/xxxx/xxxx/x.ko.gz", false , true , true, true, NULL , "gz"); | 68 | T("/xxxx/xxxx/x.ko.gz", false , true , true, 1 , NULL , "gz"); |
| 69 | T("/xxxx/xxxx/x.ko.gz", true , false , true, true, "[x]", NULL); | 69 | T("/xxxx/xxxx/x.ko.gz", true , false , true, 1 , "[x]", NULL); |
| 70 | T("/xxxx/xxxx/x.ko.gz", false , false , true, true, NULL , NULL); | 70 | T("/xxxx/xxxx/x.ko.gz", false , false , true, 1 , NULL , NULL); |
| 71 | M("/xxxx/xxxx/x.ko.gz", PERF_RECORD_MISC_CPUMODE_UNKNOWN, true); | 71 | M("/xxxx/xxxx/x.ko.gz", PERF_RECORD_MISC_CPUMODE_UNKNOWN, true); |
| 72 | M("/xxxx/xxxx/x.ko.gz", PERF_RECORD_MISC_KERNEL, true); | 72 | M("/xxxx/xxxx/x.ko.gz", PERF_RECORD_MISC_KERNEL, true); |
| 73 | M("/xxxx/xxxx/x.ko.gz", PERF_RECORD_MISC_USER, false); | 73 | M("/xxxx/xxxx/x.ko.gz", PERF_RECORD_MISC_USER, false); |
| 74 | 74 | ||
| 75 | /* path alloc_name alloc_ext kmod comp name ext */ | 75 | /* path alloc_name alloc_ext kmod comp name ext */ |
| 76 | T("/xxxx/xxxx/x.gz", true , true , false, true, "x.gz" ,"gz"); | 76 | T("/xxxx/xxxx/x.gz", true , true , false, 1 , "x.gz" ,"gz"); |
| 77 | T("/xxxx/xxxx/x.gz", false , true , false, true, NULL ,"gz"); | 77 | T("/xxxx/xxxx/x.gz", false , true , false, 1 , NULL ,"gz"); |
| 78 | T("/xxxx/xxxx/x.gz", true , false , false, true, "x.gz" , NULL); | 78 | T("/xxxx/xxxx/x.gz", true , false , false, 1 , "x.gz" , NULL); |
| 79 | T("/xxxx/xxxx/x.gz", false , false , false, true, NULL , NULL); | 79 | T("/xxxx/xxxx/x.gz", false , false , false, 1 , NULL , NULL); |
| 80 | M("/xxxx/xxxx/x.gz", PERF_RECORD_MISC_CPUMODE_UNKNOWN, false); | 80 | M("/xxxx/xxxx/x.gz", PERF_RECORD_MISC_CPUMODE_UNKNOWN, false); |
| 81 | M("/xxxx/xxxx/x.gz", PERF_RECORD_MISC_KERNEL, false); | 81 | M("/xxxx/xxxx/x.gz", PERF_RECORD_MISC_KERNEL, false); |
| 82 | M("/xxxx/xxxx/x.gz", PERF_RECORD_MISC_USER, false); | 82 | M("/xxxx/xxxx/x.gz", PERF_RECORD_MISC_USER, false); |
| 83 | 83 | ||
| 84 | /* path alloc_name alloc_ext kmod comp name ext */ | 84 | /* path alloc_name alloc_ext kmod comp name ext */ |
| 85 | T("x.gz", true , true , false, true, "x.gz", "gz"); | 85 | T("x.gz", true , true , false, 1 , "x.gz", "gz"); |
| 86 | T("x.gz", false , true , false, true, NULL , "gz"); | 86 | T("x.gz", false , true , false, 1 , NULL , "gz"); |
| 87 | T("x.gz", true , false , false, true, "x.gz", NULL); | 87 | T("x.gz", true , false , false, 1 , "x.gz", NULL); |
| 88 | T("x.gz", false , false , false, true, NULL , NULL); | 88 | T("x.gz", false , false , false, 1 , NULL , NULL); |
| 89 | M("x.gz", PERF_RECORD_MISC_CPUMODE_UNKNOWN, false); | 89 | M("x.gz", PERF_RECORD_MISC_CPUMODE_UNKNOWN, false); |
| 90 | M("x.gz", PERF_RECORD_MISC_KERNEL, false); | 90 | M("x.gz", PERF_RECORD_MISC_KERNEL, false); |
| 91 | M("x.gz", PERF_RECORD_MISC_USER, false); | 91 | M("x.gz", PERF_RECORD_MISC_USER, false); |
| 92 | 92 | ||
| 93 | /* path alloc_name alloc_ext kmod comp name ext */ | 93 | /* path alloc_name alloc_ext kmod comp name ext */ |
| 94 | T("x.ko.gz", true , true , true, true, "[x]", "gz"); | 94 | T("x.ko.gz", true , true , true, 1 , "[x]", "gz"); |
| 95 | T("x.ko.gz", false , true , true, true, NULL , "gz"); | 95 | T("x.ko.gz", false , true , true, 1 , NULL , "gz"); |
| 96 | T("x.ko.gz", true , false , true, true, "[x]", NULL); | 96 | T("x.ko.gz", true , false , true, 1 , "[x]", NULL); |
| 97 | T("x.ko.gz", false , false , true, true, NULL , NULL); | 97 | T("x.ko.gz", false , false , true, 1 , NULL , NULL); |
| 98 | M("x.ko.gz", PERF_RECORD_MISC_CPUMODE_UNKNOWN, true); | 98 | M("x.ko.gz", PERF_RECORD_MISC_CPUMODE_UNKNOWN, true); |
| 99 | M("x.ko.gz", PERF_RECORD_MISC_KERNEL, true); | 99 | M("x.ko.gz", PERF_RECORD_MISC_KERNEL, true); |
| 100 | M("x.ko.gz", PERF_RECORD_MISC_USER, false); | 100 | M("x.ko.gz", PERF_RECORD_MISC_USER, false); |
diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c index b8b5fdb1a15b..d34e47bb09d9 100644 --- a/tools/perf/util/dso.c +++ b/tools/perf/util/dso.c | |||
| @@ -189,10 +189,15 @@ int dso__read_binary_type_filename(const struct dso *dso, | |||
| 189 | return ret; | 189 | return ret; |
| 190 | } | 190 | } |
| 191 | 191 | ||
| 192 | enum { | ||
| 193 | COMP_ID__NONE = 0, | ||
| 194 | }; | ||
| 195 | |||
| 192 | static const struct { | 196 | static const struct { |
| 193 | const char *fmt; | 197 | const char *fmt; |
| 194 | int (*decompress)(const char *input, int output); | 198 | int (*decompress)(const char *input, int output); |
| 195 | } compressions[] = { | 199 | } compressions[] = { |
| 200 | [COMP_ID__NONE] = { .fmt = NULL, }, | ||
| 196 | #ifdef HAVE_ZLIB_SUPPORT | 201 | #ifdef HAVE_ZLIB_SUPPORT |
| 197 | { "gz", gzip_decompress_to_file }, | 202 | { "gz", gzip_decompress_to_file }, |
| 198 | #endif | 203 | #endif |
| @@ -202,15 +207,15 @@ static const struct { | |||
| 202 | { NULL, NULL }, | 207 | { NULL, NULL }, |
| 203 | }; | 208 | }; |
| 204 | 209 | ||
| 205 | static bool is_supported_compression(const char *ext) | 210 | static int is_supported_compression(const char *ext) |
| 206 | { | 211 | { |
| 207 | unsigned i; | 212 | unsigned i; |
| 208 | 213 | ||
| 209 | for (i = 0; compressions[i].fmt; i++) { | 214 | for (i = 1; compressions[i].fmt; i++) { |
| 210 | if (!strcmp(ext, compressions[i].fmt)) | 215 | if (!strcmp(ext, compressions[i].fmt)) |
| 211 | return true; | 216 | return i; |
| 212 | } | 217 | } |
| 213 | return false; | 218 | return COMP_ID__NONE; |
| 214 | } | 219 | } |
| 215 | 220 | ||
| 216 | bool is_kernel_module(const char *pathname, int cpumode) | 221 | bool is_kernel_module(const char *pathname, int cpumode) |
| @@ -372,10 +377,9 @@ int __kmod_path__parse(struct kmod_path *m, const char *path, | |||
| 372 | return 0; | 377 | return 0; |
| 373 | } | 378 | } |
| 374 | 379 | ||
| 375 | if (is_supported_compression(ext + 1)) { | 380 | m->comp = is_supported_compression(ext + 1); |
| 376 | m->comp = true; | 381 | if (m->comp > COMP_ID__NONE) |
| 377 | ext -= 3; | 382 | ext -= 3; |
| 378 | } | ||
| 379 | 383 | ||
| 380 | /* Check .ko extension only if there's enough name left. */ | 384 | /* Check .ko extension only if there's enough name left. */ |
| 381 | if (ext > name) | 385 | if (ext > name) |
diff --git a/tools/perf/util/dso.h b/tools/perf/util/dso.h index 870346b333ee..7bde23f6e5a9 100644 --- a/tools/perf/util/dso.h +++ b/tools/perf/util/dso.h | |||
| @@ -262,7 +262,7 @@ int dso__decompress_kmodule_path(struct dso *dso, const char *name, | |||
| 262 | struct kmod_path { | 262 | struct kmod_path { |
| 263 | char *name; | 263 | char *name; |
| 264 | char *ext; | 264 | char *ext; |
| 265 | bool comp; | 265 | int comp; |
| 266 | bool kmod; | 266 | bool kmod; |
| 267 | }; | 267 | }; |
| 268 | 268 | ||
