diff options
Diffstat (limited to 'meta/recipes-kernel/lttng/lttng-modules')
10 files changed, 409 insertions, 398 deletions
diff --git a/meta/recipes-kernel/lttng/lttng-modules/0001-Fix-ASoC-snd_doc_dapm-on-linux-6.9-rc1.patch b/meta/recipes-kernel/lttng/lttng-modules/0001-Fix-ASoC-snd_doc_dapm-on-linux-6.9-rc1.patch new file mode 100644 index 0000000000..9d5fd0de60 --- /dev/null +++ b/meta/recipes-kernel/lttng/lttng-modules/0001-Fix-ASoC-snd_doc_dapm-on-linux-6.9-rc1.patch @@ -0,0 +1,93 @@ +From fec007d9630e010062cf5699a08460f71f46b527 Mon Sep 17 00:00:00 2001 +From: Kienan Stewart <kstewart@efficios.com> +Date: Mon, 25 Mar 2024 08:54:42 -0400 +Subject: [PATCH 1/4] Fix: ASoC snd_doc_dapm on linux 6.9-rc1 + +See upstream commit: + + commit 7df3eb4cdb6bbfa482f51548b9fd47c2723c68ba + Author: Luca Ceresoli <luca.ceresoli@bootlin.com> + Date: Wed Mar 6 10:30:01 2024 +0100 + + ASoC: trace: add event to snd_soc_dapm trace events + + Add the event value to the snd_soc_dapm_start and snd_soc_dapm_done trace + events to make them more informative. + + Trace before: + + aplay-229 [000] 250.140309: snd_soc_dapm_start: card=vscn-2046 + aplay-229 [000] 250.167531: snd_soc_dapm_done: card=vscn-2046 + aplay-229 [000] 251.169588: snd_soc_dapm_start: card=vscn-2046 + aplay-229 [000] 251.195245: snd_soc_dapm_done: card=vscn-2046 + + Trace after: + + aplay-214 [000] 693.290612: snd_soc_dapm_start: card=vscn-2046 event=1 + aplay-214 [000] 693.315508: snd_soc_dapm_done: card=vscn-2046 event=1 + aplay-214 [000] 694.537349: snd_soc_dapm_start: card=vscn-2046 event=2 + aplay-214 [000] 694.563241: snd_soc_dapm_done: card=vscn-2046 event=2 + +Upstream-Status: Backport [88c4e0fe Fix: ASoC snd_doc_dapm on linux 6.9-rc1] + +Change-Id: If0d33544b8dd1dfb3d12ca9390892190fc0444b0 +Signed-off-by: Kienan Stewart <kstewart@efficios.com> +Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> +--- + include/instrumentation/events/asoc.h | 33 +++++++++++++++++++++++++++ + 1 file changed, 33 insertions(+) + +diff --git a/include/instrumentation/events/asoc.h b/include/instrumentation/events/asoc.h +index 21d13a0f..5126d4c1 100644 +--- a/include/instrumentation/events/asoc.h ++++ b/include/instrumentation/events/asoc.h +@@ -51,6 +51,38 @@ LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(asoc_snd_soc_card, snd_soc_bias_level_done, + + ) + ++#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(6,9,0)) ++LTTNG_TRACEPOINT_EVENT_CLASS(asoc_snd_soc_dapm_basic, ++ ++ TP_PROTO(struct snd_soc_card *card, int event), ++ ++ TP_ARGS(card, event), ++ ++ TP_FIELDS( ++ ctf_string(name, card->name) ++ ctf_integer(int, event, event) ++ ) ++) ++LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(asoc_snd_soc_dapm_basic, snd_soc_dapm_start, ++ ++ asoc_snd_soc_dapm_start, ++ ++ TP_PROTO(struct snd_soc_card *card, int event), ++ ++ TP_ARGS(card, event) ++ ++) ++ ++LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(asoc_snd_soc_dapm_basic, snd_soc_dapm_done, ++ ++ asoc_snd_soc_dapm_done, ++ ++ TP_PROTO(struct snd_soc_card *card, int event), ++ ++ TP_ARGS(card, event) ++ ++) ++#else + LTTNG_TRACEPOINT_EVENT_CLASS(asoc_snd_soc_dapm_basic, + + TP_PROTO(struct snd_soc_card *card), +@@ -81,6 +113,7 @@ LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(asoc_snd_soc_dapm_basic, snd_soc_dapm_done, + TP_ARGS(card) + + ) ++#endif + + LTTNG_TRACEPOINT_EVENT_CLASS(asoc_snd_soc_dapm_widget, + +-- +2.39.2 + diff --git a/meta/recipes-kernel/lttng/lttng-modules/0001-Fix-memory-leaks-on-event-destroy.patch b/meta/recipes-kernel/lttng/lttng-modules/0001-Fix-memory-leaks-on-event-destroy.patch deleted file mode 100644 index 21da932a75..0000000000 --- a/meta/recipes-kernel/lttng/lttng-modules/0001-Fix-memory-leaks-on-event-destroy.patch +++ /dev/null @@ -1,58 +0,0 @@ -From b3fdf78b15beb940918da1e41eb68e24ba31bb87 Mon Sep 17 00:00:00 2001 -From: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> -Date: Wed, 3 Mar 2021 10:10:16 -0500 -Subject: [PATCH 1/4] Fix: memory leaks on event destroy - -Both filter runtime and event enabler ref objects are owned by the -event, but are not freed upon destruction of the event object, thus -leaking memory. - -Upstream-status: backport - -Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> -Change-Id: Ice9b1c18b47584838aea2b965494d3c8391f4c84 ---- - lttng-events.c | 7 +++++++ - lttng-events.h | 1 + - 2 files changed, 8 insertions(+) - -diff --git a/lttng-events.c b/lttng-events.c -index f3398adc..984bd341 100644 ---- a/lttng-events.c -+++ b/lttng-events.c -@@ -919,6 +919,8 @@ int _lttng_event_unregister(struct lttng_event *event) - static - void _lttng_event_destroy(struct lttng_event *event) - { -+ struct lttng_enabler_ref *enabler_ref, *tmp_enabler_ref; -+ - switch (event->instrumentation) { - case LTTNG_KERNEL_TRACEPOINT: - lttng_event_put(event->desc); -@@ -944,6 +946,11 @@ void _lttng_event_destroy(struct lttng_event *event) - } - list_del(&event->list); - lttng_destroy_context(event->ctx); -+ lttng_free_event_filter_runtime(event); -+ /* Free event enabler refs */ -+ list_for_each_entry_safe(enabler_ref, tmp_enabler_ref, -+ &event->enablers_ref_head, node) -+ kfree(enabler_ref); - kmem_cache_free(event_cache, event); - } - -diff --git a/lttng-events.h b/lttng-events.h -index 1b9ab167..13b6abf5 100644 ---- a/lttng-events.h -+++ b/lttng-events.h -@@ -716,6 +716,7 @@ int lttng_enabler_attach_bytecode(struct lttng_enabler *enabler, - struct lttng_kernel_filter_bytecode __user *bytecode); - void lttng_enabler_event_link_bytecode(struct lttng_event *event, - struct lttng_enabler *enabler); -+void lttng_free_event_filter_runtime(struct lttng_event *event); - - int lttng_probes_init(void); - --- -2.19.1 - diff --git a/meta/recipes-kernel/lttng/lttng-modules/0001-src-Kbuild-change-missing-CONFIG_TRACEPOINTS-to-warn.patch b/meta/recipes-kernel/lttng/lttng-modules/0001-src-Kbuild-change-missing-CONFIG_TRACEPOINTS-to-warn.patch new file mode 100644 index 0000000000..120528bf9c --- /dev/null +++ b/meta/recipes-kernel/lttng/lttng-modules/0001-src-Kbuild-change-missing-CONFIG_TRACEPOINTS-to-warn.patch @@ -0,0 +1,46 @@ +From 878f89b6136ff7b870a19e04901cc6f316bbe10a Mon Sep 17 00:00:00 2001 +From: Bruce Ashfield <bruce.ashfield@gmail.com> +Date: Sat, 15 May 2021 10:26:38 -0400 +Subject: [PATCH] src/Kbuild: change missing CONFIG_TRACEPOINTS to warning + +Taken from a previous patch to the main lttng-modules Makefile, by +Otavio Salvador: + + The lttng-modules are being pulled by the tools-profile image feature, + however, not every kernel has the CONFIG_TRACEPOINTS feature enabled. + + This change makes the build do not fail when CONFIG_TRACEPOINTS is not + available, allowing it to be kept being pulled by default. + +Upstream-Status: Inappropriate [embedded specific] + +Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com> +--- + src/Kbuild | 7 ++++++- + 1 file changed, 6 insertions(+), 1 deletion(-) + +Index: lttng-modules-2.13.10/src/Kbuild +=================================================================== +--- lttng-modules-2.13.10.orig/src/Kbuild ++++ lttng-modules-2.13.10/src/Kbuild +@@ -2,10 +2,13 @@ + + ifdef CONFIG_LOCALVERSION # Check if dot-config is included. + ifeq ($(CONFIG_TRACEPOINTS),) +- $(error The option CONFIG_TRACEPOINTS needs to be enabled in your kernel configuration) ++ $(warning The option CONFIG_TRACEPOINTS needs to be enabled in your kernel configuration) ++ DISABLE_MODULE = y + endif # CONFIG_TRACEPOINTS + endif # ifdef CONFIG_LOCALVERSION + ++ifneq ($(DISABLE_MODULE),y) ++ + TOP_LTTNG_MODULES_DIR := $(shell dirname $(lastword $(MAKEFILE_LIST)))/.. + + lttng_check_linux_version = $(shell pwd)/include/linux/version.h +@@ -150,3 +153,5 @@ lttng-statedump-objs := lttng-statedump- + obj-$(CONFIG_LTTNG) += probes/ + obj-$(CONFIG_LTTNG) += lib/ + obj-$(CONFIG_LTTNG) += tests/ ++ ++endif # DISABLE_MODULE diff --git a/meta/recipes-kernel/lttng/lttng-modules/0002-Fix-ASoC-add-component-to-set_bias_level-events-in-l.patch b/meta/recipes-kernel/lttng/lttng-modules/0002-Fix-ASoC-add-component-to-set_bias_level-events-in-l.patch new file mode 100644 index 0000000000..6ea10ffc91 --- /dev/null +++ b/meta/recipes-kernel/lttng/lttng-modules/0002-Fix-ASoC-add-component-to-set_bias_level-events-in-l.patch @@ -0,0 +1,132 @@ +From d8379ec6365a925db33cae94fb6783cdbdb6a922 Mon Sep 17 00:00:00 2001 +From: Kienan Stewart <kstewart@efficios.com> +Date: Mon, 25 Mar 2024 09:40:29 -0400 +Subject: [PATCH 2/4] Fix: ASoC add component to set_bias_level events in linux + 6.9-rc1 + +See upstream commit: + + commit 6ef46a69ec32fe1cf56de67742fcd01af4bf48af + Author: Luca Ceresoli <luca.ceresoli@bootlin.com> + Date: Wed Mar 6 10:30:00 2024 +0100 + + ASoC: trace: add component to set_bias_level trace events + + The snd_soc_bias_level_start and snd_soc_bias_level_done trace events + currently look like: + + aplay-229 [000] 1250.140778: snd_soc_bias_level_start: card=vscn-2046 val=1 + aplay-229 [000] 1250.140784: snd_soc_bias_level_done: card=vscn-2046 val=1 + aplay-229 [000] 1250.140786: snd_soc_bias_level_start: card=vscn-2046 val=2 + aplay-229 [000] 1250.140788: snd_soc_bias_level_done: card=vscn-2046 val=2 + kworker/u8:1-21 [000] 1250.140871: snd_soc_bias_level_start: card=vscn-2046 val=1 + kworker/u8:0-11 [000] 1250.140951: snd_soc_bias_level_start: card=vscn-2046 val=1 + kworker/u8:0-11 [000] 1250.140956: snd_soc_bias_level_done: card=vscn-2046 val=1 + kworker/u8:0-11 [000] 1250.140959: snd_soc_bias_level_start: card=vscn-2046 val=2 + kworker/u8:0-11 [000] 1250.140961: snd_soc_bias_level_done: card=vscn-2046 val=2 + kworker/u8:1-21 [000] 1250.167219: snd_soc_bias_level_done: card=vscn-2046 val=1 + kworker/u8:1-21 [000] 1250.167222: snd_soc_bias_level_start: card=vscn-2046 val=2 + kworker/u8:1-21 [000] 1250.167232: snd_soc_bias_level_done: card=vscn-2046 val=2 + kworker/u8:0-11 [000] 1250.167440: snd_soc_bias_level_start: card=vscn-2046 val=3 + kworker/u8:0-11 [000] 1250.167444: snd_soc_bias_level_done: card=vscn-2046 val=3 + kworker/u8:1-21 [000] 1250.167497: snd_soc_bias_level_start: card=vscn-2046 val=3 + kworker/u8:1-21 [000] 1250.167506: snd_soc_bias_level_done: card=vscn-2046 val=3 + + There are clearly multiple calls, one per component, but they cannot be + discriminated from each other. + + Change the ftrace events to also print the component name, to make it clear + which part of the code is involved. This requires changing the passed value + from a struct snd_soc_card, where the DAPM context is not kwown, to a + struct snd_soc_dapm_context where it is obviously known but the a card + pointer is also available. + + With this change, the resulting trace becomes: + + aplay-247 [000] 1436.357332: snd_soc_bias_level_start: card=vscn-2046 component=(none) val=1 + aplay-247 [000] 1436.357338: snd_soc_bias_level_done: card=vscn-2046 component=(none) val=1 + aplay-247 [000] 1436.357340: snd_soc_bias_level_start: card=vscn-2046 component=(none) val=2 + aplay-247 [000] 1436.357343: snd_soc_bias_level_done: card=vscn-2046 component=(none) val=2 + kworker/u8:4-215 [000] 1436.357437: snd_soc_bias_level_start: card=vscn-2046 component=ff560000.codec val=1 + kworker/u8:5-231 [000] 1436.357518: snd_soc_bias_level_start: card=vscn-2046 component=ff320000.i2s val=1 + kworker/u8:5-231 [000] 1436.357523: snd_soc_bias_level_done: card=vscn-2046 component=ff320000.i2s val=1 + kworker/u8:5-231 [000] 1436.357526: snd_soc_bias_level_start: card=vscn-2046 component=ff320000.i2s val=2 + kworker/u8:5-231 [000] 1436.357528: snd_soc_bias_level_done: card=vscn-2046 component=ff320000.i2s val=2 + kworker/u8:4-215 [000] 1436.383217: snd_soc_bias_level_done: card=vscn-2046 component=ff560000.codec val=1 + kworker/u8:4-215 [000] 1436.383221: snd_soc_bias_level_start: card=vscn-2046 component=ff560000.codec val=2 + kworker/u8:4-215 [000] 1436.383231: snd_soc_bias_level_done: card=vscn-2046 component=ff560000.codec val=2 + kworker/u8:5-231 [000] 1436.383468: snd_soc_bias_level_start: card=vscn-2046 component=ff320000.i2s val=3 + kworker/u8:5-231 [000] 1436.383472: snd_soc_bias_level_done: card=vscn-2046 component=ff320000.i2s val=3 + kworker/u8:4-215 [000] 1436.383503: snd_soc_bias_level_start: card=vscn-2046 component=ff560000.codec val=3 + kworker/u8:4-215 [000] 1436.383513: snd_soc_bias_level_done: card=vscn-2046 component=ff560000.codec val=3 + +Upstream-Status: Backport [303434ab Fix: ASoC add component to set_bias_level events in linux 6.9-rc1] + +Change-Id: I959f1680c002acdf29828b968d3975247f5433d8 +Signed-off-by: Kienan Stewart <kstewart@efficios.com> +Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> +--- + include/instrumentation/events/asoc.h | 36 +++++++++++++++++++++++++++ + 1 file changed, 36 insertions(+) + +Index: lttng-modules-2.13.12/include/instrumentation/events/asoc.h +=================================================================== +--- lttng-modules-2.13.12.orig/include/instrumentation/events/asoc.h ++++ lttng-modules-2.13.12/include/instrumentation/events/asoc.h +@@ -10,6 +10,7 @@ + #include <lttng/kernel-version.h> + + #define DAPM_DIRECT "(direct)" ++#define DAPM_COMPONENT_NONE "(none)" + + #ifndef _TRACE_ASOC_DEF + #define _TRACE_ASOC_DEF +@@ -119,6 +120,40 @@ LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(asoc + ) + #endif + ++#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(6,9,0)) ++LTTNG_TRACEPOINT_EVENT_CLASS(asoc_snd_soc_dapm_context, ++ ++ TP_PROTO(struct snd_soc_dapm_context *dapm, int val), ++ ++ TP_ARGS(dapm, val), ++ ++ TP_FIELDS( ++ ctf_string(name, dapm->card->name) ++ ctf_string(component, dapm->component ? dapm->component->name : DAPM_COMPONENT_NONE) ++ ctf_integer(int, val, val) ++ ) ++) ++ ++LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(asoc_snd_soc_dapm_context, snd_soc_bias_level_start, ++ ++ asoc_snd_soc_bias_level_start, ++ ++ TP_PROTO(struct snd_soc_dapm_context *dapm, int val), ++ ++ TP_ARGS(dapm, val) ++ ++) ++ ++LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(asoc_snd_soc_dapm_context, snd_soc_bias_level_done, ++ ++ asoc_snd_soc_bias_level_done, ++ ++ TP_PROTO(struct snd_soc_dapm_context *dapm, int val), ++ ++ TP_ARGS(dapm, val) ++ ++) ++#else + LTTNG_TRACEPOINT_EVENT_CLASS(asoc_snd_soc_card, + + TP_PROTO(struct snd_soc_card *card, int val), +@@ -150,6 +185,7 @@ LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(asoc + TP_ARGS(card, val) + + ) ++#endif + + #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(6,9,0)) + LTTNG_TRACEPOINT_EVENT_CLASS(asoc_snd_soc_dapm_basic, diff --git a/meta/recipes-kernel/lttng/lttng-modules/0002-Fix-filter-interpreter-early-exits-on-uninitialized-.patch b/meta/recipes-kernel/lttng/lttng-modules/0002-Fix-filter-interpreter-early-exits-on-uninitialized-.patch deleted file mode 100644 index 609690f05c..0000000000 --- a/meta/recipes-kernel/lttng/lttng-modules/0002-Fix-filter-interpreter-early-exits-on-uninitialized-.patch +++ /dev/null @@ -1,159 +0,0 @@ -From 23a2f61ffc6a656f136fa2044c0c3b8f79766779 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20Galarneau?= - <jeremie.galarneau@efficios.com> -Date: Wed, 3 Mar 2021 18:52:19 -0500 -Subject: [PATCH 2/4] Fix: filter interpreter early-exits on uninitialized - value -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -I observed that syscall filtering on string arguments wouldn't work on -my development machines, both running 5.11.2-arch1-1 (Arch Linux). - -For instance, enabling the tracing of the `openat()` syscall with the -'filename == "/proc/cpuinfo"' filter would not produce events even -though matching events were present in another session that had no -filtering active. The same problem occurred with `execve()`. - -I tried a couple of kernel versions before (5.11.1 and 5.10.13, if -memory serves me well) and I had the same problem. Meanwhile, I couldn't -reproduce the problem on various Debian machines (the LTTng CI) nor on a -fresh Ubuntu 20.04 with both the stock kernel and with an updated 5.11.2 -kernel. - -I built the lttng-modules with the interpreter debugging printout and -saw the following warning: - LTTng: [debug bytecode in /home/jgalar/EfficiOS/src/lttng-modules/src/lttng-bytecode-interpreter.c:bytecode_interpret@1508] Bytecode warning: loading a NULL string. - -After a shedload (yes, a _shed_load) of digging, I figured that the -problem was hidden in plain sight near that logging statement. - -In the `BYTECODE_OP_LOAD_FIELD_REF_USER_STRING` operation, the 'ax' -register's 'user_str' is initialized with the stack value (the user -space string's address in our case). However, a NULL check is performed -against the register's 'str' member. - -I initialy suspected that both members would be part of the same union -and alias each-other, but they are actually contiguous in a structure. - -On the unaffected machines, I could confirm that the `str` member was -uninitialized to a non-zero value causing the condition to evaluate to -false. - -Francis Deslauriers reproduced the problem by initializing the -interpreter stack to zero. - -I am unsure of the exact kernel configuration option that reveals this -issue on Arch Linux, but my kernel has the following option enabled: - -CONFIG_GCC_PLUGIN_STRUCTLEAK_BYREF_ALL: - Zero-initialize any stack variables that may be passed by reference - and had not already been explicitly initialized. This is intended to - eliminate all classes of uninitialized stack variable exploits and - information exposures. - -I have not tried to build without this enabled as, anyhow, this seems -to be a legitimate issue. - -I have spotted what appears to be an identical problem in -`BYTECODE_OP_LOAD_FIELD_REF_USER_SEQUENCE` and corrected it. However, -I have not exercised that code path. - -The commit that introduced this problem is 5b4ad89. - -The debug print-out of the `BYTECODE_OP_LOAD_FIELD_REF_USER_STRING` -operation is modified to print the user string (truncated to 31 chars). - -Upstream-status: backport - -Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com> -Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> -Change-Id: I2da3c31b9e3ce0e1b164cf3d2711c0893cbec273 ---- - lttng-filter-interpreter.c | 41 ++++++++++++++++++++++++++++++++++---- - 1 file changed, 37 insertions(+), 4 deletions(-) - -diff --git a/lttng-filter-interpreter.c b/lttng-filter-interpreter.c -index 5d572437..6e5a5139 100644 ---- a/lttng-filter-interpreter.c -+++ b/lttng-filter-interpreter.c -@@ -22,7 +22,7 @@ LTTNG_STACK_FRAME_NON_STANDARD(lttng_filter_interpret_bytecode); - * to handle user-space read. - */ - static --char get_char(struct estack_entry *reg, size_t offset) -+char get_char(const struct estack_entry *reg, size_t offset) - { - if (unlikely(offset >= reg->u.s.seq_len)) - return '\0'; -@@ -593,6 +593,39 @@ end: - return ret; - } - -+#ifdef DEBUG -+ -+#define DBG_USER_STR_CUTOFF 32 -+ -+/* -+ * In debug mode, print user string (truncated, if necessary). -+ */ -+static inline -+void dbg_load_ref_user_str_printk(const struct estack_entry *user_str_reg) -+{ -+ size_t pos = 0; -+ char last_char; -+ char user_str[DBG_USER_STR_CUTOFF]; -+ -+ pagefault_disable(); -+ do { -+ last_char = get_char(user_str_reg, pos); -+ user_str[pos] = last_char; -+ pos++; -+ } while (last_char != '\0' && pos < sizeof(user_str)); -+ pagefault_enable(); -+ -+ user_str[sizeof(user_str) - 1] = '\0'; -+ dbg_printk("load field ref user string: '%s%s'\n", user_str, -+ last_char != '\0' ? "[...]" : ""); -+} -+#else -+static inline -+void dbg_load_ref_user_str_printk(const struct estack_entry *user_str_reg) -+{ -+} -+#endif -+ - /* - * Return 0 (discard), or raise the 0x1 flag (log event). - * Currently, other flags are kept for future extensions and have no -@@ -1313,7 +1346,7 @@ uint64_t lttng_filter_interpret_bytecode(void *filter_data, - estack_push(stack, top, ax, bx); - estack_ax(stack, top)->u.s.user_str = - *(const char * const *) &filter_stack_data[ref->offset]; -- if (unlikely(!estack_ax(stack, top)->u.s.str)) { -+ if (unlikely(!estack_ax(stack, top)->u.s.user_str)) { - dbg_printk("Filter warning: loading a NULL string.\n"); - ret = -EINVAL; - goto end; -@@ -1322,7 +1355,7 @@ uint64_t lttng_filter_interpret_bytecode(void *filter_data, - estack_ax(stack, top)->u.s.literal_type = - ESTACK_STRING_LITERAL_TYPE_NONE; - estack_ax(stack, top)->u.s.user = 1; -- dbg_printk("ref load string %s\n", estack_ax(stack, top)->u.s.str); -+ dbg_load_ref_user_str_printk(estack_ax(stack, top)); - next_pc += sizeof(struct load_op) + sizeof(struct field_ref); - PO; - } -@@ -1340,7 +1373,7 @@ uint64_t lttng_filter_interpret_bytecode(void *filter_data, - estack_ax(stack, top)->u.s.user_str = - *(const char **) (&filter_stack_data[ref->offset - + sizeof(unsigned long)]); -- if (unlikely(!estack_ax(stack, top)->u.s.str)) { -+ if (unlikely(!estack_ax(stack, top)->u.s.user_str)) { - dbg_printk("Filter warning: loading a NULL sequence.\n"); - ret = -EINVAL; - goto end; --- -2.19.1 - diff --git a/meta/recipes-kernel/lttng/lttng-modules/0003-Fix-mm_compaction_migratepages-changed-in-linux-6.9-.patch b/meta/recipes-kernel/lttng/lttng-modules/0003-Fix-mm_compaction_migratepages-changed-in-linux-6.9-.patch new file mode 100644 index 0000000000..66c48ebe8f --- /dev/null +++ b/meta/recipes-kernel/lttng/lttng-modules/0003-Fix-mm_compaction_migratepages-changed-in-linux-6.9-.patch @@ -0,0 +1,81 @@ +From f4a6415f8d5fa447868d1fdc7119e0a328966379 Mon Sep 17 00:00:00 2001 +From: Kienan Stewart <kstewart@efficios.com> +Date: Mon, 25 Mar 2024 10:30:32 -0400 +Subject: [PATCH 3/4] Fix: mm_compaction_migratepages changed in linux 6.9-rc1 + +See upstream commit: + + commit ab755bf4249b992fc2140d615ab0a686d50765b4 + Author: Baolin Wang <baolin.wang@linux.alibaba.com> + Date: Tue Feb 20 14:16:31 2024 +0800 + + mm: compaction: update the cc->nr_migratepages when allocating or freeing the freepages + + Currently we will use 'cc->nr_freepages >= cc->nr_migratepages' comparison + to ensure that enough freepages are isolated in isolate_freepages(), + however it just decreases the cc->nr_freepages without updating + cc->nr_migratepages in compaction_alloc(), which will waste more CPU + cycles and cause too many freepages to be isolated. + + So we should also update the cc->nr_migratepages when allocating or + freeing the freepages to avoid isolating excess freepages. And I can see + fewer free pages are scanned and isolated when running thpcompact on my + Arm64 server: + + k6.7 k6.7_patched + Ops Compaction pages isolated 120692036.00 118160797.00 + Ops Compaction migrate scanned 131210329.00 154093268.00 + Ops Compaction free scanned 1090587971.00 1080632536.00 + Ops Compact scan efficiency 12.03 14.26 + + Moreover, I did not see an obvious latency improvements, this is likely + because isolating freepages is not the bottleneck in the thpcompact test + case. + + k6.7 k6.7_patched + Amean fault-both-1 1089.76 ( 0.00%) 1080.16 * 0.88%* + Amean fault-both-3 1616.48 ( 0.00%) 1636.65 * -1.25%* + Amean fault-both-5 2266.66 ( 0.00%) 2219.20 * 2.09%* + Amean fault-both-7 2909.84 ( 0.00%) 2801.90 * 3.71%* + Amean fault-both-12 4861.26 ( 0.00%) 4733.25 * 2.63%* + Amean fault-both-18 7351.11 ( 0.00%) 6950.51 * 5.45%* + Amean fault-both-24 9059.30 ( 0.00%) 9159.99 * -1.11%* + Amean fault-both-30 10685.68 ( 0.00%) 11399.02 * -6.68%* + +Upstream-Status: Backport [175fe77c Fix: mm_compaction_migratepages changed in linux 6.9-rc1] + +Change-Id: I103a43fd1b549360b3fc978fd409b7c17ef3e192 +Signed-off-by: Kienan Stewart <kstewart@efficios.com> +Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> +--- + include/instrumentation/events/compaction.h | 17 ++++++++++++++++- + 1 file changed, 16 insertions(+), 1 deletion(-) + +Index: lttng-modules-2.13.12/include/instrumentation/events/compaction.h +=================================================================== +--- lttng-modules-2.13.12.orig/include/instrumentation/events/compaction.h ++++ lttng-modules-2.13.12/include/instrumentation/events/compaction.h +@@ -97,7 +97,22 @@ LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(comp + + #endif /* #else #if LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,0,0) */ + +-#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,18,0) || \ ++#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(6,9,0)) ++LTTNG_TRACEPOINT_EVENT_MAP(mm_compaction_migratepages, ++ ++ compaction_migratepages, ++ ++ TP_PROTO(unsigned int nr_migratepages, ++ unsigned int nr_succeeded), ++ ++ TP_ARGS(nr_migratepages, nr_succeeded), ++ ++ TP_FIELDS( ++ ctf_integer(unsigned long, nr_migrated, nr_succeeded) ++ ctf_integer(unsigned long, nr_failed, nr_migratepages - nr_succeeded) ++ ) ++) ++#elif (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,18,0) || \ + LTTNG_RHEL_KERNEL_RANGE(5,14,0,163,0,0, 5,15,0,0,0,0)) + LTTNG_TRACEPOINT_EVENT_MAP(mm_compaction_migratepages, + diff --git a/meta/recipes-kernel/lttng/lttng-modules/0003-fix-mm-tracing-record-slab-name-for-kmem_cache_free-.patch b/meta/recipes-kernel/lttng/lttng-modules/0003-fix-mm-tracing-record-slab-name-for-kmem_cache_free-.patch deleted file mode 100644 index 71f99b80a3..0000000000 --- a/meta/recipes-kernel/lttng/lttng-modules/0003-fix-mm-tracing-record-slab-name-for-kmem_cache_free-.patch +++ /dev/null @@ -1,91 +0,0 @@ -From 49c603ef2dc6969f4454f0d849af00ee24bb7f04 Mon Sep 17 00:00:00 2001 -From: Michael Jeanson <mjeanson@efficios.com> -Date: Thu, 4 Mar 2021 16:50:12 -0500 -Subject: [PATCH 3/4] fix: mm, tracing: record slab name for kmem_cache_free() - (v5.12) - -See upstream commit: - - commit 3544de8ee6e4817278b15fe08658de49abf58954 - Author: Jacob Wen <jian.w.wen@oracle.com> - Date: Wed Feb 24 12:00:55 2021 -0800 - - mm, tracing: record slab name for kmem_cache_free() - - Currently, a trace record generated by the RCU core is as below. - - ... kmem_cache_free: call_site=rcu_core+0x1fd/0x610 ptr=00000000f3b49a66 - - It doesn't tell us what the RCU core has freed. - - This patch adds the slab name to trace_kmem_cache_free(). - The new format is as follows. - - ... kmem_cache_free: call_site=rcu_core+0x1fd/0x610 ptr=0000000037f79c8d name=dentry - ... kmem_cache_free: call_site=rcu_core+0x1fd/0x610 ptr=00000000f78cb7b5 name=sock_inode_cache - ... kmem_cache_free: call_site=rcu_core+0x1fd/0x610 ptr=0000000018768985 name=pool_workqueue - ... kmem_cache_free: call_site=rcu_core+0x1fd/0x610 ptr=000000006a6cb484 name=radix_tree_node - - We can use it to understand what the RCU core is going to free. For - example, some users maybe interested in when the RCU core starts - freeing reclaimable slabs like dentry to reduce memory pressure. - - Link: https://lkml.kernel.org/r/20201216072804.8838-1-jian.w.wen@oracle.com - -Upstream-status: backport - -Signed-off-by: Michael Jeanson <mjeanson@efficios.com> -Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> -Change-Id: I1ee2fc476614cadcc8d3ac5d8feddc7910e1aa3a ---- - instrumentation/events/lttng-module/kmem.h | 27 ++++++++++++++++++++++ - 1 file changed, 27 insertions(+) - -diff --git a/instrumentation/events/lttng-module/kmem.h b/instrumentation/events/lttng-module/kmem.h -index b134620a..d787ea54 100644 ---- a/instrumentation/events/lttng-module/kmem.h -+++ b/instrumentation/events/lttng-module/kmem.h -@@ -87,6 +87,32 @@ LTTNG_TRACEPOINT_EVENT_INSTANCE(kmem_alloc_node, kmem_cache_alloc_node, - TP_ARGS(call_site, ptr, bytes_req, bytes_alloc, gfp_flags, node) - ) - -+#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,12,0)) -+LTTNG_TRACEPOINT_EVENT(kfree, -+ -+ TP_PROTO(unsigned long call_site, const void *ptr), -+ -+ TP_ARGS(call_site, ptr), -+ -+ TP_FIELDS( -+ ctf_integer_hex(unsigned long, call_site, call_site) -+ ctf_integer_hex(const void *, ptr, ptr) -+ ) -+) -+ -+LTTNG_TRACEPOINT_EVENT(kmem_cache_free, -+ -+ TP_PROTO(unsigned long call_site, const void *ptr, const char *name), -+ -+ TP_ARGS(call_site, ptr, name), -+ -+ TP_FIELDS( -+ ctf_integer_hex(unsigned long, call_site, call_site) -+ ctf_integer_hex(const void *, ptr, ptr) -+ ctf_string(name, name) -+ ) -+) -+#else - LTTNG_TRACEPOINT_EVENT_CLASS(kmem_free, - - TP_PROTO(unsigned long call_site, const void *ptr), -@@ -114,6 +140,7 @@ LTTNG_TRACEPOINT_EVENT_INSTANCE(kmem_free, kmem_cache_free, - - TP_ARGS(call_site, ptr) - ) -+#endif - - #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,3,0)) - LTTNG_TRACEPOINT_EVENT_MAP(mm_page_free, kmem_mm_page_free, --- -2.19.1 - diff --git a/meta/recipes-kernel/lttng/lttng-modules/0004-Fix-dev_base_lock-removed-in-linux-6.9-rc1.patch b/meta/recipes-kernel/lttng/lttng-modules/0004-Fix-dev_base_lock-removed-in-linux-6.9-rc1.patch new file mode 100644 index 0000000000..59ef4f9313 --- /dev/null +++ b/meta/recipes-kernel/lttng/lttng-modules/0004-Fix-dev_base_lock-removed-in-linux-6.9-rc1.patch @@ -0,0 +1,57 @@ +From 217bc2e4685050dddce9bdd2557b64f6b8c16622 Mon Sep 17 00:00:00 2001 +From: Kienan Stewart <kstewart@efficios.com> +Date: Mon, 25 Mar 2024 10:53:46 -0400 +Subject: [PATCH 4/4] Fix: dev_base_lock removed in linux 6.9-rc1 + +See upstream commit: + + commit 1b3ef46cb7f2618cc0b507393220a69810f6da12 + Author: Eric Dumazet <edumazet@google.com> + Date: Tue Feb 13 06:32:45 2024 +0000 + + net: remove dev_base_lock + + dev_base_lock is not needed anymore, all remaining users also hold RTNL. + +Upstream-Status: Backport [52eb2ee9 Fix: dev_base_lock removed in linux 6.9-rc1] + +Change-Id: I6b07e6eed07fd398302ca14d23162ed24d74df15 +Signed-off-by: Kienan Stewart <kstewart@efficios.com> +Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> +--- + src/lttng-statedump-impl.c | 15 +++++++++++++++ + 1 file changed, 15 insertions(+) + +Index: lttng-modules-2.13.12/src/lttng-statedump-impl.c +=================================================================== +--- lttng-modules-2.13.12.orig/src/lttng-statedump-impl.c ++++ lttng-modules-2.13.12/src/lttng-statedump-impl.c +@@ -392,6 +392,20 @@ void lttng_enumerate_device(struct lttng + } + } + ++#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(6,9,0)) ++static ++int lttng_enumerate_network_ip_interface(struct lttng_kernel_session *session) ++{ ++ struct net_device *dev; ++ ++ rtnl_lock(); ++ for_each_netdev(&init_net, dev) ++ lttng_enumerate_device(session, dev); ++ rtnl_unlock(); ++ ++ return 0; ++} ++#else + static + int lttng_enumerate_network_ip_interface(struct lttng_kernel_session *session) + { +@@ -404,6 +418,7 @@ int lttng_enumerate_network_ip_interface + + return 0; + } ++#endif /* (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(6,9,0)) */ + #else /* CONFIG_INET */ + static inline + int lttng_enumerate_network_ip_interface(struct lttng_kernel_session *session) diff --git a/meta/recipes-kernel/lttng/lttng-modules/0004-Fix-kretprobe-null-ptr-deref-on-session-destroy.patch b/meta/recipes-kernel/lttng/lttng-modules/0004-Fix-kretprobe-null-ptr-deref-on-session-destroy.patch deleted file mode 100644 index 8a839c2b43..0000000000 --- a/meta/recipes-kernel/lttng/lttng-modules/0004-Fix-kretprobe-null-ptr-deref-on-session-destroy.patch +++ /dev/null @@ -1,41 +0,0 @@ -From 92cc3e7f76a545a2cd4828576971f1eea83f4e68 Mon Sep 17 00:00:00 2001 -From: Francis Deslauriers <francis.deslauriers@efficios.com> -Date: Wed, 17 Mar 2021 10:40:56 -0400 -Subject: [PATCH 4/4] Fix: kretprobe: null ptr deref on session destroy - -The `filter_bytecode_runtime_head` list is currently not initialized for -the return event of the kretprobe. This caused a kernel null ptr -dereference when destroying a session. It can reproduced with the -following commands: - - lttng create - lttng enable-event -k --function=lttng_test_filter_event_write my_event - lttng start - lttng stop - lttng destroy - -Upstream-status: backport - -Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com> -Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> -Change-Id: I1162ce8b10dd7237a26331531f048346b984eee7 ---- - lttng-events.c | 2 ++ - 1 file changed, 2 insertions(+) - -diff --git a/lttng-events.c b/lttng-events.c -index 984bd341..3450fa40 100644 ---- a/lttng-events.c -+++ b/lttng-events.c -@@ -704,6 +704,8 @@ struct lttng_event *_lttng_event_create(struct lttng_channel *chan, - event_return->enabled = 0; - event_return->registered = 1; - event_return->instrumentation = itype; -+ INIT_LIST_HEAD(&event_return->bytecode_runtime_head); -+ INIT_LIST_HEAD(&event_return->enablers_ref_head); - /* - * Populate lttng_event structure before kretprobe registration. - */ --- -2.19.1 - diff --git a/meta/recipes-kernel/lttng/lttng-modules/Makefile-Do-not-fail-if-CONFIG_TRACEPOINTS-is-not-en.patch b/meta/recipes-kernel/lttng/lttng-modules/Makefile-Do-not-fail-if-CONFIG_TRACEPOINTS-is-not-en.patch deleted file mode 100644 index e411242272..0000000000 --- a/meta/recipes-kernel/lttng/lttng-modules/Makefile-Do-not-fail-if-CONFIG_TRACEPOINTS-is-not-en.patch +++ /dev/null @@ -1,49 +0,0 @@ -From 1b0e574d680101105a6c1e8931c78824f5a97a42 Mon Sep 17 00:00:00 2001 -From: Otavio Salvador <otavio@ossystems.com.br> -Date: Mon, 5 Sep 2016 17:08:56 +0000 -Subject: [PATCH] Makefile: Do not fail if CONFIG_TRACEPOINTS is not enabled -Organization: O.S. Systems Software LTDA. - -The lttng-modules are being pulled by the tools-profile image feature, -however, not every kernel has the CONFIG_TRACEPOINTS feature enabled. - -This change makes the build do not fail when CONFIG_TRACEPOINTS is not -available, allowing it to be kept being pulled by default. - -Upstream-Status: Inappropriate [embedded specific] - -Signed-off-by: Otavio Salvador <otavio@ossystems.com.br> ---- - Makefile | 9 +++++---- - 1 file changed, 5 insertions(+), 4 deletions(-) - -diff --git a/Makefile b/Makefile -index 8602649..75550cc 100644 ---- a/Makefile -+++ b/Makefile -@@ -8,10 +8,7 @@ ifneq ($(KERNELRELEASE),) - # and defines the modules to be built. - - ifdef CONFIG_LOCALVERSION # Check if dot-config is included. -- ifeq ($(CONFIG_TRACEPOINTS),) -- $(error The option CONFIG_TRACEPOINTS needs to be enabled in your kernel configuration) -- endif # CONFIG_TRACEPOINTS -- endif # ifdef CONFIG_LOCALVERSION -+ ifneq ($(CONFIG_TRACEPOINTS),) - - TOP_LTTNG_MODULES_DIR := $(shell dirname $(lastword $(MAKEFILE_LIST))) - -@@ -94,6 +91,10 @@ ifneq ($(KERNELRELEASE),) - obj-$(CONFIG_LTTNG) += lib/ - obj-$(CONFIG_LTTNG) += tests/ - -+ else -+ $(warning The option CONFIG_TRACEPOINTS needs to be enabled in your kernel configuration) -+ endif # CONFIG_TRACEPOINTS -+ endif # ifdef CONFIG_LOCALVERSION - else # KERNELRELEASE - - # This part of the Makefile is used when the 'make' command is runned in the --- -2.1.4 - |