public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
* [PATCH 0/1] RFC: Package perf from linux kernel tools
@ 2021-01-19 12:41 Felix Moessbauer
  2021-01-19 12:41 ` [PATCH 1/1] " Felix Moessbauer
                   ` (2 more replies)
  0 siblings, 3 replies; 22+ messages in thread
From: Felix Moessbauer @ 2021-01-19 12:41 UTC (permalink / raw)
  To: isar-users; +Cc: Felix Moessbauer, adriaan.schmidt, henning.schild, jan.kiszka

Hi all,

this patch adds support to build the linux-perf<version> package
that includes the kernel specific perf tooling.

During implementation I tried two different approaches:
1. package as part of the kernel receipt (as Debian does)
2. package as a regular package (similar to how the kselftest is packaged)

This RFC implements approach 2 but tries to be as close as possible
to the Debian upstream packaging.
By that, we use the same patches from Debian upstream to build our package.
Note, that these are dependent on the exact kernel version.
Here, I used the latest available bugfix version from upstream (4.19.160).
Perf should then be compatible with 4.19 kernels (only partially tested).

A major obstacle in implementing approach 1 was that the patches for linux-tools
are not trivial and have to match with the corresponding kernel version.
Writing that in a way that works for various kernel versions was something I
was not able to accomplish.
Hence, I decided that it might be better to avoid that much complexity in the
kernel receipt. Most users might not need the tools anyways, but probably a
custom kernel.

Finally, this patch also builds the kernel specific python bindings of perf.
This patch has already been sent upstream, but is not yet integrated in Debian.
For reference, see here: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=860957

Best regards,
Felix Mößbauer

Felix Moessbauer (1):
  RFC: Package perf from linux kernel tools

 .../recipes-kernel/linux-perf/files/rules     |  53 ++++++++
 .../linux-perf/files/tools-perf-install.patch |  58 +++++++++
 .../linux-perf/files/tools-perf-python.patch  |  55 ++++++++
 .../linux-perf/files/tools-perf-version.patch | 119 ++++++++++++++++++
 .../linux-perf/linux-perf-4.19_4.19.160.bb    |  11 ++
 .../recipes-kernel/linux-perf/linux-perf.inc  |  46 +++++++
 6 files changed, 342 insertions(+)
 create mode 100644 meta-isar/recipes-kernel/linux-perf/files/rules
 create mode 100644 meta-isar/recipes-kernel/linux-perf/files/tools-perf-install.patch
 create mode 100644 meta-isar/recipes-kernel/linux-perf/files/tools-perf-python.patch
 create mode 100644 meta-isar/recipes-kernel/linux-perf/files/tools-perf-version.patch
 create mode 100644 meta-isar/recipes-kernel/linux-perf/linux-perf-4.19_4.19.160.bb
 create mode 100644 meta-isar/recipes-kernel/linux-perf/linux-perf.inc

-- 
2.20.1


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

* [PATCH 1/1] RFC: Package perf from linux kernel tools
  2021-01-19 12:41 [PATCH 0/1] RFC: Package perf from linux kernel tools Felix Moessbauer
@ 2021-01-19 12:41 ` Felix Moessbauer
  2021-01-19 16:31   ` Baurzhan Ismagulov
  2021-01-20 11:12 ` [PATCH 0/1] RFC: Package perf from linux kernel tools Henning Schild
  2021-01-20 11:21 ` Henning Schild
  2 siblings, 1 reply; 22+ messages in thread
From: Felix Moessbauer @ 2021-01-19 12:41 UTC (permalink / raw)
  To: isar-users; +Cc: Felix Moessbauer, adriaan.schmidt, henning.schild, jan.kiszka

This patch adds the linux-perf-4.19 package for a kernel
that is build with ISAR.
As the perf binaries have to be version specific, we patch
the corresponding files from the kernel tools source to incorporate
the major and minor version number.
These patches are copied over from the official debianization of perf
that is done in the src:linux package.
Additionally, we package the perf python bindings as well and provide
them as module "perf_4_19" (in the tools-perf-python.patch).

As this debianization is not part of the kernel receipt, the perf
package can be based on a different patch version of the kernel.
While this might be intended, it is now the responibility of the
user to ensure that both the kernel and the linux-perf-<version>
packages are compatible.
---
 .../recipes-kernel/linux-perf/files/rules     |  53 ++++++++
 .../linux-perf/files/tools-perf-install.patch |  58 +++++++++
 .../linux-perf/files/tools-perf-python.patch  |  55 ++++++++
 .../linux-perf/files/tools-perf-version.patch | 119 ++++++++++++++++++
 .../linux-perf/linux-perf-4.19_4.19.160.bb    |  11 ++
 .../recipes-kernel/linux-perf/linux-perf.inc  |  46 +++++++
 6 files changed, 342 insertions(+)
 create mode 100644 meta-isar/recipes-kernel/linux-perf/files/rules
 create mode 100644 meta-isar/recipes-kernel/linux-perf/files/tools-perf-install.patch
 create mode 100644 meta-isar/recipes-kernel/linux-perf/files/tools-perf-python.patch
 create mode 100644 meta-isar/recipes-kernel/linux-perf/files/tools-perf-version.patch
 create mode 100644 meta-isar/recipes-kernel/linux-perf/linux-perf-4.19_4.19.160.bb
 create mode 100644 meta-isar/recipes-kernel/linux-perf/linux-perf.inc

