Skip to contentSkip to conversation

package/linux-tools: add rtla

PATCH Andreas Ziegler 2 participants 6 messages Oct 19, 2023 – Oct 24, 2023 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

Hi Giulio, *

Quoted 57 lines · Giulio Benetti

From: Maxime Chevallier <[email protected]>

The RealTime Linux Analysis tool includes a set of commands that relies on the osnoise and timerlat tracers from the ftrace kernel subsystem, allowing to analyze the lantency sources coming from the hardware and the kernel itself.

This tool was introduced in v5.17, and relies on libtracefs and libtraceevent, although libtraceevent itself is already a dependency for libtracefs.

[Giulio: fix install on recent Linux versions]

---
V1->V2:
* fix install with recent Linux versions V2->V3:
* deal with hwnoise presence as suggested by Yann Morin
* change Config.in comment according to the point above

---
 DEVELOPERS                                |  2 ++
 package/linux-tools/Config.in             | 10 ++++++
 package/linux-tools/linux-tool-rtla.mk.in | 40 +++++++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 package/linux-tools/linux-tool-rtla.mk.in
DEVELOPERS +2 -0
index 5c4bc87e16..8f76d471ee 100644
@@ -1223,6 +1223,7 @@ F:	package/libnss/
 F:	package/libnvme/
 F:	package/libtraceevent/
 F:	package/libtracefs
+F:	package/linux-tools/linux-tool-rtla.mk.in
 F:	package/mali-driver/
 F:	package/minicom/
 F:	package/mmc-utils/
@@ -2116,6 +2117,7 @@ F:	package/timescaledb/
 N:	Maxime Chevallier <[email protected]>
 F:	package/libtraceevent/
 F:	package/libtracefs
+F:	package/linux-tools/linux-tool-rtla.mk.in
 
 N:	Michael Durrant <[email protected]>
 F:	board/arcturus/
package/linux-tools/Config.in +0 -0
index 451b0eeff5..4df73159be 100644
@@ -102,6 +102,16 @@ config 

BR2_PACKAGE_LINUX_TOOLS_PERF_NEEDS_HOST_PYTHON3

endif

package/linux-tools/Config.in

Quoted 2 lines
package/linux-tools/Config.in +2 -0
+config BR2_PACKAGE_LINUX_TOOLS_RTLA
+	bool "rtla"

Since there is a kernel header dependency:
depends on BR2_TOOLCHAIN_HEADERS_AT_LEAST_5_17

package/linux-tools/Config.in

Quoted 4 lines
package/linux-tools/Config.in +4 -0
+	select BR2_PACKAGE_LINUX_TOOLS
+	select BR2_PACKAGE_LIBTRACEFS
+	help
+	  Linux 5.19 and later has 2 new tracers, osnoise and timerlat.

RTLA seems to have been introduced with 5.17-rc1.

Quoted 13 lines
package/linux-tools/Config.in +4 -0
+	  Linux 6.3 has new tracer hwnoise. These tracers allow performing
+	  latency analysis, for which the rtla tool provides wrapper
+	  commands to visualize and extract latency traces and reports.
+
 config BR2_PACKAGE_LINUX_TOOLS_SELFTESTS
 	bool"selftests"
 	depends on BR2_PACKAGE_BUSYBOX_SHOW_OTHERS # bash
package/linux-tools/linux-tool-rtla.mk.in new file +0 -0
new file mode 100644
index 0000000000..04b98f443d

package/linux-tools/linux-tool-rtla.mk.in line 8

Quoted 8 lines
package/linux-tools/linux-tool-rtla.mk.in new file +8 -0
@@ -0,0 +1,40 @@
+################################################################################
+#
+# rtla
+#
+################################################################################
+
+LINUX_TOOLS += rtla
+

Linux kernel needs FTRACE, TIMERLAT_TRACER, HIST_TRIGGERS for RTLA to work:

ifeq ($(BR2_PACKAGE_LINUX_TOOLS_RTLA),y)
define RTLA_LINUX_CONFIG_FIXUPS

	$(call KCONFIG_ENABLE_OPT,CONFIG_FTRACE)
	$(call KCONFIG_ENABLE_OPT,CONFIG_TIMERLAT_TRACER)
	$(call KCONFIG_ENABLE_OPT,CONFIG_HIST_TRIGGERS)

endef
endif

package/linux-tools/linux-tool-rtla.mk.in line 11

Quoted 3 lines
package/linux-tools/linux-tool-rtla.mk.in new file +3 -0
+RTLA_DEPENDENCIES = host-pkgconf libtracefs
+RTLA_MAKE_OPTS = $(LINUX_MAKE_FLAGS) \
+	CC=$(TARGET_CC) \

libtrace{event,fs} are compiled with _GNU_SOURCE enabled; in the rtla build the symbol may be missing, depending on the C library used. Define _GNU_SOURCE unconditionally to prevent build failures with musl:

	EXTRA_CFLAGS="-D_GNU_SOURCE" \

package/linux-tools/linux-tool-rtla.mk.in line 14

Quoted 3 lines
package/linux-tools/linux-tool-rtla.mk.in new file +3 -0
+	LDFLAGS="$(TARGET_LDFLAGS)" \
+	PKG_CONFIG_PATH=$(STAGING_DIR)/usr/lib/pkgconfig
+

Build fails if BR2_TOOLCHAIN_BUILDROOT_USE_SSP is set to 'n', so introduce a workaround, similar to linux-tool-tmon.mk.in:

ifeq ($(BR2_TOOLCHAIN_HAS_SSP),)
define RTLA_DISABLE_STACK_PROTECTOR

	$(SED) 's/-fstack-protector.* //' 

$(LINUX_DIR)/tools/tracing/rtla/Makefile
endef
endif

package/linux-tools/linux-tool-rtla.mk.in

Quoted 9 lines
package/linux-tools/linux-tool-rtla.mk.in new file +2 -0
+define RTLA_BUILD_CMDS
+	$(Q)if ! grep install $(LINUX_DIR)/tools/tracing/rtla/Makefile 
Quoted 1 line

/dev/null 2>&1 ; then \

package/linux-tools/linux-tool-rtla.mk.in new file +1 -0
+		echo "Your kernel version is too old and does not implement the rtla 

tool." ; \

package/linux-tools/linux-tool-rtla.mk.in new file +4 -0
+		echo "At least kernel 5.19 must be used." ; \
+		exit 1 ; \
+	fi
+
	$(RTLA_DISABLE_STACK_PROTECTOR)
Quoted 24 lines
package/linux-tools/linux-tool-rtla.mk.in new file +6 -0
+	$(TARGET_MAKE_ENV) \
+	$(MAKE) $(RTLA_MAKE_OPTS) \
+	-C $(LINUX_DIR)/tools/tracing rtla
+endef
+
+# make rtla_install build and install by default documentation using 

rst2man
+# but it's not available in Buildroot and we don't want manual files in target
+# folder so let's simply install the resulting rtla binary and create symlinks

package/linux-tools/linux-tool-rtla.mk.in new file +3 -0
+# like Linux does in its tools/tracing/rtla/Makefile
+define RTLA_INSTALL_TARGET_CMDS
+	$(INSTALL) -m 0755 -D $(LINUX_DIR)/tools/tracing/rtla/rtla 

$(TARGET_DIR)/usr/bin

package/linux-tools/linux-tool-rtla.mk.in new file +8 -1
+	ln -sf rtla $(TARGET_DIR)/usr/bin/osnoise
+	ln -sf rtla $(TARGET_DIR)/usr/bin/timerlat
+
+	# Check if hwnoise is provided or not
+	if grep -q hwnoise $(LINUX_DIR)/tools/tracing/rtla/Makefile; then \
+		ln -sf rtla $(TARGET_DIR)/usr/bin/hwnoise ; \
+	fi
+endef
--
Quoted 1 line

2.34.1

Kind regards,
Andreas
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#2 lore raw

Hi Andreas,

thank you for reviewing,

Quoted 58 lines · Andreas Ziegler

Hi Giulio, *

Quoted 55 lines · Giulio Benetti

From: Maxime Chevallier <[email protected]>

The RealTime Linux Analysis tool includes a set of commands that relies on the osnoise and timerlat tracers from the ftrace kernel subsystem, allowing to analyze the lantency sources coming from the hardware and the kernel itself.

This tool was introduced in v5.17, and relies on libtracefs and libtraceevent, although libtraceevent itself is already a dependency for libtracefs.

[Giulio: fix install on recent Linux versions]

---
V1->V2:
* fix install with recent Linux versions
V2->V3:
* deal with hwnoise presence as suggested by Yann Morin
* change Config.in comment according to the point above
---
 DEVELOPERS                                |  2 ++ package/linux-tools/Config.in             | 10 ++++++ package/linux-tools/linux-tool-rtla.mk.in | 40 +++++++++++++++++++++++

 3 files changed, 52 insertions(+)

 create mode 100644 package/linux-tools/linux-tool-rtla.mk.in

DEVELOPERS +0 -0
index 5c4bc87e16..8f76d471ee 100644
@@ -1223,6 +1223,7 @@ F:    package/libnss/

 F:    package/libnvme/
 F:    package/libtraceevent/
 F:    package/libtracefs
+F:    package/linux-tools/linux-tool-rtla.mk.in
 F:    package/mali-driver/
 F:    package/minicom/
 F:    package/mmc-utils/

DEVELOPERS +0 -0
@@ -2116,6 +2117,7 @@ F:    package/timescaledb/

 N:    Maxime Chevallier <[email protected]> F:    package/libtraceevent/
 F:    package/libtracefs
+F:    package/linux-tools/linux-tool-rtla.mk.in

 N:    Michael Durrant <[email protected]> F:    board/arcturus/

package/linux-tools/Config.in +0 -0
index 451b0eeff5..4df73159be 100644
@@ -102,6 +102,16 @@ config 

BR2_PACKAGE_LINUX_TOOLS_PERF_NEEDS_HOST_PYTHON3

Quoted 7 lines
Quoted 4 lines

 endif

+config BR2_PACKAGE_LINUX_TOOLS_RTLA
+    bool "rtla"

Since there is a kernel header dependency:
    depends on BR2_TOOLCHAIN_HEADERS_AT_LEAST_5_17

This is not enough since you can have toolchain headers and linux with different versions. Buildroot doesn't provide an easy way to check for Linux version, but this package itself check for it in .mk file as you can see below

Quoted 6 lines
Quoted 4 lines

+    select BR2_PACKAGE_LINUX_TOOLS
+    select BR2_PACKAGE_LIBTRACEFS
+    help
+      Linux 5.19 and later has 2 new tracers, osnoise and timerlat.

RTLA seems to have been introduced with 5.17-rc1.

You're right, but the problem is that it required libprocps as dependency until Linux 5.19. So chatting with Yann in IRC we came to the conclusion to skip 5.17 and 5.18 and go for 5.19 directly.

I could improve description anyway to make it clear as I've described it to you here because it's misleading.

Quoted 24 lines
Quoted 13 lines

+      Linux 6.3 has new tracer hwnoise. These tracers allow performing +      latency analysis, for which the rtla tool provides wrapper +      commands to visualize and extract latency traces and reports. +
 config BR2_PACKAGE_LINUX_TOOLS_SELFTESTS
     bool"selftests"
     depends on BR2_PACKAGE_BUSYBOX_SHOW_OTHERS # bash

package/linux-tools/linux-tool-rtla.mk.in new file +0 -0
new file mode 100644
index 0000000000..04b98f443d

package/linux-tools/linux-tool-rtla.mk.in line 8

Quoted 8 lines
package/linux-tools/linux-tool-rtla.mk.in new file +8 -0
@@ -0,0 +1,40 @@
+################################################################################
+#
+# rtla
+#
+################################################################################
+
+LINUX_TOOLS += rtla
+

Linux kernel needs FTRACE, TIMERLAT_TRACER, HIST_TRIGGERS for RTLA to work:

Quoted 7 lines

ifeq ($(BR2_PACKAGE_LINUX_TOOLS_RTLA),y) define RTLA_LINUX_CONFIG_FIXUPS
    $(call KCONFIG_ENABLE_OPT,CONFIG_FTRACE) $(call KCONFIG_ENABLE_OPT,CONFIG_TIMERLAT_TRACER) $(call KCONFIG_ENABLE_OPT,CONFIG_HIST_TRIGGERS)
endef
endif

Nice catch! I didn't think about it

Quoted 7 lines

package/linux-tools/linux-tool-rtla.mk.in line 11

Quoted 3 lines
package/linux-tools/linux-tool-rtla.mk.in new file +3 -0
+RTLA_DEPENDENCIES = host-pkgconf libtracefs
+RTLA_MAKE_OPTS = $(LINUX_MAKE_FLAGS) \
+    CC=$(TARGET_CC) \

libtrace{event,fs} are compiled with _GNU_SOURCE enabled; in the rtla build the symbol may be missing, depending on the C library used. Define _GNU_SOURCE unconditionally to prevent build failures with musl:

    EXTRA_CFLAGS="-D_GNU_SOURCE" \

I haven't found such build failure with musl, do you have a Buildroot defconfig that exhibits this bug?

Quoted 4 lines

package/linux-tools/linux-tool-rtla.mk.in line 14

Quoted 3 lines
package/linux-tools/linux-tool-rtla.mk.in new file +3 -0
+    LDFLAGS="$(TARGET_LDFLAGS)" \
+    PKG_CONFIG_PATH=$(STAGING_DIR)/usr/lib/pkgconfig
+
Quoted 8 lines

Build fails if BR2_TOOLCHAIN_BUILDROOT_USE_SSP is set to 'n', so introduce a workaround, similar to linux-tool-tmon.mk.in:

ifeq ($(BR2_TOOLCHAIN_HAS_SSP),)
define RTLA_DISABLE_STACK_PROTECTOR
    $(SED) 's/-fstack-protector.* //'
$(LINUX_DIR)/tools/tracing/rtla/Makefile
endef
endif

Thank you, I will

Quoted 11 lines
Quoted 9 lines
package/linux-tools/linux-tool-rtla.mk.in new file +2 -0
+define RTLA_BUILD_CMDS
+    $(Q)if ! grep install $(LINUX_DIR)/tools/tracing/rtla/Makefile 
Quoted 1 line

/dev/null 2>&1 ; then \

+        echo "Your kernel version is too old and does not implement the rtla tool." ; \
+        echo "At least kernel 5.19 must be used." ; \
+        exit 1 ; \
+    fi
+

    $(RTLA_DISABLE_STACK_PROTECTOR)

Ok

Quoted 17 lines
Quoted 17 lines

+    $(TARGET_MAKE_ENV) \
+    $(MAKE) $(RTLA_MAKE_OPTS) \
+    -C $(LINUX_DIR)/tools/tracing rtla

package/linux-tools/linux-tool-rtla.mk.in new file +3 -0
+endef
+
+# make rtla_install build and install by default documentation using 

rst2man
+# but it's not available in Buildroot and we don't want manual files in target
+# folder so let's simply install the resulting rtla binary and create symlinks

package/linux-tools/linux-tool-rtla.mk.in new file +3 -0
+# like Linux does in its tools/tracing/rtla/Makefile
+define RTLA_INSTALL_TARGET_CMDS
+    $(INSTALL) -m 0755 -D $(LINUX_DIR)/tools/tracing/rtla/rtla 

