linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] perf tools: Adding xz decompression support
@ 2015-03-03 15:29 Jiri Olsa
  2015-03-03 15:29 ` [PATCH 01/14] perf tools: Remove superfluous thread->comm_set setting Jiri Olsa
                   ` (15 more replies)
  0 siblings, 16 replies; 26+ messages in thread
From: Jiri Olsa @ 2015-03-03 15:29 UTC (permalink / raw)
  To: linux-kernel
  Cc: Jiri Olsa, Adrian Hunter, Arnaldo Carvalho de Melo,
	Corey Ashford, David Ahern, Frederic Weisbecker, Ingo Molnar,
	Namhyung Kim, Paul Mackerras, Peter Zijlstra, Stephane Eranian

hi,
adding support to decompress kernel modules on Fedora 21
(lzma compression) vaguely continuing in previous RFC:
  http://marc.info/?l=linux-kernel&m=142261340327588&w=2

I'm basically extending he decompression framework Namhyung
introduced earlier plus other fixes for kernel modules dso
objects handling.

Last patch adds decompression support to annotate command, so
it now displays annotation for compressed kernel modules.

Current work available at:
  git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git
  perf/lzma

thanks,
jirka


Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
---
Jiri Olsa (14):
      perf tools: Remove superfluous thread->comm_set setting
      perf tools: Add feature check for lzma library
      perf tools: Add lzma decompression support for kernel module
      perf tools: Add kmod_path__parse function
      perf tools: Add dsos__new function
      perf tools: Add machine__module_dso function
      perf tools: Use kmod_path__parse for machine__new_dso
      perf tools: Use kmod_path__parse in map_groups__set_modules_path_dir
      perf tools: Use kmod_path__parse in decompress_kmodule
      perf tools: Use kmod_path__parse in is_kernel_module
      perf tools: Remove compressed argument from is_kernel_module
      perf tools: Remove is_kmodule_extension function
      perf tools: Try to lookup kernel module map before creating one
      perf annotate: Allow annotation for decompressed kernel modules

 tools/perf/Makefile.perf                     |   2 ++
 tools/perf/config/Makefile                   |  16 ++++++++--
 tools/perf/config/feature-checks/Makefile    |   6 +++-
 tools/perf/config/feature-checks/test-lzma.c |  10 ++++++
 tools/perf/tests/Build                       |   1 +
 tools/perf/tests/builtin-test.c              |   4 +++
 tools/perf/tests/kmod-path.c                 |  73 ++++++++++++++++++++++++++++++++++++++++++++
 tools/perf/tests/tests.h                     |   1 +
 tools/perf/util/Build                        |   1 +
 tools/perf/util/annotate.c                   |  32 +++++++++++++++++++-
 tools/perf/util/dso.c                        |  52 ++++++++++++--------------------
 tools/perf/util/dso.h                        |   4 +--
 tools/perf/util/header.c                     |   2 +-
 tools/perf/util/lzma.c                       |  95 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 tools/perf/util/machine.c                    | 142 +++++++++++++++++++++++++++++++++++++++++++++-----------------------------------------
 tools/perf/util/symbol-elf.c                 |  25 ++++++++++-----
 tools/perf/util/thread.c                     |   1 -
 tools/perf/util/util.c                       |  66 ++++++++++++++++++++++++++++++++++++++++
 tools/perf/util/util.h                       |  18 +++++++++++
 19 files changed, 436 insertions(+), 115 deletions(-)
 create mode 100644 tools/perf/config/feature-checks/test-lzma.c
 create mode 100644 tools/perf/tests/kmod-path.c
 create mode 100644 tools/perf/util/lzma.c

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

* [PATCH 01/14] perf tools: Remove superfluous thread->comm_set setting
  2015-03-03 15:29 [PATCH 0/3] perf tools: Adding xz decompression support Jiri Olsa
@ 2015-03-03 15:29 ` Jiri Olsa
  2015-03-14  7:01   ` [tip:perf/core] perf tools: Remove superfluous thread-> comm_set setting tip-bot for Jiri Olsa
  2015-03-03 15:29 ` [PATCH 02/14] perf tools: Add feature check for lzma library Jiri Olsa
                   ` (14 subsequent siblings)
  15 siblings, 1 reply; 26+ messages in thread
From: Jiri Olsa @ 2015-03-03 15:29 UTC (permalink / raw)
  To: linux-kernel
  Cc: Jiri Olsa, Adrian Hunter, Arnaldo Carvalho de Melo,
	Corey Ashford, David Ahern, Frederic Weisbecker, Ingo Molnar,
	Namhyung Kim, Paul Mackerras, Peter Zijlstra, Stephane Eranian

It is set by calling thread__set_comm right before
the removed line.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
---
 tools/perf/util/thread.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/tools/perf/util/thread.c b/tools/perf/util/thread.c
index a5dbba95107f..1c8fbc9588c5 100644
--- a/tools/perf/util/thread.c
+++ b/tools/perf/util/thread.c
@@ -206,7 +206,6 @@ int thread__fork(struct thread *thread, struct thread *parent, u64 timestamp)
 		err = thread__set_comm(thread, comm, timestamp);
 		if (err)
 			return err;
-		thread->comm_set = true;
 	}
 
 	thread->ppid = parent->tid;
-- 
1.9.3


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

* [PATCH 02/14] perf tools: Add feature check for lzma library
  2015-03-03 15:29 [PATCH 0/3] perf tools: Adding xz decompression support Jiri Olsa
  2015-03-03 15:29 ` [PATCH 01/14] perf tools: Remove superfluous thread->comm_set setting Jiri Olsa
@ 2015-03-03 15:29 ` Jiri Olsa
  2015-03-03 15:50   ` Arnaldo Carvalho de Melo
  2015-03-03 15:29 ` [PATCH 03/14] perf tools: Add lzma decompression support for kernel module Jiri Olsa
                   ` (13 subsequent siblings)
  15 siblings, 1 reply; 26+ messages in thread
From: Jiri Olsa @ 2015-03-03 15:29 UTC (permalink / raw)
  To: linux-kernel
  Cc: Jiri Olsa, Adrian Hunter, Arnaldo Carvalho de Melo,
	Corey Ashford, David Ahern, Frederic Weisbecker, Ingo Molnar,
	Namhyung Kim, Paul Mackerras, Peter Zijlstra, Stephane Eranian

Will be used to decompress 'xz' objects. The check detects
the liblzma.so devel library normally delivered by xz package.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
---
 tools/perf/config/Makefile                   |  6 ++++--
 tools/perf/config/feature-checks/Makefile    |  6 +++++-
 tools/perf/config/feature-checks/test-lzma.c | 10 ++++++++++
 3 files changed, 19 insertions(+), 3 deletions(-)
 create mode 100644 tools/perf/config/feature-checks/test-lzma.c

diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index d44c64d64465..d77bcea691dd 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -228,7 +228,8 @@ CORE_FEATURE_TESTS =			\
 	timerfd				\
 	libdw-dwarf-unwind		\
 	libbabeltrace			\
-	zlib
+	zlib				\
+	lzma
 
 LIB_FEATURE_TESTS =			\
 	dwarf				\
@@ -244,7 +245,8 @@ LIB_FEATURE_TESTS =			\
 	libunwind			\
 	libdw-dwarf-unwind		\
 	libbabeltrace			\
-	zlib
+	zlib				\
+	lzma
 
 VF_FEATURE_TESTS =			\
 	backtrace			\
diff --git a/tools/perf/config/feature-checks/Makefile b/tools/perf/config/feature-checks/Makefile
index 8fe067864957..f7b1b7934782 100644
--- a/tools/perf/config/feature-checks/Makefile
+++ b/tools/perf/config/feature-checks/Makefile
@@ -32,7 +32,8 @@ FILES=					\
 	test-libbabeltrace.bin		\
 	test-compile-32.bin		\
 	test-compile-x32.bin		\
-	test-zlib.bin
+	test-zlib.bin			\
+	test-lzma.bin
 
 CC := $(CROSS_COMPILE)gcc -MD
 PKG_CONFIG := $(CROSS_COMPILE)pkg-config
@@ -151,6 +152,9 @@ test-compile-x32.bin:
 test-zlib.bin:
 	$(BUILD) -lz
 
+test-lzma.bin:
+	$(BUILD) -llzma
+
 -include *.d
 
 ###############################
diff --git a/tools/perf/config/feature-checks/test-lzma.c b/tools/perf/config/feature-checks/test-lzma.c
new file mode 100644
index 000000000000..95adc8ced3dd
--- /dev/null
+++ b/tools/perf/config/feature-checks/test-lzma.c
@@ -0,0 +1,10 @@
+#include <lzma.h>
+
+int main(void)
+{
+	lzma_stream strm = LZMA_STREAM_INIT;
+	int ret;
+
+	ret = lzma_stream_decoder(&strm, UINT64_MAX, LZMA_CONCATENATED);
+	return ret ? -1 : 0;
+}
-- 
1.9.3


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

* [PATCH 03/14] perf tools: Add lzma decompression support for kernel module
  2015-03-03 15:29 [PATCH 0/3] perf tools: Adding xz decompression support Jiri Olsa
  2015-03-03 15:29 ` [PATCH 01/14] perf tools: Remove superfluous thread->comm_set setting Jiri Olsa
  2015-03-03 15:29 ` [PATCH 02/14] perf tools: Add feature check for lzma library Jiri Olsa
@ 2015-03-03 15:29 ` Jiri Olsa
  2015-03-03 15:29 ` [PATCH 04/14] perf tools: Add kmod_path__parse function Jiri Olsa
                   ` (12 subsequent siblings)
  15 siblings, 0 replies; 26+ messages in thread
From: Jiri Olsa @ 2015-03-03 15:29 UTC (permalink / raw)
  To: linux-kernel
  Cc: Jiri Olsa, Adrian Hunter, Arnaldo Carvalho de Melo,
	Corey Ashford, David Ahern, Frederic Weisbecker, Ingo Molnar,
	Namhyung Kim, Paul Mackerras, Peter Zijlstra, Stephane Eranian

In short, Fedora compresses kernel modules now (since version 21)
with lzma compression.

Adding lzma decompress support into the dso.c:compressions array
introduced by Nmahyung earlier.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
---
 tools/perf/Makefile.perf   |  2 +
 tools/perf/config/Makefile | 10 +++++
 tools/perf/util/Build      |  1 +
 tools/perf/util/dso.c      |  3 ++
 tools/perf/util/lzma.c     | 95 ++++++++++++++++++++++++++++++++++++++++++++++
 tools/perf/util/util.h     |  4 ++
 6 files changed, 115 insertions(+)
 create mode 100644 tools/perf/util/lzma.c

diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
index ec4c063ed9f3..9b981c9e3340 100644
--- a/tools/perf/Makefile.perf
+++ b/tools/perf/Makefile.perf
@@ -71,6 +71,8 @@ include config/utilities.mak
 #
 # Define NO_LIBBABELTRACE if you do not want libbabeltrace support
 # for CTF data format.
+#
+# Define NO_LZMA if you do not want to support compressed (xz) kernel modules
 
 ifeq ($(srctree),)
 srctree := $(patsubst %/,%,$(dir $(shell pwd)))
diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index d77bcea691dd..ba9f9811812e 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -660,6 +660,16 @@ ifndef NO_ZLIB
   endif
 endif
 
+ifndef NO_LZMA
+  ifeq ($(feature-lzma), 1)
+    CFLAGS += -DHAVE_LZMA_SUPPORT
+    EXTLIBS += -llzma
+    $(call detected,CONFIG_LZMA)
+  else
+    NO_LZMA := 1
+  endif
+endif
+
 ifndef NO_BACKTRACE
   ifeq ($(feature-backtrace), 1)
     CFLAGS += -DHAVE_BACKTRACE_SUPPORT
diff --git a/tools/perf/util/Build b/tools/perf/util/Build
index 972a6e0da7ad..797490a40075 100644
--- a/tools/perf/util/Build
+++ b/tools/perf/util/Build
@@ -94,6 +94,7 @@ libperf-y += scripting-engines/
 
 libperf-$(CONFIG_PERF_REGS) += perf_regs.o
 libperf-$(CONFIG_ZLIB) += zlib.o
+libperf-$(CONFIG_LZMA) += lzma.o
 
 CFLAGS_config.o   += -DETC_PERFCONFIG="BUILD_STR($(ETC_PERFCONFIG_SQ))"
 CFLAGS_exec_cmd.o += -DPERF_EXEC_PATH="BUILD_STR($(perfexecdir_SQ))" -DPREFIX="BUILD_STR($(prefix_SQ))"
diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
index 814554d1b857..be368414036c 100644
--- a/tools/perf/util/dso.c
+++ b/tools/perf/util/dso.c
@@ -148,6 +148,9 @@ static const struct {
 #ifdef HAVE_ZLIB_SUPPORT
 	{ "gz", gzip_decompress_to_file },
 #endif
+#ifdef HAVE_LZMA_SUPPORT
+	{ "xz", lzma_decompress_to_file },
+#endif
 	{ NULL, NULL },
 };
 
diff --git a/tools/perf/util/lzma.c b/tools/perf/util/lzma.c
new file mode 100644
index 000000000000..95a1acb61245
--- /dev/null
+++ b/tools/perf/util/lzma.c
@@ -0,0 +1,95 @@
+#include <lzma.h>
+#include <stdio.h>
+#include <linux/compiler.h>
+#include "util.h"
+#include "debug.h"
+
+#define BUFSIZE 8192
+
+static const char *lzma_strerror(lzma_ret ret)
+{
+	switch ((int) ret) {
+	case LZMA_MEM_ERROR:
+		return "Memory allocation failed";
+	case LZMA_OPTIONS_ERROR:
+		return "Unsupported decompressor flags";
+	case LZMA_FORMAT_ERROR:
+		return "The input is not in the .xz format";
+	case LZMA_DATA_ERROR:
+		return "Compressed file is corrupt";
+	case LZMA_BUF_ERROR:
+		return "Compressed file is truncated or otherwise corrupt";
+	default:
+		return "Unknown error, possibly a bug";
+	}
+}
+
+int lzma_decompress_to_file(const char *input, int output_fd)
+{
+	lzma_action action = LZMA_RUN;
+	lzma_stream strm   = LZMA_STREAM_INIT;
+	lzma_ret ret;
+
+	u8 buf_in[BUFSIZE];
+	u8 buf_out[BUFSIZE];
+	FILE *infile;
+
+	infile = fopen(input, "rb");
+	if (!infile) {
+		pr_err("lzma: fopen failed on %s: '%s'\n",
+		       input, strerror(errno));
+		return -1;
+	}
+
+	ret = lzma_stream_decoder(&strm, UINT64_MAX, LZMA_CONCATENATED);
+	if (ret != LZMA_OK) {
+		pr_err("lzma: lzma_stream_decoder failed %s (%d)\n",
+			lzma_strerror(ret), ret);
+		return -1;
+	}
+
+	strm.next_in   = NULL;
+	strm.avail_in  = 0;
+	strm.next_out  = buf_out;
+	strm.avail_out = sizeof(buf_out);
+
+	while (1) {
+		if (strm.avail_in == 0 && !feof(infile)) {
+			strm.next_in  = buf_in;
+			strm.avail_in = fread(buf_in, 1, sizeof(buf_in), infile);
+
+			if (ferror(infile)) {
+				pr_err("lzma: read error: %s\n", strerror(errno));
+				return -1;
+			}
+
+			if (feof(infile))
+				action = LZMA_FINISH;
+		}
+
+		ret = lzma_code(&strm, action);
+
+		if (strm.avail_out == 0 || ret == LZMA_STREAM_END) {
+			ssize_t write_size = sizeof(buf_out) - strm.avail_out;
+
+			if (writen(output_fd, buf_out, write_size) != write_size) {
+				pr_err("lzma: write error: %s\n", strerror(errno));
+				return -1;
+			}
+
+			strm.next_out  = buf_out;
+			strm.avail_out = sizeof(buf_out);
+		}
+
+		if (ret != LZMA_OK) {
+			if (ret == LZMA_STREAM_END)
+				return 0;
+
+			pr_err("lzma: failed %s\n", lzma_strerror(ret));
+			return -1;
+		}
+	}
+
+	fclose(infile);
+	return 0;
+}
diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h
index fbd598afc606..1ff23e04ad27 100644
--- a/tools/perf/util/util.h
+++ b/tools/perf/util/util.h
@@ -329,4 +329,8 @@ bool find_process(const char *name);
 int gzip_decompress_to_file(const char *input, int output_fd);
 #endif
 
+#ifdef HAVE_LZMA_SUPPORT
+int lzma_decompress_to_file(const char *input, int output_fd);
+#endif
+
 #endif /* GIT_COMPAT_UTIL_H */
-- 
1.9.3


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

* [PATCH 04/14] perf tools: Add kmod_path__parse function
  2015-03-03 15:29 [PATCH 0/3] perf tools: Adding xz decompression support Jiri Olsa
                   ` (2 preceding siblings ...)
  2015-03-03 15:29 ` [PATCH 03/14] perf tools: Add lzma decompression support for kernel module Jiri Olsa
@ 2015-03-03 15:29 ` Jiri Olsa
  2015-03-03 15:29 ` [PATCH 05/14] perf tools: Add dsos__new function Jiri Olsa
                   ` (11 subsequent siblings)
  15 siblings, 0 replies; 26+ messages in thread
From: Jiri Olsa @ 2015-03-03 15:29 UTC (permalink / raw)
  To: linux-kernel
  Cc: Jiri Olsa, Adrian Hunter, Arnaldo Carvalho de Melo,
	Corey Ashford, David Ahern, Frederic Weisbecker, Ingo Molnar,
	Namhyung Kim, Paul Mackerras, Peter Zijlstra, Stephane Eranian

Provides united way of parsing kernel module path
into several components.

The new kmod_path__parse function and few defines:

  int __kmod_path__parse(struct kmod_path *m, const char *path,
                         bool alloc_name, bool alloc_ext);

  #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)

parse kernel module @path and updates @m argument like:

  @comp - true if @path contains supported compression suffix,
          false otherwise
  @kmod - true if @path contains '.ko' suffix in right position,
          false otherwise
  @name - if (@alloc_name && @kmod) is true, it contains strdup-ed base name
          of the kernel module without suffixes, otherwise strudup-ed
          base name of @path
  @ext  - if (@alloc_ext && @comp) is true, it contains strdup-ed string
          the compression suffix

It returns 0 if there's no strdup error, -ENOMEM otherwise.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
---
 tools/perf/tests/Build          |  1 +
 tools/perf/tests/builtin-test.c |  4 +++
 tools/perf/tests/kmod-path.c    | 73 +++++++++++++++++++++++++++++++++++++++++
 tools/perf/tests/tests.h        |  1 +
 tools/perf/util/util.c          | 66 +++++++++++++++++++++++++++++++++++++
 tools/perf/util/util.h          | 14 ++++++++
 6 files changed, 159 insertions(+)
 create mode 100644 tools/perf/tests/kmod-path.c

diff --git a/tools/perf/tests/Build b/tools/perf/tests/Build
index 2de01a4b4084..6a8801b32017 100644
--- a/tools/perf/tests/Build
+++ b/tools/perf/tests/Build
@@ -30,6 +30,7 @@ perf-y += keep-tracking.o
 perf-y += code-reading.o
 perf-y += sample-parsing.o
 perf-y += parse-no-sample-id-all.o
+perf-y += kmod-path.o
 
 perf-$(CONFIG_X86) += perf-time-to-tsc.o
 
diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c
index 4b7d9ab0f049..31f9959c04c8 100644
--- a/tools/perf/tests/builtin-test.c
+++ b/tools/perf/tests/builtin-test.c
@@ -167,6 +167,10 @@ static struct test {
 		.func = test__fdarray__add,
 	},
 	{
+		.desc = "Test kmod_path__parse function",
+		.func = test__kmod_path__parse,
+	},
+	{
 		.func = NULL,
 	},
 };
diff --git a/tools/perf/tests/kmod-path.c b/tools/perf/tests/kmod-path.c
new file mode 100644
index 000000000000..277cb851722b
--- /dev/null
+++ b/tools/perf/tests/kmod-path.c
@@ -0,0 +1,73 @@
+#include <stdbool.h>
+#include "tests.h"
+#include "util.h"
+#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)
+{
+	struct kmod_path m;
+
+	memset(&m, 0x0, sizeof(m));
+
+	TEST_ASSERT_VAL("kmod_path__parse",
+			!__kmod_path__parse(&m, path, alloc_name, alloc_ext));
+
+	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);
+
+	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;
+}
+
+#define T(path, an, ae, k, c, n, e) \
+	TEST_ASSERT_VAL("failed", !test(path, an, ae, k, c, n, e))
+
+int test__kmod_path__parse(void)
+{
+	/* 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);
+
+	/* 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);
+
+	/* 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);
+
+	/* 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);
+
+	/* 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);
+
+	return 0;
+}
diff --git a/tools/perf/tests/tests.h b/tools/perf/tests/tests.h
index 00e776a87a9c..52758a33f64c 100644
--- a/tools/perf/tests/tests.h
+++ b/tools/perf/tests/tests.h
@@ -51,6 +51,7 @@ int test__hists_cumulate(void);
 int test__switch_tracking(void);
 int test__fdarray__filter(void);
 int test__fdarray__add(void);
+int test__kmod_path__parse(void);
 
 #if defined(__x86_64__) || defined(__i386__) || defined(__arm__)
 #ifdef HAVE_DWARF_UNWIND_SUPPORT
diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c
index 4ee6d0d4c993..6226502b038f 100644
--- a/tools/perf/util/util.c
+++ b/tools/perf/util/util.c
@@ -615,3 +615,69 @@ bool find_process(const char *name)
 	closedir(dir);
 	return ret ? false : true;
 }
+
+/*
+ * Parses kernel module specified in @path and updates
+ * @m argument like:
+ *
+ *    @comp - true if @path contains supported compression suffix,
+ *            false otherwise
+ *    @kmod - true if @path contains '.ko' suffix in right position,
+ *            false otherwise
+ *    @name - if (@alloc_name && @kmod) is true, it contains strdup-ed base name
+ *            of the kernel module without suffixes, otherwise strudup-ed
+ *            base name of @path
+ *    @ext  - if (@alloc_ext && @comp) is true, it contains strdup-ed string
+ *            the compression suffix
+ *
+ * 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)
+{
+	const char *name = strrchr(path, '/');
+	const char *ext  = strrchr(path, '.');
+
+	memset(m, 0x0, sizeof(*m));
+	name = name ? name + 1 : path;
+
+	/* No extension, just return name. */
+	if (ext == NULL) {
+		if (alloc_name) {
+			m->name = strdup(name);
+			return m->name ? 0 : -ENOMEM;
+		}
+		return 0;
+	}
+
+	if (is_supported_compression(ext + 1)) {
+		m->comp = true;
+		ext -= 3;
+	}
+
+	/* Check .ko extension only if there's enough name left. */
+	if (ext > name)
+		m->kmod = !strncmp(ext, ".ko", 3);
+
+	if (alloc_name) {
+		if (m->kmod) {
+			if (asprintf(&m->name, "[%.*s]", (int) (ext - name), name) == -1)
+				return -ENOMEM;
+		} else {
+			if (asprintf(&m->name, "%s", name) == -1)
+				return -ENOMEM;
+		}
+
+		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/util.h b/tools/perf/util/util.h
index 1ff23e04ad27..ddca38a901e8 100644
--- a/tools/perf/util/util.h
+++ b/tools/perf/util/util.h
@@ -292,6 +292,20 @@ struct parse_tag {
 
 unsigned long parse_tag_value(const char *str, struct parse_tag *tags);
 
+struct kmod_path {
+	char *name;
+	char *ext;
+	bool  comp;
+	bool  kmod;
+};
+
+int __kmod_path__parse(struct kmod_path *m, const char *path,
+		     bool alloc_name, bool alloc_ext);
+
+#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 SRCLINE_UNKNOWN  ((char *) "??:0")
 
 static inline int path__join(char *bf, size_t size,
-- 
1.9.3


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

* [PATCH 05/14] perf tools: Add dsos__new function
  2015-03-03 15:29 [PATCH 0/3] perf tools: Adding xz decompression support Jiri Olsa
                   ` (3 preceding siblings ...)
  2015-03-03 15:29 ` [PATCH 04/14] perf tools: Add kmod_path__parse function Jiri Olsa
@ 2015-03-03 15:29 ` Jiri Olsa
  2015-03-03 16:20   ` Arnaldo Carvalho de Melo
  2015-03-03 15:29 ` [PATCH 06/14] perf tools: Add machine__module_dso function Jiri Olsa
                   ` (10 subsequent siblings)
  15 siblings, 1 reply; 26+ messages in thread
From: Jiri Olsa @ 2015-03-03 15:29 UTC (permalink / raw)
  To: linux-kernel
  Cc: Jiri Olsa, Adrian Hunter, Arnaldo Carvalho de Melo,
	Corey Ashford, David Ahern, Frederic Weisbecker, Ingo Molnar,
	Namhyung Kim, Paul Mackerras, Peter Zijlstra, Stephane Eranian

Separate the creation of new dso object and its addition
to the dsos list. It will be used in following patch.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
---
 tools/perf/util/dso.c | 21 ++++++++++++---------
 tools/perf/util/dso.h |  1 +
 2 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
index be368414036c..fc54cb81c7f8 100644
--- a/tools/perf/util/dso.c
+++ b/tools/perf/util/dso.c
@@ -1005,21 +1005,24 @@ struct dso *dsos__find(const struct dsos *dsos, const char *name,
 	return dso__find_by_longname(&dsos->root, name);
 }
 
-struct dso *__dsos__findnew(struct dsos *dsos, const char *name)
+struct dso *dsos__new(struct dsos *dsos, const char *name)
 {
-	struct dso *dso = dsos__find(dsos, name, false);
+	struct dso *dso = dso__new(name);
 
-	if (!dso) {
-		dso = dso__new(name);
-		if (dso != NULL) {
-			dsos__add(dsos, dso);
-			dso__set_basename(dso);
-		}
+	if (dso != NULL) {
+		dsos__add(dsos, dso);
+		dso__set_basename(dso);
 	}
-
 	return dso;
 }
 
+struct dso *__dsos__findnew(struct dsos *dsos, const char *name)
+{
+	struct dso *dso = dsos__find(dsos, name, false);
+
+	return dso ? dso : dsos__new(dsos, name);
+}
+
 size_t __dsos__fprintf_buildid(struct list_head *head, FILE *fp,
 			       bool (skip)(struct dso *dso, int parm), int parm)
 {
diff --git a/tools/perf/util/dso.h b/tools/perf/util/dso.h
index ced92841ff97..a712cbcd3a72 100644
--- a/tools/perf/util/dso.h
+++ b/tools/perf/util/dso.h
@@ -249,6 +249,7 @@ struct dso *dso__kernel_findnew(struct machine *machine, const char *name,
 				const char *short_name, int dso_type);
 
 void dsos__add(struct dsos *dsos, struct dso *dso);
+struct dso *dsos__new(struct dsos *dsos, const char *name);
 struct dso *dsos__find(const struct dsos *dsos, const char *name,
 		       bool cmp_short);
 struct dso *__dsos__findnew(struct dsos *dsos, const char *name);
-- 
1.9.3


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

* [PATCH 06/14] perf tools: Add machine__module_dso function
  2015-03-03 15:29 [PATCH 0/3] perf tools: Adding xz decompression support Jiri Olsa
                   ` (4 preceding siblings ...)
  2015-03-03 15:29 ` [PATCH 05/14] perf tools: Add dsos__new function Jiri Olsa
@ 2015-03-03 15:29 ` Jiri Olsa
  2015-03-03 15:29 ` [PATCH 07/14] perf tools: Use kmod_path__parse for machine__new_dso Jiri Olsa
                   ` (9 subsequent siblings)
  15 siblings, 0 replies; 26+ messages in thread
From: Jiri Olsa @ 2015-03-03 15:29 UTC (permalink / raw)
  To: linux-kernel
  Cc: Jiri Olsa, Adrian Hunter, Arnaldo Carvalho de Melo,
	Corey Ashford, David Ahern, Frederic Weisbecker, Ingo Molnar,
	Namhyung Kim, Paul Mackerras, Peter Zijlstra, Stephane Eranian

Separate the dso object addition and update when adding
new kernel module.

Currently we update dso's symtab_type any time we find
it in the list, because we can't distinguish between
new and found dso from __dsos__findnew function.

Adding machine__module_dso that separates finding and adding
new dso objects, so there's no superfluous update of dso.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
---
 tools/perf/util/machine.c | 36 +++++++++++++++++++++++++-----------
 1 file changed, 25 insertions(+), 11 deletions(-)

diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index 24f8c978cfd4..14f7caf4824a 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -460,12 +460,35 @@ int machine__process_lost_event(struct machine *machine __maybe_unused,
 	return 0;
 }
 