diff --git a/meta-isar/recipes-kernel/linux-perf/files/rules b/meta-isar/recipes-kernel/linux-perf/files/rules
new file mode 100644
index 0000000..e23586c
--- /dev/null
+++ b/meta-isar/recipes-kernel/linux-perf/files/rules
@@ -0,0 +1,53 @@
+#!/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 := 4.19
+deb_top_dir := $(CURDIR)/debian
+DESTDIR := $(deb_top_dir)/binarypackage
+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))
+
+
+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}/binarypackage
+
+override_dh_auto_test:
+	echo "Skip tests"
+
+%:
+	CFLAGS= LDFLAGS= dh $@ --parallel
+
diff --git a/meta-isar/recipes-kernel/linux-perf/files/tools-perf-install.patch b/meta-isar/recipes-kernel/linux-perf/files/tools-perf-install.patch
new file mode 100644
index 0000000..8cfd02a
--- /dev/null
+++ b/meta-isar/recipes-kernel/linux-perf/files/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-isar/recipes-kernel/linux-perf/files/tools-perf-python.patch b/meta-isar/recipes-kernel/linux-perf/files/tools-perf-python.patch
new file mode 100644
index 0000000..5770d9f
--- /dev/null
+++ b/meta-isar/recipes-kernel/linux-perf/files/tools-perf-python.patch
@@ -0,0 +1,55 @@
+--- a/tools/perf/Makefile.perf
++++ b/tools/perf/Makefile.perf
+@@ -829,10 +829,10 @@
+ 
+ install-bin: install-tools install-tests install-traceevent-plugins
+ 
+-install: install-bin try-install-man
+-
+ install-python_ext:
+-	$(PYTHON_WORD) util/setup.py --quiet install --root='/$(DESTDIR_SQ)'
++	$(PYTHON_WORD) util/setup.py --quiet install --root='/$(DESTDIR_SQ)' --install-layout=deb;
++
++install: install-bin try-install-man install-python_ext
+ 
+ # 'make install-doc' should call 'make -C Documentation install'
+ $(INSTALL_DOC_TARGETS):
+--- a/tools/perf/util/setup.py
++++ b/tools/perf/util/setup.py
+@@ -51,14 +51,14 @@
+ # use full paths with source files
+ ext_sources = list(map(lambda x: '%s/%s' % (src_perf, x) , ext_sources))
+ 
+-perf = Extension('perf',
++perf = Extension('perf_4_19',
+ 		  sources = ext_sources,
+ 		  include_dirs = ['util/include'],
+ 		  extra_compile_args = cflags,
+ 		  extra_objects = [libtraceevent, libapikfs],
+                  )
+ 
+-setup(name='perf',
++setup(name='perf_4_19',
+       version='0.1',
+       description='Interface with the Linux profiling infrastructure',
+       author='Arnaldo Carvalho de Melo',
+--- a/tools/perf/util/python.c
++++ b/tools/perf/util/python.c
+@@ -77,7 +77,7 @@
+ #if PY_MAJOR_VERSION < 3
+ PyMODINIT_FUNC initperf(void);
+ #else
+-PyMODINIT_FUNC PyInit_perf(void);
++PyMODINIT_FUNC PyInit_perf_4_19(void);
+ #endif
+ 
+ #define member_def(type, member, ptype, help) \
+@@ -1270,7 +1270,7 @@
+ #if PY_MAJOR_VERSION < 3
+ PyMODINIT_FUNC initperf(void)
+ #else
+-PyMODINIT_FUNC PyInit_perf(void)
++PyMODINIT_FUNC PyInit_perf_4_19(void)
+ #endif
+ {
+ 	PyObject *obj;
diff --git a/meta-isar/recipes-kernel/linux-perf/files/tools-perf-version.patch b/meta-isar/recipes-kernel/linux-perf/files/tools-perf-version.patch
new file mode 100644
index 0000000..6833bb7
--- /dev/null
+++ b/meta-isar/recipes-kernel/linux-perf/files/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-isar/recipes-kernel/linux-perf/linux-perf-4.19_4.19.160.bb b/meta-isar/recipes-kernel/linux-perf/linux-perf-4.19_4.19.160.bb
new file mode 100644
index 0000000..33ff6d2
--- /dev/null
+++ b/meta-isar/recipes-kernel/linux-perf/linux-perf-4.19_4.19.160.bb
@@ -0,0 +1,11 @@
+KERNEL_COMPAT_VERSION = "4.19"
+
+SRC_URI += " \
+	https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-${PV}.tar.xz \
+	file://tools-perf-version.patch;apply=yes \
+	file://tools-perf-install.patch;apply=yes \
+	file://tools-perf-python.patch;apply=yes \
+"
+SRC_URI[sha256sum] = "18345206f9c61e8adafa5204d0ca0b8619f1d9aafd70cbd5cb0fbf1faf521585"
+
+require recipes-kernel/linux-perf/linux-perf.inc
diff --git a/meta-isar/recipes-kernel/linux-perf/linux-perf.inc b/meta-isar/recipes-kernel/linux-perf/linux-perf.inc
new file mode 100644
index 0000000..a4bc253
--- /dev/null
+++ b/meta-isar/recipes-kernel/linux-perf/linux-perf.inc
@@ -0,0 +1,46 @@
+# Kernel specific linux-perf-<KR> package
+# Note, that only major and minor versions of the
+# kernel have to match, the patch level should be
+# irrelevant.
+
+inherit dpkg
+
+MAINTAINER ?= "Felix Moessbauer <felix.moessbauer@siemens.com>"
+DESCRIPTION ?= "Performance analysis tools for Linux ${KERNEL_COMPAT_VERSION}"
+CHANGELOG_V ?= "${PV}+isar"
+
+SRC_URI += "file://rules"
+S = "${WORKDIR}/linux-${PV}"
+
+DEBIAN_BUILD_DEPENDS ?= " \
+  asciidoctor, \
+  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, \
+  flex, \
+  bison, \
+"
+
+DEBIAN_DEPENDS ?= "\${shlibs:Depends}, \${misc:Depends}, \${perl:Depends}, \${python3:Depends}"
+
+do_prepare_build[cleandirs] += "${S}/debian"
+
+do_prepare_build() {
+	deb_debianize
+	echo "3.0 (quilt)" > ${S}/debian/source
+	echo "debian/binarypackage/usr /" > ${S}/debian/install
+	deb_add_changelog
+}
+
+dpkg_runbuild_prepend() {
+    export DEB_BUILD_OPTIONS="nocheck"
+}
-- 
2.20.1


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

* Re: [PATCH 1/1] RFC: Package perf from linux kernel tools
  2021-01-19 12:41 ` [PATCH 1/1] " Felix Moessbauer
@ 2021-01-19 16:31   ` Baurzhan Ismagulov
  2021-01-20 15:23     ` Moessbauer, Felix
  0 siblings, 1 reply; 22+ messages in thread
From: Baurzhan Ismagulov @ 2021-01-19 16:31 UTC (permalink / raw)
  To: Felix Moessbauer; +Cc: isar-users, adriaan.schmidt, henning.schild, jan.kiszka

Hello Felix,

On Tue, Jan 19, 2021 at 01:41:58PM +0100, Felix Moessbauer wrote:
> This patch adds the linux-perf-4.19 package for a kernel
> that is build with ISAR.
> As the perf binaries have to be version specific, we patch
> the corresponding files from the kernel tools source to incorporate
> the major and minor version number.
> These patches are copied over from the official debianization of perf
> that is done in the src:linux package.
> Additionally, we package the perf python bindings as well and provide
> them as module "perf_4_19" (in the tools-perf-python.patch).
> 
> As this debianization is not part of the kernel receipt, the perf

Suggest "receipt" -> "recipe".


> package can be based on a different patch version of the kernel.
> While this might be intended, it is now the responibility of the
> user to ensure that both the kernel and the linux-perf-<version>
> packages are compatible.
...
>  .../linux-perf/files/tools-perf-install.patch |  58 +++++++++
>  .../linux-perf/files/tools-perf-python.patch  |  55 ++++++++
>  .../linux-perf/files/tools-perf-version.patch | 119 ++++++++++++++++++

The patches look common sense to me; ideally, it would be better to handle that
in the kernel and have a single kernel source package. I wonder why Debian
hasn't upstreamed that yet -- whether there were any technical problems, or
just no one happened to look at that. That said, I personally could live with
this till we have a better solution.

If nothing works, maybe we could relax the goal of being able to build any
given kernel version and experiment with conditional execution paths.


With kind regards,
Baurzhan.

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

* Re: [PATCH 0/1] RFC: Package perf from linux kernel tools
  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-20 11:12 ` Henning Schild
  2021-01-20 11:21 ` Henning Schild
  2 siblings, 0 replies; 22+ messages in thread
From: Henning Schild @ 2021-01-20 11:12 UTC (permalink / raw)
  To: Felix Moessbauer
  Cc: isar-users, adriaan.schmidt, jan.kiszka, Cedric Hombourger

Hi,

i think perf support in general is something we clearly want to have.
As far as i remember Cedric might be interested as well, adding him to
CC.

Maybe a split into the basic support and the python bindings is useful.
Because those python bindings are pretty different from upstream, and
they probably deserve a test-package if we agree that we want to
support them in isar.

Henning

Am Tue, 19 Jan 2021 13:41:57 +0100
schrieb Felix Moessbauer <felix.moessbauer@siemens.com>:

> Hi all,
> 
> this patch adds support to build the linux-perf<version> package
> that includes the kernel specific perf tooling.
> 
> During implementation I tried two different approaches:
> 1. package as part of the kernel receipt (as Debian does)
> 2. package as a regular package (similar to how the kselftest is
> packaged)
> 
> This RFC implements approach 2 but tries to be as close as possible
> to the Debian upstream packaging.
> By that, we use the same patches from Debian upstream to build our
> package. Note, that these are dependent on the exact kernel version.
> Here, I used the latest available bugfix version from upstream
> (4.19.160). Perf should then be compatible with 4.19 kernels (only
> partially tested).
> 
> A major obstacle in implementing approach 1 was that the patches for
> linux-tools are not trivial and have to match with the corresponding
> kernel version. Writing that in a way that works for various kernel
> versions was something I was not able to accomplish.
> Hence, I decided that it might be better to avoid that much
> complexity in the kernel receipt. Most users might not need the tools
> anyways, but probably a custom kernel.
> 
> Finally, this patch also builds the kernel specific python bindings
> of perf. This patch has already been sent upstream, but is not yet
> integrated in Debian. For reference, see here:
> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=860957
> 
> Best regards,
> Felix Mößbauer
> 
> Felix Moessbauer (1):
>   RFC: Package perf from linux kernel tools
> 
>  .../recipes-kernel/linux-perf/files/rules     |  53 ++++++++
>  .../linux-perf/files/tools-perf-install.patch |  58 +++++++++
>  .../linux-perf/files/tools-perf-python.patch  |  55 ++++++++
>  .../linux-perf/files/tools-perf-version.patch | 119
> ++++++++++++++++++ .../linux-perf/linux-perf-4.19_4.19.160.bb    |
> 11 ++ .../recipes-kernel/linux-perf/linux-perf.inc  |  46 +++++++
>  6 files changed, 342 insertions(+)
>  create mode 100644 meta-isar/recipes-kernel/linux-perf/files/rules
>  create mode 100644
> meta-isar/recipes-kernel/linux-perf/files/tools-perf-install.patch
> create mode 100644
> meta-isar/recipes-kernel/linux-perf/files/tools-perf-python.patch
> create mode 100644
> meta-isar/recipes-kernel/linux-perf/files/tools-perf-version.patch
> create mode 100644
> meta-isar/recipes-kernel/linux-perf/linux-perf-4.19_4.19.160.bb
> create mode 100644 meta-isar/recipes-kernel/linux-perf/linux-perf.inc
> 


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

* Re: [PATCH 0/1] RFC: Package perf from linux kernel tools
  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-20 11:12 ` [PATCH 0/1] RFC: Package perf from linux kernel tools Henning Schild
@ 2021-01-20 11:21 ` Henning Schild
  2 siblings, 0 replies; 22+ messages in thread
From: Henning Schild @ 2021-01-20 11:21 UTC (permalink / raw)
  To: Felix Moessbauer; +Cc: isar-users, adriaan.schmidt, jan.kiszka

For a v2 perf should be added to scripts/ci_build or the local.conf
used by it which will probably reveal problems with bullseye and
stretch, maybe != x86 as well

You will get access to a Siemens internal CI for that and other future
contributions.

Henning

Am Tue, 19 Jan 2021 13:41:57 +0100
schrieb Felix Moessbauer <felix.moessbauer@siemens.com>:

> Hi all,
> 
> this patch adds support to build the linux-perf<version> package
> that includes the kernel specific perf tooling.
> 
> During implementation I tried two different approaches:
> 1. package as part of the kernel receipt (as Debian does)
> 2. package as a regular package (similar to how the kselftest is
> packaged)
> 
> This RFC implements approach 2 but tries to be as close as possible
> to the Debian upstream packaging.
> By that, we use the same patches from Debian upstream to build our
> package. Note, that these are dependent on the exact kernel version.
> Here, I used the latest available bugfix version from upstream
> (4.19.160). Perf should then be compatible with 4.19 kernels (only
> partially tested).
> 
> A major obstacle in implementing approach 1 was that the patches for
> linux-tools are not trivial and have to match with the corresponding
> kernel version. Writing that in a way that works for various kernel
> versions was something I was not able to accomplish.
> Hence, I decided that it might be better to avoid that much
> complexity in the kernel receipt. Most users might not need the tools
> anyways, but probably a custom kernel.
> 
> Finally, this patch also builds the kernel specific python bindings
> of perf. This patch has already been sent upstream, but is not yet
> integrated in Debian. For reference, see here:
> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=860957
> 
> Best regards,
> Felix Mößbauer
> 
> Felix Moessbauer (1):
>   RFC: Package perf from linux kernel tools
> 
>  .../recipes-kernel/linux-perf/files/rules     |  53 ++++++++
>  .../linux-perf/files/tools-perf-install.patch |  58 +++++++++
>  .../linux-perf/files/tools-perf-python.patch  |  55 ++++++++
>  .../linux-perf/files/tools-perf-version.patch | 119
> ++++++++++++++++++ .../linux-perf/linux-perf-4.19_4.19.160.bb    |
> 11 ++ .../recipes-kernel/linux-perf/linux-perf.inc  |  46 +++++++
>  6 files changed, 342 insertions(+)
>  create mode 100644 meta-isar/recipes-kernel/linux-perf/files/rules
>  create mode 100644
> meta-isar/recipes-kernel/linux-perf/files/tools-perf-install.patch
> create mode 100644
> meta-isar/recipes-kernel/linux-perf/files/tools-perf-python.patch
> create mode 100644
> meta-isar/recipes-kernel/linux-perf/files/tools-perf-version.patch
> create mode 100644
> meta-isar/recipes-kernel/linux-perf/linux-perf-4.19_4.19.160.bb
> create mode 100644 meta-isar/recipes-kernel/linux-perf/linux-perf.inc
> 


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

* RE: [PATCH 1/1] RFC: Package perf from linux kernel tools
  2021-01-19 16:31   ` Baurzhan Ismagulov
@ 2021-01-20 15:23     ` Moessbauer, Felix
  2021-01-20 15:26       ` Henning Schild
                         ` (3 more replies)
  0 siblings, 4 replies; 22+ messages in thread
From: Moessbauer, Felix @ 2021-01-20 15:23 UTC (permalink / raw)
  To: Baurzhan Ismagulov, henning.schild
  Cc: isar-users, Schmidt, Adriaan, jan.kiszka

Hi,

today I implemented the packaging in the kernel recipe and fixed some
nasty aspects like exact version numbers in the patches.
I'll send this patch to the mailing list as well.

One issue is still that we need per-kernel patches.
If anything in the original makefile of perf changed, our patches do not apply.
That lead me to the initial approach with having a dedicated package with multiple recipes,
to have different patch-sets per kernel version (and put it into the responsibility of the user).

Another issue with the kernel-recipe approach is that it's no longer possible to use the Debian kernel but customize / fix the linux-perf-<version> package.
Maybe we need both.

@Schild, Henning (T RDA IOT SES-DE):
Having the Python stuff in a dedicated commit is definitely a good idea.
It's already in its own patchset. I'll send a v2 to the list as well.

Best regards,
Felix

> -----Original Message-----
> From: Baurzhan Ismagulov <ibr@radix50.net>
> Sent: Tuesday, January 19, 2021 5:31 PM
> To: Moessbauer, Felix (T RDA IOT SES-DE) <felix.moessbauer@siemens.com>
> Cc: isar-users@googlegroups.com; Schmidt, Adriaan (T RDA IOT SES-DE)
> <adriaan.schmidt@siemens.com>; Schild, Henning (T RDA IOT SES-DE)
> <henning.schild@siemens.com>; Kiszka, Jan (T RDA IOT)
> <jan.kiszka@siemens.com>
> Subject: Re: [PATCH 1/1] RFC: Package perf from linux kernel tools
> 
> Hello Felix,
> 
> On Tue, Jan 19, 2021 at 01:41:58PM +0100, Felix Moessbauer wrote:
> > This patch adds the linux-perf-4.19 package for a kernel that is build
> > with ISAR.
> > As the perf binaries have to be version specific, we patch the
> > corresponding files from the kernel tools source to incorporate the
> > major and minor version number.
> > These patches are copied over from the official debianization of perf
> > that is done in the src:linux package.
> > Additionally, we package the perf python bindings as well and provide
> > them as module "perf_4_19" (in the tools-perf-python.patch).
> >
> > As this debianization is not part of the kernel receipt, the perf
> 
> Suggest "receipt" -> "recipe".
> 
> 
> > package can be based on a different patch version of the kernel.
> > While this might be intended, it is now the responibility of the user
> > to ensure that both the kernel and the linux-perf-<version> packages
> > are compatible.
> ...
> >  .../linux-perf/files/tools-perf-install.patch |  58 +++++++++
> > .../linux-perf/files/tools-perf-python.patch  |  55 ++++++++
> > .../linux-perf/files/tools-perf-version.patch | 119 ++++++++++++++++++
> 
> The patches look common sense to me; ideally, it would be better to handle that
> in the kernel and have a single kernel source package. I wonder why Debian
> hasn't upstreamed that yet -- whether there were any technical problems, or just
> no one happened to look at that. That said, I personally could live with this till
> we have a better solution.
> 
> If nothing works, maybe we could relax the goal of being able to build any given
> kernel version and experiment with conditional execution paths.
> 
> 
> With kind regards,
> Baurzhan.

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

* Re: [PATCH 1/1] RFC: Package perf from linux kernel tools
  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
                         ` (2 subsequent siblings)
  3 siblings, 0 replies; 22+ messages in thread
From: Henning Schild @ 2021-01-20 15:26 UTC (permalink / raw)
  To: Moessbauer, Felix (T RDA IOT SES-DE)
  Cc: Baurzhan Ismagulov, isar-users, Schmidt,
	Adriaan (T RDA IOT SES-DE), Kiszka, Jan (T RDA IOT)

Am Wed, 20 Jan 2021 16:23:18 +0100
schrieb "Moessbauer, Felix (T RDA IOT SES-DE)"
<felix.moessbauer@siemens.com>:

> Hi,
> 
> today I implemented the packaging in the kernel recipe and fixed some
> nasty aspects like exact version numbers in the patches.
> I'll send this patch to the mailing list as well.
> 
> One issue is still that we need per-kernel patches.
> If anything in the original makefile of perf changed, our patches do
> not apply. That lead me to the initial approach with having a
> dedicated package with multiple recipes, to have different patch-sets
> per kernel version (and put it into the responsibility of the user).
> 
> Another issue with the kernel-recipe approach is that it's no longer
> possible to use the Debian kernel but customize / fix the
> linux-perf-<version> package. Maybe we need both.

But i guess debian has perf packages for kernels taken from them. So
this would only be a problem if one had a need to add python binding
support to such a kernel. In which case one could always rebuild the
same sources+config under another name ...

Henning

> @Schild, Henning (T RDA IOT SES-DE):
> Having the Python stuff in a dedicated commit is definitely a good
> idea. It's already in its own patchset. I'll send a v2 to the list as
> well.
> 
> Best regards,
> Felix
> 
> > -----Original Message-----
> > From: Baurzhan Ismagulov <ibr@radix50.net>
> > Sent: Tuesday, January 19, 2021 5:31 PM
> > To: Moessbauer, Felix (T RDA IOT SES-DE)
> > <felix.moessbauer@siemens.com> Cc: isar-users@googlegroups.com;
> > Schmidt, Adriaan (T RDA IOT SES-DE) <adriaan.schmidt@siemens.com>;
> > Schild, Henning (T RDA IOT SES-DE) <henning.schild@siemens.com>;
> > Kiszka, Jan (T RDA IOT) <jan.kiszka@siemens.com>
> > Subject: Re: [PATCH 1/1] RFC: Package perf from linux kernel tools
> >
> > Hello Felix,
> >
> > On Tue, Jan 19, 2021 at 01:41:58PM +0100, Felix Moessbauer wrote:  
> > > This patch adds the linux-perf-4.19 package for a kernel that is
> > > build with ISAR.
> > > As the perf binaries have to be version specific, we patch the
> > > corresponding files from the kernel tools source to incorporate
> > > the major and minor version number.
> > > These patches are copied over from the official debianization of
> > > perf that is done in the src:linux package.
> > > Additionally, we package the perf python bindings as well and
> > > provide them as module "perf_4_19" (in the
> > > tools-perf-python.patch).
> > >
> > > As this debianization is not part of the kernel receipt, the perf
> > >  
> >
> > Suggest "receipt" -> "recipe".
> >
> >  
> > > package can be based on a different patch version of the kernel.
> > > While this might be intended, it is now the responibility of the
> > > user to ensure that both the kernel and the linux-perf-<version>
> > > packages are compatible.  
> > ...  
> > >  .../linux-perf/files/tools-perf-install.patch |  58 +++++++++
> > > .../linux-perf/files/tools-perf-python.patch  |  55 ++++++++
> > > .../linux-perf/files/tools-perf-version.patch | 119
> > > ++++++++++++++++++  
> >
> > The patches look common sense to me; ideally, it would be better to
> > handle that in the kernel and have a single kernel source package.
> > I wonder why Debian hasn't upstreamed that yet -- whether there
> > were any technical problems, or just no one happened to look at
> > that. That said, I personally could live with this till we have a
> > better solution.
> >
> > If nothing works, maybe we could relax the goal of being able to
> > build any given kernel version and experiment with conditional
> > execution paths.
> >
> >
> > With kind regards,
> > Baurzhan.  


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

* [PATCH v2 0/2] RFC: Package perf from linux kernel tools
  2021-01-20 15:23     ` Moessbauer, Felix
  2021-01-20 15:26       ` Henning Schild
@ 2021-01-21 10:52       ` Felix Moessbauer
  2021-01-21 11:56         ` Jan Kiszka
                           ` (2 more replies)
  2021-01-21 10:52       ` [PATCH 1/2] feat: package linux-perf-<version> in kernel recipe Felix Moessbauer
  2021-01-21 10:52       ` [PATCH 2/2] feat: add and package python bindings for perf Felix Moessbauer
  3 siblings, 3 replies; 22+ messages in thread
From: Felix Moessbauer @ 2021-01-21 10:52 UTC (permalink / raw)
  To: isar-users; +Cc: Felix Moessbauer

Hi,

thanks for your input that is reflected in the following patchsets.

Changes since v1:

- package as part of kernel recipe
- put python patch in dedicated commit
- add support for 5.4 kernels
- enable users to provide custom patches

One pain point is still that we have to copy the patches
from upstream debian. IMO it would be better to just fetch
them, but then we would have to somehow map to a branch on
salsa. Any recommendations?

Best regards,
Felix

Felix Moessbauer (2):
  feat: package linux-perf-<version> in kernel recipe
  feat: package perf for 5.4 kernels

 .../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-python.patch  |  16 +++
 .../patches/perf/5.4/tools-perf-version.patch | 111 ++++++++++++++++
 meta/recipes-kernel/linux/linux-custom.inc    |  11 +-
 meta/recipes-kernel/linux/linux-tools.inc     |  67 ++++++++++
 10 files changed, 538 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/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-python.patch
 create mode 100644 meta/recipes-kernel/linux/linux-tools.inc

-- 
2.20.1


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

* [PATCH 1/2] feat: package linux-perf-<version> in kernel recipe
  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 10:52       ` Felix Moessbauer
  2021-02-17 10:28         ` Baurzhan Ismagulov
  2021-01-21 10:52       ` [PATCH 2/2] feat: add and package python bindings for perf Felix Moessbauer
  3 siblings, 1 reply; 22+ messages in thread
From: Felix Moessbauer @ 2021-01-21 10:52 UTC (permalink / raw)
  To: isar-users; +Cc: Felix Moessbauer

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


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

* [PATCH 2/2] feat: add and package python bindings for perf
  2021-01-20 15:23     ` Moessbauer, Felix
                         ` (2 preceding siblings ...)
  2021-01-21 10:52       ` [PATCH 1/2] feat: package linux-perf-<version> in kernel recipe Felix Moessbauer
@ 2021-01-21 10:52       ` Felix Moessbauer
  3 siblings, 0 replies; 22+ messages in thread
From: Felix Moessbauer @ 2021-01-21 10:52 UTC (permalink / raw)
  To: isar-users; +Cc: Felix Moessbauer

Signed-off-by: Felix Moessbauer <felix.moessbauer@siemens.com>
---
 .../patches/perf/4.19/tools-perf-python.patch    | 16 ++++++++++++++++
 meta/recipes-kernel/linux/linux-tools.inc        |  1 +
 2 files changed, 17 insertions(+)
 create mode 100644 meta/recipes-kernel/linux/files/patches/perf/4.19/tools-perf-python.patch

diff --git a/meta/recipes-kernel/linux/files/patches/perf/4.19/tools-perf-python.patch b/meta/recipes-kernel/linux/files/patches/perf/4.19/tools-perf-python.patch
new file mode 100644
index 0000000..6fc1bde
--- /dev/null
+++ b/meta/recipes-kernel/linux/files/patches/perf/4.19/tools-perf-python.patch
@@ -0,0 +1,16 @@
+--- a/tools/perf/Makefile.perf
++++ b/tools/perf/Makefile.perf
+@@ -829,10 +829,10 @@
+ 
+ install-bin: install-tools install-tests install-traceevent-plugins
+ 
+-install: install-bin try-install-man
+-
+ install-python_ext:
+-	$(PYTHON_WORD) util/setup.py --quiet install --root='/$(DESTDIR_SQ)'
++	$(PYTHON_WORD) util/setup.py --quiet install --root='/$(DESTDIR_SQ)' --install-layout=deb;
++
++install: install-bin try-install-man install-python_ext
+ 
+ # 'make install-doc' should call 'make -C Documentation install'
+ $(INSTALL_DOC_TARGETS):
diff --git a/meta/recipes-kernel/linux/linux-tools.inc b/meta/recipes-kernel/linux/linux-tools.inc
index b1e9376..07b93a2 100644
--- a/meta/recipes-kernel/linux/linux-tools.inc
+++ b/meta/recipes-kernel/linux/linux-tools.inc
@@ -34,6 +34,7 @@ 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 \
+    file://patches/perf/4.19/tools-perf-python.patch \
 "
 KERNEL_PERF_PATCHES[5.4] ?= " \
     file://patches/perf/5.4/tools-perf-version.patch \
-- 
2.20.1


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

* Re: [PATCH v2 0/2] RFC: Package perf from linux kernel tools
  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-02-09  8:58         ` Anton Mikanovich
  2021-02-17 10:18         ` Baurzhan Ismagulov
  2 siblings, 1 reply; 22+ messages in thread
From: Jan Kiszka @ 2021-01-21 11:56 UTC (permalink / raw)
  To: [ext] Felix Moessbauer, isar-users

On 21.01.21 11:52, [ext] Felix Moessbauer wrote:
> Hi,
> 
> thanks for your input that is reflected in the following patchsets.
> 
> Changes since v1:
> 
> - package as part of kernel recipe
> - put python patch in dedicated commit
> - add support for 5.4 kernels
> - enable users to provide custom patches
> 
> One pain point is still that we have to copy the patches
> from upstream debian. IMO it would be better to just fetch
> them, but then we would have to somehow map to a branch on
> salsa. Any recommendations?
> 

The patches are targeting the kernel sources, right? Then upstream the
features that we are missing from the kernel. After that, we will "only"
have to deal with a shrinking number of backports for which we can
provide a view references. When keeping the patches downstream, we will
soon have a huge number of additional patches to carry - or perf support
will even bitrot again with newer kernels.

Jan

-- 
Siemens AG, T RDA IOT
Corporate Competence Center Embedded Linux

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

* RE: [PATCH v2 0/2] RFC: Package perf from linux kernel tools
  2021-01-21 11:56         ` Jan Kiszka
@ 2021-01-21 15:00           ` Moessbauer, Felix
  2021-01-21 16:35             ` Jan Kiszka
  0 siblings, 1 reply; 22+ messages in thread
From: Moessbauer, Felix @ 2021-01-21 15:00 UTC (permalink / raw)
  To: jan.kiszka, isar-users

Hi Jan,

Well... the patches target the Makefiles of perf in the kernel sources. And they add things like versioning (e.g. perf_4.19 instead of perf) and directory layouts of the install targets.
That's something which is (IMO) unlikely to be accepted by the kernel itself.
But apparently, nobody had tried to upstream this yet (according to a quick search on the LKML).

With the current approach, it cannot really rot.
When a new kernel is added, it is disabled per default.
Nonetheless, I don't see another strategy than just manually porting this to each new KR.

Best regards,
Felix

> -----Original Message-----
> From: Jan Kiszka <jan.kiszka@siemens.com>
> Sent: Thursday, January 21, 2021 12:56 PM
> To: Moessbauer, Felix (T RDA IOT SES-DE) <felix.moessbauer@siemens.com>;
> isar-users@googlegroups.com
> Subject: Re: [PATCH v2 0/2] RFC: Package perf from linux kernel tools
> 
> On 21.01.21 11:52, [ext] Felix Moessbauer wrote:
> > Hi,
> >
> > thanks for your input that is reflected in the following patchsets.
> >
> > Changes since v1:
> >
> > - package as part of kernel recipe
> > - put python patch in dedicated commit
> > - add support for 5.4 kernels
> > - enable users to provide custom patches
> >
> > One pain point is still that we have to copy the patches from upstream
> > debian. IMO it would be better to just fetch them, but then we would
> > have to somehow map to a branch on salsa. Any recommendations?
> >
> 
> The patches are targeting the kernel sources, right? Then upstream the features
> that we are missing from the kernel. After that, we will "only"
> have to deal with a shrinking number of backports for which we can provide a
> view references. When keeping the patches downstream, we will soon have a
> huge number of additional patches to carry - or perf support will even bitrot
> again with newer kernels.
> 
> Jan
> 
> --
> Siemens AG, T RDA IOT
> Corporate Competence Center Embedded Linux

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

* Re: [PATCH v2 0/2] RFC: Package perf from linux kernel tools
  2021-01-21 15:00           ` Moessbauer, Felix
@ 2021-01-21 16:35             ` Jan Kiszka
  0 siblings, 0 replies; 22+ messages in thread
From: Jan Kiszka @ 2021-01-21 16:35 UTC (permalink / raw)
  To: Moessbauer, Felix (T RDA IOT SES-DE), isar-users

On 21.01.21 16:00, Moessbauer, Felix (T RDA IOT SES-DE) wrote:
> Hi Jan,
> 
> Well... the patches target the Makefiles of perf in the kernel sources. And they add things like versioning (e.g. perf_4.19 instead of perf) and directory layouts of the install targets.
> That's something which is (IMO) unlikely to be accepted by the kernel itself.
> But apparently, nobody had tried to upstream this yet (according to a quick search on the LKML).

Hard-coded Debian-specific settings are not going to be accepted. Smart
ways to make things more configurable may be.

Jan

> 
> With the current approach, it cannot really rot.
> When a new kernel is added, it is disabled per default.
> Nonetheless, I don't see another strategy than just manually porting this to each new KR.
> 
> Best regards,
> Felix
> 
>> -----Original Message-----
>> From: Jan Kiszka <jan.kiszka@siemens.com>
>> Sent: Thursday, January 21, 2021 12:56 PM
>> To: Moessbauer, Felix (T RDA IOT SES-DE) <felix.moessbauer@siemens.com>;
>> isar-users@googlegroups.com
>> Subject: Re: [PATCH v2 0/2] RFC: Package perf from linux kernel tools
>>
>> On 21.01.21 11:52, [ext] Felix Moessbauer wrote:
>>> Hi,
>>>
>>> thanks for your input that is reflected in the following patchsets.
>>>
>>> Changes since v1:
>>>
>>> - package as part of kernel recipe
>>> - put python patch in dedicated commit
>>> - add support for 5.4 kernels
>>> - enable users to provide custom patches
>>>
>>> One pain point is still that we have to copy the patches from upstream
>>> debian. IMO it would be better to just fetch them, but then we would
>>> have to somehow map to a branch on salsa. Any recommendations?
>>>
>>
>> The patches are targeting the kernel sources, right? Then upstream the features
>> that we are missing from the kernel. After that, we will "only"
>> have to deal with a shrinking number of backports for which we can provide a
>> view references. When keeping the patches downstream, we will soon have a
>> huge number of additional patches to carry - or perf support will even bitrot
>> again with newer kernels.
>>
>> Jan
>>
>> --
>> Siemens AG, T RDA IOT
>> Corporate Competence Center Embedded Linux

-- 
Siemens AG, T RDA IOT
Corporate Competence Center Embedded Linux

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

* Re: [PATCH v2 0/2] RFC: Package perf from linux kernel tools
  2021-01-21 10:52       ` [PATCH v2 0/2] " Felix Moessbauer
  2021-01-21 11:56         ` Jan Kiszka
@ 2021-02-09  8:58         ` Anton Mikanovich
  2021-02-17 10:18         ` Baurzhan Ismagulov
  2 siblings, 0 replies; 22+ messages in thread
From: Anton Mikanovich @ 2021-02-09  8:58 UTC (permalink / raw)
  To: Felix Moessbauer, isar-users

21.01.2021 13:52, Felix Moessbauer wrote:
> Hi,
>
> thanks for your input that is reflected in the following patchsets.
>
> Changes since v1:
>
> - package as part of kernel recipe
> - put python patch in dedicated commit
> - add support for 5.4 kernels
> - enable users to provide custom patches
>
> One pain point is still that we have to copy the patches
> from upstream debian. IMO it would be better to just fetch
> them, but then we would have to somehow map to a branch on
> salsa. Any recommendations?
>
> Best regards,
> Felix

Hello, this patchset causes CI to fail on building linux-mainline-5.4.70 
at mk-build-deps stage:

 >11:24:13 ERROR: mc:de0-nano-soc-buster:linux-mainline-5.4.70-r0 
do_install_builddeps: Execution of 
'/workspace/build/isar_am_devel_fast/80/build/tmp/work/debian-buster-armhf/linux-mainline/5.4.70-r0/temp/run.do_install_builddeps.14242' 
failed with exit code 1:
 >...
 >11:24:13 dpkg-deb: building package 'linux-mainline-cross-build-deps' 
in '../linux-mainline-cross-build-deps_5.4.70+r0_armhf.deb'.
 >...
 >11:24:13 Correcting dependencies...Starting pkgProblemResolver with 
broken count: 2
 >11:24:13 Starting 2 pkgProblemResolver with broken count: 2
 >11:24:13 Investigating (0) python3:amd64 < 3.7.3-1 @ii mK Ib >
 >11:24:13 Broken python3:amd64 PreDepends on python3-minimal:amd64 < 
3.7.3-1 @ii mR > (= 3.7.3-1)
 >11:24:13   Considering python3-minimal:amd64 -1 as a solution to 
python3:amd64 3
 >11:24:13   Added python3-minimal:amd64 to the remove list
 >...
 >11:24:13 The following packages will be REMOVED:
 >11:24:13   devscripts linux-mainline-cross-build-deps:armhf python3 
python3-minimal
 >11:24:13   python3.7 python3.7-minimal
 >...
 >11:24:13 0 upgraded, 21 newly installed, 6 to remove and 0 not upgraded.
 >11:24:13 1 not fully installed or removed.
 >...
 >11:24:13 mk-build-deps: Unable to install 
linux-mainline-cross-build-deps at /usr/bin/mk-build-deps line 416.
 >11:24:13 mk-build-deps: Unable to install all build-dep packages
 >11:24:13 mk-build-deps: Unable to install all build-dep packages
 >...
 >11:24:13 NOTE: recipe linux-mainline-5.4.70-r0: task 
do_install_builddeps: Failed

Full log: 
http://ci.isar-build.org:8080/job/isar_am_devel_fast/80/consoleFull

Did you miss python patch for 5.4 also?

-- 
Anton Mikanovich
Promwad Ltd.
External service provider of ilbers GmbH
Maria-Merian-Str. 8
85521 Ottobrunn, Germany
+49 (89) 122 67 24-0
Commercial register Munich, HRB 214197
General Manager: Baurzhan Ismagulov


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

* Re: [PATCH v2 0/2] RFC: Package perf from linux kernel tools
  2021-01-21 10:52       ` [PATCH v2 0/2] " Felix Moessbauer
  2021-01-21 11:56         ` Jan Kiszka
  2021-02-09  8:58         ` Anton Mikanovich
@ 2021-02-17 10:18         ` Baurzhan Ismagulov
  2 siblings, 0 replies; 22+ messages in thread
From: Baurzhan Ismagulov @ 2021-02-17 10:18 UTC (permalink / raw)
  To: isar-users

On Thu, Jan 21, 2021 at 11:52:22AM +0100, Felix Moessbauer wrote:
> One pain point is still that we have to copy the patches
> from upstream debian. IMO it would be better to just fetch
> them, but then we would have to somehow map to a branch on
> salsa. Any recommendations?

Copying is good enough for me.

With kind regards,
Baurzhan.

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

* Re: [PATCH 1/2] feat: package linux-perf-<version> in kernel recipe
  2021-01-21 10:52       ` [PATCH 1/2] feat: package linux-perf-<version> in kernel recipe Felix Moessbauer
@ 2021-02-17 10:28         ` Baurzhan Ismagulov
  2021-02-18  8:01           ` Moessbauer, Felix
  0 siblings, 1 reply; 22+ messages in thread
From: Baurzhan Ismagulov @ 2021-02-17 10:28 UTC (permalink / raw)
  To: isar-users

On Thu, Jan 21, 2021 at 11:52:23AM +0100, Felix Moessbauer wrote:
> 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
...
> +%:
> +	CFLAGS= LDFLAGS= dh $@ --parallel
> +

> diff --git a/meta/recipes-kernel/linux/linux-tools.inc b/meta/recipes-kernel/linux/linux-tools.inc
...
> +    d.appendVar('KBUILD_DEPENDS', d.getVar('PERF_BUILD_DEPENDS'))
> +}
> +


Extra newlines.


> diff --git a/meta/recipes-kernel/linux/linux-tools.inc b/meta/recipes-kernel/linux/linux-tools.inc
...
> +PERF_BUILD_DEPENDS = "\
> +   asciidoctor <!stage1 !nodoc !pkg.linux.notools !nopython>, \

Inconsistent indentation, suggest 4 spaces.


> diff --git a/meta/recipes-kernel/linux/linux-tools.inc b/meta/recipes-kernel/linux/linux-tools.inc
...
> +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

I agree that we should at least try upstreaming the missing stuff. Also, does
anything speak against building it as is (possibly breaking the build)?


With kind regards,
Baurzhan.

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

* RE: [PATCH 1/2] feat: package linux-perf-<version> in kernel recipe
  2021-02-17 10:28         ` Baurzhan Ismagulov
@ 2021-02-18  8:01           ` Moessbauer, Felix
  2021-02-18  8:28             ` Jan Kiszka
  2021-04-22  9:52             ` Anton Mikanovich
  0 siblings, 2 replies; 22+ messages in thread
From: Moessbauer, Felix @ 2021-02-18  8:01 UTC (permalink / raw)
  To: Baurzhan Ismagulov, isar-users; +Cc: henning.schild

Hi Baurzhan,

Thanks for the review.
I'll change that in the next version.

In the meantime, I discovered that there are still a couple of things missing for Debian bullseye.
They added version bindings between linux-perf and linux-perf-<version>, so we have to build the linux-perf package as well.
I'll do that in v2 as well.

Apart from that: IMO doing the debianization of the kernel tools (also kselftest) in the kernel recipe is way better than having it in a dedicated recipe.
Using this approach, it is also possible to use an upstream kernel, but our perf package.
Technically, we then have to fetch and build the whole kernel manually, but only the perf packages are installed.
That's a bit of extra work (which could be avoided if we check inside the kernel recipe which target is attracted. Don't know if that's possible).

One issue with mixing upstream kernels and custom tools is still that we do not have a guarantee that these will still work when the kernel gets updated via APT.
Maybe we should pin the kernel as well...

Best regards,
Felix

> -----Original Message-----
> From: isar-users@googlegroups.com <isar-users@googlegroups.com> On
> Behalf Of Baurzhan Ismagulov
> Sent: Wednesday, February 17, 2021 11:29 AM
> To: isar-users@googlegroups.com
> Subject: Re: [PATCH 1/2] feat: package linux-perf-<version> in kernel recipe
> 
> On Thu, Jan 21, 2021 at 11:52:23AM +0100, Felix Moessbauer wrote:
> > 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
> ...
> > +%:
> > +	CFLAGS= LDFLAGS= dh $@ --parallel
> > +
> 
> > diff --git a/meta/recipes-kernel/linux/linux-tools.inc
> > b/meta/recipes-kernel/linux/linux-tools.inc
> ...
> > +    d.appendVar('KBUILD_DEPENDS', d.getVar('PERF_BUILD_DEPENDS')) }
> > +
> 
> 
> Extra newlines.
> 
> 
> > diff --git a/meta/recipes-kernel/linux/linux-tools.inc
> > b/meta/recipes-kernel/linux/linux-tools.inc
> ...
> > +PERF_BUILD_DEPENDS = "\
> > +   asciidoctor <!stage1 !nodoc !pkg.linux.notools !nopython>, \
> 
> Inconsistent indentation, suggest 4 spaces.
> 
> 
> > diff --git a/meta/recipes-kernel/linux/linux-tools.inc
> > b/meta/recipes-kernel/linux/linux-tools.inc
> ...
> > +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
> 
> I agree that we should at least try upstreaming the missing stuff. Also, does
> anything speak against building it as is (possibly breaking the build)?
> 
> 
> With kind regards,
> Baurzhan.
> 
> --
> You received this message because you are subscribed to the Google Groups
> "isar-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email
> to isar-users+unsubscribe@googlegroups.com.
> To view this discussion on the web visit
> https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.g
> oogle.com%2Fd%2Fmsgid%2Fisar-
> users%2F20210217102830.GB20742%2540yssyq.m.ilbers.de&amp;data=04%7C
> 01%7Cfelix.moessbauer%40siemens.com%7Cd4bc5686516141d00e2608d8d32e
> caf7%7C38ae3bcd95794fd4addab42e1495d55a%7C1%7C1%7C63749154521515
> 9014%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzI
> iLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&amp;sdata=Ayu3mTDPJ%2F8c7u
> lMVpYEWKWp2d18cUwZmZ7iYu82gm4%3D&amp;reserved=0.

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

* Re: [PATCH 1/2] feat: package linux-perf-<version> in kernel recipe
  2021-02-18  8:01           ` Moessbauer, Felix
@ 2021-02-18  8:28             ` Jan Kiszka
  2021-04-22  9:52             ` Anton Mikanovich
  1 sibling, 0 replies; 22+ messages in thread
From: Jan Kiszka @ 2021-02-18  8:28 UTC (permalink / raw)
  To: [ext] Moessbauer, Felix, Baurzhan Ismagulov, isar-users; +Cc: henning.schild

On 18.02.21 09:01, [ext] Moessbauer, Felix wrote:
> Hi Baurzhan,
> 
> Thanks for the review.
> I'll change that in the next version.
> 
> In the meantime, I discovered that there are still a couple of things missing for Debian bullseye.
> They added version bindings between linux-perf and linux-perf-<version>, so we have to build the linux-perf package as well.
> I'll do that in v2 as well.
> 
> Apart from that: IMO doing the debianization of the kernel tools (also kselftest) in the kernel recipe is way better than having it in a dedicated recipe.
> Using this approach, it is also possible to use an upstream kernel, but our perf package.
> Technically, we then have to fetch and build the whole kernel manually, but only the perf packages are installed.
> That's a bit of extra work (which could be avoided if we check inside the kernel recipe which target is attracted. Don't know if that's possible).

I don't thing you can explore that during the build. But you could add
some control variables to the kernel recipe that will decide which
packages are going to be built out of it.

Jan

-- 
Siemens AG, T RDA IOT
Corporate Competence Center Embedded Linux

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

* Re: [PATCH 1/2] feat: package linux-perf-<version> in kernel recipe
  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
                                 ` (2 more replies)
  1 sibling, 3 replies; 22+ messages in thread
From: Anton Mikanovich @ 2021-04-22  9:52 UTC (permalink / raw)
  To: Moessbauer, Felix, Baurzhan Ismagulov, isar-users; +Cc: henning.schild

Hello Felix,
Are there any news regarding next version preparation?

18.02.2021 11:01, Moessbauer, Felix wrote:
> Hi Baurzhan,
>
> Thanks for the review.
> I'll change that in the next version.
>
> In the meantime, I discovered that there are still a couple of things missing for Debian bullseye.
> They added version bindings between linux-perf and linux-perf-<version>, so we have to build the linux-perf package as well.
> I'll do that in v2 as well.
>
> Apart from that: IMO doing the debianization of the kernel tools (also kselftest) in the kernel recipe is way better than having it in a dedicated recipe.
> Using this approach, it is also possible to use an upstream kernel, but our perf package.
> Technically, we then have to fetch and build the whole kernel manually, but only the perf packages are installed.
> That's a bit of extra work (which could be avoided if we check inside the kernel recipe which target is attracted. Don't know if that's possible).
>
> One issue with mixing upstream kernels and custom tools is still that we do not have a guarantee that these will still work when the kernel gets updated via APT.
> Maybe we should pin the kernel as well...
>
> Best regards,
> Felix

-- 
Anton Mikanovich
Promwad Ltd.
External service provider of ilbers GmbH
Maria-Merian-Str. 8
85521 Ottobrunn, Germany
+49 (89) 122 67 24-0
Commercial register Munich, HRB 214197
General Manager: Baurzhan Ismagulov


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

* [RFC v2 0/2] package linux-perf-<version> in kernel recipe
  2021-04-22  9:52             ` Anton Mikanovich
@ 2021-04-27  9:24               ` 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
  2 siblings, 0 replies; 22+ messages in thread
From: Felix Moessbauer @ 2021-04-27  9:24 UTC (permalink / raw)
  To: isar-users, amikan, jan.kiszka; +Cc: henning.schild, Felix Moessbauer

Hi Anton,

there has been some back and forth on how to package perf and its python bindings.
IMO the out-of-tree packaging provides the most promising solution here,
as the kernel versions do not have to match exactly.

Also with debian bullseye things changed again, as an exact-version binding was
introduced between linux-perf and linxu-perf-<KR>. By that, both have to be
build from the same source package. Now, we build and provide that package as well.

Our final goal for all the effort was to get the python bindings of perf packaged.
These are missing in upstream debian. Unfortunately the kernel itself does not
provide any hooks to inject the version "into" the python-binding c source files,
so we have to use patches to inject the version into the c function names.
I already sent that patch to debian but did not get a response yet.
For details, see here:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=860957

Anyways, we run this patch series on a bunch of images for both
debian-buster and debian-bullseye (both custom and debian kernels) for a while.
In combination with the wrapper in patch 2, even things like
`import perf` work flawlessly.

Best regards,
Felix

Felix Moessbauer (2):
  RFC: Package perf from linux kernel tools
  Add wrapper to load correct python perf module based on kernel

 .../files/debian/linux-base.install           |   6 +
 .../files/lib/python3/dist-packages/perf.py   |  23 ++++
 .../recipes-core/linux-base/linux-base_4.6.bb |  25 ++++
 .../linux-perf/debian/control.tmpl            |  45 ++++++
 .../recipes-kernel/linux-perf/debian/rules    |  59 ++++++++
 .../files/4.19/tools-perf-install.patch       |  58 ++++++++
 .../files/4.19/tools-perf-python.patch        |  55 ++++++++
 .../files/4.19/tools-perf-version.patch       | 119 ++++++++++++++++
 .../files/5.10/tools-perf-install.patch       |  52 +++++++
 .../files/5.10/tools-perf-python.patch        |  56 ++++++++
 .../files/5.10/tools-perf-version.patch       | 128 ++++++++++++++++++
 .../recipes-kernel/linux-perf/files/rules     |  53 ++++++++
 .../linux-perf/files/tools-perf-install.patch |  58 ++++++++
 .../linux-perf/files/tools-perf-python.patch  |  55 ++++++++
 .../linux-perf/files/tools-perf-version.patch | 119 ++++++++++++++++
 .../linux-perf/linux-perf-4.19_4.19.160.bb    |  15 ++
 .../linux-perf/linux-perf-5.10_5.10.26.bb     |  15 ++
 .../recipes-kernel/linux-perf/linux-perf.inc  |  47 +++++++
 18 files changed, 988 insertions(+)
 create mode 100644 meta-isar/recipes-core/linux-base/files/debian/linux-base.install
 create mode 100644 meta-isar/recipes-core/linux-base/files/lib/python3/dist-packages/perf.py
 create mode 100644 meta-isar/recipes-core/linux-base/linux-base_4.6.bb
 create mode 100644 meta-isar/recipes-kernel/linux-perf/debian/control.tmpl
 create mode 100644 meta-isar/recipes-kernel/linux-perf/debian/rules
 create mode 100644 meta-isar/recipes-kernel/linux-perf/files/4.19/tools-perf-install.patch
 create mode 100644 meta-isar/recipes-kernel/linux-perf/files/4.19/tools-perf-python.patch
 create mode 100644 meta-isar/recipes-kernel/linux-perf/files/4.19/tools-perf-version.patch
 create mode 100644 meta-isar/recipes-kernel/linux-perf/files/5.10/tools-perf-install.patch
 create mode 100644 meta-isar/recipes-kernel/linux-perf/files/5.10/tools-perf-python.patch
 create mode 100644 meta-isar/recipes-kernel/linux-perf/files/5.10/tools-perf-version.patch
 create mode 100644 meta-isar/recipes-kernel/linux-perf/files/rules
 create mode 100644 meta-isar/recipes-kernel/linux-perf/files/tools-perf-install.patch
 create mode 100644 meta-isar/recipes-kernel/linux-perf/files/tools-perf-python.patch
 create mode 100644 meta-isar/recipes-kernel/linux-perf/files/tools-perf-version.patch
 create mode 100644 meta-isar/recipes-kernel/linux-perf/linux-perf-4.19_4.19.160.bb
 create mode 100644 meta-isar/recipes-kernel/linux-perf/linux-perf-5.10_5.10.26.bb
 create mode 100644 meta-isar/recipes-kernel/linux-perf/linux-perf.inc

-- 
2.20.1


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

* [PATCH v2 1/2] RFC: Package perf from linux kernel tools
  2021-04-22  9:52             ` Anton Mikanovich
  2021-04-27  9:24               ` [RFC v2 0/2] " Felix Moessbauer
@ 2021-04-27  9:24               ` Felix Moessbauer
  2021-04-27  9:24               ` [PATCH v2 2/2] Add wrapper to load correct python perf module based on kernel Felix Moessbauer
  2 siblings, 0 replies; 22+ messages in thread
From: Felix Moessbauer @ 2021-04-27  9:24 UTC (permalink / raw)
  To: isar-users, amikan, jan.kiszka; +Cc: henning.schild, Felix Moessbauer

This patch adds the linux-perf-<KR> package for a kernel
that is build with ISAR.
As the perf binaries have to be version specific, we patch
the corresponding files from the kernel tools source to incorporate
the major and minor version number.
These patches are copied over from the official debianization of perf
that is done in the src:linux package.
Additionally, we package the perf python bindings as well and provide
them as module "perf_<MAJOR>_<MINOR>" (in the tools-perf-python.patch).

As this debianization is not part of the kernel recipe, the perf
package can be based on a different patch version of the kernel.
While this might be intended, it is now the responibility of the
user to ensure that both the kernel and the linux-perf-<version>
packages are compatible.

Signed-off-by: Felix Moessbauer <felix.moessbauer@siemens.com>
---
 .../linux-perf/debian/control.tmpl            |  45 ++++++
 .../recipes-kernel/linux-perf/debian/rules    |  59 ++++++++
 .../files/4.19/tools-perf-install.patch       |  58 ++++++++
 .../files/4.19/tools-perf-python.patch        |  55 ++++++++
 .../files/4.19/tools-perf-version.patch       | 119 ++++++++++++++++
 .../files/5.10/tools-perf-install.patch       |  52 +++++++
 .../files/5.10/tools-perf-python.patch        |  56 ++++++++
 .../files/5.10/tools-perf-version.patch       | 128 ++++++++++++++++++
 .../recipes-kernel/linux-perf/files/rules     |  53 ++++++++
 .../linux-perf/files/tools-perf-install.patch |  58 ++++++++
 .../linux-perf/files/tools-perf-python.patch  |  55 ++++++++
 .../linux-perf/files/tools-perf-version.patch | 119 ++++++++++++++++
 .../linux-perf/linux-perf-4.19_4.19.160.bb    |  15 ++
 .../linux-perf/linux-perf-5.10_5.10.26.bb     |  15 ++
 .../recipes-kernel/linux-perf/linux-perf.inc  |  47 +++++++
 15 files changed, 934 insertions(+)
 create mode 100644 meta-isar/recipes-kernel/linux-perf/debian/control.tmpl
 create mode 100644 meta-isar/recipes-kernel/linux-perf/debian/rules
 create mode 100644 meta-isar/recipes-kernel/linux-perf/files/4.19/tools-perf-install.patch
 create mode 100644 meta-isar/recipes-kernel/linux-perf/files/4.19/tools-perf-python.patch
 create mode 100644 meta-isar/recipes-kernel/linux-perf/files/4.19/tools-perf-version.patch
 create mode 100644 meta-isar/recipes-kernel/linux-perf/files/5.10/tools-perf-install.patch
 create mode 100644 meta-isar/recipes-kernel/linux-perf/files/5.10/tools-perf-python.patch
 create mode 100644 meta-isar/recipes-kernel/linux-perf/files/5.10/tools-perf-version.patch
 create mode 100644 meta-isar/recipes-kernel/linux-perf/files/rules
 create mode 100644 meta-isar/recipes-kernel/linux-perf/files/tools-perf-install.patch
 create mode 100644 meta-isar/recipes-kernel/linux-perf/files/tools-perf-python.patch
 create mode 100644 meta-isar/recipes-kernel/linux-perf/files/tools-perf-version.patch
 create mode 100644 meta-isar/recipes-kernel/linux-perf/linux-perf-4.19_4.19.160.bb
 create mode 100644 meta-isar/recipes-kernel/linux-perf/linux-perf-5.10_5.10.26.bb
 create mode 100644 meta-isar/recipes-kernel/linux-perf/linux-perf.inc

diff --git a/meta-isar/recipes-kernel/linux-perf/debian/control.tmpl b/meta-isar/recipes-kernel/linux-perf/debian/control.tmpl
new file mode 100644
index 0000000..e204437
--- /dev/null
+++ b/meta-isar/recipes-kernel/linux-perf/debian/control.tmpl
@@ -0,0 +1,45 @@
+Source: linux-perf-${KERNEL_PERF_COMPAT}
+Maintainer: ${MAINTAINER}
+Priority: optional
+Build-Profiles: <!noperf>
+Section: devel
+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,
+ flex,
+ bison,
+
+Package: linux-perf-${KERNEL_PERF_COMPAT}
+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
+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.
+
+
+Package: linux-perf
+Build-Profiles: <!stage1 !pkg.linux.notools !nopython !pkg.linux.nometa>
+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
+Depends: linux-perf-${KERNEL_PERF_COMPAT} (= ${binary:Version}), ${misc:Depends}
+Description: Performance analysis tools for Linux (meta-package)
+ This package depends on the package containing the 'perf' performance
+ analysis tools for the latest Linux kernel.
diff --git a/meta-isar/recipes-kernel/linux-perf/debian/rules b/meta-isar/recipes-kernel/linux-perf/debian/rules
new file mode 100644
index 0000000..b21876e
--- /dev/null
+++ b/meta-isar/recipes-kernel/linux-perf/debian/rules
@@ -0,0 +1,59 @@
+#!/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)/binarypackage
+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))
+
+
+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
+
+	# do not ship python2 script
+	rm -f $(DESTDIR)/usr/lib/perf_$(VERSION)-core/scripts/python/call-graph-from-sql.py
+
+	# Check for unversioned files that are likely to result in file conflicts
+	cd $(DESTDIR) && ! find \! -type d \! -path '*[_-]$(VERS_PATTERN)*' | grep .
+
+override_dh_shlibdeps:
+	dh_shlibdeps -Xperf-read-vdso
+
+override_dh_auto_clean:
+	rm -rf ${deb_top_dir}/binarypackage
+
+override_dh_auto_test:
+	echo "Skip tests"
+
+%:
+	CFLAGS= LDFLAGS= dh $@ --parallel
+
diff --git a/meta-isar/recipes-kernel/linux-perf/files/4.19/tools-perf-install.patch b/meta-isar/recipes-kernel/linux-perf/files/4.19/tools-perf-install.patch
new file mode 100644
index 0000000..8cfd02a
--- /dev/null
+++ b/meta-isar/recipes-kernel/linux-perf/files/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-isar/recipes-kernel/linux-perf/files/4.19/tools-perf-python.patch b/meta-isar/recipes-kernel/linux-perf/files/4.19/tools-perf-python.patch
new file mode 100644
index 0000000..5770d9f
--- /dev/null
+++ b/meta-isar/recipes-kernel/linux-perf/files/4.19/tools-perf-python.patch
@@ -0,0 +1,55 @@
+--- a/tools/perf/Makefile.perf
++++ b/tools/perf/Makefile.perf
+@@ -829,10 +829,10 @@
+ 
+ install-bin: install-tools install-tests install-traceevent-plugins
+ 
+-install: install-bin try-install-man
+-
+ install-python_ext:
+-	$(PYTHON_WORD) util/setup.py --quiet install --root='/$(DESTDIR_SQ)'
++	$(PYTHON_WORD) util/setup.py --quiet install --root='/$(DESTDIR_SQ)' --install-layout=deb;
++
++install: install-bin try-install-man install-python_ext
+ 
+ # 'make install-doc' should call 'make -C Documentation install'
+ $(INSTALL_DOC_TARGETS):
+--- a/tools/perf/util/setup.py
++++ b/tools/perf/util/setup.py
+@@ -51,14 +51,14 @@
+ # use full paths with source files
+ ext_sources = list(map(lambda x: '%s/%s' % (src_perf, x) , ext_sources))
+ 
+-perf = Extension('perf',
++perf = Extension('perf_4_19',
+ 		  sources = ext_sources,
+ 		  include_dirs = ['util/include'],
+ 		  extra_compile_args = cflags,
+ 		  extra_objects = [libtraceevent, libapikfs],
+                  )
+ 
+-setup(name='perf',
++setup(name='perf_4_19',
+       version='0.1',
+       description='Interface with the Linux profiling infrastructure',
+       author='Arnaldo Carvalho de Melo',
+--- a/tools/perf/util/python.c
++++ b/tools/perf/util/python.c
+@@ -77,7 +77,7 @@
+ #if PY_MAJOR_VERSION < 3
+ PyMODINIT_FUNC initperf(void);
+ #else
+-PyMODINIT_FUNC PyInit_perf(void);
++PyMODINIT_FUNC PyInit_perf_4_19(void);
+ #endif
+ 
+ #define member_def(type, member, ptype, help) \
+@@ -1270,7 +1270,7 @@
+ #if PY_MAJOR_VERSION < 3
+ PyMODINIT_FUNC initperf(void)
+ #else
+-PyMODINIT_FUNC PyInit_perf(void)
++PyMODINIT_FUNC PyInit_perf_4_19(void)
+ #endif
+ {
+ 	PyObject *obj;
diff --git a/meta-isar/recipes-kernel/linux-perf/files/4.19/tools-perf-version.patch b/meta-isar/recipes-kernel/linux-perf/files/4.19/tools-perf-version.patch
new file mode 100644
index 0000000..6833bb7
--- /dev/null
+++ b/meta-isar/recipes-kernel/linux-perf/files/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-isar/recipes-kernel/linux-perf/files/5.10/tools-perf-install.patch b/meta-isar/recipes-kernel/linux-perf/files/5.10/tools-perf-install.patch
new file mode 100644
index 0000000..b25bd25
--- /dev/null
+++ b/meta-isar/recipes-kernel/linux-perf/files/5.10/tools-perf-install.patch
@@ -0,0 +1,52 @@
+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
+@@ -952,8 +952,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
+@@ -967,22 +967,22 @@ 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) tests/pe-file.exe* '$(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-isar/recipes-kernel/linux-perf/files/5.10/tools-perf-python.patch b/meta-isar/recipes-kernel/linux-perf/files/5.10/tools-perf-python.patch
new file mode 100644
index 0000000..205ec19
--- /dev/null
+++ b/meta-isar/recipes-kernel/linux-perf/files/5.10/tools-perf-python.patch
@@ -0,0 +1,56 @@
+--- a/tools/perf/Makefile.perf
++++ b/tools/perf/Makefile.perf
+@@ -982,10 +982,10 @@
+ 
+ install-bin: install-tools install-tests install-traceevent-plugins
+ 
+-install: install-bin try-install-man
+-
+ install-python_ext:
+-	$(PYTHON_WORD) util/setup.py --quiet install --root='/$(DESTDIR_SQ)'
++	$(PYTHON_WORD) util/setup.py --quiet install --root='/$(DESTDIR_SQ)' --install-layout=deb
++
++install: install-bin try-install-man install-python_ext
+ 
+ # 'make install-doc' should call 'make -C Documentation install'
+ $(INSTALL_DOC_TARGETS):
+--- a/tools/perf/util/python.c
++++ b/tools/perf/util/python.c
+@@ -110,7 +110,7 @@
+ #if PY_MAJOR_VERSION < 3
+ PyMODINIT_FUNC initperf(void);
+ #else
+-PyMODINIT_FUNC PyInit_perf(void);
++PyMODINIT_FUNC PyInit_perf_5_10(void);
+ #endif
+ 
+ #define member_def(type, member, ptype, help) \
+@@ -1303,7 +1303,7 @@
+ #if PY_MAJOR_VERSION < 3
+ PyMODINIT_FUNC initperf(void)
+ #else
+-PyMODINIT_FUNC PyInit_perf(void)
++PyMODINIT_FUNC PyInit_perf_5_10(void)
+ #endif
+ {
+ 	PyObject *obj;
+--- a/tools/perf/util/setup.py
++++ b/tools/perf/util/setup.py
+@@ -66,7 +66,7 @@
+ if '-DHAVE_LIBCAP_SUPPORT' in cflags:
+     extra_libraries += [ 'cap' ]
+ 
+-perf = Extension('perf',
++perf = Extension('perf_5_10',
+ 		  sources = ext_sources,
+ 		  include_dirs = ['util/include'],
+ 		  libraries = extra_libraries,
+@@ -74,7 +74,7 @@
+ 		  extra_objects = [libtraceevent, libapikfs, libperf],
+                  )
+ 
+-setup(name='perf',
++setup(name='perf_5_10',
+       version='0.1',
+       description='Interface with the Linux profiling infrastructure',
+       author='Arnaldo Carvalho de Melo',
diff --git a/meta-isar/recipes-kernel/linux-perf/files/5.10/tools-perf-version.patch b/meta-isar/recipes-kernel/linux-perf/files/5.10/tools-perf-version.patch
new file mode 100644
index 0000000..ccc2883
--- /dev/null
+++ b/meta-isar/recipes-kernel/linux-perf/files/5.10/tools-perf-version.patch
@@ -0,0 +1,128 @@
+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.]
+---
+ tools/perf/Documentation/Makefile | 14 ++++++++------
+ tools/perf/Makefile.perf          | 16 ++++++++--------
+ tools/perf/util/Build             |  1 +
+ tools/perf/util/vdso.c            |  4 ++--
+ 4 files changed, 19 insertions(+), 16 deletions(-)
+
+diff --git a/tools/perf/Documentation/Makefile b/tools/perf/Documentation/Makefile
+index 6e54979c2124..db2cb7669da1 100644
+--- a/tools/perf/Documentation/Makefile
++++ b/tools/perf/Documentation/Makefile
+@@ -195,14 +195,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
+ 
+diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
+index 86dbb51bb272..ed69643c3249 100644
+--- a/tools/perf/Makefile.perf
++++ b/tools/perf/Makefile.perf
+@@ -888,23 +888,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'; \
+@@ -942,7 +942,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)'
+@@ -967,7 +967,7 @@ install-python_ext:
+ 
+ # 'make install-doc' should call 'make -C Documentation install'
+ $(INSTALL_DOC_TARGETS):
+-	$(Q)$(MAKE) -C $(DOC_DIR) O=$(OUTPUT) $(@:-doc=) ASCIIDOC_EXTRA=$(ASCIIDOC_EXTRA)
++	$(Q)$(MAKE) -C $(DOC_DIR) O=$(OUTPUT) $(@:-doc=) ASCIIDOC_EXTRA=$(ASCIIDOC_EXTRA) VERSION=$(VERSION)
+ 
+ ### Cleaning rules
+ 
+diff --git a/tools/perf/util/Build b/tools/perf/util/Build
+index 8d18380ecd10..5dd0f6c387b3 100644
+--- a/tools/perf/util/Build
++++ b/tools/perf/util/Build
+@@ -234,6 +234,7 @@ CFLAGS_hweight.o       += -Wno-unused-parameter -DETC_PERFCONFIG="BUILD_STR($(ET
+ CFLAGS_parse-events.o  += -Wno-redundant-decls
+ CFLAGS_expr.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)
+diff --git a/tools/perf/util/vdso.c b/tools/perf/util/vdso.c
+index 3cc91ad048ea..e7483388bb5d 100644
+--- a/tools/perf/util/vdso.c
++++ b/tools/perf/util/vdso.c
+@@ -55,12 +55,12 @@ static struct vdso_info *vdso_info__new(void)
+ 		.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
+ 	};
+-- 
+2.27.0
+
diff --git a/meta-isar/recipes-kernel/linux-perf/files/rules b/meta-isar/recipes-kernel/linux-perf/files/rules
new file mode 100644
index 0000000..e23586c
--- /dev/null
+++ b/meta-isar/recipes-kernel/linux-perf/files/rules
@@ -0,0 +1,53 @@
+#!/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 := 4.19
+deb_top_dir := $(CURDIR)/debian
+DESTDIR := $(deb_top_dir)/binarypackage
+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))
+
+
+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}/binarypackage
+
+override_dh_auto_test:
+	echo "Skip tests"
+
+%:
+	CFLAGS= LDFLAGS= dh $@ --parallel
+
diff --git a/meta-isar/recipes-kernel/linux-perf/files/tools-perf-install.patch b/meta-isar/recipes-kernel/linux-perf/files/tools-perf-install.patch
new file mode 100644
index 0000000..8cfd02a
--- /dev/null
+++ b/meta-isar/recipes-kernel/linux-perf/files/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-isar/recipes-kernel/linux-perf/files/tools-perf-python.patch b/meta-isar/recipes-kernel/linux-perf/files/tools-perf-python.patch
new file mode 100644
index 0000000..5770d9f
--- /dev/null
+++ b/meta-isar/recipes-kernel/linux-perf/files/tools-perf-python.patch
@@ -0,0 +1,55 @@
+--- a/tools/perf/Makefile.perf
++++ b/tools/perf/Makefile.perf
+@@ -829,10 +829,10 @@
+ 
+ install-bin: install-tools install-tests install-traceevent-plugins
+ 
+-install: install-bin try-install-man
+-
+ install-python_ext:
+-	$(PYTHON_WORD) util/setup.py --quiet install --root='/$(DESTDIR_SQ)'
++	$(PYTHON_WORD) util/setup.py --quiet install --root='/$(DESTDIR_SQ)' --install-layout=deb;
++
++install: install-bin try-install-man install-python_ext
+ 
+ # 'make install-doc' should call 'make -C Documentation install'
+ $(INSTALL_DOC_TARGETS):
+--- a/tools/perf/util/setup.py
++++ b/tools/perf/util/setup.py
+@@ -51,14 +51,14 @@
+ # use full paths with source files
+ ext_sources = list(map(lambda x: '%s/%s' % (src_perf, x) , ext_sources))
+ 
+-perf = Extension('perf',
++perf = Extension('perf_4_19',
+ 		  sources = ext_sources,
+ 		  include_dirs = ['util/include'],
+ 		  extra_compile_args = cflags,
+ 		  extra_objects = [libtraceevent, libapikfs],
+                  )
+ 
+-setup(name='perf',
++setup(name='perf_4_19',
+       version='0.1',
+       description='Interface with the Linux profiling infrastructure',
+       author='Arnaldo Carvalho de Melo',
+--- a/tools/perf/util/python.c
++++ b/tools/perf/util/python.c
+@@ -77,7 +77,7 @@
+ #if PY_MAJOR_VERSION < 3
+ PyMODINIT_FUNC initperf(void);
+ #else
+-PyMODINIT_FUNC PyInit_perf(void);
++PyMODINIT_FUNC PyInit_perf_4_19(void);
+ #endif
+ 
+ #define member_def(type, member, ptype, help) \
+@@ -1270,7 +1270,7 @@
+ #if PY_MAJOR_VERSION < 3
+ PyMODINIT_FUNC initperf(void)
+ #else
+-PyMODINIT_FUNC PyInit_perf(void)
++PyMODINIT_FUNC PyInit_perf_4_19(void)
+ #endif
+ {
+ 	PyObject *obj;
diff --git a/meta-isar/recipes-kernel/linux-perf/files/tools-perf-version.patch b/meta-isar/recipes-kernel/linux-perf/files/tools-perf-version.patch
new file mode 100644
index 0000000..6833bb7
--- /dev/null
+++ b/meta-isar/recipes-kernel/linux-perf/files/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-isar/recipes-kernel/linux-perf/linux-perf-4.19_4.19.160.bb b/meta-isar/recipes-kernel/linux-perf/linux-perf-4.19_4.19.160.bb
new file mode 100644
index 0000000..638741c
--- /dev/null
+++ b/meta-isar/recipes-kernel/linux-perf/linux-perf-4.19_4.19.160.bb
@@ -0,0 +1,15 @@
+# This software is a part of ISAR.
+# Copyright (c) Siemens AG, 2021
+#
+# SPDX-License-Identifier: MIT
+KERNEL_PERF_COMPAT = "4.19"
+
+SRC_URI += " \
+	https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-${PV}.tar.xz \
+	file://4.19/tools-perf-version.patch; \
+	file://4.19/tools-perf-install.patch; \
+	file://4.19/tools-perf-python.patch; \
+"
+SRC_URI[sha256sum] = "18345206f9c61e8adafa5204d0ca0b8619f1d9aafd70cbd5cb0fbf1faf521585"
+
+require recipes-kernel/linux-perf/linux-perf.inc
diff --git a/meta-isar/recipes-kernel/linux-perf/linux-perf-5.10_5.10.26.bb b/meta-isar/recipes-kernel/linux-perf/linux-perf-5.10_5.10.26.bb
new file mode 100644
index 0000000..d49b5fd
--- /dev/null
+++ b/meta-isar/recipes-kernel/linux-perf/linux-perf-5.10_5.10.26.bb
@@ -0,0 +1,15 @@
+# This software is a part of ISAR.
+# Copyright (c) Siemens AG, 2021
+#
+# SPDX-License-Identifier: MIT
+KERNEL_PERF_COMPAT = "5.10"
+
+SRC_URI += " \
+	https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-${PV}.tar.xz \
+	file://5.10/tools-perf-version.patch; \
+	file://5.10/tools-perf-install.patch; \
+	file://5.10/tools-perf-python.patch; \
+"
+SRC_URI[sha256sum] = "fc532833f1ac167f363f1b9de85db39d2d635ab516f66dc381bdd70804601482"
+
+require recipes-kernel/linux-perf/linux-perf.inc
diff --git a/meta-isar/recipes-kernel/linux-perf/linux-perf.inc b/meta-isar/recipes-kernel/linux-perf/linux-perf.inc
new file mode 100644
index 0000000..8f426ad
--- /dev/null
+++ b/meta-isar/recipes-kernel/linux-perf/linux-perf.inc
@@ -0,0 +1,47 @@
+# Kernel specific linux-perf-<KR> package
+#
+# This software is a part of ISAR.
+# Copyright (c) Siemens AG, 2021
+#
+# SPDX-License-Identifier: MIT
+#
+# This recipe packages the perf tools independently
+# of the kernel build. By that, it is possible to
+# patch the perf package while still using an upstream kernel
+#
+# To build perf for a new (upstream) kernel, include this
+# recipe in a file "linux-perf-<KR>_<KR-Full>".
+# E.g. linux-perf-5.10_5.10.13
+# In this recipe, set SRC_URI to the kernel sources and add your patches
+#
+# Note: only major and minor versions of the kernel have to match,
+# the patch level should be irrelevant.
+
+inherit dpkg
+
+MAINTAINER ?= "Felix Moessbauer <felix.moessbauer@siemens.com>"
+CHANGELOG_V ?= "${PV}+rtcloud"
+
+SRC_URI += " \
+  file://debian \
+"
+S = "${WORKDIR}/linux-${PV}"
+
+TEMPLATE_FILES += "debian/control.tmpl"
+TEMPLATE_VARS += "KERNEL_PERF_COMPAT"
+
+do_prepare_build[cleandirs] += "${S}/debian"
+
+do_prepare_build() {
+  deb_debianize
+  cp ${WORKDIR}/debian/control ${S}/debian/
+  cp ${WORKDIR}/debian/rules ${S}/debian/
+  echo "native" > ${S}/debian/source
+  echo "debian/binarypackage/usr /" > ${S}/debian/linux-perf-${KERNEL_PERF_COMPAT}.install
+  deb_add_changelog
+}
+
+dpkg_runbuild_prepend() {
+  export DEB_BUILD_OPTIONS="nocheck"
+  export KERNEL_PERF_COMPAT="${KERNEL_PERF_COMPAT}"
+}
-- 
2.20.1


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

* [PATCH v2 2/2] Add wrapper to load correct python perf module based on kernel
  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               ` Felix Moessbauer
  2 siblings, 0 replies; 22+ messages in thread
From: Felix Moessbauer @ 2021-04-27  9:24 UTC (permalink / raw)
  To: isar-users, amikan, jan.kiszka; +Cc: henning.schild, Felix Moessbauer

This patch adds a wrapper around the versioned python bindings of
perf. The wrapper takes care of detecting the current kernel version
and loading the perf_<version> module. Then, it mapps this module
to just perf, so downstream python modules just have to `import perf`
instead of the versioned version.

Signed-off-by: Felix Moessbauer <felix.moessbauer@siemens.com>
---
 .../files/debian/linux-base.install           |  6 +++++
 .../files/lib/python3/dist-packages/perf.py   | 23 +++++++++++++++++
 .../recipes-core/linux-base/linux-base_4.6.bb | 25 +++++++++++++++++++
 3 files changed, 54 insertions(+)
 create mode 100644 meta-isar/recipes-core/linux-base/files/debian/linux-base.install
 create mode 100644 meta-isar/recipes-core/linux-base/files/lib/python3/dist-packages/perf.py
 create mode 100644 meta-isar/recipes-core/linux-base/linux-base_4.6.bb

diff --git a/meta-isar/recipes-core/linux-base/files/debian/linux-base.install b/meta-isar/recipes-core/linux-base/files/debian/linux-base.install
new file mode 100644
index 0000000..b94175d
--- /dev/null
+++ b/meta-isar/recipes-core/linux-base/files/debian/linux-base.install
@@ -0,0 +1,6 @@
+bin/linux-check-removal usr/bin
+bin/linux-update-symlinks usr/bin
+bin/linux-version usr/bin
+bin/perf usr/bin
+lib/DebianLinux.pm usr/share/perl5
+lib/python3/dist-packages/perf.py usr/lib/python3/dist-packages/
diff --git a/meta-isar/recipes-core/linux-base/files/lib/python3/dist-packages/perf.py b/meta-isar/recipes-core/linux-base/files/lib/python3/dist-packages/perf.py
new file mode 100644
index 0000000..26d3e81
--- /dev/null
+++ b/meta-isar/recipes-core/linux-base/files/lib/python3/dist-packages/perf.py
@@ -0,0 +1,23 @@
+#!/usr/bin/python3
+# Wrapper to load the kernel-specific version
+# of the python perf module
+
+import platform
+
+uname = platform.uname().release
+kvers = uname.split('.')
+
+if len(kvers) < 2:
+  raise RuntimeError('Could not detect kernel version in: {}'.format(kvers))
+try:
+  perf = __import__('perf_{}_{}'.format(kvers[0], kvers[1]))
+  symbols = [symbol for symbol in perf.__dict__ if not symbol.startswith("_")]
+  globals().update({symbol: getattr(perf, symbol) for symbol in symbols})
+  del perf
+  del symbols
+except ModuleNotFoundError:
+  raise ModuleNotFoundError('perf package not found. Install debian package linux-perf-{}.{}'.format(kvers[0],kvers[1]))
+
+del platform
+del uname
+del kvers
diff --git a/meta-isar/recipes-core/linux-base/linux-base_4.6.bb b/meta-isar/recipes-core/linux-base/linux-base_4.6.bb
new file mode 100644
index 0000000..178e4cb
--- /dev/null
+++ b/meta-isar/recipes-core/linux-base/linux-base_4.6.bb
@@ -0,0 +1,25 @@
+# Patched version of linux-base that includes perf python wrapper
+#
+# This software is a part of ISAR.
+# Copyright (c) Siemens AG, 2021
+#
+# SPDX-License-Identifier: MIT
+
+inherit dpkg
+
+SRC_URI = " \
+    apt://${PN} \
+    file://lib/python3/dist-packages/perf.py \
+    file://debian/linux-base.install \
+    "
+
+MAINTAINER ?= "isar-users <isar-users@googlegroups.com>"
+CHANGELOG_V ?= "<orig-version>+isar"
+
+do_prepare_build() {
+    mkdir -p ${S}/lib/python3/dist-packages
+    cp -r ${WORKDIR}/lib ${S}
+    cp -r ${WORKDIR}/debian ${S}
+    cd ${S}
+    deb_add_changelog
+}
-- 
2.20.1


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

end of thread, other threads:[~2021-04-27  9:28 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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       ` [PATCH 1/2] feat: package linux-perf-<version> in kernel recipe Felix Moessbauer
2021-02-17 10:28         ` 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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox