[PATCH 4/4] perf: support zstd-compressed kernel modules

From: Ivan Shapovalov

Date: Wed Oct 14 2026 - 13:37:31 EST


Support handling loading zstd-compressed DSOs in perf (in addition to
existing support for gzip/xz formats). This allows loading of e.g.
zstd-compressed kernel modules, as shipped by various distros
including Arch.

Signed-off-by: Ivan Shapovalov <intelfx@xxxxxxxxxxxx>
---
tools/perf/Makefile.config | 2 +-
tools/perf/util/dso.c | 5 ++++-
2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
index 4d5993da9f945..dfdda22becc39 100644
--- a/tools/perf/Makefile.config
+++ b/tools/perf/Makefile.config
@@ -982,7 +982,7 @@ ifndef NO_LIBZSTD
EXTLIBS += -lzstd
$(call detected,CONFIG_ZSTD)
else
- $(warning No libzstd found, disables trace compression, please install libzstd-dev[el] and/or set LIBZSTD_DIR)
+ $(warning No libzstd found, disables zstd kernel module decompression and trace compression, please install libzstd-dev[el] and/or set LIBZSTD_DIR)
NO_LIBZSTD := 1
endif
endif
diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
index 42bfe30a3b518..0e8886172e239 100644
--- a/tools/perf/util/dso.c
+++ b/tools/perf/util/dso.c
@@ -277,6 +277,9 @@ static const struct {
#endif
#ifdef HAVE_LZMA_SUPPORT
{ "xz", lzma_decompress_to_file, lzma_is_compressed },
+#endif
+#ifdef HAVE_ZSTD_SUPPORT
+ { "zst", zstd_decompress_to_fd, zstd_is_compressed },
#endif
{ NULL, NULL, NULL },
};
@@ -460,7 +463,7 @@ int __kmod_path__parse(struct kmod_path *m, const char *path,

m->comp = is_supported_compression(ext + 1);
if (m->comp > COMP_ID__NONE)
- ext -= 3;
+ ext -= strlen(compressions[m->comp].fmt);

/* Check .ko extension only if there's enough name left. */
if (ext > name)

--
2.55.0.8.g37e2a0019f