Skip to contentSkip to conversation

perf tools: Add lzma decompression support for kernel module

tip:perf/core tip-bot for Jiri Olsa 1 participant 1 message Mar 22, 2015 perf events

lore
Share & tools
lore

tip-bot for Jiri Olsa

author merge bot
#0 lore raw
Commit-ID:  80a32e5b498a7547073e5e4b2b804edc7219979d
Gitweb:     http://git.kernel.org/tip/80a32e5b498a7547073e5e4b2b804edc7219979d
Author:     Jiri Olsa <[email protected]>
AuthorDate: Thu, 29 Jan 2015 13:29:39 +0100
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Sat, 21 Mar 2015 14:53:40 -0300

perf tools: Add lzma decompression support for kernel module

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 Namhyung earlier.

---
 tools/perf/Makefile.perf   |  2 +
 tools/perf/config/Makefile | 11 ++++++
 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, 116 insertions(+)
tools/perf/Makefile.perf +2 -0
index d5b9e0d..e9925e6 100644
@@ -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)))
tools/perf/config/Makefile +11 -0
index 6d1918a..cd121df 100644
@@ -541,6 +541,17 @@ ifndef NO_ZLIB
   endif
 endif
 
+ifndef NO_LZMA
+  ifeq ($(feature-lzma), 1)
+    CFLAGS += -DHAVE_LZMA_SUPPORT
+    EXTLIBS += -llzma
+    $(call detected,CONFIG_LZMA)
+  else
+    msg := $(warning No liblzma found, disables xz kernel module decompression, please install xz-devel/liblzma-dev);
+    NO_LZMA := 1
+  endif
+endif
+
 ifndef NO_BACKTRACE
   ifeq ($(feature-backtrace), 1)
     CFLAGS += -DHAVE_BACKTRACE_SUPPORT
tools/perf/util/Build +1 -0
index 972a6e0..797490a 100644
@@ -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))"
tools/perf/util/dso.c +3 -0
index 814554d..be36841 100644
@@ -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 },
 };
 
tools/perf/util/lzma.c new file +95 -0

95 lines not on this page · raw message

tools/perf/util/util.h +4 -0
index fbd598a..1ff23e0 100644
@@ -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 */