$(TARGET_DIR)/usr/bin
+    ln -sf rtla $(TARGET_DIR)/usr/bin/osnoise
+    ln -sf rtla $(TARGET_DIR)/usr/bin/timerlat

Quoted 8 lines
Quoted 8 lines
package/linux-tools/linux-tool-rtla.mk.in new file +6 -0
+
+    # Check if hwnoise is provided or not
+    if grep -q hwnoise $(LINUX_DIR)/tools/tracing/rtla/Makefile; then \
+        ln -sf rtla $(TARGET_DIR)/usr/bin/hwnoise ; \
+    fi
+endef
Signature · 1 line
2.34.1

Thanks a lot for the accurate review!

Best regards

Signature · 6 lines
Giulio Benetti
CEO&CTO@Benetti Engineering sas
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#3 lore raw

Hi Giulio,

Quoted 3 lines · Giulio Benetti

Hi Andreas,

thank you for reviewing,

you're welcome, I had been experimenting with Maxime's original version, so it got tested in different configurations.

Quoted 69 lines · Andreas Ziegler
Quoted 59 lines

Hi Giulio, *

Quoted 56 lines · Giulio Benetti

From: Maxime Chevallier <[email protected]>

The RealTime Linux Analysis tool includes a set of commands that relies on the osnoise and timerlat tracers from the ftrace kernel subsystem, allowing to analyze the lantency sources coming from the hardware and the kernel itself.

This tool was introduced in v5.17, and relies on libtracefs and libtraceevent, although libtraceevent itself is already a dependency for libtracefs.

[Giulio: fix install on recent Linux versions]

---
V1->V2:
* fix install with recent Linux versions V2->V3:
* deal with hwnoise presence as suggested by Yann Morin
* change Config.in comment according to the point above
---
 DEVELOPERS                                |  2 ++ package/linux-tools/Config.in             | 10 ++++++ package/linux-tools/linux-tool-rtla.mk.in | 40
+++++++++++++++++++++++

 3 files changed, 52 insertions(+)

 create mode 100644 package/linux-tools/linux-tool-rtla.mk.in

DEVELOPERS +0 -0
index 5c4bc87e16..8f76d471ee 100644
@@ -1223,6 +1223,7 @@ F:    package/libnss/

 F:    package/libnvme/
 F:    package/libtraceevent/
 F:    package/libtracefs
+F:    package/linux-tools/linux-tool-rtla.mk.in
 F:    package/mali-driver/
 F:    package/minicom/
 F:    package/mmc-utils/

DEVELOPERS +0 -0
@@ -2116,6 +2117,7 @@ F:    package/timescaledb/

 N:    Maxime Chevallier <[email protected]> F:    package/libtraceevent/
 F:    package/libtracefs
+F:    package/linux-tools/linux-tool-rtla.mk.in

 N:    Michael Durrant <[email protected]> F:    board/arcturus/

package/linux-tools/Config.in +0 -0
index 451b0eeff5..4df73159be 100644
@@ -102,6 +102,16 @@ config 

BR2_PACKAGE_LINUX_TOOLS_PERF_NEEDS_HOST_PYTHON3

Quoted 7 lines
Quoted 4 lines

 endif

+config BR2_PACKAGE_LINUX_TOOLS_RTLA
+    bool "rtla"

Since there is a kernel header dependency:
    depends on BR2_TOOLCHAIN_HEADERS_AT_LEAST_5_17

Quoted 4 lines

This is not enough since you can have toolchain headers and linux with different versions. Buildroot doesn't provide an easy way to check for Linux version, but this package itself check for it in .mk file as you can see below

Yes, I have seen the check in rtla.mk.in; it occurs quite late in the build, which is a bit annoying :-)

Quoted 5 lines
Quoted 5 lines
Quoted 4 lines

+    select BR2_PACKAGE_LINUX_TOOLS
+    select BR2_PACKAGE_LIBTRACEFS
+    help
+      Linux 5.19 and later has 2 new tracers, osnoise and timerlat.

Quoted 8 lines
Quoted 1 line

RTLA seems to have been introduced with 5.17-rc1.

You're right, but the problem is that it required libprocps as dependency until Linux 5.19. So chatting with Yann in IRC we came to the conclusion to skip 5.17 and 5.18 and go for 5.19 directly.

I could improve description anyway to make it clear as I've described it to you here because it's misleading.

OK, that explains it. I just checked elixir.bootlin.com for the first appearance.

Quoted 41 lines
Quoted 25 lines
Quoted 14 lines

+      Linux 6.3 has new tracer hwnoise. These tracers allow performing
+      latency analysis, for which the rtla tool provides wrapper +      commands to visualize and extract latency traces and reports. +
 config BR2_PACKAGE_LINUX_TOOLS_SELFTESTS
     bool"selftests"
     depends on BR2_PACKAGE_BUSYBOX_SHOW_OTHERS # bash

package/linux-tools/linux-tool-rtla.mk.in new file +0 -0
new file mode 100644
index 0000000000..04b98f443d

package/linux-tools/linux-tool-rtla.mk.in line 8