+static struct dso *machine__module_dso(struct machine *machine, const char *filename)
+{
+	struct dso *dso;
+	bool compressed;
+
+	dso = dsos__find(&machine->kernel_dsos, filename, false);
+	if (!dso) {
+		dso = dsos__new(&machine->kernel_dsos, filename);
+		if (dso == NULL)
+			return NULL;
+
+		if (machine__is_host(machine))
+			dso->symtab_type = DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE;
+		else
+			dso->symtab_type = DSO_BINARY_TYPE__GUEST_KMODULE;
+
+		/* _KMODULE_COMP should be next to _KMODULE */
+		if (is_kernel_module(filename, &compressed) && compressed)
+			dso->symtab_type++;
+	}
+
+	return dso;
+}
+
 struct map *machine__new_module(struct machine *machine, u64 start,
 				const char *filename)
 {
 	struct map *map;
-	struct dso *dso = __dsos__findnew(&machine->kernel_dsos, filename);
-	bool compressed;
+	struct dso *dso = machine__module_dso(machine, filename);
 
 	if (dso == NULL)
 		return NULL;
@@ -474,15 +497,6 @@ struct map *machine__new_module(struct machine *machine, u64 start,
 	if (map == NULL)
 		return NULL;
 
-	if (machine__is_host(machine))
-		dso->symtab_type = DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE;
-	else
-		dso->symtab_type = DSO_BINARY_TYPE__GUEST_KMODULE;
-
-	/* _KMODULE_COMP should be next to _KMODULE */
-	if (is_kernel_module(filename, &compressed) && compressed)
-		dso->symtab_type++;
-
 	map_groups__insert(&machine->kmaps, map);
 	return map;
 }
-- 
1.9.3


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

* [PATCH 07/14] perf tools: Use kmod_path__parse for machine__new_dso
  2015-03-03 15:29 [PATCH 0/3] perf tools: Adding xz decompression support Jiri Olsa
                   ` (5 preceding siblings ...)
  2015-03-03 15:29 ` [PATCH 06/14] perf tools: Add machine__module_dso function Jiri Olsa
@ 2015-03-03 15:29 ` Jiri Olsa
  2015-03-03 15:29 ` [PATCH 08/14] perf tools: Use kmod_path__parse in map_groups__set_modules_path_dir Jiri Olsa
                   ` (8 subsequent siblings)
  15 siblings, 0 replies; 26+ messages in thread
From: Jiri Olsa @ 2015-03-03 15:29 UTC (permalink / raw)
  To: linux-kernel
  Cc: Jiri Olsa, Adrian Hunter, Arnaldo Carvalho de Melo,
	Corey Ashford, David Ahern, Frederic Weisbecker, Ingo Molnar,
	Namhyung Kim, Paul Mackerras, Peter Zijlstra, Stephane Eranian

Using kmod_path__parse to get the module name and update
the dso short name within machine__new_dso function.

This way it's done only first time when dso is created,
unlike the current way when we update it all the time
we process memory map of the kernel module.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
---
 tools/perf/util/machine.c | 57 +++++++++++++++++------------------------------
 1 file changed, 20 insertions(+), 37 deletions(-)

diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index 14f7caf4824a..5a58cdd141ae 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -460,14 +460,15 @@ int machine__process_lost_event(struct machine *machine __maybe_unused,
 	return 0;
 }
 
-static struct dso *machine__module_dso(struct machine *machine, const char *filename)
+static struct dso*
+machine__module_dso(struct machine *machine, struct kmod_path *m,
+		    const char *filename)
 {
 	struct dso *dso;
-	bool compressed;
 
-	dso = dsos__find(&machine->kernel_dsos, filename, false);
+	dso = dsos__find(&machine->kernel_dsos, m->name, true);
 	if (!dso) {
-		dso = dsos__new(&machine->kernel_dsos, filename);
+		dso = dsos__new(&machine->kernel_dsos, m->name);
 		if (dso == NULL)
 			return NULL;
 
@@ -477,8 +478,11 @@ static struct dso *machine__module_dso(struct machine *machine, const char *file
 			dso->symtab_type = DSO_BINARY_TYPE__GUEST_KMODULE;
 
 		/* _KMODULE_COMP should be next to _KMODULE */
-		if (is_kernel_module(filename, &compressed) && compressed)
+		if (m->kmod && m->comp)
 			dso->symtab_type++;
+
+		dso__set_short_name(dso, strdup(m->name), true);
+		dso__set_long_name(dso, strdup(filename), true);
 	}
 
 	return dso;
@@ -488,16 +492,24 @@ struct map *machine__new_module(struct machine *machine, u64 start,
 				const char *filename)
 {
 	struct map *map;
-	struct dso *dso = machine__module_dso(machine, filename);
+	struct dso *dso;
+	struct kmod_path m;
 
-	if (dso == NULL)
+	if (kmod_path__parse_name(&m, filename))
 		return NULL;
 
+	dso = machine__module_dso(machine, &m, filename);
+	if (dso == NULL)
+		goto out;
+
 	map = map__new2(start, dso, MAP__FUNCTION);
 	if (map == NULL)
-		return NULL;
+		goto out;
 
 	map_groups__insert(&machine->kmaps, map);
+
+out:
+	free(m.name);
 	return map;
 }
 
@@ -1058,40 +1070,11 @@ static int machine__process_kernel_mmap_event(struct machine *machine,
 				strlen(kmmap_prefix) - 1) == 0;
 	if (event->mmap.filename[0] == '/' ||
 	    (!is_kernel_mmap && event->mmap.filename[0] == '[')) {
-
-		char short_module_name[1024];
-		char *name, *dot;
-
-		if (event->mmap.filename[0] == '/') {
-			name = strrchr(event->mmap.filename, '/');
-			if (name == NULL)
-				goto out_problem;
-
-			++name; /* skip / */
-			dot = strrchr(name, '.');
-			if (dot == NULL)
-				goto out_problem;
-			/* On some system, modules are compressed like .ko.gz */
-			if (is_supported_compression(dot + 1))
-				dot -= 3;
-			if (!is_kmodule_extension(dot + 1))
-				goto out_problem;
-			snprintf(short_module_name, sizeof(short_module_name),
-					"[%.*s]", (int)(dot - name), name);
-			strxfrchar(short_module_name, '-', '_');
-		} else
-			strcpy(short_module_name, event->mmap.filename);
-
 		map = machine__new_module(machine, event->mmap.start,
 					  event->mmap.filename);
 		if (map == NULL)
 			goto out_problem;
 
-		name = strdup(short_module_name);
-		if (name == NULL)
-			goto out_problem;
-
-		dso__set_short_name(map->dso, name, true);
 		map->end = map->start + event->mmap.len;
 	} else if (is_kernel_mmap) {
 		const char *symbol_name = (event->mmap.filename +
-- 
1.9.3


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

* [PATCH 08/14] perf tools: Use kmod_path__parse in map_groups__set_modules_path_dir
  2015-03-03 15:29 [PATCH 0/3] perf tools: Adding xz decompression support Jiri Olsa
                   ` (6 preceding siblings ...)
  2015-03-03 15:29 ` [PATCH 07/14] perf tools: Use kmod_path__parse for machine__new_dso Jiri Olsa
@ 2015-03-03 15:29 ` Jiri Olsa
  2015-03-03 15:29 ` [PATCH 09/14] perf tools: Use kmod_path__parse in decompress_kmodule Jiri Olsa
                   ` (7 subsequent siblings)
  15 siblings, 0 replies; 26+ messages in thread
From: Jiri Olsa @ 2015-03-03 15:29 UTC (permalink / raw)
  To: linux-kernel
  Cc: Jiri Olsa, Adrian Hunter, Arnaldo Carvalho de Melo,
	Corey Ashford, David Ahern, Frederic Weisbecker, Ingo Molnar,
	Namhyung Kim, Paul Mackerras, Peter Zijlstra, Stephane Eranian

Replacing the file name parsing with kmod_path__parse
and moving the dso update into new separate function.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
---
 tools/perf/util/machine.c | 54 ++++++++++++++++++++++++++---------------------
 1 file changed, 30 insertions(+), 24 deletions(-)

diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index 5a58cdd141ae..0c2d9e68996b 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -851,6 +851,28 @@ static char *get_kernel_version(const char *root_dir)
 	return strdup(name);
 }
 
+static int map_groups__set_module_path(struct map_groups *mg, const char *path,
+				       struct kmod_path *m)
+{
+	struct map *map;
+	char *long_name;
+
+	map = map_groups__find_by_name(mg, MAP__FUNCTION, m->name);
+	if (map == NULL)
+		return 0;
+
+	long_name = strdup(path);
+	if (long_name == NULL)
+		return -ENOMEM;
+
+	dso__set_long_name(map->dso, long_name, true);
+	dso__kernel_module_get_build_id(map->dso, "");
+
+	if (m->comp)
+		map->dso->symtab_type++;
+	return 0;
+}
+
 static int map_groups__set_modules_path_dir(struct map_groups *mg,
 				const char *dir_name, int depth)
 {
@@ -889,35 +911,19 @@ static int map_groups__set_modules_path_dir(struct map_groups *mg,
 			if (ret < 0)
 				goto out;
 		} else {
-			char *dot = strrchr(dent->d_name, '.'),
-			     dso_name[PATH_MAX];
-			struct map *map;
-			char *long_name;
-
-			if (dot == NULL)
-				continue;
+			struct kmod_path m;
 
-			/* On some system, modules are compressed like .ko.gz */
-			if (is_supported_compression(dot + 1) &&
-			    is_kmodule_extension(dot - 2))
-				dot -= 3;
+			ret = kmod_path__parse_name(&m, dent->d_name);
+			if (ret)
+				goto out;
 
-			snprintf(dso_name, sizeof(dso_name), "[%.*s]",
-				 (int)(dot - dent->d_name), dent->d_name);
+			if (m.kmod)
+				ret = map_groups__set_module_path(mg, path, &m);
 
-			strxfrchar(dso_name, '-', '_');
-			map = map_groups__find_by_name(mg, MAP__FUNCTION,
-						       dso_name);
-			if (map == NULL)
-				continue;
+			free(m.name);
 
-			long_name = strdup(path);
-			if (long_name == NULL) {
-				ret = -1;
+			if (ret)
 				goto out;
-			}
-			dso__set_long_name(map->dso, long_name, true);
-			dso__kernel_module_get_build_id(map->dso, "");
 		}
 	}
 
-- 
1.9.3


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

* [PATCH 09/14] perf tools: Use kmod_path__parse in decompress_kmodule
  2015-03-03 15:29 [PATCH 0/3] perf tools: Adding xz decompression support Jiri Olsa
                   ` (7 preceding siblings ...)
  2015-03-03 15:29 ` [PATCH 08/14] perf tools: Use kmod_path__parse in map_groups__set_modules_path_dir Jiri Olsa
@ 2015-03-03 15:29 ` Jiri Olsa
  2015-03-04  1:42   ` Namhyung Kim
  2015-03-03 15:29 ` [PATCH 10/14] perf tools: Use kmod_path__parse in is_kernel_module Jiri Olsa
                   ` (6 subsequent siblings)
  15 siblings, 1 reply; 26+ messages in thread
From: Jiri Olsa @ 2015-03-03 15:29 UTC (permalink / raw)
  To: linux-kernel
  Cc: Jiri Olsa, Adrian Hunter, Arnaldo Carvalho de Melo,
	Corey Ashford, David Ahern, Frederic Weisbecker, Ingo Molnar,
	Namhyung Kim, Paul Mackerras, Peter Zijlstra, Stephane Eranian

Replacing the file name parsing with kmod_path__parse.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
---
 tools/perf/util/symbol-elf.c | 25 +++++++++++++++++--------
 1 file changed, 17 insertions(+), 8 deletions(-)

diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c
index ada16762fac2..8dd530ce20c5 100644
--- a/tools/perf/util/symbol-elf.c
+++ b/tools/perf/util/symbol-elf.c
@@ -579,32 +579,41 @@ static int dso__swap_init(struct dso *dso, unsigned char eidata)
 static int decompress_kmodule(struct dso *dso, const char *name,
 			      enum dso_binary_type type)
 {
-	int fd;
-	const char *ext = strrchr(name, '.');
+	int fd = -1, try = 2;
 	char tmpbuf[] = "/tmp/perf-kmod-XXXXXX";
+	struct kmod_path m;
 
 	if (type != DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE_COMP &&
 	    type != DSO_BINARY_TYPE__GUEST_KMODULE_COMP &&
 	    type != DSO_BINARY_TYPE__BUILD_ID_CACHE)
 		return -1;
 
-	if (!ext || !is_supported_compression(ext + 1)) {
-		ext = strrchr(dso->name, '.');
-		if (!ext || !is_supported_compression(ext + 1))
-			return -1;
+again:
+	if (kmod_path__parse_ext(&m, name))
+		return -1;
+
+	if (!m.comp) {
+		if (!--try)
+			goto out;
+
+		free(m.ext);
+		name = dso->name;
+		goto again;
 	}
 
 	fd = mkstemp(tmpbuf);
 	if (fd < 0)
-		return -1;
+		goto out;
 
-	if (!decompress_to_file(ext + 1, name, fd)) {
+	if (!decompress_to_file(m.ext, name, fd)) {
 		close(fd);
 		fd = -1;
 	}
 
 	unlink(tmpbuf);
 
+out:
+	free(m.ext);
 	return fd;
 }
 
-- 
1.9.3


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

* [PATCH 10/14] perf tools: Use kmod_path__parse in is_kernel_module
  2015-03-03 15:29 [PATCH 0/3] perf tools: Adding xz decompression support Jiri Olsa
                   ` (8 preceding siblings ...)
  2015-03-03 15:29 ` [PATCH 09/14] perf tools: Use kmod_path__parse in decompress_kmodule Jiri Olsa
@ 2015-03-03 15:29 ` Jiri Olsa
  2015-03-03 15:29 ` [PATCH 11/14] perf tools: Remove compressed argument from is_kernel_module Jiri Olsa
                   ` (5 subsequent siblings)
  15 siblings, 0 replies; 26+ messages in thread
From: Jiri Olsa @ 2015-03-03 15:29 UTC (permalink / raw)
  To: linux-kernel
  Cc: Jiri Olsa, Adrian Hunter, Arnaldo Carvalho de Melo,
	Corey Ashford, David Ahern, Frederic Weisbecker, Ingo Molnar,
	Namhyung Kim, Paul Mackerras, Peter Zijlstra, Stephane Eranian

Replacing the current parsing code with kmod_path__parse
function call.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
---
 tools/perf/util/dso.c | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
index fc54cb81c7f8..a17e5301af29 100644
--- a/tools/perf/util/dso.c
+++ b/tools/perf/util/dso.c
@@ -178,19 +178,15 @@ bool is_kmodule_extension(const char *ext)
 
 bool is_kernel_module(const char *pathname, bool *compressed)
 {
-	const char *ext = strrchr(pathname, '.');
+	struct kmod_path m;
 
-	if (ext == NULL)
-		return false;
+	if (kmod_path__parse(&m, pathname))
+		return NULL;
 
-	if (is_supported_compression(ext + 1)) {
-		if (compressed)
-			*compressed = true;
-		ext -= 3;
-	} else if (compressed)
-		*compressed = false;
+	if (compressed)
+		*compressed = m.comp;
 
-	return is_kmodule_extension(ext + 1);
+	return m.kmod;
 }
 
 bool decompress_to_file(const char *ext, const char *filename, int output_fd)
-- 
1.9.3


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

* [PATCH 11/14] perf tools: Remove compressed argument from is_kernel_module
  2015-03-03 15:29 [PATCH 0/3] perf tools: Adding xz decompression support Jiri Olsa
                   ` (9 preceding siblings ...)
  2015-03-03 15:29 ` [PATCH 10/14] perf tools: Use kmod_path__parse in is_kernel_module Jiri Olsa
@ 2015-03-03 15:29 ` Jiri Olsa
  2015-03-03 15:29 ` [PATCH 12/14] perf tools: Remove is_kmodule_extension function Jiri Olsa
                   ` (4 subsequent siblings)
  15 siblings, 0 replies; 26+ messages in thread
From: Jiri Olsa @ 2015-03-03 15:29 UTC (permalink / raw)
  To: linux-kernel
  Cc: Jiri Olsa, Adrian Hunter, Arnaldo Carvalho de Melo,
	Corey Ashford, David Ahern, Frederic Weisbecker, Ingo Molnar,
	Namhyung Kim, Paul Mackerras, Peter Zijlstra, Stephane Eranian

We no longer need the 'compressed' argument, because all
current users use 'NULL' for it.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
---
 tools/perf/util/dso.c     | 5 +----
 tools/perf/util/dso.h     | 2 +-
 tools/perf/util/header.c  | 2 +-
 tools/perf/util/machine.c | 2 +-
 4 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
index a17e5301af29..e2eeadfad275 100644
--- a/tools/perf/util/dso.c
+++ b/tools/perf/util/dso.c
@@ -176,16 +176,13 @@ bool is_kmodule_extension(const char *ext)
 	return false;
 }
 
-bool is_kernel_module(const char *pathname, bool *compressed)
+bool is_kernel_module(const char *pathname)
 {
 	struct kmod_path m;
 
 	if (kmod_path__parse(&m, pathname))
 		return NULL;
 
-	if (compressed)
-		*compressed = m.comp;
-
 	return m.kmod;
 }
 
diff --git a/tools/perf/util/dso.h b/tools/perf/util/dso.h
index a712cbcd3a72..357d319a87d1 100644
--- a/tools/perf/util/dso.h
+++ b/tools/perf/util/dso.h
@@ -190,7 +190,7 @@ 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_kmodule_extension(const char *ext);
-bool is_kernel_module(const char *pathname, bool *compressed);
+bool is_kernel_module(const char *pathname);
 bool decompress_to_file(const char *ext, const char *filename, int output_fd);
 bool dso__needs_decompress(struct dso *dso);
 
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index 1f407f7352a7..fb432153e2aa 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -1266,7 +1266,7 @@ static int __event_process_build_id(struct build_id_event *bev,
 
 		dso__set_build_id(dso, &bev->build_id);
 
-		if (!is_kernel_module(filename, NULL))
+		if (!is_kernel_module(filename))
 			dso->kernel = dso_type;
 
 		build_id__sprintf(dso->build_id, sizeof(dso->build_id),
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index 0c2d9e68996b..03b73261ec3e 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -1093,7 +1093,7 @@ static int machine__process_kernel_mmap_event(struct machine *machine,
 		struct dso *dso;
 
 		list_for_each_entry(dso, &machine->kernel_dsos.head, node) {
-			if (is_kernel_module(dso->long_name, NULL))
+			if (is_kernel_module(dso->long_name))
 				continue;
 
 			kernel = dso;
-- 
1.9.3


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

* [PATCH 12/14] perf tools: Remove is_kmodule_extension function
  2015-03-03 15:29 [PATCH 0/3] perf tools: Adding xz decompression support Jiri Olsa
                   ` (10 preceding siblings ...)
  2015-03-03 15:29 ` [PATCH 11/14] perf tools: Remove compressed argument from is_kernel_module Jiri Olsa
@ 2015-03-03 15:29 ` Jiri Olsa
  2015-03-03 15:29 ` [PATCH 13/14] perf tools: Try to lookup kernel module map before creating one Jiri Olsa
                   ` (3 subsequent siblings)
  15 siblings, 0 replies; 26+ messages in thread
From: Jiri Olsa @ 2015-03-03 15:29 UTC (permalink / raw)
  To: linux-kernel
  Cc: Jiri Olsa, Adrian Hunter, Arnaldo Carvalho de Melo,
	Corey Ashford, David Ahern, Frederic Weisbecker, Ingo Molnar,
	Namhyung Kim, Paul Mackerras, Peter Zijlstra, Stephane Eranian

Because it's no longer needed.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
---
 tools/perf/util/dso.c | 11 -----------
 tools/perf/util/dso.h |  1 -
 2 files changed, 12 deletions(-)

diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
index e2eeadfad275..34b9ad0ff9da 100644
--- a/tools/perf/util/dso.c
+++ b/tools/perf/util/dso.c
@@ -165,17 +165,6 @@ bool is_supported_compression(const char *ext)
 	return false;
 }
 
-bool is_kmodule_extension(const char *ext)
-{
-	if (strncmp(ext, "ko", 2))
-		return false;
-
-	if (ext[2] == '\0' || (ext[2] == '.' && is_supported_compression(ext+3)))
-		return true;
-
-	return false;
-}
-
 bool is_kernel_module(const char *pathname)
 {
 	struct kmod_path m;
diff --git a/tools/perf/util/dso.h b/tools/perf/util/dso.h
index 357d319a87d1..ec58641ce5dc 100644
--- a/tools/perf/util/dso.h
+++ b/tools/perf/util/dso.h
@@ -189,7 +189,6 @@ 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_kmodule_extension(const char *ext);
 bool is_kernel_module(const char *pathname);
 bool decompress_to_file(const char *ext, const char *filename, int output_fd);
 bool dso__needs_decompress(struct dso *dso);
-- 
1.9.3


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

* [PATCH 13/14] perf tools: Try to lookup kernel module map before creating one
  2015-03-03 15:29 [PATCH 0/3] perf tools: Adding xz decompression support Jiri Olsa
                   ` (11 preceding siblings ...)
  2015-03-03 15:29 ` [PATCH 12/14] perf tools: Remove is_kmodule_extension function Jiri Olsa
@ 2015-03-03 15:29 ` Jiri Olsa
  2015-03-03 15:29 ` [PATCH 14/14] perf annotate: Allow annotation for decompressed kernel modules Jiri Olsa
                   ` (2 subsequent siblings)
  15 siblings, 0 replies; 26+ messages in thread
From: Jiri Olsa @ 2015-03-03 15:29 UTC (permalink / raw)
  To: linux-kernel
  Cc: Jiri Olsa, Adrian Hunter, Arnaldo Carvalho de Melo,
	Corey Ashford, David Ahern, Frederic Weisbecker, Ingo Molnar,
	Namhyung Kim, Paul Mackerras, Peter Zijlstra, Stephane Eranian

Currently we assume machine__new_module is called only once
for each module so we create its map&dso unconditionally.

However it's possible that it's called multiple times for
same module. Like for perf record:
  1) via machine__create_module during machine init
  2) via kernel MMAP event processing

Trying to lookup kernel module map before creating one.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
---
 tools/perf/util/machine.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index 03b73261ec3e..5acfb11fa23f 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -498,6 +498,11 @@ struct map *machine__new_module(struct machine *machine, u64 start,
 	if (kmod_path__parse_name(&m, filename))
 		return NULL;
 
+	map = map_groups__find_by_name(&machine->kmaps, MAP__FUNCTION,
+				       m.name);
+	if (map)
+		goto out;
+
 	dso = machine__module_dso(machine, &m, filename);
 	if (dso == NULL)
 		goto out;
-- 
1.9.3


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

* [PATCH 14/14] perf annotate: Allow annotation for decompressed kernel modules
  2015-03-03 15:29 [PATCH 0/3] perf tools: Adding xz decompression support Jiri Olsa
                   ` (12 preceding siblings ...)
  2015-03-03 15:29 ` [PATCH 13/14] perf tools: Try to lookup kernel module map before creating one Jiri Olsa
@ 2015-03-03 15:29 ` Jiri Olsa
  2015-03-03 15:31 ` [PATCH 0/3] perf tools: Adding xz decompression support Jiri Olsa
  2015-03-04  2:05 ` Namhyung Kim
  15 siblings, 0 replies; 26+ messages in thread
From: Jiri Olsa @ 2015-03-03 15:29 UTC (permalink / raw)
  To: linux-kernel
  Cc: Jiri Olsa, Adrian Hunter, Arnaldo Carvalho de Melo,
	Corey Ashford, David Ahern, Frederic Weisbecker, Ingo Molnar,
	Namhyung Kim, Paul Mackerras, Peter Zijlstra, Stephane Eranian

Decompressing kernel module file for objdump command
if needed. Annotation commands now display annotation
for compressed kernel modules.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
---
 tools/perf/util/annotate.c | 32 +++++++++++++++++++++++++++++++-
 1 file changed, 31 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index 61bf9128e1f2..b72086eca943 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -1008,6 +1008,32 @@ fallback:
 			}
 			filename = symfs_filename;
 		}
+	} else if (dso__needs_decompress(dso)) {
+		char tmp[PATH_MAX];
+		struct kmod_path m;
+		int fd;
+		bool ret;
+
+		if (kmod_path__parse_ext(&m, symfs_filename))
+			goto out_free_filename;
+
+		snprintf(tmp, PATH_MAX, "/tmp/perf-kmod-XXXXXX");
+
+		fd = mkstemp(tmp);
+		if (fd < 0) {
+			free(m.ext);
+			goto out_free_filename;
+		}
+
+		ret = decompress_to_file(m.ext, symfs_filename, fd);
+
+		free(m.ext);
+		close(fd);
+
+		if (!ret)
+			goto out_free_filename;
+
+		strcpy(symfs_filename, tmp);
 	}
 
 	snprintf(command, sizeof(command),
@@ -1027,7 +1053,7 @@ fallback:
 
 	file = popen(command, "r");
 	if (!file)
-		goto out_free_filename;
+		goto out_remove_tmp;
 
 	while (!feof(file))
 		if (symbol__parse_objdump_line(sym, map, file, privsize,
@@ -1042,6 +1068,10 @@ fallback:
 		delete_last_nop(sym);
 
 	pclose(file);
+
+out_remove_tmp:
+	if (dso__needs_decompress(dso))
+		unlink(symfs_filename);
 out_free_filename:
 	if (delete_extract)
 		kcore_extract__delete(&kce);
-- 
1.9.3


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

* Re: [PATCH 0/3] perf tools: Adding xz decompression support
  2015-03-03 15:29 [PATCH 0/3] perf tools: Adding xz decompression support Jiri Olsa
                   ` (13 preceding siblings ...)
  2015-03-03 15:29 ` [PATCH 14/14] perf annotate: Allow annotation for decompressed kernel modules Jiri Olsa
@ 2015-03-03 15:31 ` Jiri Olsa
  2015-03-04  2:05 ` Namhyung Kim
  15 siblings, 0 replies; 26+ messages in thread
From: Jiri Olsa @ 2015-03-03 15:31 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: linux-kernel, Adrian Hunter, Arnaldo Carvalho de Melo,
	Corey Ashford, David Ahern, Frederic Weisbecker, Ingo Molnar,
	Namhyung Kim, Paul Mackerras, Peter Zijlstra, Stephane Eranian

On Tue, Mar 03, 2015 at 04:29:27PM +0100, Jiri Olsa wrote:
> hi,
> adding support to decompress kernel modules on Fedora 21
> (lzma compression) vaguely continuing in previous RFC:
>   http://marc.info/?l=linux-kernel&m=142261340327588&w=2
> 
> I'm basically extending he decompression framework Namhyung
> introduced earlier plus other fixes for kernel modules dso
> objects handling.
> 
> Last patch adds decompression support to annotate command, so
> it now displays annotation for compressed kernel modules.
> 
> Current work available at:
>   git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git
>   perf/lzma

ugh.. the subject should be '00/14', sry ;-)

jirka

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

* Re: [PATCH 02/14] perf tools: Add feature check for lzma library
  2015-03-03 15:29 ` [PATCH 02/14] perf tools: Add feature check for lzma library Jiri Olsa
@ 2015-03-03 15:50   ` Arnaldo Carvalho de Melo
  2015-03-03 15:57     ` Jiri Olsa
  0 siblings, 1 reply; 26+ messages in thread
From: Arnaldo Carvalho de Melo @ 2015-03-03 15:50 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: linux-kernel, Adrian Hunter, Corey Ashford, David Ahern,
	Frederic Weisbecker, Ingo Molnar, Namhyung Kim, Paul Mackerras,
	Peter Zijlstra, Stephane Eranian, acme

Em Tue, Mar 03, 2015 at 04:29:29PM +0100, Jiri Olsa escreveu:
> Will be used to decompress 'xz' objects. The check detects
> the liblzma.so devel library normally delivered by xz package.

Hey, don't we want to emit some warning like the one below for CTF/libunwind?

- Arnaldo

[perf/core 1b23d3ab8304] perf tools: Add feature check for lzma library
 Author: Jiri Olsa <jolsa@kernel.org>
 3 files changed, 19 insertions(+), 3 deletions(-)
 create mode 100644 tools/perf/config/feature-checks/test-lzma.c
[acme@ssdandy linux]$ fg
-bash: fg: current: no such job
[acme@ssdandy linux]$  time make O=/tmp/build/perf -C tools/perf install-bin
make: Entering directory `/home/acme/git/linux/tools/perf'
  BUILD:   Doing 'make -j8' parallel build
config/Makefile:427: No libunwind found. Please install libunwind-dev[el] >= 1.1 and/or set LIBUNWIND_DIR
config/Makefile:711: No libbabeltrace found, disables 'perf data' CTF format support, please install libbabeltrace-dev[el]/libbabeltrace-ctf-dev

Auto-detecting system features:
...                         dwarf: [ on  ]
...                         glibc: [ on  ]
...                          gtk2: [ on  ]
...                      libaudit: [ on  ]
...                        libbfd: [ on  ]
...                        libelf: [ on  ]
...                       libnuma: [ on  ]
...                       libperl: [ on  ]
...                     libpython: [ on  ]
...                      libslang: [ on  ]
...                     libunwind: [ OFF ]
...            libdw-dwarf-unwind: [ on  ]
...                 libbabeltrace: [ OFF ]
...                          zlib: [ on  ]
...                          lzma: [ OFF ]
...     DWARF post unwind library: libdw

  INSTALL  GTK UI
  INSTALL  binaries
  INSTALL  libexec
  INSTALL  perf-archive
  INSTALL  perf-with-kcore
  INSTALL  perl-scripts
  INSTALL  python-scripts
  INSTALL  perf_completion-script
  INSTALL  tests
make: Leaving directory `/home/acme/git/linux/tools/perf'

real	0m3.818s
user	0m3.087s
sys	0m0.970s
[acme@ssdandy linux]$ 

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

* Re: [PATCH 02/14] perf tools: Add feature check for lzma library
  2015-03-03 15:50   ` Arnaldo Carvalho de Melo
@ 2015-03-03 15:57     ` Jiri Olsa
  0 siblings, 0 replies; 26+ messages in thread
From: Jiri Olsa @ 2015-03-03 15:57 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Jiri Olsa, linux-kernel, Adrian Hunter, Corey Ashford,
	David Ahern, Frederic Weisbecker, Ingo Molnar, Namhyung Kim,
	Paul Mackerras, Peter Zijlstra, Stephane Eranian, acme

On Tue, Mar 03, 2015 at 12:50:30PM -0300, Arnaldo Carvalho de Melo wrote:
> Em Tue, Mar 03, 2015 at 04:29:29PM +0100, Jiri Olsa escreveu:
> > Will be used to decompress 'xz' objects. The check detects
> > the liblzma.so devel library normally delivered by xz package.
> 
> Hey, don't we want to emit some warning like the one below for CTF/libunwind?

hum.. we probably want, right? ;-) will add in v2

thanks,
jirka

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

* Re: [PATCH 05/14] perf tools: Add dsos__new function
  2015-03-03 15:29 ` [PATCH 05/14] perf tools: Add dsos__new function Jiri Olsa
@ 2015-03-03 16:20   ` Arnaldo Carvalho de Melo
  2015-03-04 10:20     ` Jiri Olsa
  0 siblings, 1 reply; 26+ messages in thread
From: Arnaldo Carvalho de Melo @ 2015-03-03 16:20 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: linux-kernel, Adrian Hunter, Corey Ashford, David Ahern,
	Frederic Weisbecker, Ingo Molnar, Namhyung Kim, Paul Mackerras,
	Peter Zijlstra, Stephane Eranian

Em Tue, Mar 03, 2015 at 04:29:32PM +0100, Jiri Olsa escreveu:
> Separate the creation of new dso object and its addition
> to the dsos list. It will be used in following patch.
> 
> Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> Cc: Adrian Hunter <adrian.hunter@intel.com>
> Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
> Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
> Cc: David Ahern <dsahern@gmail.com>
> Cc: Frederic Weisbecker <fweisbec@gmail.com>
> Cc: Ingo Molnar <mingo@kernel.org>
> Cc: Namhyung Kim <namhyung@kernel.org>
> Cc: Paul Mackerras <paulus@samba.org>
> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
> Cc: Stephane Eranian <eranian@google.com>
> ---
>  tools/perf/util/dso.c | 21 ++++++++++++---------
>  tools/perf/util/dso.h |  1 +
>  2 files changed, 13 insertions(+), 9 deletions(-)
> 
> diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
> index be368414036c..fc54cb81c7f8 100644
> --- a/tools/perf/util/dso.c
> +++ b/tools/perf/util/dso.c
> @@ -1005,21 +1005,24 @@ struct dso *dsos__find(const struct dsos *dsos, const char *name,
>  	return dso__find_by_longname(&dsos->root, name);
>  }
>  
> -struct dso *__dsos__findnew(struct dsos *dsos, const char *name)
> +struct dso *dsos__new(struct dsos *dsos, const char *name)

When I read dsos__new() I think that it will surely return a 'struct dsos'
pointer, as it is the constructor ('__new') for the 'dsos' class. :-)

Right now we don't have a constructor for dsos, because its only used in
machine where they are not m'allocated, i.e. we use just dsos__init(),
but if we ever need a constructor for it, it will be called dsos__new().

So, to use the same rationale for dsos__findnew(), we can call it
dsos__addnew(), because it will not find anything, just add a new dso.

- Arnaldo

>  {
> -	struct dso *dso = dsos__find(dsos, name, false);
> +	struct dso *dso = dso__new(name);
>  
> -	if (!dso) {
> -		dso = dso__new(name);
> -		if (dso != NULL) {
> -			dsos__add(dsos, dso);
> -			dso__set_basename(dso);
> -		}
> +	if (dso != NULL) {
> +		dsos__add(dsos, dso);
> +		dso__set_basename(dso);
>  	}
> -
>  	return dso;
>  }
>  
> +struct dso *__dsos__findnew(struct dsos *dsos, const char *name)
> +{
> +	struct dso *dso = dsos__find(dsos, name, false);
> +
> +	return dso ? dso : dsos__new(dsos, name);
> +}
> +
>  size_t __dsos__fprintf_buildid(struct list_head *head, FILE *fp,
>  			       bool (skip)(struct dso *dso, int parm), int parm)
>  {
> diff --git a/tools/perf/util/dso.h b/tools/perf/util/dso.h
> index ced92841ff97..a712cbcd3a72 100644
> --- a/tools/perf/util/dso.h
> +++ b/tools/perf/util/dso.h
> @@ -249,6 +249,7 @@ struct dso *dso__kernel_findnew(struct machine *machine, const char *name,
>  				const char *short_name, int dso_type);
>  
>  void dsos__add(struct dsos *dsos, struct dso *dso);
> +struct dso *dsos__new(struct dsos *dsos, const char *name);
>  struct dso *dsos__find(const struct dsos *dsos, const char *name,
>  		       bool cmp_short);
>  struct dso *__dsos__findnew(struct dsos *dsos, const char *name);
> -- 
> 1.9.3

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

* Re: [PATCH 09/14] perf tools: Use kmod_path__parse in decompress_kmodule
  2015-03-03 15:29 ` [PATCH 09/14] perf tools: Use kmod_path__parse in decompress_kmodule Jiri Olsa
@ 2015-03-04  1:42   ` Namhyung Kim
  2015-03-04 10:19     ` Jiri Olsa
  0 siblings, 1 reply; 26+ messages in thread
From: Namhyung Kim @ 2015-03-04  1:42 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: linux-kernel, Adrian Hunter, Arnaldo Carvalho de Melo,
	Corey Ashford, David Ahern, Frederic Weisbecker, Ingo Molnar,
	Paul Mackerras, Peter Zijlstra, Stephane Eranian

Hi Jiri,

On Tue, Mar 03, 2015 at 04:29:36PM +0100, Jiri Olsa wrote:
> Replacing the file name parsing with kmod_path__parse.
> 
> Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> Cc: Adrian Hunter <adrian.hunter@intel.com>
> Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
> Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
> Cc: David Ahern <dsahern@gmail.com>
> Cc: Frederic Weisbecker <fweisbec@gmail.com>
> Cc: Ingo Molnar <mingo@kernel.org>
> Cc: Namhyung Kim <namhyung@kernel.org>
> Cc: Paul Mackerras <paulus@samba.org>
> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
> Cc: Stephane Eranian <eranian@google.com>
> ---
>  tools/perf/util/symbol-elf.c | 25 +++++++++++++++++--------
>  1 file changed, 17 insertions(+), 8 deletions(-)
> 
> diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c
> index ada16762fac2..8dd530ce20c5 100644
> --- a/tools/perf/util/symbol-elf.c
> +++ b/tools/perf/util/symbol-elf.c
> @@ -579,32 +579,41 @@ static int dso__swap_init(struct dso *dso, unsigned char eidata)
>  static int decompress_kmodule(struct dso *dso, const char *name,
>  			      enum dso_binary_type type)
>  {
> -	int fd;
> -	const char *ext = strrchr(name, '.');
> +	int fd = -1, try = 2;
>  	char tmpbuf[] = "/tmp/perf-kmod-XXXXXX";
> +	struct kmod_path m;
>  
>  	if (type != DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE_COMP &&
>  	    type != DSO_BINARY_TYPE__GUEST_KMODULE_COMP &&
>  	    type != DSO_BINARY_TYPE__BUILD_ID_CACHE)
>  		return -1;
>  
> -	if (!ext || !is_supported_compression(ext + 1)) {
> -		ext = strrchr(dso->name, '.');
> -		if (!ext || !is_supported_compression(ext + 1))
> -			return -1;
> +again:
> +	if (kmod_path__parse_ext(&m, name))
> +		return -1;
> +
> +	if (!m.comp) {
> +		if (!--try)
> +			goto out;
> +
> +		free(m.ext);
> +		name = dso->name;
> +		goto again;
>  	}

Maybe we can do like this instead:

	if (type == DSO_BINARY_TYPE__BUILD_ID_CACHE)
		name = dso->name;

	if (kmod_path__parse_ext(&m, name))
		return -1;

Thanks,
Namhyung


>  
>  	fd = mkstemp(tmpbuf);
>  	if (fd < 0)
> -		return -1;
> +		goto out;
>  
> -	if (!decompress_to_file(ext + 1, name, fd)) {
> +	if (!decompress_to_file(m.ext, name, fd)) {
>  		close(fd);
>  		fd = -1;
>  	}
>  
>  	unlink(tmpbuf);
>  
> +out:
> +	free(m.ext);
>  	return fd;
>  }
>  
> -- 
> 1.9.3
> 

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

* Re: [PATCH 0/3] perf tools: Adding xz decompression support
  2015-03-03 15:29 [PATCH 0/3] perf tools: Adding xz decompression support Jiri Olsa
                   ` (14 preceding siblings ...)
  2015-03-03 15:31 ` [PATCH 0/3] perf tools: Adding xz decompression support Jiri Olsa
@ 2015-03-04  2:05 ` Namhyung Kim
  2015-03-04 10:21   ` Jiri Olsa
  15 siblings, 1 reply; 26+ messages in thread
From: Namhyung Kim @ 2015-03-04  2:05 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: linux-kernel, Adrian Hunter, Arnaldo Carvalho de Melo,
	Corey Ashford, David Ahern, Frederic Weisbecker, Ingo Molnar,
	Paul Mackerras, Peter Zijlstra, Stephane Eranian

On Tue, Mar 03, 2015 at 04:29:27PM +0100, Jiri Olsa wrote:
> hi,
> adding support to decompress kernel modules on Fedora 21
> (lzma compression) vaguely continuing in previous RFC:
>   http://marc.info/?l=linux-kernel&m=142261340327588&w=2
> 
> I'm basically extending he decompression framework Namhyung
> introduced earlier plus other fixes for kernel modules dso
> objects handling.
> 
> Last patch adds decompression support to annotate command, so
> it now displays annotation for compressed kernel modules.

Nice work!  I went through the patches and liked the kmod_path__parse
change. :) Please feel free to add my Ack's to this series when you
send v2.

Thanks,
Namhyung


> 
> Current work available at:
>   git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git
>   perf/lzma
> 
> thanks,
> jirka
> 
> 
> Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> Cc: Adrian Hunter <adrian.hunter@intel.com>
> Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
> Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
> Cc: David Ahern <dsahern@gmail.com>
> Cc: Frederic Weisbecker <fweisbec@gmail.com>
> Cc: Ingo Molnar <mingo@kernel.org>
> Cc: Namhyung Kim <namhyung@kernel.org>
> Cc: Paul Mackerras <paulus@samba.org>
> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
> Cc: Stephane Eranian <eranian@google.com>
> ---
> Jiri Olsa (14):
>       perf tools: Remove superfluous thread->comm_set setting
>       perf tools: Add feature check for lzma library
>       perf tools: Add lzma decompression support for kernel module
>       perf tools: Add kmod_path__parse function
>       perf tools: Add dsos__new function
>       perf tools: Add machine__module_dso function
>       perf tools: Use kmod_path__parse for machine__new_dso
>       perf tools: Use kmod_path__parse in map_groups__set_modules_path_dir
>       perf tools: Use kmod_path__parse in decompress_kmodule
>       perf tools: Use kmod_path__parse in is_kernel_module
>       perf tools: Remove compressed argument from is_kernel_module
>       perf tools: Remove is_kmodule_extension function
>       perf tools: Try to lookup kernel module map before creating one
>       perf annotate: Allow annotation for decompressed kernel modules
> 
>  tools/perf/Makefile.perf                     |   2 ++
>  tools/perf/config/Makefile                   |  16 ++++++++--
>  tools/perf/config/feature-checks/Makefile    |   6 +++-
>  tools/perf/config/feature-checks/test-lzma.c |  10 ++++++
>  tools/perf/tests/Build                       |   1 +
>  tools/perf/tests/builtin-test.c              |   4 +++
>  tools/perf/tests/kmod-path.c                 |  73 ++++++++++++++++++++++++++++++++++++++++++++
>  tools/perf/tests/tests.h                     |   1 +
>  tools/perf/util/Build                        |   1 +
>  tools/perf/util/annotate.c                   |  32 +++++++++++++++++++-
>  tools/perf/util/dso.c                        |  52 ++++++++++++--------------------
>  tools/perf/util/dso.h                        |   4 +--
>  tools/perf/util/header.c                     |   2 +-
>  tools/perf/util/lzma.c                       |  95 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  tools/perf/util/machine.c                    | 142 +++++++++++++++++++++++++++++++++++++++++++++-----------------------------------------
>  tools/perf/util/symbol-elf.c                 |  25 ++++++++++-----
>  tools/perf/util/thread.c                     |   1 -
>  tools/perf/util/util.c                       |  66 ++++++++++++++++++++++++++++++++++++++++
>  tools/perf/util/util.h                       |  18 +++++++++++
>  19 files changed, 436 insertions(+), 115 deletions(-)
>  create mode 100644 tools/perf/config/feature-checks/test-lzma.c
>  create mode 100644 tools/perf/tests/kmod-path.c
>  create mode 100644 tools/perf/util/lzma.c

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

* Re: [PATCH 09/14] perf tools: Use kmod_path__parse in decompress_kmodule
  2015-03-04  1:42   ` Namhyung Kim
@ 2015-03-04 10:19     ` Jiri Olsa
  0 siblings, 0 replies; 26+ messages in thread
From: Jiri Olsa @ 2015-03-04 10:19 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Jiri Olsa, linux-kernel, Adrian Hunter, Arnaldo Carvalho de Melo,
	Corey Ashford, David Ahern, Frederic Weisbecker, Ingo Molnar,
	Paul Mackerras, Peter Zijlstra, Stephane Eranian

On Wed, Mar 04, 2015 at 10:42:21AM +0900, Namhyung Kim wrote:
> Hi Jiri,
> 
> On Tue, Mar 03, 2015 at 04:29:36PM +0100, Jiri Olsa wrote:
> > Replacing the file name parsing with kmod_path__parse.
> > 
> > Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> > Cc: Adrian Hunter <adrian.hunter@intel.com>
> > Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
> > Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
> > Cc: David Ahern <dsahern@gmail.com>
> > Cc: Frederic Weisbecker <fweisbec@gmail.com>
> > Cc: Ingo Molnar <mingo@kernel.org>
> > Cc: Namhyung Kim <namhyung@kernel.org>
> > Cc: Paul Mackerras <paulus@samba.org>
> > Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
> > Cc: Stephane Eranian <eranian@google.com>
> > ---
> >  tools/perf/util/symbol-elf.c | 25 +++++++++++++++++--------
> >  1 file changed, 17 insertions(+), 8 deletions(-)
> > 
> > diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c
> > index ada16762fac2..8dd530ce20c5 100644
> > --- a/tools/perf/util/symbol-elf.c
> > +++ b/tools/perf/util/symbol-elf.c
> > @@ -579,32 +579,41 @@ static int dso__swap_init(struct dso *dso, unsigned char eidata)
> >  static int decompress_kmodule(struct dso *dso, const char *name,
> >  			      enum dso_binary_type type)
> >  {
> > -	int fd;
> > -	const char *ext = strrchr(name, '.');
> > +	int fd = -1, try = 2;
> >  	char tmpbuf[] = "/tmp/perf-kmod-XXXXXX";
> > +	struct kmod_path m;
> >  
> >  	if (type != DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE_COMP &&
> >  	    type != DSO_BINARY_TYPE__GUEST_KMODULE_COMP &&
> >  	    type != DSO_BINARY_TYPE__BUILD_ID_CACHE)
> >  		return -1;
> >  
> > -	if (!ext || !is_supported_compression(ext + 1)) {
> > -		ext = strrchr(dso->name, '.');
> > -		if (!ext || !is_supported_compression(ext + 1))
> > -			return -1;
> > +again:
> > +	if (kmod_path__parse_ext(&m, name))
> > +		return -1;
> > +
> > +	if (!m.comp) {
> > +		if (!--try)
> > +			goto out;
> > +
> > +		free(m.ext);
> > +		name = dso->name;
> > +		goto again;
> >  	}
> 
> Maybe we can do like this instead:
> 
> 	if (type == DSO_BINARY_TYPE__BUILD_ID_CACHE)
> 		name = dso->name;
> 
> 	if (kmod_path__parse_ext(&m, name))
> 		return -1;

right, looks lot simpler ;-) I'll check

thanks,
jirka

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

* Re: [PATCH 05/14] perf tools: Add dsos__new function
  2015-03-03 16:20   ` Arnaldo Carvalho de Melo
@ 2015-03-04 10:20     ` Jiri Olsa
  0 siblings, 0 replies; 26+ messages in thread
From: Jiri Olsa @ 2015-03-04 10:20 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Jiri Olsa, linux-kernel, Adrian Hunter, Corey Ashford,
	David Ahern, Frederic Weisbecker, Ingo Molnar, Namhyung Kim,
	Paul Mackerras, Peter Zijlstra, Stephane Eranian

On Tue, Mar 03, 2015 at 01:20:35PM -0300, Arnaldo Carvalho de Melo wrote:
> Em Tue, Mar 03, 2015 at 04:29:32PM +0100, Jiri Olsa escreveu:
> > Separate the creation of new dso object and its addition
> > to the dsos list. It will be used in following patch.
> > 
> > Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> > Cc: Adrian Hunter <adrian.hunter@intel.com>
> > Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
> > Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
> > Cc: David Ahern <dsahern@gmail.com>
> > Cc: Frederic Weisbecker <fweisbec@gmail.com>
> > Cc: Ingo Molnar <mingo@kernel.org>
> > Cc: Namhyung Kim <namhyung@kernel.org>
> > Cc: Paul Mackerras <paulus@samba.org>
> > Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
> > Cc: Stephane Eranian <eranian@google.com>
> > ---
> >  tools/perf/util/dso.c | 21 ++++++++++++---------
> >  tools/perf/util/dso.h |  1 +
> >  2 files changed, 13 insertions(+), 9 deletions(-)
> > 
> > diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
> > index be368414036c..fc54cb81c7f8 100644
> > --- a/tools/perf/util/dso.c
> > +++ b/tools/perf/util/dso.c
> > @@ -1005,21 +1005,24 @@ struct dso *dsos__find(const struct dsos *dsos, const char *name,
> >  	return dso__find_by_longname(&dsos->root, name);
> >  }
> >  
> > -struct dso *__dsos__findnew(struct dsos *dsos, const char *name)
> > +struct dso *dsos__new(struct dsos *dsos, const char *name)
> 
> When I read dsos__new() I think that it will surely return a 'struct dsos'
> pointer, as it is the constructor ('__new') for the 'dsos' class. :-)
> 
> Right now we don't have a constructor for dsos, because its only used in
> machine where they are not m'allocated, i.e. we use just dsos__init(),
> but if we ever need a constructor for it, it will be called dsos__new().
> 
> So, to use the same rationale for dsos__findnew(), we can call it
> dsos__addnew(), because it will not find anything, just add a new dso.

ok, sounds good

thanks,
jirka

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

* Re: [PATCH 0/3] perf tools: Adding xz decompression support
  2015-03-04  2:05 ` Namhyung Kim
@ 2015-03-04 10:21   ` Jiri Olsa
  0 siblings, 0 replies; 26+ messages in thread
From: Jiri Olsa @ 2015-03-04 10:21 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Jiri Olsa, linux-kernel, Adrian Hunter, Arnaldo Carvalho de Melo,
	Corey Ashford, David Ahern, Frederic Weisbecker, Ingo Molnar,
	Paul Mackerras, Peter Zijlstra, Stephane Eranian

On Wed, Mar 04, 2015 at 11:05:15AM +0900, Namhyung Kim wrote:
> On Tue, Mar 03, 2015 at 04:29:27PM +0100, Jiri Olsa wrote:
> > hi,
> > adding support to decompress kernel modules on Fedora 21
> > (lzma compression) vaguely continuing in previous RFC:
> >   http://marc.info/?l=linux-kernel&m=142261340327588&w=2
> > 
> > I'm basically extending he decompression framework Namhyung
> > introduced earlier plus other fixes for kernel modules dso
> > objects handling.
> > 
> > Last patch adds decompression support to annotate command, so
> > it now displays annotation for compressed kernel modules.
> 
> Nice work!  I went through the patches and liked the kmod_path__parse
> change. :) Please feel free to add my Ack's to this series when you
> send v2.

thanks! will send v2 shortly..

jirka

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

* [tip:perf/core] perf tools: Remove superfluous thread-> comm_set setting
  2015-03-03 15:29 ` [PATCH 01/14] perf tools: Remove superfluous thread->comm_set setting Jiri Olsa
@ 2015-03-14  7:01   ` tip-bot for Jiri Olsa
  0 siblings, 0 replies; 26+ messages in thread
From: tip-bot for Jiri Olsa @ 2015-03-14  7:01 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: dsahern, cjashfor, namhyung, fweisbec, jolsa, acme, a.p.zijlstra,
	mingo, adrian.hunter, tglx, linux-kernel, hpa, eranian, paulus

Commit-ID:  01fbc1fee926888f7c256ada95fa5fa3b06cba94
Gitweb:     http://git.kernel.org/tip/01fbc1fee926888f7c256ada95fa5fa3b06cba94
Author:     Jiri Olsa <jolsa@kernel.org>
AuthorDate: Tue, 3 Mar 2015 16:29:28 +0100
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Thu, 12 Mar 2015 12:39:50 -0300

perf tools: Remove superfluous thread->comm_set setting

It is set by calling thread__set_comm right before the removed line.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1425396581-17716-2-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/thread.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/tools/perf/util/thread.c b/tools/perf/util/thread.c
index a5dbba9..1c8fbc9 100644
--- a/tools/perf/util/thread.c
+++ b/tools/perf/util/thread.c
@@ -206,7 +206,6 @@ int thread__fork(struct thread *thread, struct thread *parent, u64 timestamp)
 		err = thread__set_comm(thread, comm, timestamp);
 		if (err)
 			return err;
-		thread->comm_set = true;
 	}
 
 	thread->ppid = parent->tid;

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

* [PATCH 01/14] perf tools: Remove superfluous thread->comm_set setting
  2015-03-06 11:13 [PATCHv2 00/14] " Jiri Olsa
@ 2015-03-06 11:13 ` Jiri Olsa
  0 siblings, 0 replies; 26+ messages in thread
From: Jiri Olsa @ 2015-03-06 11:13 UTC (permalink / raw)
  To: linux-kernel
  Cc: Jiri Olsa, Adrian Hunter, Arnaldo Carvalho de Melo,
	Corey Ashford, David Ahern, Frederic Weisbecker, Ingo Molnar,
	Namhyung Kim, Paul Mackerras, Peter Zijlstra, Stephane Eranian

It is set by calling thread__set_comm right before
the removed line.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
---
 tools/perf/util/thread.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/tools/perf/util/thread.c b/tools/perf/util/thread.c
index a5dbba95107f..1c8fbc9588c5 100644
--- a/tools/perf/util/thread.c
+++ b/tools/perf/util/thread.c
@@ -206,7 +206,6 @@ int thread__fork(struct thread *thread, struct thread *parent, u64 timestamp)
 		err = thread__set_comm(thread, comm, timestamp);
 		if (err)
 			return err;
-		thread->comm_set = true;
 	}
 
 	thread->ppid = parent->tid;
-- 
1.9.3


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

end of thread, other threads:[~2015-03-14  7:02 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-03 15:29 [PATCH 0/3] perf tools: Adding xz decompression support Jiri Olsa
2015-03-03 15:29 ` [PATCH 01/14] perf tools: Remove superfluous thread->comm_set setting Jiri Olsa
2015-03-14  7:01   ` [tip:perf/core] perf tools: Remove superfluous thread-> comm_set setting tip-bot for Jiri Olsa
2015-03-03 15:29 ` [PATCH 02/14] perf tools: Add feature check for lzma library Jiri Olsa
2015-03-03 15:50   ` Arnaldo Carvalho de Melo
2015-03-03 15:57     ` Jiri Olsa
2015-03-03 15:29 ` [PATCH 03/14] perf tools: Add lzma decompression support for kernel module Jiri Olsa
2015-03-03 15:29 ` [PATCH 04/14] perf tools: Add kmod_path__parse function Jiri Olsa
2015-03-03 15:29 ` [PATCH 05/14] perf tools: Add dsos__new function Jiri Olsa
2015-03-03 16:20   ` Arnaldo Carvalho de Melo
2015-03-04 10:20     ` Jiri Olsa
2015-03-03 15:29 ` [PATCH 06/14] perf tools: Add machine__module_dso function Jiri Olsa
2015-03-03 15:29 ` [PATCH 07/14] perf tools: Use kmod_path__parse for machine__new_dso Jiri Olsa
2015-03-03 15:29 ` [PATCH 08/14] perf tools: Use kmod_path__parse in map_groups__set_modules_path_dir Jiri Olsa
2015-03-03 15:29 ` [PATCH 09/14] perf tools: Use kmod_path__parse in decompress_kmodule Jiri Olsa
2015-03-04  1:42   ` Namhyung Kim
2015-03-04 10:19     ` Jiri Olsa
2015-03-03 15:29 ` [PATCH 10/14] perf tools: Use kmod_path__parse in is_kernel_module Jiri Olsa
2015-03-03 15:29 ` [PATCH 11/14] perf tools: Remove compressed argument from is_kernel_module Jiri Olsa
2015-03-03 15:29 ` [PATCH 12/14] perf tools: Remove is_kmodule_extension function Jiri Olsa
2015-03-03 15:29 ` [PATCH 13/14] perf tools: Try to lookup kernel module map before creating one Jiri Olsa
2015-03-03 15:29 ` [PATCH 14/14] perf annotate: Allow annotation for decompressed kernel modules Jiri Olsa
2015-03-03 15:31 ` [PATCH 0/3] perf tools: Adding xz decompression support Jiri Olsa
2015-03-04  2:05 ` Namhyung Kim
2015-03-04 10:21   ` Jiri Olsa
2015-03-06 11:13 [PATCHv2 00/14] " Jiri Olsa
2015-03-06 11:13 ` [PATCH 01/14] perf tools: Remove superfluous thread->comm_set setting Jiri Olsa

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).