From: Felix Moessbauer <felix.moessbauer@siemens.com>
To: isar-users@googlegroups.com
Cc: Felix Moessbauer <felix.moessbauer@siemens.com>
Subject: [PATCH 1/2] feat: package linux-perf-<version> in kernel recipe
Date: Thu, 21 Jan 2021 11:52:23 +0100 [thread overview]
Message-ID: <20210121105224.26285-2-felix.moessbauer@siemens.com> (raw)
In-Reply-To: <AM0PR10MB1939687D1ABFBE66DAAB702689A20@AM0PR10MB1939.EURPRD10.PROD.OUTLOOK.COM>
This patch builds and packages the version specific bindings of perf
as part of the kernel recipe.
The support can be disabled by setting KERNEL_PACKAGE_PERF="0".
As special patches are needed for each kernel version, support for perf
is automatically disabled for kernels where no patches are provided.
A user of this recipe can provide these patches for a custom kernel
by setting / replacing KERNEL_PERF_PATCHES[<version-major>.<version-minor>].
It is also possible to only patch the linux-perf-<version> package and use
an upstream kernel by adding a dependency to the linux-perf-<version> package.
Signed-off-by: Felix Moessbauer <felix.moessbauer@siemens.com>
---
.../linux/files/debian/control.tmpl | 31 +++++
.../files/debian/rules.d/tools/perf/Makefile | 60 +++++++++
.../linux/files/debian/rules.tmpl | 18 ++-
.../perf/4.19/tools-perf-install.patch | 58 +++++++++
.../perf/4.19/tools-perf-version.patch | 119 ++++++++++++++++++
.../patches/perf/5.4/tools-perf-install.patch | 51 ++++++++
.../patches/perf/5.4/tools-perf-version.patch | 111 ++++++++++++++++
meta/recipes-kernel/linux/linux-custom.inc | 11 +-
meta/recipes-kernel/linux/linux-tools.inc | 66 ++++++++++
9 files changed, 521 insertions(+), 4 deletions(-)
create mode 100644 meta/recipes-kernel/linux/files/debian/rules.d/tools/perf/Makefile
create mode 100644 meta/recipes-kernel/linux/files/patches/perf/4.19/tools-perf-install.patch
create mode 100644 meta/recipes-kernel/linux/files/patches/perf/4.19/tools-perf-version.patch
create mode 100644 meta/recipes-kernel/linux/files/patches/perf/5.4/tools-perf-install.patch
create mode 100644 meta/recipes-kernel/linux/files/patches/perf/5.4/tools-perf-version.patch
create mode 100644 meta/recipes-kernel/linux/linux-tools.inc
diff --git a/meta/recipes-kernel/linux/files/debian/control.tmpl b/meta/recipes-kernel/linux/files/debian/control.tmpl
index dd0b624..3a09938 100644
--- a/meta/recipes-kernel/linux/files/debian/control.tmpl
+++ b/meta/recipes-kernel/linux/files/debian/control.tmpl
@@ -35,3 +35,34 @@ Architecture: any
Description: Linux kernel debugging symbols for @KR@
This package will come in handy if you need to debug the kernel. It provides
all the necessary debug symbols for the kernel and its modules.
+
+Package: linux-perf-${KERNEL_PERF_COMPAT}
+Build-Profiles: <!noperf>
+Section: devel
+Architecture: alpha amd64 arm64 armel armhf hppa i386 mips mips64 mips64el mipsel mipsn32 mipsn32el mipsr6 mipsr6el mipsn32r6 mipsn32r6el mips64r6 mips64r6el powerpc ppc64 ppc64el riscv64 s390 s390x sh4 sparc sparc64
+Build-Depends:
+ asciidoctor <!stage1 !nodoc !pkg.linux.notools !nopython>,
+ gcc-multilib [amd64 mips64 mips64el mips64r6 mips64r6el ppc64 s390x sparc64],
+ libaudit-dev,
+ libbabeltrace-dev (>= 1.5.0),
+ libbabeltrace-dev (>= 1.5.3-2~) | libbabeltrace-ctf-dev (>= 1.5.0),
+ libdw-dev,
+ libiberty-dev,
+ libnewt-dev,
+ libnuma-dev,
+ libperl-dev,
+ libunwind-dev [amd64 arm64 armel armhf hppa i386 mips mips64 mips64el mipsel powerpc ppc64 ppc64el sh4],
+ libopencsd-dev,
+ python3-dev,
+Depends: ${shlibs:Depends}, ${misc:Depends}, ${perl:Depends}, ${python3:Depends}
+Recommends: linux-base
+Provides: linux-tools-${KERNEL_PERF_COMPAT}
+Conflicts: linux-tools-${KERNEL_PERF_COMPAT}
+Replaces: linux-tools-${KERNEL_PERF_COMPAT}
+Suggests: linux-doc-${KERNEL_PERF_COMPAT}
+Description: Performance analysis tools for Linux ${KERNEL_PERF_COMPAT}
+ This package contains the 'perf' performance analysis tools for Linux
+ kernel version ${KERNEL_PERF_COMPAT}.
+ .
+ The linux-base package contains a 'perf' command which will invoke the
+ appropriate version for the running kernel.
diff --git a/meta/recipes-kernel/linux/files/debian/rules.d/tools/perf/Makefile b/meta/recipes-kernel/linux/files/debian/rules.d/tools/perf/Makefile
new file mode 100644
index 0000000..3de82e1
--- /dev/null
+++ b/meta/recipes-kernel/linux/files/debian/rules.d/tools/perf/Makefile
@@ -0,0 +1,60 @@
+#!/usr/bin/make -f
+# Note: this ruleset is based on the Makefile
+# that is used for building the linux-perf-<KR>
+# package in debian
+
+VERSION := $(KERNEL_PERF_COMPAT)
+deb_top_dir := $(CURDIR)/debian
+DESTDIR := $(deb_top_dir)/linux-perf-$(VERSION)
+PARALLEL_BUILD=-j $(shell echo $$(($$(nproc) * 2)))
+
+CFLAGS := $(shell dpkg-buildflags --get CFLAGS) -Wall
+CXXFLAGS := $(shell dpkg-buildflags --get CXXFLAGS) -Wall
+LDFLAGS := $(shell dpkg-buildflags --get LDFLAGS)
+
+MAKE_PERF := $(MAKE) O=$(CURDIR) prefix=/usr V=1 VF=1 WERROR=0 EXTRA_CFLAGS='$(CFLAGS) $(CPPFLAGS)' LDFLAGS='$(LDFLAGS)'
+MAKE_PERF += NO_GTK2=1
+MAKE_PERF += feature-jvmti=0
+MAKE_PERF += perfexecdir=lib/perf_$(VERSION)-core plugindir=/usr/lib/traceevent_$(VERSION)/plugins STRACE_GROUPS_DIR=share/perf_$(VERSION)-core/strace/groups tipdir=share/doc/linux-perf-$(VERSION) perf_include_dir=include/perf_$(VERSION) perf_examples_dir=share/doc/linux-perf-$(VERSION)/examples
+MAKE_PERF += feature-libbfd=0 feature-libbfd-liberty=0 feature-libbfd-liberty-z=0 HAVE_CPLUS_DEMANGLE_SUPPORT=1
+MAKE_PERF += NO_LIBCRYPTO=1
+MAKE_PERF += LIBBABELTRACE=1
+MAKE_PERF += USE_ASCIIDOCTOR=1
+MAKE_PERF += PYTHON=/usr/bin/python3
+VERS_PATTERN := $(subst .,[._],$(VERSION))
+VERS_PERFPY := $(subst .,_,$(VERSION))
+
+override_dh_auto_configure:
+ sed -i s/\'perf\'/\'perf_$(VERS_PERFPY)\'/g tools/perf/util/setup.py
+ sed -i s/PyInit_perf\(/PyInit_perf_$(VERS_PERFPY)\(/g tools/perf/util/python.c
+
+override_dh_auto_build:
+ +${MAKE_PERF} ${PARALLEL_MAKE} -C tools/perf -f Makefile.perf all VERSION=$(VERSION) DESTDIR=dummy
+ # Check that perf didn't get linked against libbfd or libcrypto
+ ! ldd $(CURDIR)/perf | grep -E '\blib(bfd|crypto)'
+ # Check that it includes cplus_demangle from libiberty
+ grep cplus_demangle $(CURDIR)/perf
+
+override_dh_auto_install:
+ +${MAKE_PERF} ${PARALLEL_MAKE} -C tools/perf -f Makefile.perf install VERSION=$(VERSION) DESTDIR=$(DESTDIR)
+ rm -f $(DESTDIR)/usr/bin/trace_$(VERSION)
+ mkdir -p $(DESTDIR)/usr/share/bash-completion/
+ mv $(DESTDIR)/etc/bash_completion.d \
+ $(DESTDIR)/usr/share/bash-completion/completions
+ rmdir --ignore-fail-on-non-empty $(DESTDIR)/etc
+
+ # Check for unversioned files that are likely to result in file conflicts
+ cd $(DESTDIR) && ! find \! -type d \! -path '*[_-]$(VERS_PATTERN)*' | grep .
+
+override_dh_auto_clean:
+ rm -rf ${deb_top_dir}/linux-perf-$(VERSION)
+ # undo the replacements
+ sed -i s/\'perf_$(VERS_PERFPY)\'/\'perf\'/g tools/perf/util/setup.py
+ sed -i s/PyInit_perf_$(VERS_PERFPY)\(/PyInit_perf\(/g tools/perf/util/python.c
+
+override_dh_auto_test:
+ echo "Skip tests"
+
+%:
+ CFLAGS= LDFLAGS= dh $@ --parallel
+
diff --git a/meta/recipes-kernel/linux/files/debian/rules.tmpl b/meta/recipes-kernel/linux/files/debian/rules.tmpl
index 05a26fe..a70fc2c 100755
--- a/meta/recipes-kernel/linux/files/debian/rules.tmpl
+++ b/meta/recipes-kernel/linux/files/debian/rules.tmpl
@@ -13,20 +13,36 @@ isar_env=$(strip \
export DEB_HOST_GNU_TYPE='$(DEB_HOST_GNU_TYPE)' && \
export MAKE='$(MAKE)' && \
export O='${O}' && \
- export S='${S}' \
+ export S='${S}' && \
+ export KERNEL_PACKAGE_PERF='${KERNEL_PACKAGE_PERF}' && \
+ export KERNEL_PERF_COMPAT='${KERNEL_PERF_COMPAT}' \
)
%:
dh $(@)
+override_dh_auto_configure:
+ifeq (${KERNEL_PACKAGE_PERF},1)
+ $(isar_env) && $(MAKE) -f $(deb_top_dir)/rules.d/tools/perf/Makefile $@
+endif
+
override_dh_auto_clean:
$(isar_env) && bash $(deb_top_dir)/isar/clean
+ifeq (${KERNEL_PACKAGE_PERF},1)
+ $(isar_env) && $(MAKE) -f $(deb_top_dir)/rules.d/tools/perf/Makefile $@
+endif
override_dh_auto_build:
$(isar_env) && bash $(deb_top_dir)/isar/build
+ifeq (${KERNEL_PACKAGE_PERF},1)
+ $(isar_env) && $(MAKE) -f $(deb_top_dir)/rules.d/tools/perf/Makefile $@
+endif
override_dh_auto_install:
$(isar_env) && bash $(deb_top_dir)/isar/install
+ifeq (${KERNEL_PACKAGE_PERF},1)
+ $(isar_env) && $(MAKE) -f $(deb_top_dir)/rules.d/tools/perf/Makefile $@
+endif
override_dh_auto_test:
true
diff --git a/meta/recipes-kernel/linux/files/patches/perf/4.19/tools-perf-install.patch b/meta/recipes-kernel/linux/files/patches/perf/4.19/tools-perf-install.patch
new file mode 100644
index 0000000..8cfd02a
--- /dev/null
+++ b/meta/recipes-kernel/linux/files/patches/perf/4.19/tools-perf-install.patch
@@ -0,0 +1,58 @@
+From: Bastian Blank <waldi@debian.org>
+Date: Fri, 07 Oct 2011 21:37:52 +0100
+Subject: Install perf scripts non-executable
+Forwarded: no
+
+[bwh: Forward-ported to 4.13]
+
+Index: linux/tools/perf/Makefile.perf
+===================================================================
+--- linux.orig/tools/perf/Makefile.perf
++++ linux/tools/perf/Makefile.perf
+@@ -796,8 +796,8 @@ endif
+ ifndef NO_LIBPERL
+ $(call QUIET_INSTALL, perl-scripts) \
+ $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/Perf-Trace-Util/lib/Perf/Trace'; \
+- $(INSTALL) scripts/perl/Perf-Trace-Util/lib/Perf/Trace/* -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/Perf-Trace-Util/lib/Perf/Trace'; \
+- $(INSTALL) scripts/perl/*.pl -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl'; \
++ $(INSTALL) -m 644 scripts/perl/Perf-Trace-Util/lib/Perf/Trace/* -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/Perf-Trace-Util/lib/Perf/Trace'; \
++ $(INSTALL) -m 644 scripts/perl/*.pl -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl'; \
+ $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/bin'; \
+ $(INSTALL) scripts/perl/bin/* -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/bin'
+ endif
+@@ -805,27 +805,27 @@ ifndef NO_LIBPYTHON
+ $(call QUIET_INSTALL, python-scripts) \
+ $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python/Perf-Trace-Util/lib/Perf/Trace'; \
+ $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python/bin'; \
+- $(INSTALL) scripts/python/Perf-Trace-Util/lib/Perf/Trace/* -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python/Perf-Trace-Util/lib/Perf/Trace'; \
+- $(INSTALL) scripts/python/*.py -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python'; \
++ $(INSTALL) -m 644 scripts/python/Perf-Trace-Util/lib/Perf/Trace/* -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python/Perf-Trace-Util/lib/Perf/Trace'; \
++ $(INSTALL) -m 644 scripts/python/*.py -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python'; \
+ $(INSTALL) scripts/python/bin/* -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python/bin'
+ endif
+ $(call QUIET_INSTALL, perf_completion-script) \
+ $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(sysconfdir_SQ)/bash_completion.d'; \
+- $(INSTALL) perf-completion.sh '$(DESTDIR_SQ)$(sysconfdir_SQ)/bash_completion.d/perf_$(VERSION)'
++ $(INSTALL) -m 644 perf-completion.sh '$(DESTDIR_SQ)$(sysconfdir_SQ)/bash_completion.d/perf_$(VERSION)'
+ $(call QUIET_INSTALL, perf-tip) \
+ $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(tip_instdir_SQ)'; \
+- $(INSTALL) Documentation/tips.txt -t '$(DESTDIR_SQ)$(tip_instdir_SQ)'
++ $(INSTALL) -m 644 Documentation/tips.txt -t '$(DESTDIR_SQ)$(tip_instdir_SQ)'
+
+ install-tests: all install-gtk
+ $(call QUIET_INSTALL, tests) \
+ $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests'; \
+- $(INSTALL) tests/attr.py '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests'; \
++ $(INSTALL) -m 644 tests/attr.py '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests'; \
+ $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/attr'; \
+- $(INSTALL) tests/attr/* '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/attr'; \
++ $(INSTALL) -m 644 tests/attr/* '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/attr'; \
+ $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell'; \
+- $(INSTALL) tests/shell/*.sh '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell'; \
++ $(INSTALL) -m 644 tests/shell/*.sh '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell'; \
+ $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/lib'; \
+- $(INSTALL) tests/shell/lib/*.sh '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/lib'
++ $(INSTALL) -m 644 tests/shell/lib/*.sh '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/lib'
+
+ install-bin: install-tools install-tests install-traceevent-plugins
+
diff --git a/meta/recipes-kernel/linux/files/patches/perf/4.19/tools-perf-version.patch b/meta/recipes-kernel/linux/files/patches/perf/4.19/tools-perf-version.patch
new file mode 100644
index 0000000..6833bb7
--- /dev/null
+++ b/meta/recipes-kernel/linux/files/patches/perf/4.19/tools-perf-version.patch
@@ -0,0 +1,119 @@
+From: Bastian Blank <waldi@debian.org>
+Date: Mon, 26 Sep 2011 13:53:12 +0100
+Subject: Create manpages and binaries including the version
+Forwarded: no
+
+[bwh: Fix version insertion in perf man page cross-references and perf
+man page title. Install bash_completion script for perf with a
+version-dependent name. And do the same for trace.]
+
+Index: linux/tools/perf/Makefile.perf
+===================================================================
+--- linux.orig/tools/perf/Makefile.perf
++++ linux/tools/perf/Makefile.perf
+@@ -759,23 +759,23 @@ endif
+ install-tools: all install-gtk
+ $(call QUIET_INSTALL, binaries) \
+ $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(bindir_SQ)'; \
+- $(INSTALL) $(OUTPUT)perf '$(DESTDIR_SQ)$(bindir_SQ)'; \
+- $(LN) '$(DESTDIR_SQ)$(bindir_SQ)/perf' '$(DESTDIR_SQ)$(bindir_SQ)/trace'
++ $(INSTALL) $(OUTPUT)perf '$(DESTDIR_SQ)$(bindir_SQ)/perf_$(VERSION)'; \
++ $(LN) '$(DESTDIR_SQ)$(bindir_SQ)/perf_$(VERSION)' '$(DESTDIR_SQ)$(bindir_SQ)/trace_$(VERSION)'
++ $(call QUIET_INSTALL, libexec) \
++ $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)'
+ ifndef NO_PERF_READ_VDSO32
+ $(call QUIET_INSTALL, perf-read-vdso32) \
+- $(INSTALL) $(OUTPUT)perf-read-vdso32 '$(DESTDIR_SQ)$(bindir_SQ)';
++ $(INSTALL) $(OUTPUT)perf-read-vdso32 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)';
+ endif
+ ifndef NO_PERF_READ_VDSOX32
+ $(call QUIET_INSTALL, perf-read-vdsox32) \
+- $(INSTALL) $(OUTPUT)perf-read-vdsox32 '$(DESTDIR_SQ)$(bindir_SQ)';
++ $(INSTALL) $(OUTPUT)perf-read-vdsox32 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)';
+ endif
+ ifndef NO_JVMTI
+ $(call QUIET_INSTALL, $(LIBJVMTI)) \
+ $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(libdir_SQ)'; \
+ $(INSTALL) $(OUTPUT)$(LIBJVMTI) '$(DESTDIR_SQ)$(libdir_SQ)';
+ endif
+- $(call QUIET_INSTALL, libexec) \
+- $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)'
+ ifndef NO_LIBBPF
+ $(call QUIET_INSTALL, bpf-headers) \
+ $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perf_include_instdir_SQ)/bpf'; \
+@@ -811,7 +811,7 @@ ifndef NO_LIBPYTHON
+ endif
+ $(call QUIET_INSTALL, perf_completion-script) \
+ $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(sysconfdir_SQ)/bash_completion.d'; \
+- $(INSTALL) perf-completion.sh '$(DESTDIR_SQ)$(sysconfdir_SQ)/bash_completion.d/perf'
++ $(INSTALL) perf-completion.sh '$(DESTDIR_SQ)$(sysconfdir_SQ)/bash_completion.d/perf_$(VERSION)'
+ $(call QUIET_INSTALL, perf-tip) \
+ $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(tip_instdir_SQ)'; \
+ $(INSTALL) Documentation/tips.txt -t '$(DESTDIR_SQ)$(tip_instdir_SQ)'
+@@ -836,7 +836,7 @@ install-python_ext:
+
+ # 'make install-doc' should call 'make -C Documentation install'
+ $(INSTALL_DOC_TARGETS):
+- $(QUIET_SUBDIR0)Documentation $(QUIET_SUBDIR1) $(@:-doc=)
++ $(QUIET_SUBDIR0)Documentation $(QUIET_SUBDIR1) $(@:-doc=) VERSION=$(VERSION)
+
+ ### Cleaning rules
+
+Index: linux/tools/perf/Documentation/Makefile
+===================================================================
+--- linux.orig/tools/perf/Documentation/Makefile
++++ linux/tools/perf/Documentation/Makefile
+@@ -194,14 +194,16 @@ ifdef missing_tools
+ $(error "You need to install $(missing_tools) for man pages")
+ endif
+
+-do-install-man: man
++do-install-man: $(addprefix install-man-,$(_DOC_MAN1))
++
++install-man-perf.1: $(OUTPUT)perf.1
++ $(INSTALL) -d -m 755 $(DESTDIR)$(man1dir)
++ sed -e 's/"PERF"/"PERF_$(VERSION)"/' -e 's/fBperf-/fBperf_$(VERSION)-/g' $^ > $(DESTDIR)$(man1dir)/perf_$(VERSION).1
++
++install-man-perf%.1: $(OUTPUT)perf%.1
+ $(call QUIET_INSTALL, Documentation-man) \
+ $(INSTALL) -d -m 755 $(DESTDIR)$(man1dir); \
+-# $(INSTALL) -d -m 755 $(DESTDIR)$(man5dir); \
+-# $(INSTALL) -d -m 755 $(DESTDIR)$(man7dir); \
+- $(INSTALL) -m 644 $(DOC_MAN1) $(DESTDIR)$(man1dir); \
+-# $(INSTALL) -m 644 $(DOC_MAN5) $(DESTDIR)$(man5dir); \
+-# $(INSTALL) -m 644 $(DOC_MAN7) $(DESTDIR)$(man7dir)
++ sed -e 's/"PERF\\-/"PERF_$(VERSION)\\-/' -e 's/fBperf-/fBperf_$(VERSION)-/g' $^ > $(DESTDIR)$(man1dir)/perf_$(VERSION)$*.1
+
+ install-man: check-man-tools man do-install-man
+
+Index: linux/tools/perf/util/Build
+===================================================================
+--- linux.orig/tools/perf/util/Build
++++ linux/tools/perf/util/Build
+@@ -193,6 +193,7 @@ CFLAGS_libstring.o += -Wno-unused-pa
+ CFLAGS_hweight.o += -Wno-unused-parameter -DETC_PERFCONFIG="BUILD_STR($(ETC_PERFCONFIG_SQ))"
+ CFLAGS_parse-events.o += -Wno-redundant-decls
+ CFLAGS_header.o += -include $(OUTPUT)PERF-VERSION-FILE
++CFLAGS_vdso.o += -DPERFEXECDIR='"$(perfexec_instdir_SQ)"'
+
+ $(OUTPUT)util/kallsyms.o: ../lib/symbol/kallsyms.c FORCE
+ $(call rule_mkdir)
+Index: linux/tools/perf/util/vdso.c
+===================================================================
+--- linux.orig/tools/perf/util/vdso.c
++++ linux/tools/perf/util/vdso.c
+@@ -52,12 +52,12 @@ static struct vdso_info *vdso_info__new(
+ .vdso32 = {
+ .temp_file_name = VDSO__TEMP_FILE_NAME,
+ .dso_name = DSO__NAME_VDSO32,
+- .read_prog = "perf-read-vdso32",
++ .read_prog = PERFEXECDIR "/perf-read-vdso32",
+ },
+ .vdsox32 = {
+ .temp_file_name = VDSO__TEMP_FILE_NAME,
+ .dso_name = DSO__NAME_VDSOX32,
+- .read_prog = "perf-read-vdsox32",
++ .read_prog = PERFEXECDIR "/perf-read-vdsox32",
+ },
+ #endif
+ };
diff --git a/meta/recipes-kernel/linux/files/patches/perf/5.4/tools-perf-install.patch b/meta/recipes-kernel/linux/files/patches/perf/5.4/tools-perf-install.patch
new file mode 100644
index 0000000..c6e53e3
--- /dev/null
+++ b/meta/recipes-kernel/linux/files/patches/perf/5.4/tools-perf-install.patch
@@ -0,0 +1,51 @@
+From: Bastian Blank <waldi@debian.org>
+Date: Fri, 07 Oct 2011 21:37:52 +0100
+Subject: Install perf scripts non-executable
+Forwarded: no
+
+[bwh: Forward-ported to 4.13]
+---
+ tools/perf/Makefile.perf | 20 ++++++++++----------
+ 1 file changed, 10 insertions(+), 10 deletions(-)
+
+--- a/tools/perf/Makefile.perf
++++ b/tools/perf/Makefile.perf
+@@ -854,8 +854,8 @@ endif
+ ifndef NO_LIBPERL
+ $(call QUIET_INSTALL, perl-scripts) \
+ $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/Perf-Trace-Util/lib/Perf/Trace'; \
+- $(INSTALL) scripts/perl/Perf-Trace-Util/lib/Perf/Trace/* -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/Perf-Trace-Util/lib/Perf/Trace'; \
+- $(INSTALL) scripts/perl/*.pl -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl'; \
++ $(INSTALL) -m 644 scripts/perl/Perf-Trace-Util/lib/Perf/Trace/* -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/Perf-Trace-Util/lib/Perf/Trace'; \
++ $(INSTALL) -m 644 scripts/perl/*.pl -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl'; \
+ $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/bin'; \
+ $(INSTALL) scripts/perl/bin/* -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/bin'
+ endif
+@@ -869,21 +869,21 @@ ifndef NO_LIBPYTHON
+ endif
+ $(call QUIET_INSTALL, perf_completion-script) \
+ $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(sysconfdir_SQ)/bash_completion.d'; \
+- $(INSTALL) perf-completion.sh '$(DESTDIR_SQ)$(sysconfdir_SQ)/bash_completion.d/perf_$(VERSION)'
++ $(INSTALL) -m 644 perf-completion.sh '$(DESTDIR_SQ)$(sysconfdir_SQ)/bash_completion.d/perf_$(VERSION)'
+ $(call QUIET_INSTALL, perf-tip) \
+ $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(tip_instdir_SQ)'; \
+- $(INSTALL) Documentation/tips.txt -t '$(DESTDIR_SQ)$(tip_instdir_SQ)'
++ $(INSTALL) -m 644 Documentation/tips.txt -t '$(DESTDIR_SQ)$(tip_instdir_SQ)'
+
+ install-tests: all install-gtk
+ $(call QUIET_INSTALL, tests) \
+ $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests'; \
+- $(INSTALL) tests/attr.py '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests'; \
++ $(INSTALL) -m 644 tests/attr.py '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests'; \
+ $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/attr'; \
+- $(INSTALL) tests/attr/* '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/attr'; \
++ $(INSTALL) -m 644 tests/attr/* '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/attr'; \
+ $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell'; \
+- $(INSTALL) tests/shell/*.sh '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell'; \
++ $(INSTALL) -m 644 tests/shell/*.sh '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell'; \
+ $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/lib'; \
+- $(INSTALL) tests/shell/lib/*.sh '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/lib'
++ $(INSTALL) -m 644 tests/shell/lib/*.sh '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/lib'
+
+ install-bin: install-tools install-tests install-traceevent-plugins
+
diff --git a/meta/recipes-kernel/linux/files/patches/perf/5.4/tools-perf-version.patch b/meta/recipes-kernel/linux/files/patches/perf/5.4/tools-perf-version.patch
new file mode 100644
index 0000000..e82a305
--- /dev/null
+++ b/meta/recipes-kernel/linux/files/patches/perf/5.4/tools-perf-version.patch
@@ -0,0 +1,111 @@
+From: Bastian Blank <waldi@debian.org>
+Date: Mon, 26 Sep 2011 13:53:12 +0100
+Subject: Create manpages and binaries including the version
+Forwarded: no
+
+[bwh: Fix version insertion in perf man page cross-references and perf
+man page title. Install bash_completion script for perf with a
+version-dependent name. And do the same for trace.]
+
+--- a/tools/perf/Makefile.perf
++++ b/tools/perf/Makefile.perf
+@@ -759,23 +759,23 @@ endif
+ install-tools: all install-gtk
+ $(call QUIET_INSTALL, binaries) \
+ $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(bindir_SQ)'; \
+- $(INSTALL) $(OUTPUT)perf '$(DESTDIR_SQ)$(bindir_SQ)'; \
+- $(LN) '$(DESTDIR_SQ)$(bindir_SQ)/perf' '$(DESTDIR_SQ)$(bindir_SQ)/trace'
++ $(INSTALL) $(OUTPUT)perf '$(DESTDIR_SQ)$(bindir_SQ)/perf_$(VERSION)'; \
++ $(LN) '$(DESTDIR_SQ)$(bindir_SQ)/perf_$(VERSION)' '$(DESTDIR_SQ)$(bindir_SQ)/trace_$(VERSION)'
++ $(call QUIET_INSTALL, libexec) \
++ $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)'
+ ifndef NO_PERF_READ_VDSO32
+ $(call QUIET_INSTALL, perf-read-vdso32) \
+- $(INSTALL) $(OUTPUT)perf-read-vdso32 '$(DESTDIR_SQ)$(bindir_SQ)';
++ $(INSTALL) $(OUTPUT)perf-read-vdso32 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)';
+ endif
+ ifndef NO_PERF_READ_VDSOX32
+ $(call QUIET_INSTALL, perf-read-vdsox32) \
+- $(INSTALL) $(OUTPUT)perf-read-vdsox32 '$(DESTDIR_SQ)$(bindir_SQ)';
++ $(INSTALL) $(OUTPUT)perf-read-vdsox32 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)';
+ endif
+ ifndef NO_JVMTI
+ $(call QUIET_INSTALL, $(LIBJVMTI)) \
+ $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(libdir_SQ)'; \
+ $(INSTALL) $(OUTPUT)$(LIBJVMTI) '$(DESTDIR_SQ)$(libdir_SQ)';
+ endif
+- $(call QUIET_INSTALL, libexec) \
+- $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)'
+ ifndef NO_LIBBPF
+ $(call QUIET_INSTALL, bpf-headers) \
+ $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perf_include_instdir_SQ)/bpf'; \
+@@ -811,7 +811,7 @@ ifndef NO_LIBPYTHON
+ endif
+ $(call QUIET_INSTALL, perf_completion-script) \
+ $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(sysconfdir_SQ)/bash_completion.d'; \
+- $(INSTALL) perf-completion.sh '$(DESTDIR_SQ)$(sysconfdir_SQ)/bash_completion.d/perf'
++ $(INSTALL) perf-completion.sh '$(DESTDIR_SQ)$(sysconfdir_SQ)/bash_completion.d/perf_$(VERSION)'
+ $(call QUIET_INSTALL, perf-tip) \
+ $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(tip_instdir_SQ)'; \
+ $(INSTALL) Documentation/tips.txt -t '$(DESTDIR_SQ)$(tip_instdir_SQ)'
+@@ -836,7 +836,7 @@ install-python_ext:
+
+ # 'make install-doc' should call 'make -C Documentation install'
+ $(INSTALL_DOC_TARGETS):
+- $(QUIET_SUBDIR0)Documentation $(QUIET_SUBDIR1) $(@:-doc=)
++ $(QUIET_SUBDIR0)Documentation $(QUIET_SUBDIR1) $(@:-doc=) VERSION=$(VERSION)
+
+ ### Cleaning rules
+
+--- a/tools/perf/Documentation/Makefile
++++ b/tools/perf/Documentation/Makefile
+@@ -194,14 +194,16 @@ ifdef missing_tools
+ $(error "You need to install $(missing_tools) for man pages")
+ endif
+
+-do-install-man: man
++do-install-man: $(addprefix install-man-,$(_DOC_MAN1))
++
++install-man-perf.1: $(OUTPUT)perf.1
++ $(INSTALL) -d -m 755 $(DESTDIR)$(man1dir)
++ sed -e 's/"PERF"/"PERF_$(VERSION)"/' -e 's/fBperf-/fBperf_$(VERSION)-/g' $^ > $(DESTDIR)$(man1dir)/perf_$(VERSION).1
++
++install-man-perf%.1: $(OUTPUT)perf%.1
+ $(call QUIET_INSTALL, Documentation-man) \
+ $(INSTALL) -d -m 755 $(DESTDIR)$(man1dir); \
+-# $(INSTALL) -d -m 755 $(DESTDIR)$(man5dir); \
+-# $(INSTALL) -d -m 755 $(DESTDIR)$(man7dir); \
+- $(INSTALL) -m 644 $(DOC_MAN1) $(DESTDIR)$(man1dir); \
+-# $(INSTALL) -m 644 $(DOC_MAN5) $(DESTDIR)$(man5dir); \
+-# $(INSTALL) -m 644 $(DOC_MAN7) $(DESTDIR)$(man7dir)
++ sed -e 's/"PERF\\-/"PERF_$(VERSION)\\-/' -e 's/fBperf-/fBperf_$(VERSION)-/g' $^ > $(DESTDIR)$(man1dir)/perf_$(VERSION)$*.1
+
+ install-man: check-man-tools man do-install-man
+
+--- a/tools/perf/util/Build
++++ b/tools/perf/util/Build
+@@ -193,6 +193,7 @@ CFLAGS_libstring.o += -Wno-unused-pa
+ CFLAGS_hweight.o += -Wno-unused-parameter -DETC_PERFCONFIG="BUILD_STR($(ETC_PERFCONFIG_SQ))"
+ CFLAGS_parse-events.o += -Wno-redundant-decls
+ CFLAGS_header.o += -include $(OUTPUT)PERF-VERSION-FILE
++CFLAGS_vdso.o += -DPERFEXECDIR='"$(perfexec_instdir_SQ)"'
+
+ $(OUTPUT)util/kallsyms.o: ../lib/symbol/kallsyms.c FORCE
+ $(call rule_mkdir)
+--- a/tools/perf/util/vdso.c
++++ b/tools/perf/util/vdso.c
+@@ -52,12 +52,12 @@ static struct vdso_info *vdso_info__new(
+ .vdso32 = {
+ .temp_file_name = VDSO__TEMP_FILE_NAME,
+ .dso_name = DSO__NAME_VDSO32,
+- .read_prog = "perf-read-vdso32",
++ .read_prog = PERFEXECDIR "/perf-read-vdso32",
+ },
+ .vdsox32 = {
+ .temp_file_name = VDSO__TEMP_FILE_NAME,
+ .dso_name = DSO__NAME_VDSOX32,
+- .read_prog = "perf-read-vdsox32",
++ .read_prog = PERFEXECDIR "/perf-read-vdsox32",
+ },
+ #endif
+ };
diff --git a/meta/recipes-kernel/linux/linux-custom.inc b/meta/recipes-kernel/linux/linux-custom.inc
index ed89aa0..2faceec 100644
--- a/meta/recipes-kernel/linux/linux-custom.inc
+++ b/meta/recipes-kernel/linux/linux-custom.inc
@@ -33,6 +33,9 @@ KERNEL_HEADERS_DEBIAN_DEPENDS ?= "libc6, \
KERNEL_LIBC_DEV_DEPLOY ?= "0"
+# include perf recipe
+include linux-tools.inc
+
# Settings that may be changed on a per distro, machine or layer basis
# --------------------------------------------------------------------
@@ -71,6 +74,8 @@ TEMPLATE_VARS += " \
KERNEL_HEADERS_DEBIAN_DEPENDS \
LINUX_VERSION_EXTENSION \
KERNEL_NAME_PROVIDED \
+ KERNEL_PACKAGE_PERF \
+ KERNEL_PERF_COMPAT \
"
inherit dpkg
@@ -81,9 +86,9 @@ KERNEL_NAME_PROVIDED ?= "${@ d.getVar('PN', True).partition('linux-')[2]}"
# Make bitbake know we will be producing linux-image and linux-headers packages
python() {
- kernel_name = d.getVar("KERNEL_NAME_PROVIDED", True)
- d.setVar('PROVIDES', 'linux-image-' + kernel_name + ' ' + \
- 'linux-headers-' + kernel_name)
+ kernel_name = d.getVar("KERNEL_NAME_PROVIDED", True)
+ d.appendVar('PROVIDES', ' linux-image-' + kernel_name + \
+ ' linux-headers-' + kernel_name + ' ')
}
def get_kernel_arch(d):
diff --git a/meta/recipes-kernel/linux/linux-tools.inc b/meta/recipes-kernel/linux/linux-tools.inc
new file mode 100644
index 0000000..b1e9376
--- /dev/null
+++ b/meta/recipes-kernel/linux/linux-tools.inc
@@ -0,0 +1,66 @@
+# Packaging of linux kernel tools
+#
+# This software is a part of ISAR.
+# Copyright (c) Siemens AG, 2020
+#
+# SPDX-License-Identifier: MIT
+
+# Settings related to kernel tools
+# --------------------------------
+
+KERNEL_PACKAGE_PERF ?= "1"
+PERF_BUILD_DEPENDS = "\
+ asciidoctor <!stage1 !nodoc !pkg.linux.notools !nopython>, \
+ gcc-multilib [amd64 mips64 mips64el mips64r6 mips64r6el ppc64 s390x sparc64], \
+ libaudit-dev, \
+ libbabeltrace-dev (>= 1.5.0), \
+ libbabeltrace-dev (>= 1.5.3-2~) | libbabeltrace-ctf-dev (>= 1.5.0), \
+ libdw-dev, \
+ libiberty-dev, \
+ libnewt-dev, \
+ libnuma-dev, \
+ libperl-dev, \
+ libunwind-dev [amd64 arm64 armel armhf hppa i386 mips mips64 mips64el mipsel powerpc ppc64 ppc64el sh4], \
+ libopencsd-dev, \
+ python3-dev, \
+"
+
+# we need patches for each kernel version
+# if a kernel is not in the list of kernels we have patches for,
+# we just disable the perf support.
+# To add perf support for an previously unsupported kernel, simply
+# provide the necessary patches in KERNEL_PERF_PATCHES[<version-major>,<version-minor>]
+KERNEL_PERF_COMPAT = "nopackage"
+KERNEL_PERF_PATCHES[4.19] ?= " \
+ file://patches/perf/4.19/tools-perf-version.patch \
+ file://patches/perf/4.19/tools-perf-install.patch \
+"
+KERNEL_PERF_PATCHES[5.4] ?= " \
+ file://patches/perf/5.4/tools-perf-version.patch \
+ file://patches/perf/5.4/tools-perf-install.patch \
+"
+
+python() {
+ if d.getVar('KERNEL_PACKAGE_PERF') != '1':
+ return
+ try:
+ kvers = d.getVar('PV', True).split('.')
+ except:
+ bb.warn('could not extract kernel version. Disabling perf support. Version provided: {}'.format(d.getVar('PV', True)))
+ d.setVar('KERNEL_PACKAGE_PERF', '0')
+ return
+
+ perf_version = kvers[0] + '.' + kvers[1]
+ # read patch-list for this kernel version
+ patches_dict = d.getVarFlags('KERNEL_PERF_PATCHES')
+ if not perf_version in patches_dict.keys():
+ bb.warn('no perf packaging for kernel version {}. Disable perf support'.format(perf_version))
+ d.setVar('KERNEL_PACKAGE_PERF', '0')
+ return
+
+ d.setVar('KERNEL_PERF_COMPAT', perf_version)
+ d.appendVar('PROVIDES', ' linux-perf-' + perf_version + ' ')
+ d.appendVar('SRC_URI', ' ' + patches_dict[perf_version] + ' ')
+ d.appendVar('KBUILD_DEPENDS', d.getVar('PERF_BUILD_DEPENDS'))
+}
+
--
2.20.1
next prev parent reply other threads:[~2021-01-21 10:52 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-19 12:41 [PATCH 0/1] RFC: Package perf from linux kernel tools Felix Moessbauer
2021-01-19 12:41 ` [PATCH 1/1] " Felix Moessbauer
2021-01-19 16:31 ` Baurzhan Ismagulov
2021-01-20 15:23 ` Moessbauer, Felix
2021-01-20 15:26 ` Henning Schild
2021-01-21 10:52 ` [PATCH v2 0/2] " Felix Moessbauer
2021-01-21 11:56 ` Jan Kiszka
2021-01-21 15:00 ` Moessbauer, Felix
2021-01-21 16:35 ` Jan Kiszka
2021-02-09 8:58 ` Anton Mikanovich
2021-02-17 10:18 ` Baurzhan Ismagulov
2021-01-21 10:52 ` Felix Moessbauer [this message]
2021-02-17 10:28 ` [PATCH 1/2] feat: package linux-perf-<version> in kernel recipe Baurzhan Ismagulov
2021-02-18 8:01 ` Moessbauer, Felix
2021-02-18 8:28 ` Jan Kiszka
2021-04-22 9:52 ` Anton Mikanovich
2021-04-27 9:24 ` [RFC v2 0/2] " Felix Moessbauer
2021-04-27 9:24 ` [PATCH v2 1/2] RFC: Package perf from linux kernel tools Felix Moessbauer
2021-04-27 9:24 ` [PATCH v2 2/2] Add wrapper to load correct python perf module based on kernel Felix Moessbauer
2021-01-21 10:52 ` [PATCH 2/2] feat: add and package python bindings for perf Felix Moessbauer
2021-01-20 11:12 ` [PATCH 0/1] RFC: Package perf from linux kernel tools Henning Schild
2021-01-20 11:21 ` Henning Schild
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210121105224.26285-2-felix.moessbauer@siemens.com \
--to=felix.moessbauer@siemens.com \
--cc=isar-users@googlegroups.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox