Linux kernel specific infrastructure
v5 cover Linux kernel specific infrastructure
This patches series introduces a new infrastructure to build Linux tools available in the kernel tree.
Currently, the only Linux tool packaged in Buildroot is Perf and it is use the generic package infrastructure.
But before introduce this new infra, merge some patches for Perf.
- Fix Perf optional dependencies.
- Add the Linux tools core infra.
- Add a new Linux tool: cpupower.
- Migrate the perf package to the new Linux tool infra.
- Add the documentation about Linux tool infra and Linux extensions.
Thanks Yann and Arnout for your help and review.
Romain Naour (4):
linux: add linux-tools infra
linux-tools: add cpupower
package/perf: migrate perf to use the new linux-tools infrastructure docs/manual: add documentation for linux-ext and linux-tools.
Steven Noonan (4):
package/perf: if slang is enabled, depend on it package/perf: if numactl (libnuma) is enabled, depend on it package/perf: if libunwind is enabled, depend on it package/perf: use correct definition of ARCH on x86_64
Config.in.legacy | 7 + docs/manual/adding-packages-kernel-module.txt | 1 + .../adding-packages-linux-kernel-spec-infra.txt | 143 +++++++++++++++++++++ docs/manual/adding-packages.txt | 2 + linux/Config.in | 3 + package/perf/Config.in => linux/Config.tools.in | 18 ++- linux/linux-tool-cpupower.mk | 39 ++++++ package/perf/perf.mk => linux/linux-tool-perf.mk | 43 +++++-- linux/linux.mk | 24 ++++ package/Config.in | 1 - 10 files changed, 262 insertions(+), 19 deletions(-) create mode 100644 docs/manual/adding-packages-linux-kernel-spec-infra.txt rename package/perf/Config.in => linux/Config.tools.in (63%) create mode 100644 linux/linux-tool-cpupower.mk rename package/perf/perf.mk => linux/linux-tool-perf.mk (65%)
Signature · 1 line
2.4.3
PATCH v5 1/8 package/perf: if slang is enabled, depend on it
From: Steven Noonan <[email protected]>
[Romain:
- fix coding style]
---
V5: new patch
--- package/perf/perf.mk | 4 ++++ 1 file changed, 4 insertions(+)
package/perf/perf.mk +4 -0
@@ -32,6 +32,10 @@ ifeq ($(BR2_arc),y) PERF_MAKE_FLAGS += NO_BACKTRACE=1 endif +ifeq ($(BR2_PACKAGE_SLANG),y) +PERF_DEPENDENCIES += slang +endif + ifeq ($(BR2_PACKAGE_ELFUTILS),y) PERF_DEPENDENCIES += elfutils else
Signature · 1 line
2.4.3
PATCH v5 2/8 package/perf: if numactl (libnuma) is enabled, depend on it
In reply to Romain NaourFrom: Steven Noonan <[email protected]>
[Romain:
- fix coding style]
---
v5: new patch
--- package/perf/perf.mk | 4 ++++ 1 file changed, 4 insertions(+)
package/perf/perf.mk +4 -0
@@ -36,6 +36,10 @@ ifeq ($(BR2_PACKAGE_SLANG),y) PERF_DEPENDENCIES += slang endif +ifeq ($(BR2_PACKAGE_NUMACTL),y) +PERF_DEPENDENCIES += numactl +endif + ifeq ($(BR2_PACKAGE_ELFUTILS),y) PERF_DEPENDENCIES += elfutils else
Signature · 1 line
2.4.3
PATCH v5 3/8 package/perf: if libunwind is enabled, depend on it
In reply to Romain NaourFrom: Steven Noonan <[email protected]>
[Romain:
- fix coding style]
---
v5: new patch
--- package/perf/perf.mk | 4 ++++ 1 file changed, 4 insertions(+)
package/perf/perf.mk +4 -0
@@ -36,6 +36,10 @@ ifeq ($(BR2_PACKAGE_SLANG),y) PERF_DEPENDENCIES += slang endif +ifeq ($(BR2_PACKAGE_LIBUNWIND),y) +PERF_DEPENDENCIES += libunwind +endif + ifeq ($(BR2_PACKAGE_NUMACTL),y) PERF_DEPENDENCIES += numactl endif
Signature · 1 line
2.4.3
PATCH v5 4/8 package/perf: use correct definition of ARCH on x86_64
In reply to Romain NaourFrom: Steven Noonan <[email protected]>
LINUX_MAKE_FLAGS defines ARCH=$(KERNEL_ARCH), and KERNEL_ARCH is x86_64 on a 64-bit x86 kernel build. The perf Makefiles expect that the ARCH will be "x86" on both 32-bit x86 and 64-bit x86.
I didn't experience issues with the Linux 3.14.x version of perf, but this issue cropped up once I started building 3.19.x.
[Romain:
- fix coding style]
---
v5: new patch
--- package/perf/perf.mk | 7 +++++++ 1 file changed, 7 insertions(+)
package/perf/perf.mk +7 -0
@@ -10,8 +10,15 @@ PERF_VERSION = $(call qstrip,$(BR2_LINUX_KERNEL_VERSION)) PERF_DEPENDENCIES = linux host-flex host-bison +ifeq ($(KERNEL_ARCH),x86_64) +PERF_ARCH=x86 +else +PERF_ARCH=$(KERNEL_ARCH) +endif + PERF_MAKE_FLAGS = \ $(LINUX_MAKE_FLAGS) \ + ARCH=$(PERF_ARCH) \ NO_LIBAUDIT=1 \ NO_NEWT=1 \ NO_GTK2=1 \
Signature · 1 line
2.4.3
PATCH v5 5/8 linux: add linux-tools infra
In reply to Romain NaourThis commit add an infrastructure to build linux kernel tools available in the kernel sources.
Currently, the only linux kernel tool packaged in Buildroot is perf and it's packaged as a separate generic package. This is a problem for licence information raised in this thread [1].
Since these tools require to build a Linux kernel, we can use some hooks in linux package like we did for linux extensions [2] and remove the perf package.
[1] http://lists.busybox.net/pipermail/buildroot/2015-May/128783.html
[2] http://lists.busybox.net/pipermail/buildroot/2015-March/121835.html
---
v5: no change
v4: no change
v3: unconditionally set LINUX_INSTALL_STAGING to YES
v2: remove LINUX_TOOL prefix
--- linux/linux.mk | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
linux/linux.mk +24 -0
@@ -313,6 +313,8 @@ define LINUX_INSTALL_TARGET_CMDS $(LINUX_INSTALL_HOST_TOOLS) endef +# Include all our externsions and tools definitions. +# # Note: our package infrastructure uses the full-path of the last-scanned # Makefile to determine what package we're currently defining, using the # last directory component in the path. As such, including other Makefile,
@@ -322,6 +324,7 @@ endef # the current Makefile, we are OK. But this is a hard requirement: files # included here *must* be in the same directory! include $(sort $(wildcard linux/linux-ext-*.mk)) +include $(sort $(wildcard linux/linux-tool-*.mk)) LINUX_PATCH_DEPENDENCIES += $(foreach ext,$(LINUX_EXTENSIONS),\ $(if $(BR2_LINUX_KERNEL_EXT_$(call UPPERCASE,$(ext))),$(ext)))
@@ -330,6 +333,27 @@ LINUX_PRE_PATCH_HOOKS += $(foreach ext,$(LINUX_EXTENSIONS),\ $(if $(BR2_LINUX_KERNEL_EXT_$(call UPPERCASE,$(ext))),\ $(call UPPERCASE,$(ext))_PREPARE_KERNEL)) +# Install Linux kernel tools in staging directory since some tools +# may install shared libraries and headers (e.g. cpupower). The +# kernel image is NOT installed in staging directory. +LINUX_INSTALL_STAGING = YES + +LINUX_DEPENDENCIES += $(foreach tool,$(LINUX_TOOLS),\ + $(if $(BR2_LINUX_KERNEL_TOOL_$(call UPPERCASE,$(tool))),\ + $($(call UPPERCASE,$(tool))_DEPENDENCIES))) + +LINUX_POST_BUILD_HOOKS += $(foreach tool,$(LINUX_TOOLS),\ + $(if $(BR2_LINUX_KERNEL_TOOL_$(call UPPERCASE,$(tool))),\ + $(call UPPERCASE,$(tool))_BUILD_CMDS)) + +LINUX_POST_INSTALL_STAGING_HOOKS += $(foreach tool,$(LINUX_TOOLS),\ + $(if $(BR2_LINUX_KERNEL_TOOL_$(call UPPERCASE,$(tool))),\ + $(call UPPERCASE,$(tool))_INSTALL_STAGING_CMDS)) + +LINUX_POST_INSTALL_TARGET_HOOKS += $(foreach tool,$(LINUX_TOOLS),\ + $(if $(BR2_LINUX_KERNEL_TOOL_$(call UPPERCASE,$(tool))),\ + $(call UPPERCASE,$(tool))_INSTALL_TARGET_CMDS)) + # Checks to give errors that the user can understand ifeq ($(BR_BUILDING),y)
Signature · 1 line
2.4.3
PATCH v5 6/8 linux-tools: add cpupower
In reply to Romain NaourThis patch is based on the patch send by James Knight:
http://lists.busybox.net/pipermail/buildroot/2015-May/128754.html
---
v5: no change
v4: no change
v3: Use CPUPOWER_MAKE_OPTS to factorize commun options
v2: remove LINUX_TOOL prefix
use $(D) instead of $(LINUX_DIR)
fix title style
--- linux/Config.in | 3 +++ linux/Config.tools.in | 11 +++++++++++ linux/linux-tool-cpupower.mk | 39 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 53 insertions(+) create mode 100644 linux/Config.tools.in create mode 100644 linux/linux-tool-cpupower.mk
linux/Config.in +3 -0
@@ -364,6 +364,9 @@ config BR2_LINUX_KERNEL_INSTALL_TARGET # Linux extensions source "linux/Config.ext.in" +# Linux tools +source "linux/Config.tools.in" + endif # BR2_LINUX_KERNEL endmenu
linux/Config.tools.in new file +11 -0
@@ -0,0 +1,11 @@ +menu "Linux Kernel Tools" + +config BR2_LINUX_KERNEL_TOOL_CPUPOWER + bool "cpupower" + depends on !BR2_bfin # pciutils + select BR2_PACKAGE_PCIUTILS + help + cpupower is a collection of tools to examine and tune power + saving related features of your processor. + +endmenu
linux/linux-tool-cpupower.mk new file +39 -0
@@ -0,0 +1,39 @@ +################################################################################ +# +# cpupower +# +################################################################################ + +LINUX_TOOLS += cpupower + +CPUPOWER_DEPENDENCIES = pciutils + +CPUPOWER_MAKE_OPTS = CROSS=$(TARGET_CROSS) \ + CPUFREQ_BENCH=false \ + DEBUG=false + +define CPUPOWER_BUILD_CMDS + $(Q)if test ! -f $(@D)/tools/power/cpupower/Makefile ; then \ + echo "Your kernel version is too old and does not have the cpupower tool." ; \ + echo "At least kernel 3.4 must be used." ; \ + exit 1 ; \ + fi + + $(TARGET_MAKE_ENV) $(MAKE) -C $(@D)/tools \ + $(CPUPOWER_MAKE_OPTS) \ + cpupower +endef + +define CPUPOWER_INSTALL_STAGING_CMDS + $(TARGET_MAKE_ENV) $(MAKE) -C $(@D)/tools \ + $(CPUPOWER_MAKE_OPTS) \ + DESTDIR=$(STAGING_DIR) \ + cpupower_install +endef + +define CPUPOWER_INSTALL_TARGET_CMDS + $(TARGET_MAKE_ENV) $(MAKE) -C $(@D)/tools \ + $(CPUPOWER_MAKE_OPTS) \ + DESTDIR=$(TARGET_DIR) \ + cpupower_install +endef
Signature · 1 line
2.4.3
PATCH v5 7/8 package/perf: migrate perf to use the new linux-tools infrastructure
In reply to Romain NaourRemove perf package and add legacy handling.
---
v5: build inside tools/perf directory
v4: revert the O=$(@D) removal and add a comment
why it's needed.
fix the legacy prompt.
v3: remove last LINUX_TOOL prefix
v2: remove LINUX_TOOL prefix
use $(D) instead of $(LINUX_DIR)
fix title style
remove useless O=$(@D)
---
Config.in.legacy | 7 +++++++
linux/Config.tools.in | 18 ++++++++++++++++++
package/perf/perf.mk => linux/linux-tool-perf.mk | 24 +++++++++++-------------
package/Config.in | 1 -
package/perf/Config.in | 21 ---------------------
5 files changed, 36 insertions(+), 35 deletions(-)
rename package/perf/perf.mk => linux/linux-tool-perf.mk (76%)
delete mode 100644 package/perf/Config.inConfig.in.legacy +7 -0
@@ -107,6 +107,13 @@ endif ############################################################################### comment "Legacy options removed in 2015.08" +config BR2_PACKAGE_PERF + bool "perf option has been renamed" + select BR2_LEGACY + select BR2_LINUX_KERNEL_TOOL_PERF + help + Perf package has been moved to linux tools package. + config BR2_BINUTILS_VERSION_2_22 bool "binutils 2.22 removed" select BR2_LEGACY
linux/Config.tools.in +18 -0
@@ -8,4 +8,22 @@ config BR2_LINUX_KERNEL_TOOL_CPUPOWER cpupower is a collection of tools to examine and tune power saving related features of your processor. +config BR2_LINUX_KERNEL_TOOL_PERF + bool "perf" + help + perf (sometimes "Perf Events" or perf tools, originally + "Performance Counters for Linux") - is a performance + analyzing tool in Linux, available from kernel version + 2.6.31. User-space controlling utility, called 'perf' has + git-like interface with subcommands. It is capable of + statistical profiling of entire system (both kernel and user + code), single CPU or severals threads. + + This will build and install the userspace 'perf' + command. It is up to the user to ensure that the kernel + configuration has all the suitable options enabled to allow a + proper operation of 'perf'. + + https://perf.wiki.kernel.org/ + endmenu
linux/linux-tool-perf.mk renamed from package/perf/perf.mk +11 -13
@@ -4,11 +4,9 @@ # ################################################################################ -# Source taken from the Linux kernel tree -PERF_SOURCE = -PERF_VERSION = $(call qstrip,$(BR2_LINUX_KERNEL_VERSION)) +LINUX_TOOLS += perf -PERF_DEPENDENCIES = linux host-flex host-bison +PERF_DEPENDENCIES = host-flex host-bison ifeq ($(KERNEL_ARCH),x86_64) PERF_ARCH=x86
@@ -57,31 +55,31 @@ else PERF_MAKE_FLAGS += NO_LIBELF=1 NO_DWARF=1 endif +# O must be defined here with $(@D) to overwrite the one used by Buildroot +# for out of tree build. define PERF_BUILD_CMDS - $(Q)if test ! -f $(LINUX_DIR)/tools/perf/Makefile ; then \ + $(Q)if test ! -f $(@D)/tools/perf/Makefile ; then \ echo "Your kernel version is too old and does not have the perf tool." ; \ echo "At least kernel 2.6.31 must be used." ; \ exit 1 ; \ fi $(Q)if test "$(BR2_PACKAGE_ELFUTILS)" = "" ; then \ - if ! grep -q NO_LIBELF $(LINUX_DIR)/tools/perf/Makefile* ; then \ - if ! test -r $(LINUX_DIR)/tools/perf/config/Makefile ; then \ + if ! grep -q NO_LIBELF $(@D)/tools/perf/Makefile* ; then \ + if ! test -r $(@D)/tools/perf/config/Makefile ; then \ echo "The perf tool in your kernel cannot be built without libelf." ; \ echo "Either upgrade your kernel to >= 3.7, or enable the elfutils package." ; \ exit 1 ; \ fi \ fi \ fi - $(TARGET_MAKE_ENV) $(MAKE1) -C $(LINUX_DIR)/tools/perf \ - $(PERF_MAKE_FLAGS) O=$(@D) + $(TARGET_MAKE_ENV) $(MAKE1) $(PERF_MAKE_FLAGS) \ + -C $(@D)/tools/perf O=$(@D)/tools/perf/ endef # After installation, we remove the Perl and Python scripts from the # target. define PERF_INSTALL_TARGET_CMDS - $(TARGET_MAKE_ENV) $(MAKE1) -C $(LINUX_DIR)/tools/perf \ - $(PERF_MAKE_FLAGS) O=$(@D) install + $(TARGET_MAKE_ENV) $(MAKE1) $(PERF_MAKE_FLAGS) \ + -C $(@D)/tools/perf O=$(@D)/tools/perf/ install $(RM) -rf $(TARGET_DIR)/usr/libexec/perf-core/scripts/ endef - -$(eval $(generic-package))
package/Config.in +0 -1
@@ -88,7 +88,6 @@ endif source "package/netperf/Config.in" source "package/oprofile/Config.in" source "package/pax-utils/Config.in" - source "package/perf/Config.in" source "package/pv/Config.in" source "package/racehound/Config.in" source "package/ramsmp/Config.in"
package/perf/Config.in deleted +0 -21
@@ -1,21 +0,0 @@ -config BR2_PACKAGE_PERF - bool "perf" - depends on BR2_LINUX_KERNEL - help - perf (sometimes "Perf Events" or perf tools, originally - "Performance Counters for Linux") - is a performance - analyzing tool in Linux, available from kernel version - 2.6.31. User-space controlling utility, called 'perf' has - git-like interface with subcommands. It is capable of - statistical profiling of entire system (both kernel and user - code), single CPU or severals threads. - - This package builds and install the userspace 'perf' - command. It is up to the user to ensure that the kernel - configuration has all the suitable options enabled to allow a - proper operation of 'perf'. - - https://perf.wiki.kernel.org/ - -comment "perf needs a Linux kernel to be built" - depends on !BR2_LINUX_KERNEL
Signature · 1 line
2.4.3
PATCH v5 8/8 docs/manual: add documentation for linux-ext and linux-tools.
In reply to Romain Naour---
v5: manual:
rename linux specific infra title.
move the chapiter higher with other infra. add a comment about what should be done by the Linux extension package.
v4: no change
v3: complete the linux kernel extention manual about the
moment where are applied the PREPARE_KERNEL.
v2: new patch
--- docs/manual/adding-packages-kernel-module.txt | 1 + .../adding-packages-linux-kernel-spec-infra.txt | 143 +++++++++++++++++++++ docs/manual/adding-packages.txt | 2 + 3 files changed, 146 insertions(+) create mode 100644 docs/manual/adding-packages-linux-kernel-spec-infra.txt
docs/manual/adding-packages-kernel-module.txt +1 -0
@@ -128,6 +128,7 @@ configure the build of the kernel module: * +FOO_MODULE_MAKE_OPTS+ may be set to contain extra variable definitions to pass to the Linux buildsystem. +[[kernel-variables]] You may also reference (but you may *not* set!) those variables: * +LINUX_DIR+ contains the path to where the Linux kernel has been
docs/manual/adding-packages-linux-kernel-spec-infra.txt new file +143 -0
144 lines not on this page · raw message
docs/manual/adding-packages.txt +2 -0
@@ -33,6 +33,8 @@ include::adding-packages-kernel-module.txt[] include::adding-packages-asciidoc.txt[] +include::adding-packages-linux-kernel-spec-infra.txt[] + include::adding-packages-hooks.txt[] include::adding-packages-gettext.txt[]
Signature · 1 line
2.4.3
v5 cover Linux kernel specific infrastructure
In reply to Romain NaourDear Romain Naour,
Quoted 11 lines · Romain Naour
Romain Naour (4):
linux: add linux-tools infra
linux-tools: add cpupower
package/perf: migrate perf to use the new linux-tools infrastructure docs/manual: add documentation for linux-ext and linux-tools.Steven Noonan (4):
package/perf: if slang is enabled, depend on it package/perf: if numactl (libnuma) is enabled, depend on it package/perf: if libunwind is enabled, depend on it package/perf: use correct definition of ARCH onx86_64
I've applied all the patches. I've done some minor changes on some of them, except to the documentation where I did some more substantial changes. Each commit has some details about the changes I made.
Thanks a lot!
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com