linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/13] perf tools: Use plain debug files for compressed objects
@ 2018-08-17  9:48 Jiri Olsa
  2018-08-17  9:48 ` [PATCH 01/13] perf tools: Get rid of dso__needs_decompress call in read_object_code Jiri Olsa
                   ` (13 more replies)
  0 siblings, 14 replies; 32+ messages in thread
From: Jiri Olsa @ 2018-08-17  9:48 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: lkml, Ingo Molnar, Namhyung Kim, David Ahern, Alexander Shishkin,
	Peter Zijlstra, Michael Petlan

hi,
currently we don't allow to open plain debug files for
compressed kernel module objects, ending up with following
warning:

  $ perf report --stdio
  lzma: failed The input is not in the .xz format
  lzma: failed The input is not in the .xz format
  lzma: failed The input is not in the .xz format
  lzma: failed The input is not in the .xz format
  # To display the perf.data header info, please use --header/--header-only options.

The reason is behind the logic we open the DSO object files,
when we try all possible 'debug' objects until we find the
data. So even if the DSO is represented by 'krava.xz' module,
we can end up opening ~/.debug/....23432432/debug' file which
is not compressed and we fail with above error.

This patchset adds the code to detect un/compressed files and
return plain debug file when available even for compressed
kernel modules.

Also available in here:
  git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git
  perf/fixes

thanks,
jirka


---
Jiri Olsa (13):
      perf tools: Get rid of dso__needs_decompress call in read_object_code
      perf tools: Get rid of dso__needs_decompress call in symbol__disassemble
      perf tools: Get rid of dso__needs_decompress call in __open_dso
      perf tools: Make decompress_to_file function static
      perf tools: Make is_supported_compression function static
      perf tools: Add compression id into struct kmod_path
      perf tools: Store compression id into struct dso
      perf tools: Use compression id in decompress_kmodule function
      perf tools: Move the temp file processing into decompress_kmodule
      perf tools: Add is_compressed callback to compressions array
      perf tools: Add lzma_is_compressed function
      perf tools: Add gzip_is_compressed function
      perf tools: Remove ext from struct kmod_path

 tools/perf/tests/code-reading.c |   4 +++-
 tools/perf/tests/kmod-path.c    | 136 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------------------------------------------------------
 tools/perf/util/annotate.c      |   4 +++-
 tools/perf/util/compress.h      |   2 ++
 tools/perf/util/dso.c           | 111 ++++++++++++++++++++++++++++++++++++++++++++++++++-------------------------------------------------------
 tools/perf/util/dso.h           |  13 +++++--------
 tools/perf/util/lzma.c          |  20 +++++++++++++++++++
 tools/perf/util/machine.c       |   4 +++-
 tools/perf/util/zlib.c          |  18 +++++++++++++++++
 9 files changed, 172 insertions(+), 140 deletions(-)

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [PATCH 01/13] perf tools: Get rid of dso__needs_decompress call in read_object_code
  2018-08-17  9:48 [PATCH 00/13] perf tools: Use plain debug files for compressed objects Jiri Olsa
@ 2018-08-17  9:48 ` Jiri Olsa
  2018-08-23  8:39   ` [tip:perf/urgent] perf tools: Get rid of dso__needs_decompress() call in read_object_code() tip-bot for Jiri Olsa
  2018-08-17  9:48 ` [PATCH 02/13] perf tools: Get rid of dso__needs_decompress call in symbol__disassemble Jiri Olsa
                   ` (12 subsequent siblings)
  13 siblings, 1 reply; 32+ messages in thread
From: Jiri Olsa @ 2018-08-17  9:48 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: lkml, Ingo Molnar, Namhyung Kim, David Ahern, Alexander Shishkin,
	Peter Zijlstra, Michael Petlan

There's no need to call dso__needs_decompress twice
in the function.

Link: http://lkml.kernel.org/n/tip-ze5ga3ioou08aq94pe59vzzu@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/perf/tests/code-reading.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/tools/perf/tests/code-reading.c b/tools/perf/tests/code-reading.c
index 4892bd2dc33e..6b049f3f5cf4 100644
--- a/tools/perf/tests/code-reading.c
+++ b/tools/perf/tests/code-reading.c
@@ -232,6 +232,7 @@ static int read_object_code(u64 addr, size_t len, u8 cpumode,
 	u64 objdump_addr;
 	const char *objdump_name;
 	char decomp_name[KMOD_DECOMP_LEN];
+	bool decomp = false;
 	int ret;
 
 	pr_debug("Reading object code for memory address: %#"PRIx64"\n", addr);
@@ -305,6 +306,7 @@ static int read_object_code(u64 addr, size_t len, u8 cpumode,
 			return -1;
 		}
 
+		decomp = true;
 		objdump_name = decomp_name;
 	}
 
@@ -312,7 +314,7 @@ static int read_object_code(u64 addr, size_t len, u8 cpumode,
 	objdump_addr = map__rip_2objdump(al.map, al.addr);
 	ret = read_via_objdump(objdump_name, objdump_addr, buf2, len);
 
-	if (dso__needs_decompress(al.map->dso))
+	if (decomp)
 		unlink(objdump_name);
 
 	if (ret > 0) {
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 02/13] perf tools: Get rid of dso__needs_decompress call in symbol__disassemble
  2018-08-17  9:48 [PATCH 00/13] perf tools: Use plain debug files for compressed objects Jiri Olsa
  2018-08-17  9:48 ` [PATCH 01/13] perf tools: Get rid of dso__needs_decompress call in read_object_code Jiri Olsa
@ 2018-08-17  9:48 ` Jiri Olsa
  2018-08-23  8:39   ` [tip:perf/urgent] perf tools: Get rid of dso__needs_decompress() call in symbol__disassemble() tip-bot for Jiri Olsa
  2018-08-17  9:48 ` [PATCH 03/13] perf tools: Get rid of dso__needs_decompress call in __open_dso Jiri Olsa
                   ` (11 subsequent siblings)
  13 siblings, 1 reply; 32+ messages in thread
From: Jiri Olsa @ 2018-08-17  9:48 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: lkml, Ingo Molnar, Namhyung Kim, David Ahern, Alexander Shishkin,
	Peter Zijlstra, Michael Petlan

There's no need to call dso__needs_decompress twice
in the function.

Link: http://lkml.kernel.org/n/tip-4lygwpnkdyed2rtiof4blint@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/perf/util/annotate.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index e4268b948e0e..20061cf42288 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -1629,6 +1629,7 @@ static int symbol__disassemble(struct symbol *sym, struct annotate_args *args)
 	char symfs_filename[PATH_MAX];
 	struct kcore_extract kce;
 	bool delete_extract = false;
+	bool decomp = false;
 	int stdout_fd[2];
 	int lineno = 0;
 	int nline;
@@ -1662,6 +1663,7 @@ static int symbol__disassemble(struct symbol *sym, struct annotate_args *args)
 						 tmp, sizeof(tmp)) < 0)
 			goto out;
 
+		decomp = true;
 		strcpy(symfs_filename, tmp);
 	}
 
@@ -1748,7 +1750,7 @@ static int symbol__disassemble(struct symbol *sym, struct annotate_args *args)
 out_remove_tmp:
 	close(stdout_fd[0]);
 
-	if (dso__needs_decompress(dso))
+	if (decomp)
 		unlink(symfs_filename);
 
 	if (delete_extract)
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 03/13] perf tools: Get rid of dso__needs_decompress call in __open_dso
  2018-08-17  9:48 [PATCH 00/13] perf tools: Use plain debug files for compressed objects Jiri Olsa
  2018-08-17  9:48 ` [PATCH 01/13] perf tools: Get rid of dso__needs_decompress call in read_object_code Jiri Olsa
  2018-08-17  9:48 ` [PATCH 02/13] perf tools: Get rid of dso__needs_decompress call in symbol__disassemble Jiri Olsa
@ 2018-08-17  9:48 ` Jiri Olsa
  2018-08-23  8:40   ` [tip:perf/urgent] perf tools: Get rid of dso__needs_decompress() call in __open_dso() tip-bot for Jiri Olsa
  2018-08-17  9:48 ` [PATCH 04/13] perf tools: Make decompress_to_file function static Jiri Olsa
                   ` (10 subsequent siblings)
  13 siblings, 1 reply; 32+ messages in thread
From: Jiri Olsa @ 2018-08-17  9:48 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: lkml, Ingo Molnar, Namhyung Kim, David Ahern, Alexander Shishkin,
	Peter Zijlstra, Michael Petlan

There's no need to call dso__needs_decompress twice
in the function.

Link: http://lkml.kernel.org/n/tip-06j86wkfb4lxw3oqj50gahsi@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/perf/util/dso.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
index 51cf82cf1882..8ee1faa5726f 100644
--- a/tools/perf/util/dso.c
+++ b/tools/perf/util/dso.c
@@ -468,6 +468,7 @@ static int __open_dso(struct dso *dso, struct machine *machine)
 	int fd = -EINVAL;
 	char *root_dir = (char *)"";
 	char *name = malloc(PATH_MAX);
+	bool decomp = false;
 
 	if (!name)
 		return -ENOMEM;
@@ -491,12 +492,13 @@ static int __open_dso(struct dso *dso, struct machine *machine)
 			goto out;
 		}
 
+		decomp = true;
 		strcpy(name, newpath);
 	}
 
 	fd = do_open(name);
 
-	if (dso__needs_decompress(dso))
+	if (decomp)
 		unlink(name);
 
 out:
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 04/13] perf tools: Make decompress_to_file function static
  2018-08-17  9:48 [PATCH 00/13] perf tools: Use plain debug files for compressed objects Jiri Olsa
                   ` (2 preceding siblings ...)
  2018-08-17  9:48 ` [PATCH 03/13] perf tools: Get rid of dso__needs_decompress call in __open_dso Jiri Olsa
@ 2018-08-17  9:48 ` Jiri Olsa
  2018-08-23  8:40   ` [tip:perf/urgent] perf tools: Make decompress_to_file() " tip-bot for Jiri Olsa
  2018-08-17  9:48 ` [PATCH 05/13] perf tools: Make is_supported_compression " Jiri Olsa
                   ` (9 subsequent siblings)
  13 siblings, 1 reply; 32+ messages in thread
From: Jiri Olsa @ 2018-08-17  9:48 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: lkml, Ingo Molnar, Namhyung Kim, David Ahern, Alexander Shishkin,
	Peter Zijlstra, Michael Petlan

There's no outside user of it.

Link: http://lkml.kernel.org/n/tip-w7pmh9n76tz9xt5r4xnsnck4@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/perf/util/dso.c | 3 ++-
 tools/perf/util/dso.h | 1 -
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
index 8ee1faa5726f..3f38b6a08a9a 100644
--- a/tools/perf/util/dso.c
+++ b/tools/perf/util/dso.c
@@ -239,7 +239,8 @@ bool is_kernel_module(const char *pathname, int cpumode)
 	return m.kmod;
 }
 
-bool decompress_to_file(const char *ext, const char *filename, int output_fd)
+static bool
+decompress_to_file(const char *ext, const char *filename, int output_fd)
 {
 	unsigned i;
 
diff --git a/tools/perf/util/dso.h b/tools/perf/util/dso.h
index ef69de2e69ea..e1adadd1fe1e 100644
--- a/tools/perf/util/dso.h
+++ b/tools/perf/util/dso.h
@@ -252,7 +252,6 @@ int dso__read_binary_type_filename(const struct dso *dso, enum dso_binary_type t
 				   char *root_dir, char *filename, size_t size);
 bool is_supported_compression(const char *ext);
 bool is_kernel_module(const char *pathname, int cpumode);
-bool decompress_to_file(const char *ext, const char *filename, int output_fd);
 bool dso__needs_decompress(struct dso *dso);
 int dso__decompress_kmodule_fd(struct dso *dso, const char *name);
 int dso__decompress_kmodule_path(struct dso *dso, const char *name,
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 05/13] perf tools: Make is_supported_compression function static
  2018-08-17  9:48 [PATCH 00/13] perf tools: Use plain debug files for compressed objects Jiri Olsa
                   ` (3 preceding siblings ...)
  2018-08-17  9:48 ` [PATCH 04/13] perf tools: Make decompress_to_file function static Jiri Olsa
@ 2018-08-17  9:48 ` Jiri Olsa
  2018-08-23  8:41   ` [tip:perf/urgent] perf tools: Make is_supported_compression() static tip-bot for Jiri Olsa
  2018-08-17  9:48 ` [PATCH 06/13] perf tools: Add compression id into struct kmod_path Jiri Olsa
                   ` (8 subsequent siblings)
  13 siblings, 1 reply; 32+ messages in thread
From: Jiri Olsa @ 2018-08-17  9:48 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: lkml, Ingo Molnar, Namhyung Kim, David Ahern, Alexander Shishkin,
	Peter Zijlstra, Michael Petlan

There's no outside user of it.

Link: http://lkml.kernel.org/n/tip-w7pmh9n76tz9xt5r4xnsnck4@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/perf/util/dso.c | 2 +-
 tools/perf/util/dso.h | 1 -
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
index 3f38b6a08a9a..4449a7257340 100644
--- a/tools/perf/util/dso.c
+++ b/tools/perf/util/dso.c
@@ -202,7 +202,7 @@ static const struct {
 	{ NULL, NULL },
 };
 
-bool is_supported_compression(const char *ext)
+static bool is_supported_compression(const char *ext)
 {
 	unsigned i;
 
diff --git a/tools/perf/util/dso.h b/tools/perf/util/dso.h
index e1adadd1fe1e..870346b333ee 100644
--- a/tools/perf/util/dso.h
+++ b/tools/perf/util/dso.h
@@ -250,7 +250,6 @@ int dso__kernel_module_get_build_id(struct dso *dso, const char *root_dir);
 char dso__symtab_origin(const struct dso *dso);
 int dso__read_binary_type_filename(const struct dso *dso, enum dso_binary_type type,
 				   char *root_dir, char *filename, size_t size);
-bool is_supported_compression(const char *ext);
 bool is_kernel_module(const char *pathname, int cpumode);
 bool dso__needs_decompress(struct dso *dso);
 int dso__decompress_kmodule_fd(struct dso *dso, const char *name);
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 06/13] perf tools: Add compression id into struct kmod_path
  2018-08-17  9:48 [PATCH 00/13] perf tools: Use plain debug files for compressed objects Jiri Olsa
                   ` (4 preceding siblings ...)
  2018-08-17  9:48 ` [PATCH 05/13] perf tools: Make is_supported_compression " Jiri Olsa
@ 2018-08-17  9:48 ` Jiri Olsa
  2018-08-17 18:23   ` Arnaldo Carvalho de Melo
  2018-08-23  8:41   ` [tip:perf/urgent] perf tools: Add compression id into 'struct kmod_path' tip-bot for Jiri Olsa
  2018-08-17  9:48 ` [PATCH 07/13] perf tools: Store compression id into struct dso Jiri Olsa
                   ` (7 subsequent siblings)
  13 siblings, 2 replies; 32+ messages in thread
From: Jiri Olsa @ 2018-08-17  9:48 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: lkml, Ingo Molnar, Namhyung Kim, David Ahern, Alexander Shishkin,
	Peter Zijlstra, Michael Petlan

Storing decompression ID in the struct kmod_path, so it
can be later stored in the struct dso.

Switching the struct kmod_path::comp from bool to int
to return the compressions array index. Adding 0 index
item into compressions array, so the comp usage stays
as it was: 0 - no compression, != 0 index of compression.

Updating the kmod_path tests.

Link: http://lkml.kernel.org/n/tip-vxxfco32fh5veg1817udcx2c@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/perf/tests/kmod-path.c | 42 ++++++++++++++++++------------------
 tools/perf/util/dso.c        | 18 ++++++++++------
 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 @@
 #include "debug.h"
 
 static int test(const char *path, bool alloc_name, bool alloc_ext,
-		bool kmod, bool comp, const char *name, const char *ext)
+		bool kmod, int comp, const char *name, const char *ext)
 {
 	struct kmod_path m;
 
@@ -54,47 +54,47 @@ static int test_is_kernel_module(const char *path, int cpumode, bool expect)
 int test__kmod_path__parse(struct test *t __maybe_unused, int subtest __maybe_unused)
 {
 	/* path                alloc_name  alloc_ext   kmod  comp   name     ext */
-	T("/xxxx/xxxx/x-x.ko", true      , true      , true, false, "[x_x]", NULL);
-	T("/xxxx/xxxx/x-x.ko", false     , true      , true, false, NULL   , NULL);
-	T("/xxxx/xxxx/x-x.ko", true      , false     , true, false, "[x_x]", NULL);
-	T("/xxxx/xxxx/x-x.ko", false     , false     , true, false, NULL   , NULL);
+	T("/xxxx/xxxx/x-x.ko", true      , true      , true, 0    , "[x_x]", NULL);
+	T("/xxxx/xxxx/x-x.ko", false     , true      , true, 0    , NULL   , NULL);
+	T("/xxxx/xxxx/x-x.ko", true      , false     , true, 0    , "[x_x]", NULL);
+	T("/xxxx/xxxx/x-x.ko", false     , false     , true, 0    , NULL   , NULL);
 	M("/xxxx/xxxx/x-x.ko", PERF_RECORD_MISC_CPUMODE_UNKNOWN, true);
 	M("/xxxx/xxxx/x-x.ko", PERF_RECORD_MISC_KERNEL, true);
 	M("/xxxx/xxxx/x-x.ko", PERF_RECORD_MISC_USER, false);
 
 #ifdef HAVE_ZLIB_SUPPORT
 	/* path                alloc_name  alloc_ext   kmod  comp  name   ext */
-	T("/xxxx/xxxx/x.ko.gz", true     , true      , true, true, "[x]", "gz");
-	T("/xxxx/xxxx/x.ko.gz", false    , true      , true, true, NULL , "gz");
-	T("/xxxx/xxxx/x.ko.gz", true     , false     , true, true, "[x]", NULL);
-	T("/xxxx/xxxx/x.ko.gz", false    , false     , true, true, NULL , NULL);
+	T("/xxxx/xxxx/x.ko.gz", true     , true      , true, 1   , "[x]", "gz");
+	T("/xxxx/xxxx/x.ko.gz", false    , true      , true, 1   , NULL , "gz");
+	T("/xxxx/xxxx/x.ko.gz", true     , false     , true, 1   , "[x]", NULL);
+	T("/xxxx/xxxx/x.ko.gz", false    , false     , true, 1   , NULL , NULL);
 	M("/xxxx/xxxx/x.ko.gz", PERF_RECORD_MISC_CPUMODE_UNKNOWN, true);
 	M("/xxxx/xxxx/x.ko.gz", PERF_RECORD_MISC_KERNEL, true);
 	M("/xxxx/xxxx/x.ko.gz", PERF_RECORD_MISC_USER, false);
 
 	/* path              alloc_name  alloc_ext  kmod   comp  name    ext */
-	T("/xxxx/xxxx/x.gz", true      , true     , false, true, "x.gz" ,"gz");
-	T("/xxxx/xxxx/x.gz", false     , true     , false, true, NULL   ,"gz");
-	T("/xxxx/xxxx/x.gz", true      , false    , false, true, "x.gz" , NULL);
-	T("/xxxx/xxxx/x.gz", false     , false    , false, true, NULL   , NULL);
+	T("/xxxx/xxxx/x.gz", true      , true     , false, 1   , "x.gz" ,"gz");
+	T("/xxxx/xxxx/x.gz", false     , true     , false, 1   , NULL   ,"gz");
+	T("/xxxx/xxxx/x.gz", true      , false    , false, 1   , "x.gz" , NULL);
+	T("/xxxx/xxxx/x.gz", false     , false    , false, 1   , NULL   , NULL);
 	M("/xxxx/xxxx/x.gz", PERF_RECORD_MISC_CPUMODE_UNKNOWN, false);
 	M("/xxxx/xxxx/x.gz", PERF_RECORD_MISC_KERNEL, false);
 	M("/xxxx/xxxx/x.gz", PERF_RECORD_MISC_USER, false);
 
 	/* path   alloc_name  alloc_ext  kmod   comp  name     ext */
-	T("x.gz", true      , true     , false, true, "x.gz", "gz");
-	T("x.gz", false     , true     , false, true, NULL  , "gz");
-	T("x.gz", true      , false    , false, true, "x.gz", NULL);
-	T("x.gz", false     , false    , false, true, NULL  , NULL);
+	T("x.gz", true      , true     , false, 1   , "x.gz", "gz");
+	T("x.gz", false     , true     , false, 1   , NULL  , "gz");
+	T("x.gz", true      , false    , false, 1   , "x.gz", NULL);
+	T("x.gz", false     , false    , false, 1   , NULL  , NULL);
 	M("x.gz", PERF_RECORD_MISC_CPUMODE_UNKNOWN, false);
 	M("x.gz", PERF_RECORD_MISC_KERNEL, false);
 	M("x.gz", PERF_RECORD_MISC_USER, false);
 
 	/* path      alloc_name  alloc_ext  kmod  comp  name  ext */
-	T("x.ko.gz", true      , true     , true, true, "[x]", "gz");
-	T("x.ko.gz", false     , true     , true, true, NULL , "gz");
-	T("x.ko.gz", true      , false    , true, true, "[x]", NULL);
-	T("x.ko.gz", false     , false    , true, true, NULL , NULL);
+	T("x.ko.gz", true      , true     , true, 1   , "[x]", "gz");
+	T("x.ko.gz", false     , true     , true, 1   , NULL , "gz");
+	T("x.ko.gz", true      , false    , true, 1   , "[x]", NULL);
+	T("x.ko.gz", false     , false    , true, 1   , NULL , NULL);
 	M("x.ko.gz", PERF_RECORD_MISC_CPUMODE_UNKNOWN, true);
 	M("x.ko.gz", PERF_RECORD_MISC_KERNEL, true);
 	M("x.ko.gz", PERF_RECORD_MISC_USER, false);
diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
index 4449a7257340..f5f8babea17c 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,
 	return ret;
 }
 
+enum {
+	COMP_ID__NONE = 0,
+};
+
 static const struct {
 	const char *fmt;
 	int (*decompress)(const char *input, int output);
 } compressions[] = {
+	[COMP_ID__NONE] = { 0 },
 #ifdef HAVE_ZLIB_SUPPORT
 	{ "gz", gzip_decompress_to_file },
 #endif
@@ -202,15 +207,15 @@ static const struct {
 	{ NULL, NULL },
 };
 
-static bool is_supported_compression(const char *ext)
+static int is_supported_compression(const char *ext)
 {
 	unsigned i;
 
-	for (i = 0; compressions[i].fmt; i++) {
+	for (i = 1; compressions[i].fmt; i++) {
 		if (!strcmp(ext, compressions[i].fmt))
-			return true;
+			return i;
 	}
-	return false;
+	return COMP_ID__NONE;
 }
 
 bool is_kernel_module(const char *pathname, int cpumode)
@@ -373,10 +378,9 @@ int __kmod_path__parse(struct kmod_path *m, const char *path,
 		return 0;
 	}
 
-	if (is_supported_compression(ext + 1)) {
-		m->comp = true;
+	m->comp = is_supported_compression(ext + 1);
+	if (m->comp > COMP_ID__NONE)
 		ext -= 3;
-	}
 
 	/* Check .ko extension only if there's enough name left. */
 	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,
 struct kmod_path {
 	char *name;
 	char *ext;
-	bool  comp;
+	int   comp;
 	bool  kmod;
 };
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 07/13] perf tools: Store compression id into struct dso
  2018-08-17  9:48 [PATCH 00/13] perf tools: Use plain debug files for compressed objects Jiri Olsa
                   ` (5 preceding siblings ...)
  2018-08-17  9:48 ` [PATCH 06/13] perf tools: Add compression id into struct kmod_path Jiri Olsa
@ 2018-08-17  9:48 ` Jiri Olsa
  2018-08-23  8:42   ` [tip:perf/urgent] " tip-bot for Jiri Olsa
  2018-08-17  9:48 ` [PATCH 08/13] perf tools: Use compression id in decompress_kmodule function Jiri Olsa
                   ` (6 subsequent siblings)
  13 siblings, 1 reply; 32+ messages in thread
From: Jiri Olsa @ 2018-08-17  9:48 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: lkml, Ingo Molnar, Namhyung Kim, David Ahern, Alexander Shishkin,
	Peter Zijlstra, Michael Petlan

Adding comp into struct dso to hold the compression index.
It will be used in following patches.

Link: http://lkml.kernel.org/n/tip-84cxf8bbc0etndwzrzqxxi2d@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/perf/util/dso.c     | 5 ++++-
 tools/perf/util/dso.h     | 1 +
 tools/perf/util/machine.c | 4 +++-
 3 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
index f5f8babea17c..f0e4cc43c97e 100644
--- a/tools/perf/util/dso.c
+++ b/tools/perf/util/dso.c
@@ -418,8 +418,10 @@ void dso__set_module_info(struct dso *dso, struct kmod_path *m,
 		dso->symtab_type = DSO_BINARY_TYPE__GUEST_KMODULE;
 
 	/* _KMODULE_COMP should be next to _KMODULE */
-	if (m->kmod && m->comp)
+	if (m->kmod && m->comp) {
 		dso->symtab_type++;
+		dso->comp = m->comp;
+	}
 
 	dso__set_short_name(dso, strdup(m->name), true);
 }
@@ -1225,6 +1227,7 @@ struct dso *dso__new(const char *name)
 		dso->a2l_fails = 1;
 		dso->kernel = DSO_TYPE_USER;
 		dso->needs_swap = DSO_SWAP__UNSET;
+		dso->comp = COMP_ID__NONE;
 		RB_CLEAR_NODE(&dso->rb_node);
 		dso->root = NULL;
 		INIT_LIST_HEAD(&dso->node);
diff --git a/tools/perf/util/dso.h b/tools/perf/util/dso.h
index 7bde23f6e5a9..a6c7af52115f 100644
--- a/tools/perf/util/dso.h
+++ b/tools/perf/util/dso.h
@@ -175,6 +175,7 @@ struct dso {
 	u16		 short_name_len;
 	void		*dwfl;			/* DWARF debug info */
 	struct auxtrace_cache *auxtrace_cache;
+	int		 comp;
 
 	/* dso data file */
 	struct {
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index b300a3973448..c4acd2001db0 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -1212,8 +1212,10 @@ static int map_groups__set_module_path(struct map_groups *mg, const char *path,
 	 * Full name could reveal us kmod compression, so
 	 * we need to update the symtab_type if needed.
 	 */
-	if (m->comp && is_kmod_dso(map->dso))
+	if (m->comp && is_kmod_dso(map->dso)) {
 		map->dso->symtab_type++;
+		map->dso->comp = m->comp;
+	}
 
 	return 0;
 }
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 08/13] perf tools: Use compression id in decompress_kmodule function
  2018-08-17  9:48 [PATCH 00/13] perf tools: Use plain debug files for compressed objects Jiri Olsa
                   ` (6 preceding siblings ...)
  2018-08-17  9:48 ` [PATCH 07/13] perf tools: Store compression id into struct dso Jiri Olsa
@ 2018-08-17  9:48 ` Jiri Olsa
  2018-08-23  8:42   ` [tip:perf/urgent] perf tools: Use compression id in decompress_kmodule() tip-bot for Jiri Olsa
  2018-08-17  9:48 ` [PATCH 09/13] perf tools: Move the temp file processing into decompress_kmodule Jiri Olsa
                   ` (5 subsequent siblings)
  13 siblings, 1 reply; 32+ messages in thread
From: Jiri Olsa @ 2018-08-17  9:48 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: lkml, Ingo Molnar, Namhyung Kim, David Ahern, Alexander Shishkin,
	Peter Zijlstra, Michael Petlan

Once we parsed out the compression ID, we dont need to
iterate all available compressions and we can call it
directly.

Link: http://lkml.kernel.org/n/tip-55zrhxhr699pswx34d0hd4u9@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/perf/util/dso.c | 25 +++----------------------
 1 file changed, 3 insertions(+), 22 deletions(-)

diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
index f0e4cc43c97e..1cee958c9a2a 100644
--- a/tools/perf/util/dso.c
+++ b/tools/perf/util/dso.c
@@ -244,19 +244,6 @@ bool is_kernel_module(const char *pathname, int cpumode)
 	return m.kmod;
 }
 
-static bool
-decompress_to_file(const char *ext, const char *filename, int output_fd)
-{
-	unsigned i;
-
-	for (i = 0; compressions[i].fmt; i++) {
-		if (!strcmp(ext, compressions[i].fmt))
-			return !compressions[i].decompress(filename,
-							   output_fd);
-	}
-	return false;
-}
-
 bool dso__needs_decompress(struct dso *dso)
 {
 	return dso->symtab_type == DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE_COMP ||
@@ -266,31 +253,25 @@ bool dso__needs_decompress(struct dso *dso)
 static int decompress_kmodule(struct dso *dso, const char *name, char *tmpbuf)
 {
 	int fd = -1;
-	struct kmod_path m;
 
 	if (!dso__needs_decompress(dso))
 		return -1;
 
-	if (kmod_path__parse_ext(&m, dso->long_name))
+	if (dso->comp == COMP_ID__NONE)
 		return -1;
 
-	if (!m.comp)
-		goto out;
-
 	fd = mkstemp(tmpbuf);
 	if (fd < 0) {
 		dso->load_errno = errno;
-		goto out;
+		return -1;
 	}
 
-	if (!decompress_to_file(m.ext, name, fd)) {
+	if (compressions[dso->comp].decompress(name, fd)) {
 		dso->load_errno = DSO_LOAD_ERRNO__DECOMPRESSION_FAILURE;
 		close(fd);
 		fd = -1;
 	}
 
-out:
-	free(m.ext);
 	return fd;
 }
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 09/13] perf tools: Move the temp file processing into decompress_kmodule
  2018-08-17  9:48 [PATCH 00/13] perf tools: Use plain debug files for compressed objects Jiri Olsa
                   ` (7 preceding siblings ...)
  2018-08-17  9:48 ` [PATCH 08/13] perf tools: Use compression id in decompress_kmodule function Jiri Olsa
@ 2018-08-17  9:48 ` Jiri Olsa
  2018-08-23  8:43   ` [tip:perf/urgent] " tip-bot for Jiri Olsa
  2018-08-17  9:48 ` [PATCH 10/13] perf tools: Add is_compressed callback to compressions array Jiri Olsa
                   ` (4 subsequent siblings)
  13 siblings, 1 reply; 32+ messages in thread
From: Jiri Olsa @ 2018-08-17  9:48 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: lkml, Ingo Molnar, Namhyung Kim, David Ahern, Alexander Shishkin,
	Peter Zijlstra, Michael Petlan

We will add compression check in following patch and it
makes it easier if the tem file processing is done in the
single place. It also makes the current code simpler.

The decompress_kmodule function now returns the fd of the
uncompressed file and the file name in pathname arg, if it's
provided.

Link: http://lkml.kernel.org/n/tip-n8ul4r0tny6n16012uncxe6q@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/perf/util/dso.c | 29 ++++++++++++-----------------
 1 file changed, 12 insertions(+), 17 deletions(-)

diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
index 1cee958c9a2a..0f07aab30ffe 100644
--- a/tools/perf/util/dso.c
+++ b/tools/perf/util/dso.c
@@ -250,8 +250,10 @@ bool dso__needs_decompress(struct dso *dso)
 		dso->symtab_type == DSO_BINARY_TYPE__GUEST_KMODULE_COMP;
 }
 
-static int decompress_kmodule(struct dso *dso, const char *name, char *tmpbuf)
+static int decompress_kmodule(struct dso *dso, const char *name,
+			      char *pathname, size_t len)
 {
+	char tmpbuf[] = KMOD_DECOMP_NAME;
 	int fd = -1;
 
 	if (!dso__needs_decompress(dso))
@@ -272,34 +274,27 @@ static int decompress_kmodule(struct dso *dso, const char *name, char *tmpbuf)
 		fd = -1;
 	}
 
+	if (!pathname || (fd < 0))
+		unlink(tmpbuf);
+
+	if (pathname && (fd >= 0))
+		strncpy(pathname, tmpbuf, len);
+
 	return fd;
 }
 
 int dso__decompress_kmodule_fd(struct dso *dso, const char *name)
 {
-	char tmpbuf[] = KMOD_DECOMP_NAME;
-	int fd;
-
-	fd = decompress_kmodule(dso, name, tmpbuf);
-	unlink(tmpbuf);
-	return fd;
+	return decompress_kmodule(dso, name, NULL, 0);
 }
 
 int dso__decompress_kmodule_path(struct dso *dso, const char *name,
 				 char *pathname, size_t len)
 {
-	char tmpbuf[] = KMOD_DECOMP_NAME;
-	int fd;
-
-	fd = decompress_kmodule(dso, name, tmpbuf);
-	if (fd < 0) {
-		unlink(tmpbuf);
-		return -1;
-	}
+	int fd = decompress_kmodule(dso, name, pathname, len);
 
-	strncpy(pathname, tmpbuf, len);
 	close(fd);
-	return 0;
+	return fd >= 0 ? 0 : -1;
 }
 
 /*
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 10/13] perf tools: Add is_compressed callback to compressions array
  2018-08-17  9:48 [PATCH 00/13] perf tools: Use plain debug files for compressed objects Jiri Olsa
                   ` (8 preceding siblings ...)
  2018-08-17  9:48 ` [PATCH 09/13] perf tools: Move the temp file processing into decompress_kmodule Jiri Olsa
@ 2018-08-17  9:48 ` Jiri Olsa
  2018-08-23  8:43   ` [tip:perf/urgent] " tip-bot for Jiri Olsa
  2018-08-17  9:48 ` [PATCH 11/13] perf tools: Add lzma_is_compressed function Jiri Olsa
                   ` (3 subsequent siblings)
  13 siblings, 1 reply; 32+ messages in thread
From: Jiri Olsa @ 2018-08-17  9:48 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: lkml, Ingo Molnar, Namhyung Kim, David Ahern, Alexander Shishkin,
	Peter Zijlstra, Michael Petlan

Adding is_compressed callback to compressions array,
that returns 0 if the file is compressed or != 0 if not.

The new callback is used to recognize the situation when
we have 'compressed' object, like:
  /lib/modules/.../drivers/net/ethernet/intel/igb/igb.ko.xz

but we need to read its debug data from debuginfo files,
which might not be compressed, like:
  /root/.debug/.build-id/d6/...c4b301f/debug

So even for 'compressed' object we read data from plain
uncompressed object. To keep this transparent, we detect
this in decompress_kmodule and return the file descriptor
to the uncompressed file.

Link: http://lkml.kernel.org/n/tip-diw1xpztojz0pj2wgdt6axxr@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/perf/util/compress.h |  2 ++
 tools/perf/util/dso.c      | 23 ++++++++++++++++++++---
 tools/perf/util/lzma.c     |  5 +++++
 tools/perf/util/zlib.c     |  6 ++++++
 4 files changed, 33 insertions(+), 3 deletions(-)

diff --git a/tools/perf/util/compress.h b/tools/perf/util/compress.h
index ecca688a25fb..892e92e7e7fc 100644
--- a/tools/perf/util/compress.h
+++ b/tools/perf/util/compress.h
@@ -4,10 +4,12 @@
 
 #ifdef HAVE_ZLIB_SUPPORT
 int gzip_decompress_to_file(const char *input, int output_fd);
+bool gzip_is_compressed(const char *input);
 #endif
 
 #ifdef HAVE_LZMA_SUPPORT
 int lzma_decompress_to_file(const char *input, int output_fd);
+bool lzma_is_compressed(const char *input);
 #endif
 
 #endif /* PERF_COMPRESS_H */
diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
index 0f07aab30ffe..a7f2162ba730 100644
--- a/tools/perf/util/dso.c
+++ b/tools/perf/util/dso.c
@@ -196,15 +196,16 @@ enum {
 static const struct {
 	const char *fmt;
 	int (*decompress)(const char *input, int output);
+	bool (*is_compressed)(const char *input);
 } compressions[] = {
 	[COMP_ID__NONE] = { 0 },
 #ifdef HAVE_ZLIB_SUPPORT
-	{ "gz", gzip_decompress_to_file },
+	{ "gz", gzip_decompress_to_file, gzip_is_compressed },
 #endif
 #ifdef HAVE_LZMA_SUPPORT
-	{ "xz", lzma_decompress_to_file },
+	{ "xz", lzma_decompress_to_file, lzma_is_compressed },
 #endif
-	{ NULL, NULL },
+	{ NULL, NULL, NULL },
 };
 
 static int is_supported_compression(const char *ext)
@@ -262,6 +263,22 @@ static int decompress_kmodule(struct dso *dso, const char *name,
 	if (dso->comp == COMP_ID__NONE)
 		return -1;
 
+	/*
+	 * We have proper compression id for DSO and yet the file
+	 * behind the 'name' can still be plain uncompressed object.
+	 *
+	 * The reason is behind the logic we open the DSO object files,
+	 * when we try all possible 'debug' objects until we find the
+	 * data. So even if the DSO is represented by 'krava.xz' module,
+	 * we can end up here opening ~/.debug/....23432432/debug' file
+	 * which is not compressed.
+	 *
+	 * To keep this transparent, we detect this and return the file
+	 * descriptor to the uncompressed file.
+	 */
+	if (!compressions[dso->comp].is_compressed(name))
+		return open(name, O_RDONLY);
+
 	fd = mkstemp(tmpbuf);
 	if (fd < 0) {
 		dso->load_errno = errno;
diff --git a/tools/perf/util/lzma.c b/tools/perf/util/lzma.c
index 07498eaddc08..7032caaf75eb 100644
--- a/tools/perf/util/lzma.c
+++ b/tools/perf/util/lzma.c
@@ -99,3 +99,8 @@ int lzma_decompress_to_file(const char *input, int output_fd)
 	fclose(infile);
 	return err;
 }
+
+bool lzma_is_compressed(const char *input __maybe_unused)
+{
+	return true;
+}
diff --git a/tools/perf/util/zlib.c b/tools/perf/util/zlib.c
index a725b958cf31..e68317214679 100644
--- a/tools/perf/util/zlib.c
+++ b/tools/perf/util/zlib.c
@@ -5,6 +5,7 @@
 #include <sys/stat.h>
 #include <sys/mman.h>
 #include <zlib.h>
+#include <linux/compiler.h>
 
 #include "util/compress.h"
 #include "util/util.h"
@@ -79,3 +80,8 @@ int gzip_decompress_to_file(const char *input, int output_fd)
 
 	return ret == Z_STREAM_END ? 0 : -1;
 }
+
+bool gzip_is_compressed(const char *input __maybe_unused)
+{
+	return true;
+}
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 11/13] perf tools: Add lzma_is_compressed function
  2018-08-17  9:48 [PATCH 00/13] perf tools: Use plain debug files for compressed objects Jiri Olsa
                   ` (9 preceding siblings ...)
  2018-08-17  9:48 ` [PATCH 10/13] perf tools: Add is_compressed callback to compressions array Jiri Olsa
@ 2018-08-17  9:48 ` Jiri Olsa
  2018-08-23  8:44   ` [tip:perf/urgent] " tip-bot for Jiri Olsa
  2018-08-17  9:48 ` [PATCH 12/13] perf tools: Add gzip_is_compressed function Jiri Olsa
                   ` (2 subsequent siblings)
  13 siblings, 1 reply; 32+ messages in thread
From: Jiri Olsa @ 2018-08-17  9:48 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: lkml, Ingo Molnar, Namhyung Kim, David Ahern, Alexander Shishkin,
	Peter Zijlstra, Michael Petlan

Add implementation of the is_compressed callback for lzma.

Link: http://lkml.kernel.org/n/tip-tdgpdhdfk7sm5hsyjvfs2skh@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/perf/util/lzma.c | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/lzma.c b/tools/perf/util/lzma.c
index 7032caaf75eb..b1dd29a9d915 100644
--- a/tools/perf/util/lzma.c
+++ b/tools/perf/util/lzma.c
@@ -3,9 +3,13 @@
 #include <lzma.h>
 #include <stdio.h>
 #include <linux/compiler.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
 #include "compress.h"
 #include "util.h"
 #include "debug.h"
+#include <unistd.h>
 
 #define BUFSIZE 8192
 
@@ -100,7 +104,18 @@ int lzma_decompress_to_file(const char *input, int output_fd)
 	return err;
 }
 
-bool lzma_is_compressed(const char *input __maybe_unused)
+bool lzma_is_compressed(const char *input)
 {
-	return true;
+	int fd = open(input, O_RDONLY);
+	const uint8_t magic[6] = { 0xFD, '7', 'z', 'X', 'Z', 0x00 };
+	char buf[6] = { 0 };
+	ssize_t rc;
+
+	if (fd < 0)
+		return -1;
+
+	rc = read(fd, buf, sizeof(buf));
+	close(fd);
+	return rc == sizeof(buf) ?
+	       memcmp(buf, magic, sizeof(buf)) == 0 : false;
 }
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 12/13] perf tools: Add gzip_is_compressed function
  2018-08-17  9:48 [PATCH 00/13] perf tools: Use plain debug files for compressed objects Jiri Olsa
                   ` (10 preceding siblings ...)
  2018-08-17  9:48 ` [PATCH 11/13] perf tools: Add lzma_is_compressed function Jiri Olsa
@ 2018-08-17  9:48 ` Jiri Olsa
  2018-08-23  8:44   ` [tip:perf/urgent] " tip-bot for Jiri Olsa
  2018-08-17  9:48 ` [PATCH 13/13] perf tools: Remove ext from struct kmod_path Jiri Olsa
  2018-08-17 14:52 ` [PATCH 00/13] perf tools: Use plain debug files for compressed objects Arnaldo Carvalho de Melo
  13 siblings, 1 reply; 32+ messages in thread
From: Jiri Olsa @ 2018-08-17  9:48 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: lkml, Ingo Molnar, Namhyung Kim, David Ahern, Alexander Shishkin,
	Peter Zijlstra, Michael Petlan

Add implementation of the is_compressed callback for gzip.

Link: http://lkml.kernel.org/n/tip-f9ponomi33whctnx9vnadlt7@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/perf/util/zlib.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/zlib.c b/tools/perf/util/zlib.c
index e68317214679..902ce6384f57 100644
--- a/tools/perf/util/zlib.c
+++ b/tools/perf/util/zlib.c
@@ -6,6 +6,7 @@
 #include <sys/mman.h>
 #include <zlib.h>
 #include <linux/compiler.h>
+#include <unistd.h>
 
 #include "util/compress.h"
 #include "util/util.h"
@@ -81,7 +82,18 @@ int gzip_decompress_to_file(const char *input, int output_fd)
 	return ret == Z_STREAM_END ? 0 : -1;
 }
 
-bool gzip_is_compressed(const char *input __maybe_unused)
+bool gzip_is_compressed(const char *input)
 {
-	return true;
+	int fd = open(input, O_RDONLY);
+	const uint8_t magic[2] = { 0x1f, 0x8b };
+	char buf[2] = { 0 };
+	ssize_t rc;
+
+	if (fd < 0)
+		return -1;
+
+	rc = read(fd, buf, sizeof(buf));
+	close(fd);
+	return rc == sizeof(buf) ?
+	       memcmp(buf, magic, sizeof(buf)) == 0 : false;
 }
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 13/13] perf tools: Remove ext from struct kmod_path
  2018-08-17  9:48 [PATCH 00/13] perf tools: Use plain debug files for compressed objects Jiri Olsa
                   ` (11 preceding siblings ...)
  2018-08-17  9:48 ` [PATCH 12/13] perf tools: Add gzip_is_compressed function Jiri Olsa
@ 2018-08-17  9:48 ` Jiri Olsa
  2018-08-23  8:45   ` [tip:perf/urgent] " tip-bot for Jiri Olsa
  2018-08-17 14:52 ` [PATCH 00/13] perf tools: Use plain debug files for compressed objects Arnaldo Carvalho de Melo
  13 siblings, 1 reply; 32+ messages in thread
From: Jiri Olsa @ 2018-08-17  9:48 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: lkml, Ingo Molnar, Namhyung Kim, David Ahern, Alexander Shishkin,
	Peter Zijlstra, Michael Petlan

Having comp carrying the compression ID, we no longer
need return the extension. Removing it and updating the
automated test.

Link: http://lkml.kernel.org/n/tip-u2gmyuspmefg0ns9svpzdr6f@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/perf/tests/kmod-path.c | 136 +++++++++++++++++------------------
 tools/perf/util/dso.c        |  10 +--
 tools/perf/util/dso.h        |   8 +--
 3 files changed, 69 insertions(+), 85 deletions(-)

diff --git a/tools/perf/tests/kmod-path.c b/tools/perf/tests/kmod-path.c
index f92f78f683ea..0579a70bbbff 100644
--- a/tools/perf/tests/kmod-path.c
+++ b/tools/perf/tests/kmod-path.c
@@ -5,34 +5,28 @@
 #include "dso.h"
 #include "debug.h"
 
-static int test(const char *path, bool alloc_name, bool alloc_ext,
-		bool kmod, int comp, const char *name, const char *ext)
+static int test(const char *path, bool alloc_name, bool kmod,
+		int comp, const char *name)
 {
 	struct kmod_path m;
 
 	memset(&m, 0x0, sizeof(m));
 
 	TEST_ASSERT_VAL("kmod_path__parse",
-			!__kmod_path__parse(&m, path, alloc_name, alloc_ext));
+			!__kmod_path__parse(&m, path, alloc_name));
 
-	pr_debug("%s - alloc name %d, alloc ext %d, kmod %d, comp %d, name '%s', ext '%s'\n",
-		 path, alloc_name, alloc_ext, m.kmod, m.comp, m.name, m.ext);
+	pr_debug("%s - alloc name %d, kmod %d, comp %d, name '%s'\n",
+		 path, alloc_name, m.kmod, m.comp, m.name);
 
 	TEST_ASSERT_VAL("wrong kmod", m.kmod == kmod);
 	TEST_ASSERT_VAL("wrong comp", m.comp == comp);
 
-	if (ext)
-		TEST_ASSERT_VAL("wrong ext", m.ext && !strcmp(ext, m.ext));
-	else
-		TEST_ASSERT_VAL("wrong ext", !m.ext);
-
 	if (name)
 		TEST_ASSERT_VAL("wrong name", m.name && !strcmp(name, m.name));
 	else
 		TEST_ASSERT_VAL("wrong name", !m.name);
 
 	free(m.name);
-	free(m.ext);
 	return 0;
 }
 
@@ -45,118 +39,118 @@ static int test_is_kernel_module(const char *path, int cpumode, bool expect)
 	return 0;
 }
 
-#define T(path, an, ae, k, c, n, e) \
-	TEST_ASSERT_VAL("failed", !test(path, an, ae, k, c, n, e))
+#define T(path, an, k, c, n) \
+	TEST_ASSERT_VAL("failed", !test(path, an, k, c, n))
 
 #define M(path, c, e) \
 	TEST_ASSERT_VAL("failed", !test_is_kernel_module(path, c, e))
 
 int test__kmod_path__parse(struct test *t __maybe_unused, int subtest __maybe_unused)
 {
-	/* path                alloc_name  alloc_ext   kmod  comp   name     ext */
-	T("/xxxx/xxxx/x-x.ko", true      , true      , true, 0    , "[x_x]", NULL);
-	T("/xxxx/xxxx/x-x.ko", false     , true      , true, 0    , NULL   , NULL);
-	T("/xxxx/xxxx/x-x.ko", true      , false     , true, 0    , "[x_x]", NULL);
-	T("/xxxx/xxxx/x-x.ko", false     , false     , true, 0    , NULL   , NULL);
+	/* path                alloc_name  kmod  comp   name   */
+	T("/xxxx/xxxx/x-x.ko", true      , true, 0    , "[x_x]");
+	T("/xxxx/xxxx/x-x.ko", false     , true, 0    , NULL   );
+	T("/xxxx/xxxx/x-x.ko", true      , true, 0    , "[x_x]");
+	T("/xxxx/xxxx/x-x.ko", false     , true, 0    , NULL   );
 	M("/xxxx/xxxx/x-x.ko", PERF_RECORD_MISC_CPUMODE_UNKNOWN, true);
 	M("/xxxx/xxxx/x-x.ko", PERF_RECORD_MISC_KERNEL, true);
 	M("/xxxx/xxxx/x-x.ko", PERF_RECORD_MISC_USER, false);
 
 #ifdef HAVE_ZLIB_SUPPORT
-	/* path                alloc_name  alloc_ext   kmod  comp  name   ext */
-	T("/xxxx/xxxx/x.ko.gz", true     , true      , true, 1   , "[x]", "gz");
-	T("/xxxx/xxxx/x.ko.gz", false    , true      , true, 1   , NULL , "gz");
-	T("/xxxx/xxxx/x.ko.gz", true     , false     , true, 1   , "[x]", NULL);
-	T("/xxxx/xxxx/x.ko.gz", false    , false     , true, 1   , NULL , NULL);
+	/* path                alloc_name   kmod  comp  name  */
+	T("/xxxx/xxxx/x.ko.gz", true     , true, 1   , "[x]");
+	T("/xxxx/xxxx/x.ko.gz", false    , true, 1   , NULL );
+	T("/xxxx/xxxx/x.ko.gz", true     , true, 1   , "[x]");
+	T("/xxxx/xxxx/x.ko.gz", false    , true, 1   , NULL );
 	M("/xxxx/xxxx/x.ko.gz", PERF_RECORD_MISC_CPUMODE_UNKNOWN, true);
 	M("/xxxx/xxxx/x.ko.gz", PERF_RECORD_MISC_KERNEL, true);
 	M("/xxxx/xxxx/x.ko.gz", PERF_RECORD_MISC_USER, false);
 
-	/* path              alloc_name  alloc_ext  kmod   comp  name    ext */
-	T("/xxxx/xxxx/x.gz", true      , true     , false, 1   , "x.gz" ,"gz");
-	T("/xxxx/xxxx/x.gz", false     , true     , false, 1   , NULL   ,"gz");
-	T("/xxxx/xxxx/x.gz", true      , false    , false, 1   , "x.gz" , NULL);
-	T("/xxxx/xxxx/x.gz", false     , false    , false, 1   , NULL   , NULL);
+	/* path              alloc_name  kmod   comp  name  */
+	T("/xxxx/xxxx/x.gz", true      , false, 1   , "x.gz");
+	T("/xxxx/xxxx/x.gz", false     , false, 1   , NULL  );
+	T("/xxxx/xxxx/x.gz", true      , false, 1   , "x.gz");
+	T("/xxxx/xxxx/x.gz", false     , false, 1   , NULL  );
 	M("/xxxx/xxxx/x.gz", PERF_RECORD_MISC_CPUMODE_UNKNOWN, false);
 	M("/xxxx/xxxx/x.gz", PERF_RECORD_MISC_KERNEL, false);
 	M("/xxxx/xxxx/x.gz", PERF_RECORD_MISC_USER, false);
 
-	/* path   alloc_name  alloc_ext  kmod   comp  name     ext */
-	T("x.gz", true      , true     , false, 1   , "x.gz", "gz");
-	T("x.gz", false     , true     , false, 1   , NULL  , "gz");
-	T("x.gz", true      , false    , false, 1   , "x.gz", NULL);
-	T("x.gz", false     , false    , false, 1   , NULL  , NULL);
+	/* path   alloc_name  kmod   comp  name   */
+	T("x.gz", true      , false, 1   , "x.gz");
+	T("x.gz", false     , false, 1   , NULL  );
+	T("x.gz", true      , false, 1   , "x.gz");
+	T("x.gz", false     , false, 1   , NULL  );
 	M("x.gz", PERF_RECORD_MISC_CPUMODE_UNKNOWN, false);
 	M("x.gz", PERF_RECORD_MISC_KERNEL, false);
 	M("x.gz", PERF_RECORD_MISC_USER, false);
 
-	/* path      alloc_name  alloc_ext  kmod  comp  name  ext */
-	T("x.ko.gz", true      , true     , true, 1   , "[x]", "gz");
-	T("x.ko.gz", false     , true     , true, 1   , NULL , "gz");
-	T("x.ko.gz", true      , false    , true, 1   , "[x]", NULL);
-	T("x.ko.gz", false     , false    , true, 1   , NULL , NULL);
+	/* path      alloc_name  kmod  comp  name  */
+	T("x.ko.gz", true      , true, 1   , "[x]");
+	T("x.ko.gz", false     , true, 1   , NULL );
+	T("x.ko.gz", true      , true, 1   , "[x]");
+	T("x.ko.gz", false     , true, 1   , NULL );
 	M("x.ko.gz", PERF_RECORD_MISC_CPUMODE_UNKNOWN, true);
 	M("x.ko.gz", PERF_RECORD_MISC_KERNEL, true);
 	M("x.ko.gz", PERF_RECORD_MISC_USER, false);
 #endif
 
-	/* path            alloc_name  alloc_ext  kmod  comp   name             ext */
-	T("[test_module]", true      , true     , true, false, "[test_module]", NULL);
-	T("[test_module]", false     , true     , true, false, NULL           , NULL);
-	T("[test_module]", true      , false    , true, false, "[test_module]", NULL);
-	T("[test_module]", false     , false    , true, false, NULL           , NULL);
+	/* path            alloc_name  kmod  comp   name           */
+	T("[test_module]", true      , true, false, "[test_module]");
+	T("[test_module]", false     , true, false, NULL           );
+	T("[test_module]", true      , true, false, "[test_module]");
+	T("[test_module]", false     , true, false, NULL           );
 	M("[test_module]", PERF_RECORD_MISC_CPUMODE_UNKNOWN, true);
 	M("[test_module]", PERF_RECORD_MISC_KERNEL, true);
 	M("[test_module]", PERF_RECORD_MISC_USER, false);
 
-	/* path            alloc_name  alloc_ext  kmod  comp   name             ext */
-	T("[test.module]", true      , true     , true, false, "[test.module]", NULL);
-	T("[test.module]", false     , true     , true, false, NULL           , NULL);
-	T("[test.module]", true      , false    , true, false, "[test.module]", NULL);
-	T("[test.module]", false     , false    , true, false, NULL           , NULL);
+	/* path            alloc_name  kmod  comp   name           */
+	T("[test.module]", true      , true, false, "[test.module]");
+	T("[test.module]", false     , true, false, NULL           );
+	T("[test.module]", true      , true, false, "[test.module]");
+	T("[test.module]", false     , true, false, NULL           );
 	M("[test.module]", PERF_RECORD_MISC_CPUMODE_UNKNOWN, true);
 	M("[test.module]", PERF_RECORD_MISC_KERNEL, true);
 	M("[test.module]", PERF_RECORD_MISC_USER, false);
 
-	/* path     alloc_name  alloc_ext  kmod   comp   name      ext */
-	T("[vdso]", true      , true     , false, false, "[vdso]", NULL);
-	T("[vdso]", false     , true     , false, false, NULL    , NULL);
-	T("[vdso]", true      , false    , false, false, "[vdso]", NULL);
-	T("[vdso]", false     , false    , false, false, NULL    , NULL);
+	/* path     alloc_name  kmod   comp   name    */
+	T("[vdso]", true      , false, false, "[vdso]");
+	T("[vdso]", false     , false, false, NULL    );
+	T("[vdso]", true      , false, false, "[vdso]");
+	T("[vdso]", false     , false, false, NULL    );
 	M("[vdso]", PERF_RECORD_MISC_CPUMODE_UNKNOWN, false);
 	M("[vdso]", PERF_RECORD_MISC_KERNEL, false);
 	M("[vdso]", PERF_RECORD_MISC_USER, false);
 
-	T("[vdso32]", true      , true     , false, false, "[vdso32]", NULL);
-	T("[vdso32]", false     , true     , false, false, NULL    , NULL);
-	T("[vdso32]", true      , false    , false, false, "[vdso32]", NULL);
-	T("[vdso32]", false     , false    , false, false, NULL    , NULL);
+	T("[vdso32]", true      , false, false, "[vdso32]");
+	T("[vdso32]", false     , false, false, NULL      );
+	T("[vdso32]", true      , false, false, "[vdso32]");
+	T("[vdso32]", false     , false, false, NULL      );
 	M("[vdso32]", PERF_RECORD_MISC_CPUMODE_UNKNOWN, false);
 	M("[vdso32]", PERF_RECORD_MISC_KERNEL, false);
 	M("[vdso32]", PERF_RECORD_MISC_USER, false);
 
-	T("[vdsox32]", true      , true     , false, false, "[vdsox32]", NULL);
-	T("[vdsox32]", false     , true     , false, false, NULL    , NULL);
-	T("[vdsox32]", true      , false    , false, false, "[vdsox32]", NULL);
-	T("[vdsox32]", false     , false    , false, false, NULL    , NULL);
+	T("[vdsox32]", true      , false, false, "[vdsox32]");
+	T("[vdsox32]", false     , false, false, NULL       );
+	T("[vdsox32]", true      , false, false, "[vdsox32]");
+	T("[vdsox32]", false     , false, false, NULL       );
 	M("[vdsox32]", PERF_RECORD_MISC_CPUMODE_UNKNOWN, false);
 	M("[vdsox32]", PERF_RECORD_MISC_KERNEL, false);
 	M("[vdsox32]", PERF_RECORD_MISC_USER, false);
 
-	/* path         alloc_name  alloc_ext  kmod   comp   name          ext */
-	T("[vsyscall]", true      , true     , false, false, "[vsyscall]", NULL);
-	T("[vsyscall]", false     , true     , false, false, NULL        , NULL);
-	T("[vsyscall]", true      , false    , false, false, "[vsyscall]", NULL);
-	T("[vsyscall]", false     , false    , false, false, NULL        , NULL);
+	/* path         alloc_name  kmod   comp   name        */
+	T("[vsyscall]", true      , false, false, "[vsyscall]");
+	T("[vsyscall]", false     , false, false, NULL        );
+	T("[vsyscall]", true      , false, false, "[vsyscall]");
+	T("[vsyscall]", false     , false, false, NULL        );
 	M("[vsyscall]", PERF_RECORD_MISC_CPUMODE_UNKNOWN, false);
 	M("[vsyscall]", PERF_RECORD_MISC_KERNEL, false);
 	M("[vsyscall]", PERF_RECORD_MISC_USER, false);
 
-	/* path                alloc_name  alloc_ext  kmod   comp   name      ext */
-	T("[kernel.kallsyms]", true      , true     , false, false, "[kernel.kallsyms]", NULL);
-	T("[kernel.kallsyms]", false     , true     , false, false, NULL               , NULL);
-	T("[kernel.kallsyms]", true      , false    , false, false, "[kernel.kallsyms]", NULL);
-	T("[kernel.kallsyms]", false     , false    , false, false, NULL               , NULL);
+	/* path                alloc_name  kmod   comp   name      */
+	T("[kernel.kallsyms]", true      , false, false, "[kernel.kallsyms]");
+	T("[kernel.kallsyms]", false     , false, false, NULL               );
+	T("[kernel.kallsyms]", true      , false, false, "[kernel.kallsyms]");
+	T("[kernel.kallsyms]", false     , false, false, NULL               );
 	M("[kernel.kallsyms]", PERF_RECORD_MISC_CPUMODE_UNKNOWN, false);
 	M("[kernel.kallsyms]", PERF_RECORD_MISC_KERNEL, false);
 	M("[kernel.kallsyms]", PERF_RECORD_MISC_USER, false);
diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
index a7f2162ba730..8ce3de665993 100644
--- a/tools/perf/util/dso.c
+++ b/tools/perf/util/dso.c
@@ -331,7 +331,7 @@ int dso__decompress_kmodule_path(struct dso *dso, const char *name,
  * Returns 0 if there's no strdup error, -ENOMEM otherwise.
  */
 int __kmod_path__parse(struct kmod_path *m, const char *path,
-		       bool alloc_name, bool alloc_ext)
+		       bool alloc_name)
 {
 	const char *name = strrchr(path, '/');
 	const char *ext  = strrchr(path, '.');
@@ -391,14 +391,6 @@ int __kmod_path__parse(struct kmod_path *m, const char *path,
 		strxfrchar(m->name, '-', '_');
 	}
 
-	if (alloc_ext && m->comp) {
-		m->ext = strdup(ext + 4);
-		if (!m->ext) {
-			free((void *) m->name);
-			return -ENOMEM;
-		}
-	}
-
 	return 0;
 }
 
diff --git a/tools/perf/util/dso.h b/tools/perf/util/dso.h
index a6c7af52115f..c5380500bed4 100644
--- a/tools/perf/util/dso.h
+++ b/tools/perf/util/dso.h
@@ -262,17 +262,15 @@ int dso__decompress_kmodule_path(struct dso *dso, const char *name,
 
 struct kmod_path {
 	char *name;
-	char *ext;
 	int   comp;
 	bool  kmod;
 };
 
 int __kmod_path__parse(struct kmod_path *m, const char *path,
-		     bool alloc_name, bool alloc_ext);
+		     bool alloc_name);
 
-#define kmod_path__parse(__m, __p)      __kmod_path__parse(__m, __p, false, false)
-#define kmod_path__parse_name(__m, __p) __kmod_path__parse(__m, __p, true , false)
-#define kmod_path__parse_ext(__m, __p)  __kmod_path__parse(__m, __p, false, true)
+#define kmod_path__parse(__m, __p)      __kmod_path__parse(__m, __p, false)
+#define kmod_path__parse_name(__m, __p) __kmod_path__parse(__m, __p, true)
 
 void dso__set_module_info(struct dso *dso, struct kmod_path *m,
 			  struct machine *machine);
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* Re: [PATCH 00/13] perf tools: Use plain debug files for compressed objects
  2018-08-17  9:48 [PATCH 00/13] perf tools: Use plain debug files for compressed objects Jiri Olsa
                   ` (12 preceding siblings ...)
  2018-08-17  9:48 ` [PATCH 13/13] perf tools: Remove ext from struct kmod_path Jiri Olsa
@ 2018-08-17 14:52 ` Arnaldo Carvalho de Melo
  13 siblings, 0 replies; 32+ messages in thread
From: Arnaldo Carvalho de Melo @ 2018-08-17 14:52 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: lkml, Ingo Molnar, Namhyung Kim, David Ahern, Alexander Shishkin,
	Peter Zijlstra, Michael Petlan

Em Fri, Aug 17, 2018 at 11:48:00AM +0200, Jiri Olsa escreveu:
> hi,
> currently we don't allow to open plain debug files for
> compressed kernel module objects, ending up with following
> warning:
> 
>   $ perf report --stdio
>   lzma: failed The input is not in the .xz format
>   lzma: failed The input is not in the .xz format
>   lzma: failed The input is not in the .xz format
>   lzma: failed The input is not in the .xz format
>   # To display the perf.data header info, please use --header/--header-only options.
> 
> The reason is behind the logic we open the DSO object files,
> when we try all possible 'debug' objects until we find the
> data. So even if the DSO is represented by 'krava.xz' module,
> we can end up opening ~/.debug/....23432432/debug' file which
> is not compressed and we fail with above error.
> 
> This patchset adds the code to detect un/compressed files and
> return plain debug file when available even for compressed
> kernel modules.
> 
> Also available in here:
>   git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git
>   perf/fixes

Thanks, applied.

- Arnaldo

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH 06/13] perf tools: Add compression id into struct kmod_path
  2018-08-17  9:48 ` [PATCH 06/13] perf tools: Add compression id into struct kmod_path Jiri Olsa
@ 2018-08-17 18:23   ` Arnaldo Carvalho de Melo
  2018-08-17 18:28     ` Arnaldo Carvalho de Melo
  2018-08-23  8:41   ` [tip:perf/urgent] perf tools: Add compression id into 'struct kmod_path' tip-bot for Jiri Olsa
  1 sibling, 1 reply; 32+ messages in thread
From: Arnaldo Carvalho de Melo @ 2018-08-17 18:23 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: lkml, Ingo Molnar, Namhyung Kim, David Ahern, Alexander Shishkin,
	Peter Zijlstra, Michael Petlan

Em Fri, Aug 17, 2018 at 11:48:06AM +0200, Jiri Olsa escreveu:
> Storing decompression ID in the struct kmod_path, so it
> can be later stored in the struct dso.
> 
> Switching the struct kmod_path::comp from bool to int
> to return the compressions array index. Adding 0 index
> item into compressions array, so the comp usage stays
> as it was: 0 - no compression, != 0 index of compression.
> 
> Updating the kmod_path tests.
> 
> Link: http://lkml.kernel.org/n/tip-vxxfco32fh5veg1817udcx2c@git.kernel.org
> Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> ---
>  tools/perf/tests/kmod-path.c | 42 ++++++++++++++++++------------------
>  tools/perf/util/dso.c        | 18 ++++++++++------
>  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 @@
>  #include "debug.h"
>  
>  static int test(const char *path, bool alloc_name, bool alloc_ext,
> -		bool kmod, bool comp, const char *name, const char *ext)
> +		bool kmod, int comp, const char *name, const char *ext)
>  {
>  	struct kmod_path m;
>  
> @@ -54,47 +54,47 @@ static int test_is_kernel_module(const char *path, int cpumode, bool expect)
>  int test__kmod_path__parse(struct test *t __maybe_unused, int subtest __maybe_unused)
>  {
>  	/* path                alloc_name  alloc_ext   kmod  comp   name     ext */
> -	T("/xxxx/xxxx/x-x.ko", true      , true      , true, false, "[x_x]", NULL);
> -	T("/xxxx/xxxx/x-x.ko", false     , true      , true, false, NULL   , NULL);
> -	T("/xxxx/xxxx/x-x.ko", true      , false     , true, false, "[x_x]", NULL);
> -	T("/xxxx/xxxx/x-x.ko", false     , false     , true, false, NULL   , NULL);
> +	T("/xxxx/xxxx/x-x.ko", true      , true      , true, 0    , "[x_x]", NULL);
> +	T("/xxxx/xxxx/x-x.ko", false     , true      , true, 0    , NULL   , NULL);
> +	T("/xxxx/xxxx/x-x.ko", true      , false     , true, 0    , "[x_x]", NULL);
> +	T("/xxxx/xxxx/x-x.ko", false     , false     , true, 0    , NULL   , NULL);
>  	M("/xxxx/xxxx/x-x.ko", PERF_RECORD_MISC_CPUMODE_UNKNOWN, true);
>  	M("/xxxx/xxxx/x-x.ko", PERF_RECORD_MISC_KERNEL, true);
>  	M("/xxxx/xxxx/x-x.ko", PERF_RECORD_MISC_USER, false);
>  
>  #ifdef HAVE_ZLIB_SUPPORT
>  	/* path                alloc_name  alloc_ext   kmod  comp  name   ext */
> -	T("/xxxx/xxxx/x.ko.gz", true     , true      , true, true, "[x]", "gz");
> -	T("/xxxx/xxxx/x.ko.gz", false    , true      , true, true, NULL , "gz");
> -	T("/xxxx/xxxx/x.ko.gz", true     , false     , true, true, "[x]", NULL);
> -	T("/xxxx/xxxx/x.ko.gz", false    , false     , true, true, NULL , NULL);
> +	T("/xxxx/xxxx/x.ko.gz", true     , true      , true, 1   , "[x]", "gz");
> +	T("/xxxx/xxxx/x.ko.gz", false    , true      , true, 1   , NULL , "gz");
> +	T("/xxxx/xxxx/x.ko.gz", true     , false     , true, 1   , "[x]", NULL);
> +	T("/xxxx/xxxx/x.ko.gz", false    , false     , true, 1   , NULL , NULL);
>  	M("/xxxx/xxxx/x.ko.gz", PERF_RECORD_MISC_CPUMODE_UNKNOWN, true);
>  	M("/xxxx/xxxx/x.ko.gz", PERF_RECORD_MISC_KERNEL, true);
>  	M("/xxxx/xxxx/x.ko.gz", PERF_RECORD_MISC_USER, false);
>  
>  	/* path              alloc_name  alloc_ext  kmod   comp  name    ext */
> -	T("/xxxx/xxxx/x.gz", true      , true     , false, true, "x.gz" ,"gz");
> -	T("/xxxx/xxxx/x.gz", false     , true     , false, true, NULL   ,"gz");
> -	T("/xxxx/xxxx/x.gz", true      , false    , false, true, "x.gz" , NULL);
> -	T("/xxxx/xxxx/x.gz", false     , false    , false, true, NULL   , NULL);
> +	T("/xxxx/xxxx/x.gz", true      , true     , false, 1   , "x.gz" ,"gz");
> +	T("/xxxx/xxxx/x.gz", false     , true     , false, 1   , NULL   ,"gz");
> +	T("/xxxx/xxxx/x.gz", true      , false    , false, 1   , "x.gz" , NULL);
> +	T("/xxxx/xxxx/x.gz", false     , false    , false, 1   , NULL   , NULL);
>  	M("/xxxx/xxxx/x.gz", PERF_RECORD_MISC_CPUMODE_UNKNOWN, false);
>  	M("/xxxx/xxxx/x.gz", PERF_RECORD_MISC_KERNEL, false);
>  	M("/xxxx/xxxx/x.gz", PERF_RECORD_MISC_USER, false);
>  
>  	/* path   alloc_name  alloc_ext  kmod   comp  name     ext */
> -	T("x.gz", true      , true     , false, true, "x.gz", "gz");
> -	T("x.gz", false     , true     , false, true, NULL  , "gz");
> -	T("x.gz", true      , false    , false, true, "x.gz", NULL);
> -	T("x.gz", false     , false    , false, true, NULL  , NULL);
> +	T("x.gz", true      , true     , false, 1   , "x.gz", "gz");
> +	T("x.gz", false     , true     , false, 1   , NULL  , "gz");
> +	T("x.gz", true      , false    , false, 1   , "x.gz", NULL);
> +	T("x.gz", false     , false    , false, 1   , NULL  , NULL);
>  	M("x.gz", PERF_RECORD_MISC_CPUMODE_UNKNOWN, false);
>  	M("x.gz", PERF_RECORD_MISC_KERNEL, false);
>  	M("x.gz", PERF_RECORD_MISC_USER, false);
>  
>  	/* path      alloc_name  alloc_ext  kmod  comp  name  ext */
> -	T("x.ko.gz", true      , true     , true, true, "[x]", "gz");
> -	T("x.ko.gz", false     , true     , true, true, NULL , "gz");
> -	T("x.ko.gz", true      , false    , true, true, "[x]", NULL);
> -	T("x.ko.gz", false     , false    , true, true, NULL , NULL);
> +	T("x.ko.gz", true      , true     , true, 1   , "[x]", "gz");
> +	T("x.ko.gz", false     , true     , true, 1   , NULL , "gz");
> +	T("x.ko.gz", true      , false    , true, 1   , "[x]", NULL);
> +	T("x.ko.gz", false     , false    , true, 1   , NULL , NULL);
>  	M("x.ko.gz", PERF_RECORD_MISC_CPUMODE_UNKNOWN, true);
>  	M("x.ko.gz", PERF_RECORD_MISC_KERNEL, true);
>  	M("x.ko.gz", PERF_RECORD_MISC_USER, false);
> diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
> index 4449a7257340..f5f8babea17c 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,
>  	return ret;
>  }
>  
> +enum {
> +	COMP_ID__NONE = 0,
> +};
> +
>  static const struct {
>  	const char *fmt;
>  	int (*decompress)(const char *input, int output);
>  } compressions[] = {
> +	[COMP_ID__NONE] = { 0 },


This broke the build in many places, problems of this kind:

  CC       /tmp/build/perf/util/dso.o
  LD       /tmp/build/perf/scripts/python/Perf-Trace-Util/libperf-in.o
  LD       /tmp/build/perf/scripts/libperf-in.o
  CC       /tmp/build/perf/trace/beauty/clone.o
  CC       /tmp/build/perf/util/symbol.o
util/dso.c:201:24: error: missing field 'decompress' initializer [-Werror,-Wmissing-field-initializers]
        [COMP_ID__NONE] = { 0 },
                              ^
1 error generated.
  CC       /tmp/build/perf/trace/beauty/fcntl.o
mv: cannot stat '/tmp/build/perf/util/.dso.o.tmp': No such file or directory
/git/linux/tools/build/Makefile.build:96: recipe for target '/tmp/build/perf/util/dso.o' failed

If we look just at those that failed, its several gcc versions:

  11     9.91 centos:5                      : FAIL gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-55)
  12    14.34 centos:6                      : FAIL gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-23)
  16    47.50 debian:9                      : FAIL gcc (Debian 6.3.0-18+deb9u1) 6.3.0 20170516
  28    53.92 fedora:25                     : FAIL gcc (GCC) 6.4.1 20170727 (Red Hat 6.4.1-1)
  29    60.75 fedora:26                     : FAIL gcc (GCC) 7.3.1 20180130 (Red Hat 7.3.1-2)
  30    90.76 fedora:27                     : FAIL gcc (GCC) 7.3.1 20180712 (Red Hat 7.3.1-6)
  41    12.78 oraclelinux:6                 : FAIL gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-23.0.1)
  43    12.85 ubuntu:12.04.5                : FAIL gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3
  46    45.56 ubuntu:16.04                  : FAIL gcc (Ubuntu 5.4.0-6ubuntu1~16.04.10) 5.4.0 20160609
  54    49.60 ubuntu:17.10                  : FAIL gcc (Ubuntu 7.2.0-8ubuntu3.2) 7.2.0

[root@seventh ~]# grep error: /tmp/dm.log/*
/tmp/dm.log/centos:6:util/dso.c:201: error: missing initializer
/tmp/dm.log/centos:6:util/dso.c:201: error: (near initialization for 'compressions[0].decompress')
/tmp/dm.log/debian:9:util/dso.c:201:24: error: missing field 'decompress' initializer [-Werror,-Wmissing-field-initializers]
/tmp/dm.log/fedora:25:util/dso.c:201:24: error: missing field 'decompress' initializer [-Werror,-Wmissing-field-initializers]
/tmp/dm.log/fedora:26:util/dso.c:201:24: error: missing field 'decompress' initializer [-Werror,-Wmissing-field-initializers]
/tmp/dm.log/fedora:27:util/dso.c:201:24: error: missing field 'decompress' initializer [-Werror,-Wmissing-field-initializers]
/tmp/dm.log/oraclelinux:6:util/dso.c:201: error: missing initializer
/tmp/dm.log/oraclelinux:6:util/dso.c:201: error: (near initialization for 'compressions[0].decompress')
/tmp/dm.log/ubuntu:12.04.5:util/dso.c:201:2: error: missing initializer [-Werror=missing-field-initializers]
/tmp/dm.log/ubuntu:12.04.5:util/dso.c:201:2: error: (near initialization for 'compressions[0].decompress') [-Werror=missing-field-initializers]
/tmp/dm.log/ubuntu:16.04:util/dso.c:201:24: error: missing field 'decompress' initializer [-Werror,-Wmissing-field-initializers]
/tmp/dm.log/ubuntu:16.10:util/dso.c:201:24: error: missing field 'decompress' initializer [-Werror,-Wmissing-field-initializers]
/tmp/dm.log/ubuntu:16.10:util/dso.c:201:24: error: missing field 'decompress' initializer [-Werror,-Wmissing-field-initializers]
/tmp/dm.log/ubuntu:17.10:util/dso.c:201:24: error: missing field 'decompress' initializer [-Werror,-Wmissing-field-initializers]
[root@seventh ~]#

Trying to fix...



# dm
   1    43.58 alpine:3.4                    : Ok   gcc (Alpine 5.3.0) 5.3.0
   2    47.76 alpine:3.5                    : Ok   gcc (Alpine 6.2.1) 6.2.1 20160822
   3    48.40 alpine:3.6                    : Ok   gcc (Alpine 6.3.0) 6.3.0
   4    44.07 alpine:3.7                    : Ok   gcc (Alpine 6.4.0) 6.4.0
   5    47.43 alpine:3.8                    : Ok   gcc (Alpine 6.4.0) 6.4.0
   6    44.54 alpine:edge                   : Ok   gcc (Alpine 6.4.0) 6.4.0
   7    36.61 amazonlinux:1                 : Ok   gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-28)
   8    41.03 amazonlinux:2                 : Ok   gcc (GCC) 7.3.1 20180303 (Red Hat 7.3.1-5)
   9    27.49 android-ndk:r12b-arm          : Ok   arm-linux-androideabi-gcc (GCC) 4.9.x 20150123 (prerelease)
  10    29.10 android-ndk:r15c-arm          : Ok   arm-linux-androideabi-gcc (GCC) 4.9.x 20150123 (prerelease)
  11     9.91 centos:5                      : FAIL gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-55)
  12    14.34 centos:6                      : FAIL gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-23)
  13    40.77 centos:7                      : Ok   gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-28)
  14    38.91 debian:7                      : Ok   gcc (Debian 4.7.2-5) 4.7.2
  15    38.01 debian:8                      : Ok   gcc (Debian 4.9.2-10+deb8u1) 4.9.2
  16    47.50 debian:9                      : FAIL gcc (Debian 6.3.0-18+deb9u1) 6.3.0 20170516
  17   106.91 debian:experimental           : Ok   gcc (Debian 8.2.0-4) 8.2.0
  18    43.17 debian:experimental-x-arm64   : Ok   aarch64-linux-gnu-gcc (Debian 8.1.0-12) 8.1.0
  19    41.17 debian:experimental-x-mips    : Ok   mips-linux-gnu-gcc (Debian 8.1.0-12) 8.1.0
  20    38.28 debian:experimental-x-mips64  : Ok   mips64-linux-gnuabi64-gcc (Debian 8.1.0-12) 8.1.0
  21    40.77 debian:experimental-x-mipsel  : Ok   mipsel-linux-gnu-gcc (Debian 8.1.0-12) 8.1.0
  22    40.36 fedora:20                     : Ok   gcc (GCC) 4.8.3 20140911 (Red Hat 4.8.3-7)
  23    41.30 fedora:21                     : Ok   gcc (GCC) 4.9.2 20150212 (Red Hat 4.9.2-6)
  24    41.42 fedora:22                     : Ok   gcc (GCC) 5.3.1 20160406 (Red Hat 5.3.1-6)
  25    40.67 fedora:23                     : Ok   gcc (GCC) 5.3.1 20160406 (Red Hat 5.3.1-6)
  26    42.09 fedora:24                     : Ok   gcc (GCC) 6.3.1 20161221 (Red Hat 6.3.1-1)
  27    35.26 fedora:24-x-ARC-uClibc        : Ok   arc-linux-gcc (ARCompact ISA Linux uClibc toolchain 2017.09-rc2) 7.1.1 20170710
  28    53.92 fedora:25                     : FAIL gcc (GCC) 6.4.1 20170727 (Red Hat 6.4.1-1)
  29    60.75 fedora:26                     : FAIL gcc (GCC) 7.3.1 20180130 (Red Hat 7.3.1-2)
  30    90.76 fedora:27                     : FAIL gcc (GCC) 7.3.1 20180712 (Red Hat 7.3.1-6)
  31   157.29 fedora:28                     : Ok   gcc (GCC) 8.1.1 20180712 (Red Hat 8.1.1-5)
  32   148.43 fedora:rawhide                : Ok   gcc (GCC) 8.0.1 20180324 (Red Hat 8.0.1-0.20)
  33    43.37 gentoo-stage3-amd64:latest    : Ok   gcc (Gentoo 7.3.0-r3 p1.4) 7.3.0
  34    43.06 mageia:5                      : Ok   gcc (GCC) 4.9.2
  35    43.06 mageia:6                      : Ok   gcc (Mageia 5.5.0-1.mga6) 5.5.0
  36    40.29 opensuse:13.2                 : Ok   gcc (SUSE Linux) 4.8.3 20140627 [gcc-4_8-branch revision 212064]
  37    39.97 opensuse:42.1                 : Ok   gcc (SUSE Linux) 4.8.5
  38    40.38 opensuse:42.2                 : Ok   gcc (SUSE Linux) 4.8.5
  39    40.92 opensuse:42.3                 : Ok   gcc (SUSE Linux) 4.8.5
  40   157.84 opensuse:tumbleweed           : Ok   gcc (SUSE Linux) 7.3.1 20180323 [gcc-7-branch revision 258812]
  41    12.78 oraclelinux:6                 : FAIL gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-23.0.1)
  42    39.10 oraclelinux:7                 : Ok   gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-28.0.1)
  43    12.85 ubuntu:12.04.5                : FAIL gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3
  44    37.24 ubuntu:14.04.4                : Ok   gcc (Ubuntu 4.8.4-2ubuntu1~14.04.3) 4.8.4
  45    36.18 ubuntu:14.04.4-x-linaro-arm64 : Ok   aarch64-linux-gnu-gcc (Linaro GCC 5.5-2017.10) 5.5.0
  46    45.56 ubuntu:16.04                  : FAIL gcc (Ubuntu 5.4.0-6ubuntu1~16.04.10) 5.4.0 20160609
  47    32.61 ubuntu:16.04-x-arm            : Ok   arm-linux-gnueabihf-gcc (Ubuntu/Linaro 5.4.0-6ubuntu1~16.04.9) 5.4.0 20160609
  48    33.76 ubuntu:16.04-x-arm64          : Ok   aarch64-linux-gnu-gcc (Ubuntu/Linaro 5.4.0-6ubuntu1~16.04.9) 5.4.0 20160609
  49    32.23 ubuntu:16.04-x-powerpc        : Ok   powerpc-linux-gnu-gcc (Ubuntu 5.4.0-6ubuntu1~16.04.9) 5.4.0 20160609
  50    32.71 ubuntu:16.04-x-powerpc64      : Ok   powerpc64-linux-gnu-gcc (Ubuntu/IBM 5.4.0-6ubuntu1~16.04.9) 5.4.0 20160609
  51    33.16 ubuntu:16.04-x-powerpc64el    : Ok   powerpc64le-linux-gnu-gcc (Ubuntu/IBM 5.4.0-6ubuntu1~16.04.9) 5.4.0 20160609
  52    33.28 ubuntu:16.04-x-s390           : Ok   s390x-linux-gnu-gcc (Ubuntu 5.4.0-6ubuntu1~16.04.9) 5.4.0 20160609
  53    70.61 ubuntu:16.10                  : Ok   gcc (Ubuntu 6.2.0-5ubuntu12) 6.2.0 20161005
  54    49.60 ubuntu:17.10                  : FAIL gcc (Ubuntu 7.2.0-8ubuntu3.2) 7.2.0
  55   111.93 ubuntu:18.04                  : Ok   gcc (Ubuntu 7.3.0-16ubuntu3) 7.3.0
  56    37.08 ubuntu:18.04-x-arm            : Ok   arm-linux-gnueabihf-gcc (Ubuntu/Linaro 7.3.0-16ubuntu3) 7.3.0
  57    38.00 ubuntu:18.04-x-arm64          : Ok   aarch64-linux-gnu-gcc (Ubuntu/Linaro 7.3.0-16ubuntu3) 7.3.0
  58    27.10 ubuntu:18.04-x-m68k           : Ok   m68k-linux-gnu-gcc (Ubuntu 7.3.0-16ubuntu3) 7.3.0
  59    35.10 ubuntu:18.04-x-powerpc        : Ok   powerpc-linux-gnu-gcc (Ubuntu 7.3.0-16ubuntu3) 7.3.0
  60    38.07 ubuntu:18.04-x-powerpc64      : Ok   powerpc64-linux-gnu-gcc (Ubuntu 7.3.0-16ubuntu3) 7.3.0
  61    38.46 ubuntu:18.04-x-powerpc64el    : Ok   powerpc64le-linux-gnu-gcc (Ubuntu 7.3.0-16ubuntu3) 7.3.0
  62    71.15 ubuntu:18.04-x-riscv64        : Ok   riscv64-linux-gnu-gcc (Ubuntu 7.3.0-16ubuntu3) 7.3.0
  63    31.69 ubuntu:18.04-x-s390           : Ok   s390x-linux-gnu-gcc (Ubuntu 7.3.0-16ubuntu3) 7.3.0
  64    35.60 ubuntu:18.04-x-sh4            : Ok   sh4-linux-gnu-gcc (Ubuntu 7.3.0-16ubuntu3) 7.3.0
  65    30.86 ubuntu:18.04-x-sparc64        : Ok   sparc64-linux-gnu-gcc (Ubuntu 7.3.0-16ubuntu3) 7.3.0
  66   105.18 ubuntu:18.10                  : Ok   gcc (Ubuntu 8.2.0-1ubuntu2) 8.2.0


>  #ifdef HAVE_ZLIB_SUPPORT
>  	{ "gz", gzip_decompress_to_file },
>  #endif
> @@ -202,15 +207,15 @@ static const struct {
>  	{ NULL, NULL },
>  };
>  
> -static bool is_supported_compression(const char *ext)
> +static int is_supported_compression(const char *ext)
>  {
>  	unsigned i;
>  
> -	for (i = 0; compressions[i].fmt; i++) {
> +	for (i = 1; compressions[i].fmt; i++) {
>  		if (!strcmp(ext, compressions[i].fmt))
> -			return true;
> +			return i;
>  	}
> -	return false;
> +	return COMP_ID__NONE;
>  }
>  
>  bool is_kernel_module(const char *pathname, int cpumode)
> @@ -373,10 +378,9 @@ int __kmod_path__parse(struct kmod_path *m, const char *path,
>  		return 0;
>  	}
>  
> -	if (is_supported_compression(ext + 1)) {
> -		m->comp = true;
> +	m->comp = is_supported_compression(ext + 1);
> +	if (m->comp > COMP_ID__NONE)
>  		ext -= 3;
> -	}
>  
>  	/* Check .ko extension only if there's enough name left. */
>  	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,
>  struct kmod_path {
>  	char *name;
>  	char *ext;
> -	bool  comp;
> +	int   comp;
>  	bool  kmod;
>  };
>  
> -- 
> 2.17.1

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH 06/13] perf tools: Add compression id into struct kmod_path
  2018-08-17 18:23   ` Arnaldo Carvalho de Melo
@ 2018-08-17 18:28     ` Arnaldo Carvalho de Melo
  2018-08-17 18:56       ` Arnaldo Carvalho de Melo
  0 siblings, 1 reply; 32+ messages in thread
From: Arnaldo Carvalho de Melo @ 2018-08-17 18:28 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: lkml, Ingo Molnar, Namhyung Kim, David Ahern, Alexander Shishkin,
	Peter Zijlstra, Michael Petlan

Em Fri, Aug 17, 2018 at 03:23:15PM -0300, Arnaldo Carvalho de Melo escreveu:
> Em Fri, Aug 17, 2018 at 11:48:06AM +0200, Jiri Olsa escreveu:
> >  static const struct {
> >  	const char *fmt;
> >  	int (*decompress)(const char *input, int output);
> >  } compressions[] = {
> > +	[COMP_ID__NONE] = { 0 },
> 
> 
> This broke the build in many places, problems of this kind:
> 
>   CC       /tmp/build/perf/util/dso.o
>   LD       /tmp/build/perf/scripts/python/Perf-Trace-Util/libperf-in.o
>   LD       /tmp/build/perf/scripts/libperf-in.o
>   CC       /tmp/build/perf/trace/beauty/clone.o
>   CC       /tmp/build/perf/util/symbol.o
> util/dso.c:201:24: error: missing field 'decompress' initializer [-Werror,-Wmissing-field-initializers]
>         [COMP_ID__NONE] = { 0 },
>                               ^
> 1 error generated.
>   CC       /tmp/build/perf/trace/beauty/fcntl.o
> mv: cannot stat '/tmp/build/perf/util/.dso.o.tmp': No such file or directory
> /git/linux/tools/build/Makefile.build:96: recipe for target '/tmp/build/perf/util/dso.o' failed
> 
> If we look just at those that failed, its several gcc versions:
> 
>   11     9.91 centos:5                      : FAIL gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-55)
>   12    14.34 centos:6                      : FAIL gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-23)
>   16    47.50 debian:9                      : FAIL gcc (Debian 6.3.0-18+deb9u1) 6.3.0 20170516
>   28    53.92 fedora:25                     : FAIL gcc (GCC) 6.4.1 20170727 (Red Hat 6.4.1-1)
>   29    60.75 fedora:26                     : FAIL gcc (GCC) 7.3.1 20180130 (Red Hat 7.3.1-2)
>   30    90.76 fedora:27                     : FAIL gcc (GCC) 7.3.1 20180712 (Red Hat 7.3.1-6)
>   41    12.78 oraclelinux:6                 : FAIL gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-23.0.1)
>   43    12.85 ubuntu:12.04.5                : FAIL gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3
>   46    45.56 ubuntu:16.04                  : FAIL gcc (Ubuntu 5.4.0-6ubuntu1~16.04.10) 5.4.0 20160609
>   54    49.60 ubuntu:17.10                  : FAIL gcc (Ubuntu 7.2.0-8ubuntu3.2) 7.2.0

Sorry, gcc eats this with gusto, its just clang that is not taking it,
for instance, this is the one in fedora:27:

clang version 5.0.2 (tags/RELEASE_502/final)

- Arnaldo

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH 06/13] perf tools: Add compression id into struct kmod_path
  2018-08-17 18:28     ` Arnaldo Carvalho de Melo
@ 2018-08-17 18:56       ` Arnaldo Carvalho de Melo
  2018-08-17 20:01         ` Jiri Olsa
  0 siblings, 1 reply; 32+ messages in thread
From: Arnaldo Carvalho de Melo @ 2018-08-17 18:56 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: lkml, Ingo Molnar, Namhyung Kim, David Ahern, Alexander Shishkin,
	Peter Zijlstra, Michael Petlan

Em Fri, Aug 17, 2018 at 03:28:49PM -0300, Arnaldo Carvalho de Melo escreveu:
> Em Fri, Aug 17, 2018 at 03:23:15PM -0300, Arnaldo Carvalho de Melo escreveu:
> > Em Fri, Aug 17, 2018 at 11:48:06AM +0200, Jiri Olsa escreveu:
> > >  static const struct {
> > >  	const char *fmt;
> > >  	int (*decompress)(const char *input, int output);
> > >  } compressions[] = {
> > > +	[COMP_ID__NONE] = { 0 },
> > 
> > 
> > This broke the build in many places, problems of this kind:
> > 
> >   CC       /tmp/build/perf/util/dso.o
> >   LD       /tmp/build/perf/scripts/python/Perf-Trace-Util/libperf-in.o
> >   LD       /tmp/build/perf/scripts/libperf-in.o
> >   CC       /tmp/build/perf/trace/beauty/clone.o
> >   CC       /tmp/build/perf/util/symbol.o
> > util/dso.c:201:24: error: missing field 'decompress' initializer [-Werror,-Wmissing-field-initializers]
> >         [COMP_ID__NONE] = { 0 },
> >                               ^
> > 1 error generated.
> >   CC       /tmp/build/perf/trace/beauty/fcntl.o
> > mv: cannot stat '/tmp/build/perf/util/.dso.o.tmp': No such file or directory
> > /git/linux/tools/build/Makefile.build:96: recipe for target '/tmp/build/perf/util/dso.o' failed
> > 
> > If we look just at those that failed, its several gcc versions:
> > 
> >   11     9.91 centos:5                      : FAIL gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-55)
> >   12    14.34 centos:6                      : FAIL gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-23)
> >   16    47.50 debian:9                      : FAIL gcc (Debian 6.3.0-18+deb9u1) 6.3.0 20170516
> >   28    53.92 fedora:25                     : FAIL gcc (GCC) 6.4.1 20170727 (Red Hat 6.4.1-1)
> >   29    60.75 fedora:26                     : FAIL gcc (GCC) 7.3.1 20180130 (Red Hat 7.3.1-2)
> >   30    90.76 fedora:27                     : FAIL gcc (GCC) 7.3.1 20180712 (Red Hat 7.3.1-6)
> >   41    12.78 oraclelinux:6                 : FAIL gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-23.0.1)
> >   43    12.85 ubuntu:12.04.5                : FAIL gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3
> >   46    45.56 ubuntu:16.04                  : FAIL gcc (Ubuntu 5.4.0-6ubuntu1~16.04.10) 5.4.0 20160609
> >   54    49.60 ubuntu:17.10                  : FAIL gcc (Ubuntu 7.2.0-8ubuntu3.2) 7.2.0
> 
> Sorry, gcc eats this with gusto, its just clang that is not taking it,
> for instance, this is the one in fedora:27:
> 
> clang version 5.0.2 (tags/RELEASE_502/final)

Nah, this cures it, and its not just clang, as we don't have it in the older
images like centos:5.

Patch below seems to cure in all cases, I'll do what is usual, use
designated initializers everywhere...

- Arnaldo

diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
index 8ce3de665993..bbed90e5d9bb 100644
--- a/tools/perf/util/dso.c
+++ b/tools/perf/util/dso.c
@@ -198,7 +198,7 @@ static const struct {
 	int (*decompress)(const char *input, int output);
 	bool (*is_compressed)(const char *input);
 } compressions[] = {
-	[COMP_ID__NONE] = { 0 },
+	[COMP_ID__NONE] = { .fmt = NULL, },
 #ifdef HAVE_ZLIB_SUPPORT
 	{ "gz", gzip_decompress_to_file, gzip_is_compressed },
 #endif

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* Re: [PATCH 06/13] perf tools: Add compression id into struct kmod_path
  2018-08-17 18:56       ` Arnaldo Carvalho de Melo
@ 2018-08-17 20:01         ` Jiri Olsa
  0 siblings, 0 replies; 32+ messages in thread
From: Jiri Olsa @ 2018-08-17 20:01 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Jiri Olsa, lkml, Ingo Molnar, Namhyung Kim, David Ahern,
	Alexander Shishkin, Peter Zijlstra, Michael Petlan

On Fri, Aug 17, 2018 at 03:56:41PM -0300, Arnaldo Carvalho de Melo wrote:
> Em Fri, Aug 17, 2018 at 03:28:49PM -0300, Arnaldo Carvalho de Melo escreveu:
> > Em Fri, Aug 17, 2018 at 03:23:15PM -0300, Arnaldo Carvalho de Melo escreveu:
> > > Em Fri, Aug 17, 2018 at 11:48:06AM +0200, Jiri Olsa escreveu:
> > > >  static const struct {
> > > >  	const char *fmt;
> > > >  	int (*decompress)(const char *input, int output);
> > > >  } compressions[] = {
> > > > +	[COMP_ID__NONE] = { 0 },
> > > 
> > > 
> > > This broke the build in many places, problems of this kind:
> > > 
> > >   CC       /tmp/build/perf/util/dso.o
> > >   LD       /tmp/build/perf/scripts/python/Perf-Trace-Util/libperf-in.o
> > >   LD       /tmp/build/perf/scripts/libperf-in.o
> > >   CC       /tmp/build/perf/trace/beauty/clone.o
> > >   CC       /tmp/build/perf/util/symbol.o
> > > util/dso.c:201:24: error: missing field 'decompress' initializer [-Werror,-Wmissing-field-initializers]
> > >         [COMP_ID__NONE] = { 0 },
> > >                               ^
> > > 1 error generated.
> > >   CC       /tmp/build/perf/trace/beauty/fcntl.o
> > > mv: cannot stat '/tmp/build/perf/util/.dso.o.tmp': No such file or directory
> > > /git/linux/tools/build/Makefile.build:96: recipe for target '/tmp/build/perf/util/dso.o' failed
> > > 
> > > If we look just at those that failed, its several gcc versions:
> > > 
> > >   11     9.91 centos:5                      : FAIL gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-55)
> > >   12    14.34 centos:6                      : FAIL gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-23)
> > >   16    47.50 debian:9                      : FAIL gcc (Debian 6.3.0-18+deb9u1) 6.3.0 20170516
> > >   28    53.92 fedora:25                     : FAIL gcc (GCC) 6.4.1 20170727 (Red Hat 6.4.1-1)
> > >   29    60.75 fedora:26                     : FAIL gcc (GCC) 7.3.1 20180130 (Red Hat 7.3.1-2)
> > >   30    90.76 fedora:27                     : FAIL gcc (GCC) 7.3.1 20180712 (Red Hat 7.3.1-6)
> > >   41    12.78 oraclelinux:6                 : FAIL gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-23.0.1)
> > >   43    12.85 ubuntu:12.04.5                : FAIL gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3
> > >   46    45.56 ubuntu:16.04                  : FAIL gcc (Ubuntu 5.4.0-6ubuntu1~16.04.10) 5.4.0 20160609
> > >   54    49.60 ubuntu:17.10                  : FAIL gcc (Ubuntu 7.2.0-8ubuntu3.2) 7.2.0
> > 
> > Sorry, gcc eats this with gusto, its just clang that is not taking it,
> > for instance, this is the one in fedora:27:
> > 
> > clang version 5.0.2 (tags/RELEASE_502/final)
> 
> Nah, this cures it, and its not just clang, as we don't have it in the older
> images like centos:5.

ugh.. for some reason I thought this one is failing '= { }' , so I used this one '= { 0 }',
so it's this one then ' = { .xxx = 0 }' :-\ nice

thanks,
jirka

> 
> Patch below seems to cure in all cases, I'll do what is usual, use
> designated initializers everywhere...
> 
> - Arnaldo
> 
> diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
> index 8ce3de665993..bbed90e5d9bb 100644
> --- a/tools/perf/util/dso.c
> +++ b/tools/perf/util/dso.c
> @@ -198,7 +198,7 @@ static const struct {
>  	int (*decompress)(const char *input, int output);
>  	bool (*is_compressed)(const char *input);
>  } compressions[] = {
> -	[COMP_ID__NONE] = { 0 },
> +	[COMP_ID__NONE] = { .fmt = NULL, },
>  #ifdef HAVE_ZLIB_SUPPORT
>  	{ "gz", gzip_decompress_to_file, gzip_is_compressed },
>  #endif

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [tip:perf/urgent] perf tools: Get rid of dso__needs_decompress() call in read_object_code()
  2018-08-17  9:48 ` [PATCH 01/13] perf tools: Get rid of dso__needs_decompress call in read_object_code Jiri Olsa
@ 2018-08-23  8:39   ` tip-bot for Jiri Olsa
  0 siblings, 0 replies; 32+ messages in thread
From: tip-bot for Jiri Olsa @ 2018-08-23  8:39 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: mpetlan, hpa, mingo, jolsa, linux-kernel, namhyung, acme, tglx,
	alexander.shishkin, peterz, dsahern

Commit-ID:  bcd4287ead885e010cd49265d8c68f2373476b08
Gitweb:     https://git.kernel.org/tip/bcd4287ead885e010cd49265d8c68f2373476b08
Author:     Jiri Olsa <jolsa@kernel.org>
AuthorDate: Fri, 17 Aug 2018 11:48:01 +0200
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Mon, 20 Aug 2018 08:54:59 -0300

perf tools: Get rid of dso__needs_decompress() call in read_object_code()

There's no need to call dso__needs_decompress() twice in the function.

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-2-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/tests/code-reading.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/tools/perf/tests/code-reading.c b/tools/perf/tests/code-reading.c
index 4892bd2dc33e..6b049f3f5cf4 100644
--- a/tools/perf/tests/code-reading.c
+++ b/tools/perf/tests/code-reading.c
@@ -232,6 +232,7 @@ static int read_object_code(u64 addr, size_t len, u8 cpumode,
 	u64 objdump_addr;
 	const char *objdump_name;
 	char decomp_name[KMOD_DECOMP_LEN];
+	bool decomp = false;
 	int ret;
 
 	pr_debug("Reading object code for memory address: %#"PRIx64"\n", addr);
@@ -305,6 +306,7 @@ static int read_object_code(u64 addr, size_t len, u8 cpumode,
 			return -1;
 		}
 
+		decomp = true;
 		objdump_name = decomp_name;
 	}
 
@@ -312,7 +314,7 @@ static int read_object_code(u64 addr, size_t len, u8 cpumode,
 	objdump_addr = map__rip_2objdump(al.map, al.addr);
 	ret = read_via_objdump(objdump_name, objdump_addr, buf2, len);
 
-	if (dso__needs_decompress(al.map->dso))
+	if (decomp)
 		unlink(objdump_name);
 
 	if (ret > 0) {

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [tip:perf/urgent] perf tools: Get rid of dso__needs_decompress() call in symbol__disassemble()
  2018-08-17  9:48 ` [PATCH 02/13] perf tools: Get rid of dso__needs_decompress call in symbol__disassemble Jiri Olsa
@ 2018-08-23  8:39   ` tip-bot for Jiri Olsa
  0 siblings, 0 replies; 32+ messages in thread
From: tip-bot for Jiri Olsa @ 2018-08-23  8:39 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: mpetlan, linux-kernel, peterz, mingo, acme, jolsa, namhyung,
	dsahern, alexander.shishkin, tglx, hpa

Commit-ID:  2354ae9bdc320939cc74695b564ccf178780dd61
Gitweb:     https://git.kernel.org/tip/2354ae9bdc320939cc74695b564ccf178780dd61
Author:     Jiri Olsa <jolsa@kernel.org>
AuthorDate: Fri, 17 Aug 2018 11:48:02 +0200
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Mon, 20 Aug 2018 08:54:59 -0300

perf tools: Get rid of dso__needs_decompress() call in symbol__disassemble()

There's no need to call dso__needs_decompress() twice in the function.

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-3-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/annotate.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index e4268b948e0e..20061cf42288 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -1629,6 +1629,7 @@ static int symbol__disassemble(struct symbol *sym, struct annotate_args *args)
 	char symfs_filename[PATH_MAX];
 	struct kcore_extract kce;
 	bool delete_extract = false;
+	bool decomp = false;
 	int stdout_fd[2];
 	int lineno = 0;
 	int nline;
@@ -1662,6 +1663,7 @@ static int symbol__disassemble(struct symbol *sym, struct annotate_args *args)
 						 tmp, sizeof(tmp)) < 0)
 			goto out;
 
+		decomp = true;
 		strcpy(symfs_filename, tmp);
 	}
 
@@ -1748,7 +1750,7 @@ out_free_command:
 out_remove_tmp:
 	close(stdout_fd[0]);
 
-	if (dso__needs_decompress(dso))
+	if (decomp)
 		unlink(symfs_filename);
 
 	if (delete_extract)

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [tip:perf/urgent] perf tools: Get rid of dso__needs_decompress() call in __open_dso()
  2018-08-17  9:48 ` [PATCH 03/13] perf tools: Get rid of dso__needs_decompress call in __open_dso Jiri Olsa
@ 2018-08-23  8:40   ` tip-bot for Jiri Olsa
  0 siblings, 0 replies; 32+ messages in thread
From: tip-bot for Jiri Olsa @ 2018-08-23  8:40 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: acme, jolsa, alexander.shishkin, mingo, linux-kernel, peterz,
	namhyung, hpa, dsahern, tglx, mpetlan

Commit-ID:  d68a29c2823ff6bd7a25cb748b577f2d88c1f47a
Gitweb:     https://git.kernel.org/tip/d68a29c2823ff6bd7a25cb748b577f2d88c1f47a
Author:     Jiri Olsa <jolsa@kernel.org>
AuthorDate: Fri, 17 Aug 2018 11:48:03 +0200
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Mon, 20 Aug 2018 08:54:59 -0300

perf tools: Get rid of dso__needs_decompress() call in __open_dso()

There's no need to call dso__needs_decompress() twice in the function.

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-4-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/dso.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
index 51cf82cf1882..8ee1faa5726f 100644
--- a/tools/perf/util/dso.c
+++ b/tools/perf/util/dso.c
@@ -468,6 +468,7 @@ static int __open_dso(struct dso *dso, struct machine *machine)
 	int fd = -EINVAL;
 	char *root_dir = (char *)"";
 	char *name = malloc(PATH_MAX);
+	bool decomp = false;
 
 	if (!name)
 		return -ENOMEM;
@@ -491,12 +492,13 @@ static int __open_dso(struct dso *dso, struct machine *machine)
 			goto out;
 		}
 
+		decomp = true;
 		strcpy(name, newpath);
 	}
 
 	fd = do_open(name);
 
-	if (dso__needs_decompress(dso))
+	if (decomp)
 		unlink(name);
 
 out:

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [tip:perf/urgent] perf tools: Make decompress_to_file() function static
  2018-08-17  9:48 ` [PATCH 04/13] perf tools: Make decompress_to_file function static Jiri Olsa
@ 2018-08-23  8:40   ` tip-bot for Jiri Olsa
  0 siblings, 0 replies; 32+ messages in thread
From: tip-bot for Jiri Olsa @ 2018-08-23  8:40 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: dsahern, namhyung, peterz, hpa, linux-kernel, alexander.shishkin,
	mingo, acme, mpetlan, tglx, jolsa

Commit-ID:  85e1d419e71eaa39248a9fa6572502a3c802f9ca
Gitweb:     https://git.kernel.org/tip/85e1d419e71eaa39248a9fa6572502a3c802f9ca
Author:     Jiri Olsa <jolsa@kernel.org>
AuthorDate: Fri, 17 Aug 2018 11:48:04 +0200
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Mon, 20 Aug 2018 08:54:59 -0300

perf tools: Make decompress_to_file() function static

There's no outside user of it.

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-5-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/dso.c | 2 +-
 tools/perf/util/dso.h | 1 -
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
index 8ee1faa5726f..9f4b72d8f50f 100644
--- a/tools/perf/util/dso.c
+++ b/tools/perf/util/dso.c
@@ -239,7 +239,7 @@ bool is_kernel_module(const char *pathname, int cpumode)
 	return m.kmod;
 }
 
-bool decompress_to_file(const char *ext, const char *filename, int output_fd)
+static bool decompress_to_file(const char *ext, const char *filename, int output_fd)
 {
 	unsigned i;
 
diff --git a/tools/perf/util/dso.h b/tools/perf/util/dso.h
index ef69de2e69ea..e1adadd1fe1e 100644
--- a/tools/perf/util/dso.h
+++ b/tools/perf/util/dso.h
@@ -252,7 +252,6 @@ int dso__read_binary_type_filename(const struct dso *dso, enum dso_binary_type t
 				   char *root_dir, char *filename, size_t size);
 bool is_supported_compression(const char *ext);
 bool is_kernel_module(const char *pathname, int cpumode);
-bool decompress_to_file(const char *ext, const char *filename, int output_fd);
 bool dso__needs_decompress(struct dso *dso);
 int dso__decompress_kmodule_fd(struct dso *dso, const char *name);
 int dso__decompress_kmodule_path(struct dso *dso, const char *name,

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [tip:perf/urgent] perf tools: Make is_supported_compression() static
  2018-08-17  9:48 ` [PATCH 05/13] perf tools: Make is_supported_compression " Jiri Olsa
@ 2018-08-23  8:41   ` tip-bot for Jiri Olsa
  0 siblings, 0 replies; 32+ messages in thread
From: tip-bot for Jiri Olsa @ 2018-08-23  8:41 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: dsahern, jolsa, tglx, linux-kernel, mpetlan, acme, mingo, peterz,
	namhyung, alexander.shishkin, hpa

Commit-ID:  e1e139463db363a253296b431e61519d8809e386
Gitweb:     https://git.kernel.org/tip/e1e139463db363a253296b431e61519d8809e386
Author:     Jiri Olsa <jolsa@kernel.org>
AuthorDate: Fri, 17 Aug 2018 11:48:05 +0200
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Mon, 20 Aug 2018 08:54:59 -0300

perf tools: Make is_supported_compression() static

There's no outside user of it.

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-6-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/dso.c | 2 +-
 tools/perf/util/dso.h | 1 -
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
index 9f4b72d8f50f..b8b5fdb1a15b 100644
--- a/tools/perf/util/dso.c
+++ b/tools/perf/util/dso.c
@@ -202,7 +202,7 @@ static const struct {
 	{ NULL, NULL },
 };
 
-bool is_supported_compression(const char *ext)
+static bool is_supported_compression(const char *ext)
 {
 	unsigned i;
 
diff --git a/tools/perf/util/dso.h b/tools/perf/util/dso.h
index e1adadd1fe1e..870346b333ee 100644
--- a/tools/perf/util/dso.h
+++ b/tools/perf/util/dso.h
@@ -250,7 +250,6 @@ int dso__kernel_module_get_build_id(struct dso *dso, const char *root_dir);
 char dso__symtab_origin(const struct dso *dso);
 int dso__read_binary_type_filename(const struct dso *dso, enum dso_binary_type type,
 				   char *root_dir, char *filename, size_t size);
-bool is_supported_compression(const char *ext);
 bool is_kernel_module(const char *pathname, int cpumode);
 bool dso__needs_decompress(struct dso *dso);
 int dso__decompress_kmodule_fd(struct dso *dso, const char *name);

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [tip:perf/urgent] perf tools: Add compression id into 'struct kmod_path'
  2018-08-17  9:48 ` [PATCH 06/13] perf tools: Add compression id into struct kmod_path Jiri Olsa
  2018-08-17 18:23   ` Arnaldo Carvalho de Melo
@ 2018-08-23  8:41   ` tip-bot for Jiri Olsa
  1 sibling, 0 replies; 32+ messages in thread
From: tip-bot for Jiri Olsa @ 2018-08-23  8:41 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: mingo, namhyung, acme, alexander.shishkin, hpa, jolsa, mpetlan,
	linux-kernel, dsahern, peterz, tglx

Commit-ID:  4b838b0db4e9cb3892b181ea9adc13cefb90d210
Gitweb:     https://git.kernel.org/tip/4b838b0db4e9cb3892b181ea9adc13cefb90d210
Author:     Jiri Olsa <jolsa@kernel.org>
AuthorDate: Fri, 17 Aug 2018 11:48:06 +0200
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Mon, 20 Aug 2018 08:54:59 -0300

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>
---
 tools/perf/tests/kmod-path.c | 42 +++++++++++++++++++++---------------------
 tools/perf/util/dso.c        | 18 +++++++++++-------
 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 @@
 #include "debug.h"
 
 static int test(const char *path, bool alloc_name, bool alloc_ext,
-		bool kmod, bool comp, const char *name, const char *ext)
+		bool kmod, int comp, const char *name, const char *ext)
 {
 	struct kmod_path m;
 
@@ -54,47 +54,47 @@ static int test_is_kernel_module(const char *path, int cpumode, bool expect)
 int test__kmod_path__parse(struct test *t __maybe_unused, int subtest __maybe_unused)
 {
 	/* path                alloc_name  alloc_ext   kmod  comp   name     ext */
-	T("/xxxx/xxxx/x-x.ko", true      , true      , true, false, "[x_x]", NULL);
-	T("/xxxx/xxxx/x-x.ko", false     , true      , true, false, NULL   , NULL);
-	T("/xxxx/xxxx/x-x.ko", true      , false     , true, false, "[x_x]", NULL);
-	T("/xxxx/xxxx/x-x.ko", false     , false     , true, false, NULL   , NULL);
+	T("/xxxx/xxxx/x-x.ko", true      , true      , true, 0    , "[x_x]", NULL);
+	T("/xxxx/xxxx/x-x.ko", false     , true      , true, 0    , NULL   , NULL);
+	T("/xxxx/xxxx/x-x.ko", true      , false     , true, 0    , "[x_x]", NULL);
+	T("/xxxx/xxxx/x-x.ko", false     , false     , true, 0    , NULL   , NULL);
 	M("/xxxx/xxxx/x-x.ko", PERF_RECORD_MISC_CPUMODE_UNKNOWN, true);
 	M("/xxxx/xxxx/x-x.ko", PERF_RECORD_MISC_KERNEL, true);
 	M("/xxxx/xxxx/x-x.ko", PERF_RECORD_MISC_USER, false);
 
 #ifdef HAVE_ZLIB_SUPPORT
 	/* path                alloc_name  alloc_ext   kmod  comp  name   ext */
-	T("/xxxx/xxxx/x.ko.gz", true     , true      , true, true, "[x]", "gz");
-	T("/xxxx/xxxx/x.ko.gz", false    , true      , true, true, NULL , "gz");
-	T("/xxxx/xxxx/x.ko.gz", true     , false     , true, true, "[x]", NULL);
-	T("/xxxx/xxxx/x.ko.gz", false    , false     , true, true, NULL , NULL);
+	T("/xxxx/xxxx/x.ko.gz", true     , true      , true, 1   , "[x]", "gz");
+	T("/xxxx/xxxx/x.ko.gz", false    , true      , true, 1   , NULL , "gz");
+	T("/xxxx/xxxx/x.ko.gz", true     , false     , true, 1   , "[x]", NULL);
+	T("/xxxx/xxxx/x.ko.gz", false    , false     , true, 1   , NULL , NULL);
 	M("/xxxx/xxxx/x.ko.gz", PERF_RECORD_MISC_CPUMODE_UNKNOWN, true);
 	M("/xxxx/xxxx/x.ko.gz", PERF_RECORD_MISC_KERNEL, true);
 	M("/xxxx/xxxx/x.ko.gz", PERF_RECORD_MISC_USER, false);
 
 	/* path              alloc_name  alloc_ext  kmod   comp  name    ext */
-	T("/xxxx/xxxx/x.gz", true      , true     , false, true, "x.gz" ,"gz");
-	T("/xxxx/xxxx/x.gz", false     , true     , false, true, NULL   ,"gz");
-	T("/xxxx/xxxx/x.gz", true      , false    , false, true, "x.gz" , NULL);
-	T("/xxxx/xxxx/x.gz", false     , false    , false, true, NULL   , NULL);
+	T("/xxxx/xxxx/x.gz", true      , true     , false, 1   , "x.gz" ,"gz");
+	T("/xxxx/xxxx/x.gz", false     , true     , false, 1   , NULL   ,"gz");
+	T("/xxxx/xxxx/x.gz", true      , false    , false, 1   , "x.gz" , NULL);
+	T("/xxxx/xxxx/x.gz", false     , false    , false, 1   , NULL   , NULL);
 	M("/xxxx/xxxx/x.gz", PERF_RECORD_MISC_CPUMODE_UNKNOWN, false);
 	M("/xxxx/xxxx/x.gz", PERF_RECORD_MISC_KERNEL, false);
 	M("/xxxx/xxxx/x.gz", PERF_RECORD_MISC_USER, false);
 
 	/* path   alloc_name  alloc_ext  kmod   comp  name     ext */
-	T("x.gz", true      , true     , false, true, "x.gz", "gz");
-	T("x.gz", false     , true     , false, true, NULL  , "gz");
-	T("x.gz", true      , false    , false, true, "x.gz", NULL);
-	T("x.gz", false     , false    , false, true, NULL  , NULL);
+	T("x.gz", true      , true     , false, 1   , "x.gz", "gz");
+	T("x.gz", false     , true     , false, 1   , NULL  , "gz");
+	T("x.gz", true      , false    , false, 1   , "x.gz", NULL);
+	T("x.gz", false     , false    , false, 1   , NULL  , NULL);
 	M("x.gz", PERF_RECORD_MISC_CPUMODE_UNKNOWN, false);
 	M("x.gz", PERF_RECORD_MISC_KERNEL, false);
 	M("x.gz", PERF_RECORD_MISC_USER, false);
 
 	/* path      alloc_name  alloc_ext  kmod  comp  name  ext */
-	T("x.ko.gz", true      , true     , true, true, "[x]", "gz");
-	T("x.ko.gz", false     , true     , true, true, NULL , "gz");
-	T("x.ko.gz", true      , false    , true, true, "[x]", NULL);
-	T("x.ko.gz", false     , false    , true, true, NULL , NULL);
+	T("x.ko.gz", true      , true     , true, 1   , "[x]", "gz");
+	T("x.ko.gz", false     , true     , true, 1   , NULL , "gz");
+	T("x.ko.gz", true      , false    , true, 1   , "[x]", NULL);
+	T("x.ko.gz", false     , false    , true, 1   , NULL , NULL);
 	M("x.ko.gz", PERF_RECORD_MISC_CPUMODE_UNKNOWN, true);
 	M("x.ko.gz", PERF_RECORD_MISC_KERNEL, true);
 	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,
 	return ret;
 }
 
+enum {
+	COMP_ID__NONE = 0,
+};
+
 static const struct {
 	const char *fmt;
 	int (*decompress)(const char *input, int output);
 } compressions[] = {
+	[COMP_ID__NONE] = { .fmt = NULL, },
 #ifdef HAVE_ZLIB_SUPPORT
 	{ "gz", gzip_decompress_to_file },
 #endif
@@ -202,15 +207,15 @@ static const struct {
 	{ NULL, NULL },
 };
 
-static bool is_supported_compression(const char *ext)
+static int is_supported_compression(const char *ext)
 {
 	unsigned i;
 
-	for (i = 0; compressions[i].fmt; i++) {
+	for (i = 1; compressions[i].fmt; i++) {
 		if (!strcmp(ext, compressions[i].fmt))
-			return true;
+			return i;
 	}
-	return false;
+	return COMP_ID__NONE;
 }
 
 bool is_kernel_module(const char *pathname, int cpumode)
@@ -372,10 +377,9 @@ int __kmod_path__parse(struct kmod_path *m, const char *path,
 		return 0;
 	}
 
-	if (is_supported_compression(ext + 1)) {
-		m->comp = true;
+	m->comp = is_supported_compression(ext + 1);
+	if (m->comp > COMP_ID__NONE)
 		ext -= 3;
-	}
 
 	/* Check .ko extension only if there's enough name left. */
 	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,
 struct kmod_path {
 	char *name;
 	char *ext;
-	bool  comp;
+	int   comp;
 	bool  kmod;
 };
 

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [tip:perf/urgent] perf tools: Store compression id into struct dso
  2018-08-17  9:48 ` [PATCH 07/13] perf tools: Store compression id into struct dso Jiri Olsa
@ 2018-08-23  8:42   ` tip-bot for Jiri Olsa
  0 siblings, 0 replies; 32+ messages in thread
From: tip-bot for Jiri Olsa @ 2018-08-23  8:42 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: mpetlan, mingo, namhyung, hpa, linux-kernel, alexander.shishkin,
	acme, jolsa, dsahern, peterz, tglx

Commit-ID:  2af5247530e073f4146d74ecd96cf64c953c001c
Gitweb:     https://git.kernel.org/tip/2af5247530e073f4146d74ecd96cf64c953c001c
Author:     Jiri Olsa <jolsa@kernel.org>
AuthorDate: Fri, 17 Aug 2018 11:48:07 +0200
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Mon, 20 Aug 2018 08:54:59 -0300

perf tools: Store compression id into struct dso

Add comp to 'struct dso' to hold the compression index.  It will be used
in the following patches.

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-8-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/dso.c     | 5 ++++-
 tools/perf/util/dso.h     | 1 +
 tools/perf/util/machine.c | 4 +++-
 3 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
index d34e47bb09d9..d875e6956a3e 100644
--- a/tools/perf/util/dso.c
+++ b/tools/perf/util/dso.c
@@ -417,8 +417,10 @@ void dso__set_module_info(struct dso *dso, struct kmod_path *m,
 		dso->symtab_type = DSO_BINARY_TYPE__GUEST_KMODULE;
 
 	/* _KMODULE_COMP should be next to _KMODULE */
-	if (m->kmod && m->comp)
+	if (m->kmod && m->comp) {
 		dso->symtab_type++;
+		dso->comp = m->comp;
+	}
 
 	dso__set_short_name(dso, strdup(m->name), true);
 }
@@ -1224,6 +1226,7 @@ struct dso *dso__new(const char *name)
 		dso->a2l_fails = 1;
 		dso->kernel = DSO_TYPE_USER;
 		dso->needs_swap = DSO_SWAP__UNSET;
+		dso->comp = COMP_ID__NONE;
 		RB_CLEAR_NODE(&dso->rb_node);
 		dso->root = NULL;
 		INIT_LIST_HEAD(&dso->node);
diff --git a/tools/perf/util/dso.h b/tools/perf/util/dso.h
index 7bde23f6e5a9..a6c7af52115f 100644
--- a/tools/perf/util/dso.h
+++ b/tools/perf/util/dso.h
@@ -175,6 +175,7 @@ struct dso {
 	u16		 short_name_len;
 	void		*dwfl;			/* DWARF debug info */
 	struct auxtrace_cache *auxtrace_cache;
+	int		 comp;
 
 	/* dso data file */
 	struct {
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index b300a3973448..c4acd2001db0 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -1212,8 +1212,10 @@ static int map_groups__set_module_path(struct map_groups *mg, const char *path,
 	 * Full name could reveal us kmod compression, so
 	 * we need to update the symtab_type if needed.
 	 */
-	if (m->comp && is_kmod_dso(map->dso))
+	if (m->comp && is_kmod_dso(map->dso)) {
 		map->dso->symtab_type++;
+		map->dso->comp = m->comp;
+	}
 
 	return 0;
 }

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [tip:perf/urgent] perf tools: Use compression id in decompress_kmodule()
  2018-08-17  9:48 ` [PATCH 08/13] perf tools: Use compression id in decompress_kmodule function Jiri Olsa
@ 2018-08-23  8:42   ` tip-bot for Jiri Olsa
  0 siblings, 0 replies; 32+ messages in thread
From: tip-bot for Jiri Olsa @ 2018-08-23  8:42 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: hpa, dsahern, tglx, mpetlan, peterz, jolsa, alexander.shishkin,
	acme, linux-kernel, namhyung, mingo

Commit-ID:  dde755a90e98a1c57f6a92d1a79bc5554024065c
Gitweb:     https://git.kernel.org/tip/dde755a90e98a1c57f6a92d1a79bc5554024065c
Author:     Jiri Olsa <jolsa@kernel.org>
AuthorDate: Fri, 17 Aug 2018 11:48:08 +0200
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Mon, 20 Aug 2018 08:54:59 -0300

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>
---
 tools/perf/util/dso.c | 24 +++---------------------
 1 file 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)
 	return m.kmod;
 }
 
-static bool decompress_to_file(const char *ext, const char *filename, int output_fd)
-{
-	unsigned i;
-
-	for (i = 0; compressions[i].fmt; i++) {
-		if (!strcmp(ext, compressions[i].fmt))
-			return !compressions[i].decompress(filename,
-							   output_fd);
-	}
-	return false;
-}
-
 bool dso__needs_decompress(struct dso *dso)
 {
 	return dso->symtab_type == DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE_COMP ||
@@ -265,31 +253,25 @@ bool dso__needs_decompress(struct dso *dso)
 static int decompress_kmodule(struct dso *dso, const char *name, char *tmpbuf)
 {
 	int fd = -1;
-	struct kmod_path m;
 
 	if (!dso__needs_decompress(dso))
 		return -1;
 
-	if (kmod_path__parse_ext(&m, dso->long_name))
+	if (dso->comp == COMP_ID__NONE)
 		return -1;
 
-	if (!m.comp)
-		goto out;
-
 	fd = mkstemp(tmpbuf);
 	if (fd < 0) {
 		dso->load_errno = errno;
-		goto out;
+		return -1;
 	}
 
-	if (!decompress_to_file(m.ext, name, fd)) {
+	if (compressions[dso->comp].decompress(name, fd)) {
 		dso->load_errno = DSO_LOAD_ERRNO__DECOMPRESSION_FAILURE;
 		close(fd);
 		fd = -1;
 	}
 
-out:
-	free(m.ext);
 	return fd;
 }
 

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [tip:perf/urgent] perf tools: Move the temp file processing into decompress_kmodule
  2018-08-17  9:48 ` [PATCH 09/13] perf tools: Move the temp file processing into decompress_kmodule Jiri Olsa
@ 2018-08-23  8:43   ` tip-bot for Jiri Olsa
  0 siblings, 0 replies; 32+ messages in thread
From: tip-bot for Jiri Olsa @ 2018-08-23  8:43 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: dsahern, namhyung, mingo, tglx, alexander.shishkin, hpa, mpetlan,
	linux-kernel, jolsa, peterz, acme

Commit-ID:  c9a8a6131fb68f6eabec34fd855e69b4855155e4
Gitweb:     https://git.kernel.org/tip/c9a8a6131fb68f6eabec34fd855e69b4855155e4
Author:     Jiri Olsa <jolsa@kernel.org>
AuthorDate: Fri, 17 Aug 2018 11:48:09 +0200
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Mon, 20 Aug 2018 08:54:59 -0300

perf tools: Move the temp file processing into decompress_kmodule

We will add a compression check in the following patch and it makes it
easier if the file processing is done in a single place. It also makes
the current code simpler.

The decompress_kmodule function now returns the fd of the uncompressed
file and the file name in the pathname arg, if it's provided.

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-10-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/dso.c | 29 ++++++++++++-----------------
 1 file changed, 12 insertions(+), 17 deletions(-)

diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
index 54bfe1f4762f..cbeecf683333 100644
--- a/tools/perf/util/dso.c
+++ b/tools/perf/util/dso.c
@@ -250,8 +250,10 @@ bool dso__needs_decompress(struct dso *dso)
 		dso->symtab_type == DSO_BINARY_TYPE__GUEST_KMODULE_COMP;
 }
 
-static int decompress_kmodule(struct dso *dso, const char *name, char *tmpbuf)
+static int decompress_kmodule(struct dso *dso, const char *name,
+			      char *pathname, size_t len)
 {
+	char tmpbuf[] = KMOD_DECOMP_NAME;
 	int fd = -1;
 
 	if (!dso__needs_decompress(dso))
@@ -272,34 +274,27 @@ static int decompress_kmodule(struct dso *dso, const char *name, char *tmpbuf)
 		fd = -1;
 	}
 
+	if (!pathname || (fd < 0))
+		unlink(tmpbuf);
+
+	if (pathname && (fd >= 0))
+		strncpy(pathname, tmpbuf, len);
+
 	return fd;
 }
 
 int dso__decompress_kmodule_fd(struct dso *dso, const char *name)
 {
-	char tmpbuf[] = KMOD_DECOMP_NAME;
-	int fd;
-
-	fd = decompress_kmodule(dso, name, tmpbuf);
-	unlink(tmpbuf);
-	return fd;
+	return decompress_kmodule(dso, name, NULL, 0);
 }
 
 int dso__decompress_kmodule_path(struct dso *dso, const char *name,
 				 char *pathname, size_t len)
 {
-	char tmpbuf[] = KMOD_DECOMP_NAME;
-	int fd;
-
-	fd = decompress_kmodule(dso, name, tmpbuf);
-	if (fd < 0) {
-		unlink(tmpbuf);
-		return -1;
-	}
+	int fd = decompress_kmodule(dso, name, pathname, len);
 
-	strncpy(pathname, tmpbuf, len);
 	close(fd);
-	return 0;
+	return fd >= 0 ? 0 : -1;
 }
 
 /*

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [tip:perf/urgent] perf tools: Add is_compressed callback to compressions array
  2018-08-17  9:48 ` [PATCH 10/13] perf tools: Add is_compressed callback to compressions array Jiri Olsa
@ 2018-08-23  8:43   ` tip-bot for Jiri Olsa
  0 siblings, 0 replies; 32+ messages in thread
From: tip-bot for Jiri Olsa @ 2018-08-23  8:43 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: namhyung, alexander.shishkin, peterz, linux-kernel, mingo, hpa,
	jolsa, tglx, acme, dsahern, mpetlan

Commit-ID:  8b42b7e5e8b5692bc5e57342bf00c40d64978407
Gitweb:     https://git.kernel.org/tip/8b42b7e5e8b5692bc5e57342bf00c40d64978407
Author:     Jiri Olsa <jolsa@kernel.org>
AuthorDate: Fri, 17 Aug 2018 11:48:10 +0200
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Mon, 20 Aug 2018 08:54:59 -0300

perf tools: Add is_compressed callback to compressions array

Add is_compressed callback to the compressions array, that returns 0 if
the file is compressed or != 0 if not.

The new callback is used to recognize the situation when we have a
'compressed' object, like:

  /lib/modules/.../drivers/net/ethernet/intel/igb/igb.ko.xz

but we need to read its debug data from debuginfo files, which might not
be compressed, like:

  /root/.debug/.build-id/d6/...c4b301f/debug

So even for a 'compressed' object we read debug data from a plain
uncompressed object. To keep this transparent, we detect this in
decompress_kmodule() and return the file descriptor to the uncompressed
file.

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-11-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/compress.h |  2 ++
 tools/perf/util/dso.c      | 23 ++++++++++++++++++++---
 tools/perf/util/lzma.c     |  5 +++++
 tools/perf/util/zlib.c     |  6 ++++++
 4 files changed, 33 insertions(+), 3 deletions(-)

diff --git a/tools/perf/util/compress.h b/tools/perf/util/compress.h
index ecca688a25fb..892e92e7e7fc 100644
--- a/tools/perf/util/compress.h
+++ b/tools/perf/util/compress.h
@@ -4,10 +4,12 @@
 
 #ifdef HAVE_ZLIB_SUPPORT
 int gzip_decompress_to_file(const char *input, int output_fd);
+bool gzip_is_compressed(const char *input);
 #endif
 
 #ifdef HAVE_LZMA_SUPPORT
 int lzma_decompress_to_file(const char *input, int output_fd);
+bool lzma_is_compressed(const char *input);
 #endif
 
 #endif /* PERF_COMPRESS_H */
diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
index cbeecf683333..8b9243f13b88 100644
--- a/tools/perf/util/dso.c
+++ b/tools/perf/util/dso.c
@@ -196,15 +196,16 @@ enum {
 static const struct {
 	const char *fmt;
 	int (*decompress)(const char *input, int output);
+	bool (*is_compressed)(const char *input);
 } compressions[] = {
 	[COMP_ID__NONE] = { .fmt = NULL, },
 #ifdef HAVE_ZLIB_SUPPORT
-	{ "gz", gzip_decompress_to_file },
+	{ "gz", gzip_decompress_to_file, gzip_is_compressed },
 #endif
 #ifdef HAVE_LZMA_SUPPORT
-	{ "xz", lzma_decompress_to_file },
+	{ "xz", lzma_decompress_to_file, lzma_is_compressed },
 #endif
-	{ NULL, NULL },
+	{ NULL, NULL, NULL },
 };
 
 static int is_supported_compression(const char *ext)
@@ -262,6 +263,22 @@ static int decompress_kmodule(struct dso *dso, const char *name,
 	if (dso->comp == COMP_ID__NONE)
 		return -1;
 
+	/*
+	 * We have proper compression id for DSO and yet the file
+	 * behind the 'name' can still be plain uncompressed object.
+	 *
+	 * The reason is behind the logic we open the DSO object files,
+	 * when we try all possible 'debug' objects until we find the
+	 * data. So even if the DSO is represented by 'krava.xz' module,
+	 * we can end up here opening ~/.debug/....23432432/debug' file
+	 * which is not compressed.
+	 *
+	 * To keep this transparent, we detect this and return the file
+	 * descriptor to the uncompressed file.
+	 */
+	if (!compressions[dso->comp].is_compressed(name))
+		return open(name, O_RDONLY);
+
 	fd = mkstemp(tmpbuf);
 	if (fd < 0) {
 		dso->load_errno = errno;
diff --git a/tools/perf/util/lzma.c b/tools/perf/util/lzma.c
index 07498eaddc08..7032caaf75eb 100644
--- a/tools/perf/util/lzma.c
+++ b/tools/perf/util/lzma.c
@@ -99,3 +99,8 @@ err_fclose:
 	fclose(infile);
 	return err;
 }
+
+bool lzma_is_compressed(const char *input __maybe_unused)
+{
+	return true;
+}
diff --git a/tools/perf/util/zlib.c b/tools/perf/util/zlib.c
index a725b958cf31..e68317214679 100644
--- a/tools/perf/util/zlib.c
+++ b/tools/perf/util/zlib.c
@@ -5,6 +5,7 @@
 #include <sys/stat.h>
 #include <sys/mman.h>
 #include <zlib.h>
+#include <linux/compiler.h>
 
 #include "util/compress.h"
 #include "util/util.h"
@@ -79,3 +80,8 @@ out_close:
 
 	return ret == Z_STREAM_END ? 0 : -1;
 }
+
+bool gzip_is_compressed(const char *input __maybe_unused)
+{
+	return true;
+}

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [tip:perf/urgent] perf tools: Add lzma_is_compressed function
  2018-08-17  9:48 ` [PATCH 11/13] perf tools: Add lzma_is_compressed function Jiri Olsa
@ 2018-08-23  8:44   ` tip-bot for Jiri Olsa
  0 siblings, 0 replies; 32+ messages in thread
From: tip-bot for Jiri Olsa @ 2018-08-23  8:44 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: mpetlan, peterz, acme, dsahern, tglx, jolsa, namhyung,
	linux-kernel, alexander.shishkin, hpa, mingo

Commit-ID:  4b57fd44b61beb51b7d64f21c72941ba10c1ea2b
Gitweb:     https://git.kernel.org/tip/4b57fd44b61beb51b7d64f21c72941ba10c1ea2b
Author:     Jiri Olsa <jolsa@kernel.org>
AuthorDate: Fri, 17 Aug 2018 11:48:11 +0200
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Mon, 20 Aug 2018 08:54:59 -0300

perf tools: Add lzma_is_compressed function

Add implementation of the is_compressed callback for lzma.

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-12-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/lzma.c | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/lzma.c b/tools/perf/util/lzma.c
index 7032caaf75eb..b1dd29a9d915 100644
--- a/tools/perf/util/lzma.c
+++ b/tools/perf/util/lzma.c
@@ -3,9 +3,13 @@
 #include <lzma.h>
 #include <stdio.h>
 #include <linux/compiler.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
 #include "compress.h"
 #include "util.h"
 #include "debug.h"
+#include <unistd.h>
 
 #define BUFSIZE 8192
 
@@ -100,7 +104,18 @@ err_fclose:
 	return err;
 }
 
-bool lzma_is_compressed(const char *input __maybe_unused)
+bool lzma_is_compressed(const char *input)
 {
-	return true;
+	int fd = open(input, O_RDONLY);
+	const uint8_t magic[6] = { 0xFD, '7', 'z', 'X', 'Z', 0x00 };
+	char buf[6] = { 0 };
+	ssize_t rc;
+
+	if (fd < 0)
+		return -1;
+
+	rc = read(fd, buf, sizeof(buf));
+	close(fd);
+	return rc == sizeof(buf) ?
+	       memcmp(buf, magic, sizeof(buf)) == 0 : false;
 }

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [tip:perf/urgent] perf tools: Add gzip_is_compressed function
  2018-08-17  9:48 ` [PATCH 12/13] perf tools: Add gzip_is_compressed function Jiri Olsa
@ 2018-08-23  8:44   ` tip-bot for Jiri Olsa
  0 siblings, 0 replies; 32+ messages in thread
From: tip-bot for Jiri Olsa @ 2018-08-23  8:44 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: hpa, namhyung, jolsa, mpetlan, acme, tglx, linux-kernel,
	alexander.shishkin, mingo, dsahern, peterz

Commit-ID:  88c74dc76a30b9242c2df687deb44788d93fee6b
Gitweb:     https://git.kernel.org/tip/88c74dc76a30b9242c2df687deb44788d93fee6b
Author:     Jiri Olsa <jolsa@kernel.org>
AuthorDate: Fri, 17 Aug 2018 11:48:12 +0200
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Mon, 20 Aug 2018 08:54:59 -0300

perf tools: Add gzip_is_compressed function

Add implementation of the is_compressed callback for gzip.

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-13-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/zlib.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/zlib.c b/tools/perf/util/zlib.c
index e68317214679..902ce6384f57 100644
--- a/tools/perf/util/zlib.c
+++ b/tools/perf/util/zlib.c
@@ -6,6 +6,7 @@
 #include <sys/mman.h>
 #include <zlib.h>
 #include <linux/compiler.h>
+#include <unistd.h>
 
 #include "util/compress.h"
 #include "util/util.h"
@@ -81,7 +82,18 @@ out_close:
 	return ret == Z_STREAM_END ? 0 : -1;
 }
 
-bool gzip_is_compressed(const char *input __maybe_unused)
+bool gzip_is_compressed(const char *input)
 {
-	return true;
+	int fd = open(input, O_RDONLY);
+	const uint8_t magic[2] = { 0x1f, 0x8b };
+	char buf[2] = { 0 };
+	ssize_t rc;
+
+	if (fd < 0)
+		return -1;
+
+	rc = read(fd, buf, sizeof(buf));
+	close(fd);
+	return rc == sizeof(buf) ?
+	       memcmp(buf, magic, sizeof(buf)) == 0 : false;
 }

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [tip:perf/urgent] perf tools: Remove ext from struct kmod_path
  2018-08-17  9:48 ` [PATCH 13/13] perf tools: Remove ext from struct kmod_path Jiri Olsa
@ 2018-08-23  8:45   ` tip-bot for Jiri Olsa
  0 siblings, 0 replies; 32+ messages in thread
From: tip-bot for Jiri Olsa @ 2018-08-23  8:45 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: acme, jolsa, namhyung, mpetlan, alexander.shishkin, linux-kernel,
	tglx, peterz, mingo, hpa, dsahern

Commit-ID:  b946cd37348aaef443a1d951144f79a70274867f
Gitweb:     https://git.kernel.org/tip/b946cd37348aaef443a1d951144f79a70274867f
Author:     Jiri Olsa <jolsa@kernel.org>
AuthorDate: Fri, 17 Aug 2018 11:48:13 +0200
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Mon, 20 Aug 2018 08:54:59 -0300

perf tools: Remove ext from struct kmod_path

Having comp carrying the compression ID, we no longer need return the
extension. Removing it and updating the automated test.

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-14-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/tests/kmod-path.c | 136 +++++++++++++++++++++----------------------
 tools/perf/util/dso.c        |  10 +---
 tools/perf/util/dso.h        |   8 +--
 3 files changed, 69 insertions(+), 85 deletions(-)

diff --git a/tools/perf/tests/kmod-path.c b/tools/perf/tests/kmod-path.c
index f92f78f683ea..0579a70bbbff 100644
--- a/tools/perf/tests/kmod-path.c
+++ b/tools/perf/tests/kmod-path.c
@@ -5,34 +5,28 @@
 #include "dso.h"
 #include "debug.h"
 
-static int test(const char *path, bool alloc_name, bool alloc_ext,
-		bool kmod, int comp, const char *name, const char *ext)
+static int test(const char *path, bool alloc_name, bool kmod,
+		int comp, const char *name)
 {
 	struct kmod_path m;
 
 	memset(&m, 0x0, sizeof(m));
 
 	TEST_ASSERT_VAL("kmod_path__parse",
-			!__kmod_path__parse(&m, path, alloc_name, alloc_ext));
+			!__kmod_path__parse(&m, path, alloc_name));
 
-	pr_debug("%s - alloc name %d, alloc ext %d, kmod %d, comp %d, name '%s', ext '%s'\n",
-		 path, alloc_name, alloc_ext, m.kmod, m.comp, m.name, m.ext);
+	pr_debug("%s - alloc name %d, kmod %d, comp %d, name '%s'\n",
+		 path, alloc_name, m.kmod, m.comp, m.name);
 
 	TEST_ASSERT_VAL("wrong kmod", m.kmod == kmod);
 	TEST_ASSERT_VAL("wrong comp", m.comp == comp);
 
-	if (ext)
-		TEST_ASSERT_VAL("wrong ext", m.ext && !strcmp(ext, m.ext));
-	else
-		TEST_ASSERT_VAL("wrong ext", !m.ext);
-
 	if (name)
 		TEST_ASSERT_VAL("wrong name", m.name && !strcmp(name, m.name));
 	else
 		TEST_ASSERT_VAL("wrong name", !m.name);
 
 	free(m.name);
-	free(m.ext);
 	return 0;
 }
 
@@ -45,118 +39,118 @@ static int test_is_kernel_module(const char *path, int cpumode, bool expect)
 	return 0;
 }
 
-#define T(path, an, ae, k, c, n, e) \
-	TEST_ASSERT_VAL("failed", !test(path, an, ae, k, c, n, e))
+#define T(path, an, k, c, n) \
+	TEST_ASSERT_VAL("failed", !test(path, an, k, c, n))
 
 #define M(path, c, e) \
 	TEST_ASSERT_VAL("failed", !test_is_kernel_module(path, c, e))
 
 int test__kmod_path__parse(struct test *t __maybe_unused, int subtest __maybe_unused)
 {
-	/* path                alloc_name  alloc_ext   kmod  comp   name     ext */
-	T("/xxxx/xxxx/x-x.ko", true      , true      , true, 0    , "[x_x]", NULL);
-	T("/xxxx/xxxx/x-x.ko", false     , true      , true, 0    , NULL   , NULL);
-	T("/xxxx/xxxx/x-x.ko", true      , false     , true, 0    , "[x_x]", NULL);
-	T("/xxxx/xxxx/x-x.ko", false     , false     , true, 0    , NULL   , NULL);
+	/* path                alloc_name  kmod  comp   name   */
+	T("/xxxx/xxxx/x-x.ko", true      , true, 0    , "[x_x]");
+	T("/xxxx/xxxx/x-x.ko", false     , true, 0    , NULL   );
+	T("/xxxx/xxxx/x-x.ko", true      , true, 0    , "[x_x]");
+	T("/xxxx/xxxx/x-x.ko", false     , true, 0    , NULL   );
 	M("/xxxx/xxxx/x-x.ko", PERF_RECORD_MISC_CPUMODE_UNKNOWN, true);
 	M("/xxxx/xxxx/x-x.ko", PERF_RECORD_MISC_KERNEL, true);
 	M("/xxxx/xxxx/x-x.ko", PERF_RECORD_MISC_USER, false);
 
 #ifdef HAVE_ZLIB_SUPPORT
-	/* path                alloc_name  alloc_ext   kmod  comp  name   ext */
-	T("/xxxx/xxxx/x.ko.gz", true     , true      , true, 1   , "[x]", "gz");
-	T("/xxxx/xxxx/x.ko.gz", false    , true      , true, 1   , NULL , "gz");
-	T("/xxxx/xxxx/x.ko.gz", true     , false     , true, 1   , "[x]", NULL);
-	T("/xxxx/xxxx/x.ko.gz", false    , false     , true, 1   , NULL , NULL);
+	/* path                alloc_name   kmod  comp  name  */
+	T("/xxxx/xxxx/x.ko.gz", true     , true, 1   , "[x]");
+	T("/xxxx/xxxx/x.ko.gz", false    , true, 1   , NULL );
+	T("/xxxx/xxxx/x.ko.gz", true     , true, 1   , "[x]");
+	T("/xxxx/xxxx/x.ko.gz", false    , true, 1   , NULL );
 	M("/xxxx/xxxx/x.ko.gz", PERF_RECORD_MISC_CPUMODE_UNKNOWN, true);
 	M("/xxxx/xxxx/x.ko.gz", PERF_RECORD_MISC_KERNEL, true);
 	M("/xxxx/xxxx/x.ko.gz", PERF_RECORD_MISC_USER, false);
 
-	/* path              alloc_name  alloc_ext  kmod   comp  name    ext */
-	T("/xxxx/xxxx/x.gz", true      , true     , false, 1   , "x.gz" ,"gz");
-	T("/xxxx/xxxx/x.gz", false     , true     , false, 1   , NULL   ,"gz");
-	T("/xxxx/xxxx/x.gz", true      , false    , false, 1   , "x.gz" , NULL);
-	T("/xxxx/xxxx/x.gz", false     , false    , false, 1   , NULL   , NULL);
+	/* path              alloc_name  kmod   comp  name  */
+	T("/xxxx/xxxx/x.gz", true      , false, 1   , "x.gz");
+	T("/xxxx/xxxx/x.gz", false     , false, 1   , NULL  );
+	T("/xxxx/xxxx/x.gz", true      , false, 1   , "x.gz");
+	T("/xxxx/xxxx/x.gz", false     , false, 1   , NULL  );
 	M("/xxxx/xxxx/x.gz", PERF_RECORD_MISC_CPUMODE_UNKNOWN, false);
 	M("/xxxx/xxxx/x.gz", PERF_RECORD_MISC_KERNEL, false);
 	M("/xxxx/xxxx/x.gz", PERF_RECORD_MISC_USER, false);
 
-	/* path   alloc_name  alloc_ext  kmod   comp  name     ext */
-	T("x.gz", true      , true     , false, 1   , "x.gz", "gz");
-	T("x.gz", false     , true     , false, 1   , NULL  , "gz");
-	T("x.gz", true      , false    , false, 1   , "x.gz", NULL);
-	T("x.gz", false     , false    , false, 1   , NULL  , NULL);
+	/* path   alloc_name  kmod   comp  name   */
+	T("x.gz", true      , false, 1   , "x.gz");
+	T("x.gz", false     , false, 1   , NULL  );
+	T("x.gz", true      , false, 1   , "x.gz");
+	T("x.gz", false     , false, 1   , NULL  );
 	M("x.gz", PERF_RECORD_MISC_CPUMODE_UNKNOWN, false);
 	M("x.gz", PERF_RECORD_MISC_KERNEL, false);
 	M("x.gz", PERF_RECORD_MISC_USER, false);
 
-	/* path      alloc_name  alloc_ext  kmod  comp  name  ext */
-	T("x.ko.gz", true      , true     , true, 1   , "[x]", "gz");
-	T("x.ko.gz", false     , true     , true, 1   , NULL , "gz");
-	T("x.ko.gz", true      , false    , true, 1   , "[x]", NULL);
-	T("x.ko.gz", false     , false    , true, 1   , NULL , NULL);
+	/* path      alloc_name  kmod  comp  name  */
+	T("x.ko.gz", true      , true, 1   , "[x]");
+	T("x.ko.gz", false     , true, 1   , NULL );
+	T("x.ko.gz", true      , true, 1   , "[x]");
+	T("x.ko.gz", false     , true, 1   , NULL );
 	M("x.ko.gz", PERF_RECORD_MISC_CPUMODE_UNKNOWN, true);
 	M("x.ko.gz", PERF_RECORD_MISC_KERNEL, true);
 	M("x.ko.gz", PERF_RECORD_MISC_USER, false);
 #endif
 
-	/* path            alloc_name  alloc_ext  kmod  comp   name             ext */
-	T("[test_module]", true      , true     , true, false, "[test_module]", NULL);
-	T("[test_module]", false     , true     , true, false, NULL           , NULL);
-	T("[test_module]", true      , false    , true, false, "[test_module]", NULL);
-	T("[test_module]", false     , false    , true, false, NULL           , NULL);
+	/* path            alloc_name  kmod  comp   name           */
+	T("[test_module]", true      , true, false, "[test_module]");
+	T("[test_module]", false     , true, false, NULL           );
+	T("[test_module]", true      , true, false, "[test_module]");
+	T("[test_module]", false     , true, false, NULL           );
 	M("[test_module]", PERF_RECORD_MISC_CPUMODE_UNKNOWN, true);
 	M("[test_module]", PERF_RECORD_MISC_KERNEL, true);
 	M("[test_module]", PERF_RECORD_MISC_USER, false);
 
-	/* path            alloc_name  alloc_ext  kmod  comp   name             ext */
-	T("[test.module]", true      , true     , true, false, "[test.module]", NULL);
-	T("[test.module]", false     , true     , true, false, NULL           , NULL);
-	T("[test.module]", true      , false    , true, false, "[test.module]", NULL);
-	T("[test.module]", false     , false    , true, false, NULL           , NULL);
+	/* path            alloc_name  kmod  comp   name           */
+	T("[test.module]", true      , true, false, "[test.module]");
+	T("[test.module]", false     , true, false, NULL           );
+	T("[test.module]", true      , true, false, "[test.module]");
+	T("[test.module]", false     , true, false, NULL           );
 	M("[test.module]", PERF_RECORD_MISC_CPUMODE_UNKNOWN, true);
 	M("[test.module]", PERF_RECORD_MISC_KERNEL, true);
 	M("[test.module]", PERF_RECORD_MISC_USER, false);
 
-	/* path     alloc_name  alloc_ext  kmod   comp   name      ext */
-	T("[vdso]", true      , true     , false, false, "[vdso]", NULL);
-	T("[vdso]", false     , true     , false, false, NULL    , NULL);
-	T("[vdso]", true      , false    , false, false, "[vdso]", NULL);
-	T("[vdso]", false     , false    , false, false, NULL    , NULL);
+	/* path     alloc_name  kmod   comp   name    */
+	T("[vdso]", true      , false, false, "[vdso]");
+	T("[vdso]", false     , false, false, NULL    );
+	T("[vdso]", true      , false, false, "[vdso]");
+	T("[vdso]", false     , false, false, NULL    );
 	M("[vdso]", PERF_RECORD_MISC_CPUMODE_UNKNOWN, false);
 	M("[vdso]", PERF_RECORD_MISC_KERNEL, false);
 	M("[vdso]", PERF_RECORD_MISC_USER, false);
 
-	T("[vdso32]", true      , true     , false, false, "[vdso32]", NULL);
-	T("[vdso32]", false     , true     , false, false, NULL    , NULL);
-	T("[vdso32]", true      , false    , false, false, "[vdso32]", NULL);
-	T("[vdso32]", false     , false    , false, false, NULL    , NULL);
+	T("[vdso32]", true      , false, false, "[vdso32]");
+	T("[vdso32]", false     , false, false, NULL      );
+	T("[vdso32]", true      , false, false, "[vdso32]");
+	T("[vdso32]", false     , false, false, NULL      );
 	M("[vdso32]", PERF_RECORD_MISC_CPUMODE_UNKNOWN, false);
 	M("[vdso32]", PERF_RECORD_MISC_KERNEL, false);
 	M("[vdso32]", PERF_RECORD_MISC_USER, false);
 
-	T("[vdsox32]", true      , true     , false, false, "[vdsox32]", NULL);
-	T("[vdsox32]", false     , true     , false, false, NULL    , NULL);
-	T("[vdsox32]", true      , false    , false, false, "[vdsox32]", NULL);
-	T("[vdsox32]", false     , false    , false, false, NULL    , NULL);
+	T("[vdsox32]", true      , false, false, "[vdsox32]");
+	T("[vdsox32]", false     , false, false, NULL       );
+	T("[vdsox32]", true      , false, false, "[vdsox32]");
+	T("[vdsox32]", false     , false, false, NULL       );
 	M("[vdsox32]", PERF_RECORD_MISC_CPUMODE_UNKNOWN, false);
 	M("[vdsox32]", PERF_RECORD_MISC_KERNEL, false);
 	M("[vdsox32]", PERF_RECORD_MISC_USER, false);
 
-	/* path         alloc_name  alloc_ext  kmod   comp   name          ext */
-	T("[vsyscall]", true      , true     , false, false, "[vsyscall]", NULL);
-	T("[vsyscall]", false     , true     , false, false, NULL        , NULL);
-	T("[vsyscall]", true      , false    , false, false, "[vsyscall]", NULL);
-	T("[vsyscall]", false     , false    , false, false, NULL        , NULL);
+	/* path         alloc_name  kmod   comp   name        */
+	T("[vsyscall]", true      , false, false, "[vsyscall]");
+	T("[vsyscall]", false     , false, false, NULL        );
+	T("[vsyscall]", true      , false, false, "[vsyscall]");
+	T("[vsyscall]", false     , false, false, NULL        );
 	M("[vsyscall]", PERF_RECORD_MISC_CPUMODE_UNKNOWN, false);
 	M("[vsyscall]", PERF_RECORD_MISC_KERNEL, false);
 	M("[vsyscall]", PERF_RECORD_MISC_USER, false);
 
-	/* path                alloc_name  alloc_ext  kmod   comp   name      ext */
-	T("[kernel.kallsyms]", true      , true     , false, false, "[kernel.kallsyms]", NULL);
-	T("[kernel.kallsyms]", false     , true     , false, false, NULL               , NULL);
-	T("[kernel.kallsyms]", true      , false    , false, false, "[kernel.kallsyms]", NULL);
-	T("[kernel.kallsyms]", false     , false    , false, false, NULL               , NULL);
+	/* path                alloc_name  kmod   comp   name      */
+	T("[kernel.kallsyms]", true      , false, false, "[kernel.kallsyms]");
+	T("[kernel.kallsyms]", false     , false, false, NULL               );
+	T("[kernel.kallsyms]", true      , false, false, "[kernel.kallsyms]");
+	T("[kernel.kallsyms]", false     , false, false, NULL               );
 	M("[kernel.kallsyms]", PERF_RECORD_MISC_CPUMODE_UNKNOWN, false);
 	M("[kernel.kallsyms]", PERF_RECORD_MISC_KERNEL, false);
 	M("[kernel.kallsyms]", PERF_RECORD_MISC_USER, false);
diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
index 8b9243f13b88..bbed90e5d9bb 100644
--- a/tools/perf/util/dso.c
+++ b/tools/perf/util/dso.c
@@ -331,7 +331,7 @@ int dso__decompress_kmodule_path(struct dso *dso, const char *name,
  * Returns 0 if there's no strdup error, -ENOMEM otherwise.
  */
 int __kmod_path__parse(struct kmod_path *m, const char *path,
-		       bool alloc_name, bool alloc_ext)
+		       bool alloc_name)
 {
 	const char *name = strrchr(path, '/');
 	const char *ext  = strrchr(path, '.');
@@ -391,14 +391,6 @@ int __kmod_path__parse(struct kmod_path *m, const char *path,
 		strxfrchar(m->name, '-', '_');
 	}
 
-	if (alloc_ext && m->comp) {
-		m->ext = strdup(ext + 4);
-		if (!m->ext) {
-			free((void *) m->name);
-			return -ENOMEM;
-		}
-	}
-
 	return 0;
 }
 
diff --git a/tools/perf/util/dso.h b/tools/perf/util/dso.h
index a6c7af52115f..c5380500bed4 100644
--- a/tools/perf/util/dso.h
+++ b/tools/perf/util/dso.h
@@ -262,17 +262,15 @@ int dso__decompress_kmodule_path(struct dso *dso, const char *name,
 
 struct kmod_path {
 	char *name;
-	char *ext;
 	int   comp;
 	bool  kmod;
 };
 
 int __kmod_path__parse(struct kmod_path *m, const char *path,
-		     bool alloc_name, bool alloc_ext);
+		     bool alloc_name);
 
-#define kmod_path__parse(__m, __p)      __kmod_path__parse(__m, __p, false, false)
-#define kmod_path__parse_name(__m, __p) __kmod_path__parse(__m, __p, true , false)
-#define kmod_path__parse_ext(__m, __p)  __kmod_path__parse(__m, __p, false, true)
+#define kmod_path__parse(__m, __p)      __kmod_path__parse(__m, __p, false)
+#define kmod_path__parse_name(__m, __p) __kmod_path__parse(__m, __p, true)
 
 void dso__set_module_info(struct dso *dso, struct kmod_path *m,
 			  struct machine *machine);

^ permalink raw reply related	[flat|nested] 32+ messages in thread

end of thread, other threads:[~2018-08-23  8:45 UTC | newest]

Thread overview: 32+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-17  9:48 [PATCH 00/13] perf tools: Use plain debug files for compressed objects Jiri Olsa
2018-08-17  9:48 ` [PATCH 01/13] perf tools: Get rid of dso__needs_decompress call in read_object_code Jiri Olsa
2018-08-23  8:39   ` [tip:perf/urgent] perf tools: Get rid of dso__needs_decompress() call in read_object_code() tip-bot for Jiri Olsa
2018-08-17  9:48 ` [PATCH 02/13] perf tools: Get rid of dso__needs_decompress call in symbol__disassemble Jiri Olsa
2018-08-23  8:39   ` [tip:perf/urgent] perf tools: Get rid of dso__needs_decompress() call in symbol__disassemble() tip-bot for Jiri Olsa
2018-08-17  9:48 ` [PATCH 03/13] perf tools: Get rid of dso__needs_decompress call in __open_dso Jiri Olsa
2018-08-23  8:40   ` [tip:perf/urgent] perf tools: Get rid of dso__needs_decompress() call in __open_dso() tip-bot for Jiri Olsa
2018-08-17  9:48 ` [PATCH 04/13] perf tools: Make decompress_to_file function static Jiri Olsa
2018-08-23  8:40   ` [tip:perf/urgent] perf tools: Make decompress_to_file() " tip-bot for Jiri Olsa
2018-08-17  9:48 ` [PATCH 05/13] perf tools: Make is_supported_compression " Jiri Olsa
2018-08-23  8:41   ` [tip:perf/urgent] perf tools: Make is_supported_compression() static tip-bot for Jiri Olsa
2018-08-17  9:48 ` [PATCH 06/13] perf tools: Add compression id into struct kmod_path Jiri Olsa
2018-08-17 18:23   ` Arnaldo Carvalho de Melo
2018-08-17 18:28     ` Arnaldo Carvalho de Melo
2018-08-17 18:56       ` Arnaldo Carvalho de Melo
2018-08-17 20:01         ` Jiri Olsa
2018-08-23  8:41   ` [tip:perf/urgent] perf tools: Add compression id into 'struct kmod_path' tip-bot for Jiri Olsa
2018-08-17  9:48 ` [PATCH 07/13] perf tools: Store compression id into struct dso Jiri Olsa
2018-08-23  8:42   ` [tip:perf/urgent] " tip-bot for Jiri Olsa
2018-08-17  9:48 ` [PATCH 08/13] perf tools: Use compression id in decompress_kmodule function Jiri Olsa
2018-08-23  8:42   ` [tip:perf/urgent] perf tools: Use compression id in decompress_kmodule() tip-bot for Jiri Olsa
2018-08-17  9:48 ` [PATCH 09/13] perf tools: Move the temp file processing into decompress_kmodule Jiri Olsa
2018-08-23  8:43   ` [tip:perf/urgent] " tip-bot for Jiri Olsa
2018-08-17  9:48 ` [PATCH 10/13] perf tools: Add is_compressed callback to compressions array Jiri Olsa
2018-08-23  8:43   ` [tip:perf/urgent] " tip-bot for Jiri Olsa
2018-08-17  9:48 ` [PATCH 11/13] perf tools: Add lzma_is_compressed function Jiri Olsa
2018-08-23  8:44   ` [tip:perf/urgent] " tip-bot for Jiri Olsa
2018-08-17  9:48 ` [PATCH 12/13] perf tools: Add gzip_is_compressed function Jiri Olsa
2018-08-23  8:44   ` [tip:perf/urgent] " tip-bot for Jiri Olsa
2018-08-17  9:48 ` [PATCH 13/13] perf tools: Remove ext from struct kmod_path Jiri Olsa
2018-08-23  8:45   ` [tip:perf/urgent] " tip-bot for Jiri Olsa
2018-08-17 14:52 ` [PATCH 00/13] perf tools: Use plain debug files for compressed objects Arnaldo Carvalho de Melo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).