Skip to contentSkip to conversation

Fix arg3 for sched enqueue and dequeue probes

PATCH In review [email protected] 2 participants 2 messages Mar 30, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix arg3 for sched enqueue and dequeue probes

From: Eugene Loh <[email protected]>

For sched enqueue and dequeue probes, arg3 should be an int for enqueue and not exist for dequeue. In the code it was the other way around. Fix this and the associated tests.

The trampoline was already set up to get this argument correct.

---
 libdtrace/dt_prov_sched.c            | 3 ++-
 test/unittest/sched/tst.lv-dequeue.r | 1 -
 test/unittest/sched/tst.lv-enqueue.r | 1 +
 3 files changed, 3 insertions(+), 2 deletions(-)
libdtrace/dt_prov_sched.c +2 -1
index 125d58917..3a218f3cb 100644
@@ -46,10 +46,10 @@ static probe_arg_t probe_args[] = {
 	{ "dequeue", 0, { 0, 0, "struct task_struct *", "lwpsinfo_t *" } },
 	{ "dequeue", 1, { 0, 0, "struct task_struct *", "psinfo_t *" } },
 	{ "dequeue", 2, { 1, 0, "cpuinfo_t *", } },
-	{ "dequeue", 3, { 2, 0, "int", } },
 	{ "enqueue", 0, { 0, 0, "struct task_struct *", "lwpsinfo_t *" } },
 	{ "enqueue", 1, { 0, 0, "struct task_struct *", "psinfo_t *" } },
 	{ "enqueue", 2, { 1, 0, "cpuinfo_t *", } },
+	{ "enqueue", 3, { 2, 0, "int", } },
 	{ "off-cpu", 0, { 0, 0, "struct task_struct *", "lwpsinfo_t *" } },
 	{ "off-cpu", 1, { 0, 0, "struct task_struct *", "psinfo_t *" } },
 	{ "on-cpu", },
@@ -128,6 +128,7 @@ static int trampoline(dt_pcb_t *pcb, uint_t exitlbl)
 		 *	  associated with the runqueue.
 		 */
 		emit(dlp, BPF_STORE_IMM(BPF_DW, BPF_REG_7, DMST_ARG(1), 0));
+
 		emit(dlp, BPF_LOAD(BPF_DW, BPF_REG_0, BPF_REG_7, DMST_ARG(2)));
 		emit(dlp, BPF_ALU64_IMM(BPF_AND, BPF_REG_0, ENQUEUE_HEAD));
 		emit(dlp, BPF_STORE(BPF_DW, BPF_REG_7, DMST_ARG(2), BPF_REG_0));
test/unittest/sched/tst.lv-dequeue.r +0 -1
index 7580a8abc..657667f34 100644
@@ -14,5 +14,4 @@ PROBE sched vmlinux dequeue
 		args[0]: lwpsinfo_t *
 		args[1]: psinfo_t *
 		args[2]: cpuinfo_t *
-		args[3]: int
 
test/unittest/sched/tst.lv-enqueue.r +1 -0
index edc5e2c4c..2f5efa30c 100644
@@ -14,4 +14,5 @@ PROBE sched vmlinux enqueue
 		args[0]: lwpsinfo_t *
 		args[1]: psinfo_t *
 		args[2]: cpuinfo_t *
+		args[3]: int
 
Signature · 1 line
2.43.5
Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · On Sun, Mar 30, 2025 at 04:57:36PM -0400, [email protected] wrote:

From: Eugene Loh <[email protected]>

For sched enqueue and dequeue probes, arg3 should be an int for enqueue and not exist for dequeue. In the code it was the other way around. Fix this and the associated tests.

The trampoline was already set up to get this argument correct.

Quoted 53 lines
---
 libdtrace/dt_prov_sched.c            | 3 ++-
 test/unittest/sched/tst.lv-dequeue.r | 1 -
 test/unittest/sched/tst.lv-enqueue.r | 1 +
 3 files changed, 3 insertions(+), 2 deletions(-)
libdtrace/dt_prov_sched.c +2 -1
index 125d58917..3a218f3cb 100644
@@ -46,10 +46,10 @@ static probe_arg_t probe_args[] = {
 	{ "dequeue", 0, { 0, 0, "struct task_struct *", "lwpsinfo_t *" } },
 	{ "dequeue", 1, { 0, 0, "struct task_struct *", "psinfo_t *" } },
 	{ "dequeue", 2, { 1, 0, "cpuinfo_t *", } },
-	{ "dequeue", 3, { 2, 0, "int", } },
 	{ "enqueue", 0, { 0, 0, "struct task_struct *", "lwpsinfo_t *" } },
 	{ "enqueue", 1, { 0, 0, "struct task_struct *", "psinfo_t *" } },
 	{ "enqueue", 2, { 1, 0, "cpuinfo_t *", } },
+	{ "enqueue", 3, { 2, 0, "int", } },
 	{ "off-cpu", 0, { 0, 0, "struct task_struct *", "lwpsinfo_t *" } },
 	{ "off-cpu", 1, { 0, 0, "struct task_struct *", "psinfo_t *" } },
 	{ "on-cpu", },
@@ -128,6 +128,7 @@ static int trampoline(dt_pcb_t *pcb, uint_t exitlbl)
 		 *	  associated with the runqueue.
 		 */
 		emit(dlp, BPF_STORE_IMM(BPF_DW, BPF_REG_7, DMST_ARG(1), 0));
+
 		emit(dlp, BPF_LOAD(BPF_DW, BPF_REG_0, BPF_REG_7, DMST_ARG(2)));
 		emit(dlp, BPF_ALU64_IMM(BPF_AND, BPF_REG_0, ENQUEUE_HEAD));
 		emit(dlp, BPF_STORE(BPF_DW, BPF_REG_7, DMST_ARG(2), BPF_REG_0));
test/unittest/sched/tst.lv-dequeue.r +0 -1
index 7580a8abc..657667f34 100644
@@ -14,5 +14,4 @@ PROBE sched vmlinux dequeue
 		args[0]: lwpsinfo_t *
 		args[1]: psinfo_t *
 		args[2]: cpuinfo_t *
-		args[3]: int
 
test/unittest/sched/tst.lv-enqueue.r +1 -0
index edc5e2c4c..2f5efa30c 100644
@@ -14,4 +14,5 @@ PROBE sched vmlinux enqueue
 		args[0]: lwpsinfo_t *
 		args[1]: psinfo_t *
 		args[2]: cpuinfo_t *
+		args[3]: int
 
Signature · 1 line
2.43.5