Skip to contentSkip to conversation

lttng-modules: fix build against 5.18-rc7+

PATCH New [email protected] 1 participant 1 message May 20, 2022

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 lttng-modules: fix build against 5.18-rc7+

From: Bruce Ashfield <[email protected]>

lttng-modules fails to build against 5.18-rc7, the details of the fix are as follows:

The commit [fix: sched/tracing: Don't re-read p->state when emitting sched_switch event (v5.18)] was correct, but the kernel changed their mind with the following commit:

commit 9c2136be0878c88c53dea26943ce40bb03ad8d8d
Author: Delyan Kratunov <[email protected]>
Date: Wed May 11 18:28:36 2022 +0000

sched/tracing: Append prev_state to tp args instead

Commit fa2c3254d7cf (sched/tracing: Don't re-read p->state when emitting sched_switch event, 2022-01-20) added a new prev_state argument to the sched_switch tracepoint, before the prev task_struct pointer.

This reordering of arguments broke BPF programs that use the raw tracepoint (e.g. tp_btf programs). The type of the second argument has changed and existing programs that assume a task_struct* argument (e.g. for bpf_task_storage access) will now fail to verify.

If we instead append the new argument to the end, all existing programs would continue to work and can conditionally extract the prev_state argument on supported kernel versions.

Fixes fa2c3254d7cf (sched/tracing: Don't re-read p->state when emitting sched_switch event, 2022-01-20)

By reordering the parameters (again) we can get back up and building.

Upstream-Status: Backport

---

v2: upstream merged their fix for 5.18-rc7+, so I've updated with that fix and spun v2.

Bruce

 ...g-Append-prev_state-to-tp-args-inste.patch | 59 +++++++++++++++++++
 .../lttng/lttng-modules_2.13.3.bb             |  1 +
 2 files changed, 60 insertions(+)
 create mode 100644 meta/recipes-kernel/lttng/lttng-modules/0001-fix-sched-tracing-Append-prev_state-to-tp-args-inste.patch
meta/recipes-kernel/lttng/lttng-modules/0001-fix-sched-tracing-Append-prev_state-to-tp-args-inste.patch new file +59 -0
new file mode 100644
index 0000000000..b41053b6bc
@@ -0,0 +1,59 @@
+From 9c5b8de32b5745f3ff31079c02da64595e101bee Mon Sep 17 00:00:00 2001
+From: Michael Jeanson <[email protected]>
+Date: Tue, 17 May 2022 11:46:29 -0400
+Subject: [PATCH] fix: sched/tracing: Append prev_state to tp args instead
+ (v5.18)
+
+See upstream commit :
+
+  commit 9c2136be0878c88c53dea26943ce40bb03ad8d8d
+  Author: Delyan Kratunov <[email protected]>
+  Date:   Wed May 11 18:28:36 2022 +0000
+
+    sched/tracing: Append prev_state to tp args instead
+
+    Commit fa2c3254d7cf (sched/tracing: Don't re-read p->state when emitting
+    sched_switch event, 2022-01-20) added a new prev_state argument to the
+    sched_switch tracepoint, before the prev task_struct pointer.
+
+    This reordering of arguments broke BPF programs that use the raw
+    tracepoint (e.g. tp_btf programs). The type of the second argument has
+    changed and existing programs that assume a task_struct* argument
+    (e.g. for bpf_task_storage access) will now fail to verify.
+
+    If we instead append the new argument to the end, all existing programs
+    would continue to work and can conditionally extract the prev_state
+    argument on supported kernel versions.
+
+
+Upstream-Status: Backport
+
+Change-Id: Ife2ec88a8bea2743562590cbd357068d7773863f
+Signed-off-by: Michael Jeanson <[email protected]>
+Signed-off-by: Mathieu Desnoyers <[email protected]>
+---
+ include/instrumentation/events/sched.h | 6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/include/instrumentation/events/sched.h b/include/instrumentation/events/sched.h
+index 339bec94..c1c3df15 100644
+--- a/include/instrumentation/events/sched.h
++++ b/include/instrumentation/events/sched.h
+@@ -356,11 +356,11 @@ LTTNG_TRACEPOINT_EVENT_INSTANCE(sched_wakeup_template, sched_wakeup_new,
+ LTTNG_TRACEPOINT_EVENT(sched_switch,
+ 
+ 	TP_PROTO(bool preempt,
+-		unsigned int prev_state,
+ 		struct task_struct *prev,
+-		struct task_struct *next),
++		struct task_struct *next,
++		unsigned int prev_state),
+ 
+-	TP_ARGS(preempt, prev_state, prev, next),
++	TP_ARGS(preempt, prev, next, prev_state),
+ 
+ 	TP_FIELDS(
+ 		ctf_array_text(char, prev_comm,	prev->comm, TASK_COMM_LEN)
+-- 
+2.19.1
+
meta/recipes-kernel/lttng/lttng-modules_2.13.3.bb +1 -0
index 2b00534e53..a5e6b906d2 100644
@@ -20,6 +20,7 @@ SRC_URI = "https://lttng.org/files/${BPN}/${BPN}-${PV}.tar.bz2 \
            file://0008-fix-scsi-core-Remove-scsi-scsi_request.h-v5.18.patch \
            file://0009-Rename-genhd-wrapper-to-blkdev.patch \
            file://0010-fix-mm-compaction-cleanup-the-compaction-trace-event.patch \
+           file://0001-fix-sched-tracing-Append-prev_state-to-tp-args-inste.patch \
           "
 
 # Use :append here so that the patch is applied also when using devupstream
Signature · 1 line
2.19.1