Quoted 8 lines
package/linux-tools/linux-tool-rtla.mk.in new file +8 -0
@@ -0,0 +1,40 @@
+################################################################################
+#
+# rtla
+#
+################################################################################
+
+LINUX_TOOLS += rtla
+

Linux kernel needs FTRACE, TIMERLAT_TRACER, HIST_TRIGGERS for RTLA to work:

Quoted 7 lines

ifeq ($(BR2_PACKAGE_LINUX_TOOLS_RTLA),y) define RTLA_LINUX_CONFIG_FIXUPS
    $(call KCONFIG_ENABLE_OPT,CONFIG_FTRACE) $(call KCONFIG_ENABLE_OPT,CONFIG_TIMERLAT_TRACER) $(call KCONFIG_ENABLE_OPT,CONFIG_HIST_TRIGGERS)
endef
endif

Nice catch! I didn't think about it

Quoted 6 lines

package/linux-tools/linux-tool-rtla.mk.in line 11

Quoted 3 lines
package/linux-tools/linux-tool-rtla.mk.in new file +3 -0
+RTLA_DEPENDENCIES = host-pkgconf libtracefs
+RTLA_MAKE_OPTS = $(LINUX_MAKE_FLAGS) \
+    CC=$(TARGET_CC) \

libtrace{event,fs} are compiled with _GNU_SOURCE enabled; in the rtla build the symbol may be missing, depending on the C library used. Define _GNU_SOURCE unconditionally to prevent build failures with musl:

Quoted 3 lines
Quoted 1 line

    EXTRA_CFLAGS="-D_GNU_SOURCE" \

I haven't found such build failure with musl, do you have a Buildroot defconfig that exhibits this bug?

Actually yes, but I need to pare it down, it contains too many BR2_EXTERNAL references. My original report to Maxime is here: https://marc.info/?l=buildroot&m=167688843104878&w=2

Quoted 57 lines
Quoted 4 lines

package/linux-tools/linux-tool-rtla.mk.in line 14

Quoted 3 lines
package/linux-tools/linux-tool-rtla.mk.in new file +3 -0
+    LDFLAGS="$(TARGET_LDFLAGS)" \
+    PKG_CONFIG_PATH=$(STAGING_DIR)/usr/lib/pkgconfig
+
Quoted 8 lines

Build fails if BR2_TOOLCHAIN_BUILDROOT_USE_SSP is set to 'n', so introduce a workaround, similar to linux-tool-tmon.mk.in:

ifeq ($(BR2_TOOLCHAIN_HAS_SSP),)
define RTLA_DISABLE_STACK_PROTECTOR
    $(SED) 's/-fstack-protector.* //'
$(LINUX_DIR)/tools/tracing/rtla/Makefile
endef
endif

Thank you, I will

Quoted 11 lines
Quoted 9 lines
package/linux-tools/linux-tool-rtla.mk.in new file +2 -0
+define RTLA_BUILD_CMDS
+    $(Q)if ! grep install $(LINUX_DIR)/tools/tracing/rtla/Makefile 
Quoted 1 line

/dev/null 2>&1 ; then \

+        echo "Your kernel version is too old and does not implement the rtla tool." ; \
+        echo "At least kernel 5.19 must be used." ; \
+        exit 1 ; \
+    fi
+

    $(RTLA_DISABLE_STACK_PROTECTOR)

Ok

Quoted 17 lines
Quoted 17 lines

+    $(TARGET_MAKE_ENV) \
+    $(MAKE) $(RTLA_MAKE_OPTS) \
+    -C $(LINUX_DIR)/tools/tracing rtla

package/linux-tools/linux-tool-rtla.mk.in new file +3 -0
+endef
+
+# make rtla_install build and install by default documentation using 

rst2man
+# but it's not available in Buildroot and we don't want manual files in target
+# folder so let's simply install the resulting rtla binary and create symlinks

package/linux-tools/linux-tool-rtla.mk.in new file +3 -0
+# like Linux does in its tools/tracing/rtla/Makefile
+define RTLA_INSTALL_TARGET_CMDS
+    $(INSTALL) -m 0755 -D $(LINUX_DIR)/tools/tracing/rtla/rtla 

$(TARGET_DIR)/usr/bin
+    ln -sf rtla $(TARGET_DIR)/usr/bin/osnoise
+    ln -sf rtla $(TARGET_DIR)/usr/bin/timerlat

Quoted 8 lines
Quoted 8 lines

+
+    # Check if hwnoise is provided or not
+    if grep -q hwnoise $(LINUX_DIR)/tools/tracing/rtla/Makefile; then \
+        ln -sf rtla $(TARGET_DIR)/usr/bin/hwnoise ; \
+    fi
+endef
-- 2.34.1

Thanks a lot for the accurate review!

Quoted 4 lines

Best regards
--
Giulio Benetti
CEO&CTO@Benetti Engineering sas

Kind regards,
Andreas
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#4 lore raw
In reply to Giulio Benetti

Hi Giulio, *

[remove everything not related to linux-tool-rtla.mk.in]

Quoted 8 lines · Giulio Benetti

Hi Andreas,

thank you for reviewing,

Quoted 3 lines · Andreas Ziegler

Hi Giulio, *

On 2023-10-14 23:57, Giulio Benetti wrote:

[cut]

Quoted 33 lines
Quoted 17 lines
Quoted 6 lines
package/linux-tools/linux-tool-rtla.mk.in new file +0 -0
new file mode 100644
index 0000000000..04b98f443d

package/linux-tools/linux-tool-rtla.mk.in line 8

Quoted 8 lines
package/linux-tools/linux-tool-rtla.mk.in new file +8 -0
@@ -0,0 +1,40 @@
+################################################################################
+#
+# rtla
+#
+################################################################################
+
+LINUX_TOOLS += rtla
+

Linux kernel needs FTRACE, TIMERLAT_TRACER, HIST_TRIGGERS for RTLA to work:

Quoted 7 lines

ifeq ($(BR2_PACKAGE_LINUX_TOOLS_RTLA),y) define RTLA_LINUX_CONFIG_FIXUPS
    $(call KCONFIG_ENABLE_OPT,CONFIG_FTRACE) $(call KCONFIG_ENABLE_OPT,CONFIG_TIMERLAT_TRACER) $(call KCONFIG_ENABLE_OPT,CONFIG_HIST_TRIGGERS)
endef
endif

Nice catch! I didn't think about it

Quoted 6 lines

package/linux-tools/linux-tool-rtla.mk.in line 11

Quoted 3 lines
package/linux-tools/linux-tool-rtla.mk.in new file +3 -0
+RTLA_DEPENDENCIES = host-pkgconf libtracefs
+RTLA_MAKE_OPTS = $(LINUX_MAKE_FLAGS) \
+    CC=$(TARGET_CC) \

libtrace{event,fs} are compiled with _GNU_SOURCE enabled; in the rtla build the symbol may be missing, depending on the C library used. Define _GNU_SOURCE unconditionally to prevent build failures with musl:

Quoted 4 lines
Quoted 1 line

    EXTRA_CFLAGS="-D_GNU_SOURCE" \

I haven't found such build failure with musl, do you have a Buildroot defconfig that exhibits this bug?

I put together a defconfig, based on configs/raspberrypi4_64_defconfig; changes are, roughly:

C-library musl
binutils 2.41
gcc 13

PIC/PIE not set
SSP none
RELRO none

kernel version 6.6-rc6
kernel patch
https://mirrors.edge.kernel.org/pub/linux/kernel/projects/rt/6.6/patch-6.6-rc6-rt9.patch.xz
no overlay support
linux kernel tools -> rtla

You will run into another error first, because libtracefs is missing host dependencies.

From src/meson.build:
flex = find_program('flex', required: true)
bison = find_program('bison', required: true)

Modified package/libtracefs/libtracefs.mk:
LIBTRACEFS_DEPENDENCIES = host-bison host-flex host-pkgconf
libtraceevent

BR2_aarch64=y
BR2_cortex_a72=y
BR2_ARM_FPU_VFPV4=y
BR2_TOOLCHAIN_BUILDROOT_MUSL=y
BR2_BINUTILS_VERSION_2_41_X=y
BR2_GCC_VERSION_13_X=y
BR2_TOOLCHAIN_BUILDROOT_CXX=y
# BR2_PIC_PIE is not set
BR2_SSP_NONE=y
BR2_RELRO_NONE=y
BR2_SYSTEM_DHCP="eth0"
BR2_ROOTFS_POST_BUILD_SCRIPT="board/raspberrypi4-64/post-build.sh" BR2_ROOTFS_POST_IMAGE_SCRIPT="board/raspberrypi4-64/post-image.sh"
BR2_LINUX_KERNEL=y
BR2_LINUX_KERNEL_CUSTOM_VERSION=y
BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="6.6-rc6" BR2_LINUX_KERNEL_PATCH="https://mirrors.edge.kernel.org/pub/linux/kernel/projects/rt/6.6/patch-6.6-rc6-rt9.patch.xz" BR2_LINUX_KERNEL_DEFCONFIG="bcm2711"
BR2_LINUX_KERNEL_DTS_SUPPORT=y
BR2_LINUX_KERNEL_INTREE_DTS_NAME="broadcom/bcm2711-rpi-4-b"
BR2_LINUX_KERNEL_NEEDS_HOST_OPENSSL=y
BR2_PACKAGE_LINUX_TOOLS_RTLA=y
BR2_PACKAGE_RPI_FIRMWARE=y
BR2_PACKAGE_RPI_FIRMWARE_VARIANT_PI4=y BR2_PACKAGE_RPI_FIRMWARE_CONFIG_FILE="board/raspberrypi4-64/config_4_64bit.txt"
# BR2_PACKAGE_RPI_FIRMWARE_INSTALL_DTB_OVERLAYS is not set
BR2_TARGET_ROOTFS_EXT2=y
BR2_TARGET_ROOTFS_EXT2_4=y
BR2_TARGET_ROOTFS_EXT2_SIZE="120M"
# BR2_TARGET_ROOTFS_TAR is not set
BR2_PACKAGE_HOST_DOSFSTOOLS=y
BR2_PACKAGE_HOST_GENIMAGE=y
BR2_PACKAGE_HOST_MTOOLS=y

Quoted 57 lines
Quoted 4 lines

package/linux-tools/linux-tool-rtla.mk.in line 14

Quoted 3 lines
package/linux-tools/linux-tool-rtla.mk.in new file +3 -0
+    LDFLAGS="$(TARGET_LDFLAGS)" \
+    PKG_CONFIG_PATH=$(STAGING_DIR)/usr/lib/pkgconfig
+
Quoted 8 lines

Build fails if BR2_TOOLCHAIN_BUILDROOT_USE_SSP is set to 'n', so introduce a workaround, similar to linux-tool-tmon.mk.in:

ifeq ($(BR2_TOOLCHAIN_HAS_SSP),)
define RTLA_DISABLE_STACK_PROTECTOR
    $(SED) 's/-fstack-protector.* //'
$(LINUX_DIR)/tools/tracing/rtla/Makefile
endef
endif

Thank you, I will

Quoted 11 lines
Quoted 9 lines
package/linux-tools/linux-tool-rtla.mk.in new file +2 -0
+define RTLA_BUILD_CMDS
+    $(Q)if ! grep install $(LINUX_DIR)/tools/tracing/rtla/Makefile 
Quoted 1 line

/dev/null 2>&1 ; then \

+        echo "Your kernel version is too old and does not implement the rtla tool." ; \
+        echo "At least kernel 5.19 must be used." ; \
+        exit 1 ; \
+    fi
+

    $(RTLA_DISABLE_STACK_PROTECTOR)

Ok

Quoted 17 lines
Quoted 17 lines

+    $(TARGET_MAKE_ENV) \
+    $(MAKE) $(RTLA_MAKE_OPTS) \
+    -C $(LINUX_DIR)/tools/tracing rtla

package/linux-tools/linux-tool-rtla.mk.in new file +3 -0
+endef
+
+# make rtla_install build and install by default documentation using 

rst2man
+# but it's not available in Buildroot and we don't want manual files in target
+# folder so let's simply install the resulting rtla binary and create symlinks

package/linux-tools/linux-tool-rtla.mk.in new file +3 -0
+# like Linux does in its tools/tracing/rtla/Makefile
+define RTLA_INSTALL_TARGET_CMDS
+    $(INSTALL) -m 0755 -D $(LINUX_DIR)/tools/tracing/rtla/rtla 

$(TARGET_DIR)/usr/bin
+    ln -sf rtla $(TARGET_DIR)/usr/bin/osnoise
+    ln -sf rtla $(TARGET_DIR)/usr/bin/timerlat

Quoted 8 lines
Quoted 8 lines

+
+    # Check if hwnoise is provided or not
+    if grep -q hwnoise $(LINUX_DIR)/tools/tracing/rtla/Makefile; then \
+        ln -sf rtla $(TARGET_DIR)/usr/bin/hwnoise ; \
+    fi
+endef
-- 2.34.1

Thanks a lot for the accurate review!

Quoted 4 lines

Best regards
--
Giulio Benetti
CEO&CTO@Benetti Engineering sas

Kind regards,
Andreas
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#5 lore raw

Hi Andreas,

On 24/10/23 08:27, Andreas Ziegler wrote:

[ SNIP ]

Quoted 51 lines

I put together a defconfig, based on configs/raspberrypi4_64_defconfig; changes are, roughly:

  C-library musl
  binutils 2.41
  gcc 13

  PIC/PIE not set
  SSP none
  RELRO none

  kernel version 6.6-rc6
  kernel patch
https://mirrors.edge.kernel.org/pub/linux/kernel/projects/rt/6.6/patch-6.6-rc6-rt9.patch.xz
  no overlay support
  linux kernel tools -> rtla

You will run into another error first, because libtracefs is missing host dependencies.

From src/meson.build:
  flex = find_program('flex', required: true)
  bison = find_program('bison', required: true)

Modified package/libtracefs/libtracefs.mk:
  LIBTRACEFS_DEPENDENCIES = host-bison host-flex host-pkgconf
libtraceevent

BR2_aarch64=y
BR2_cortex_a72=y
BR2_ARM_FPU_VFPV4=y
BR2_TOOLCHAIN_BUILDROOT_MUSL=y
BR2_BINUTILS_VERSION_2_41_X=y
BR2_GCC_VERSION_13_X=y
BR2_TOOLCHAIN_BUILDROOT_CXX=y
# BR2_PIC_PIE is not set
BR2_SSP_NONE=y
BR2_RELRO_NONE=y
BR2_SYSTEM_DHCP="eth0"
BR2_ROOTFS_POST_BUILD_SCRIPT="board/raspberrypi4-64/post-build.sh" BR2_ROOTFS_POST_IMAGE_SCRIPT="board/raspberrypi4-64/post-image.sh"
BR2_LINUX_KERNEL=y
BR2_LINUX_KERNEL_CUSTOM_VERSION=y
BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="6.6-rc6" BR2_LINUX_KERNEL_PATCH="https://mirrors.edge.kernel.org/pub/linux/kernel/projects/rt/6.6/patch-6.6-rc6-rt9.patch.xz" BR2_LINUX_KERNEL_DEFCONFIG="bcm2711"
BR2_LINUX_KERNEL_DTS_SUPPORT=y
BR2_LINUX_KERNEL_INTREE_DTS_NAME="broadcom/bcm2711-rpi-4-b"
BR2_LINUX_KERNEL_NEEDS_HOST_OPENSSL=y
BR2_PACKAGE_LINUX_TOOLS_RTLA=y
BR2_PACKAGE_RPI_FIRMWARE=y
BR2_PACKAGE_RPI_FIRMWARE_VARIANT_PI4=y BR2_PACKAGE_RPI_FIRMWARE_CONFIG_FILE="board/raspberrypi4-64/config_4_64bit.txt"

Quoted 9 lines

# BR2_PACKAGE_RPI_FIRMWARE_INSTALL_DTB_OVERLAYS is not set BR2_TARGET_ROOTFS_EXT2=y BR2_TARGET_ROOTFS_EXT2_4=y BR2_TARGET_ROOTFS_EXT2_SIZE="120M"
# BR2_TARGET_ROOTFS_TAR is not set BR2_PACKAGE_HOST_DOSFSTOOLS=y BR2_PACKAGE_HOST_GENIMAGE=y BR2_PACKAGE_HOST_MTOOLS=y

Reproduced and yes it's fixed with -D_GNU_SOURCE as pointed here:
https://man7.org/linux/man-pages/man3/CPU_SET.3.html

A huge thank you for the help!

Do you mind if I add your SoB describing what you've added on this patch?

Signature · 6 lines
Giulio Benetti
CEO/CTO@Benetti Engineering sas
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#6 lore raw

Hi Giulio,

Nice that this was useful.

Quoted 67 lines · Giulio Benetti

Hi Andreas,

On 24/10/23 08:27, Andreas Ziegler wrote:

[ SNIP ]

Quoted 51 lines

I put together a defconfig, based on configs/raspberrypi4_64_defconfig; changes are, roughly:

  C-library musl
  binutils 2.41
  gcc 13

  PIC/PIE not set
  SSP none
  RELRO none

  kernel version 6.6-rc6
  kernel patch
https://mirrors.edge.kernel.org/pub/linux/kernel/projects/rt/6.6/patch-6.6-rc6-rt9.patch.xz
  no overlay support
  linux kernel tools -> rtla

You will run into another error first, because libtracefs is missing host dependencies.

From src/meson.build:
  flex = find_program('flex', required: true)
  bison = find_program('bison', required: true)

Modified package/libtracefs/libtracefs.mk:
  LIBTRACEFS_DEPENDENCIES = host-bison host-flex host-pkgconf
libtraceevent

BR2_aarch64=y
BR2_cortex_a72=y
BR2_ARM_FPU_VFPV4=y
BR2_TOOLCHAIN_BUILDROOT_MUSL=y
BR2_BINUTILS_VERSION_2_41_X=y
BR2_GCC_VERSION_13_X=y
BR2_TOOLCHAIN_BUILDROOT_CXX=y
# BR2_PIC_PIE is not set
BR2_SSP_NONE=y
BR2_RELRO_NONE=y
BR2_SYSTEM_DHCP="eth0"
BR2_ROOTFS_POST_BUILD_SCRIPT="board/raspberrypi4-64/post-build.sh" BR2_ROOTFS_POST_IMAGE_SCRIPT="board/raspberrypi4-64/post-image.sh"
BR2_LINUX_KERNEL=y
BR2_LINUX_KERNEL_CUSTOM_VERSION=y
BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="6.6-rc6" BR2_LINUX_KERNEL_PATCH="https://mirrors.edge.kernel.org/pub/linux/kernel/projects/rt/6.6/patch-6.6-rc6-rt9.patch.xz" BR2_LINUX_KERNEL_DEFCONFIG="bcm2711"
BR2_LINUX_KERNEL_DTS_SUPPORT=y
BR2_LINUX_KERNEL_INTREE_DTS_NAME="broadcom/bcm2711-rpi-4-b"
BR2_LINUX_KERNEL_NEEDS_HOST_OPENSSL=y
BR2_PACKAGE_LINUX_TOOLS_RTLA=y
BR2_PACKAGE_RPI_FIRMWARE=y
BR2_PACKAGE_RPI_FIRMWARE_VARIANT_PI4=y BR2_PACKAGE_RPI_FIRMWARE_CONFIG_FILE="board/raspberrypi4-64/config_4_64bit.txt"

Quoted 9 lines

# BR2_PACKAGE_RPI_FIRMWARE_INSTALL_DTB_OVERLAYS is not set BR2_TARGET_ROOTFS_EXT2=y BR2_TARGET_ROOTFS_EXT2_4=y BR2_TARGET_ROOTFS_EXT2_SIZE="120M"
# BR2_TARGET_ROOTFS_TAR is not set BR2_PACKAGE_HOST_DOSFSTOOLS=y BR2_PACKAGE_HOST_GENIMAGE=y BR2_PACKAGE_HOST_MTOOLS=y

Quoted 7 lines

Reproduced and yes it's fixed with -D_GNU_SOURCE as pointed here:
https://man7.org/linux/man-pages/man3/CPU_SET.3.html

A huge thank you for the help!

Do you mind if I add your SoB describing what you've added on this patch?

Not at all:

Quoted 3 lines

--
Giulio Benetti
CEO/CTO@Benetti Engineering sas

Kind regards,
Andreas
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot