Skip to contentSkip to conversation

sched_ext: Update demo schedulers and selftests for deprecated APIs

PATCH Superseded Cheng-Yang Chou 2 participants 5 messages Mar 12

Subsystems (2)

v1 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

cover sched_ext: Update demo schedulers and selftests for deprecated APIs

Two sets of sched_ext APIs have been deprecated:

- Direct writes to p->scx.dsq_vtime in favor of scx_bpf_task_set_dsq_vtime()
- ops.cpu_acquire/release() in favor of handling CPU preemption via the sched_switch tracepoint

This series updates the demo schedulers (scx_simple, scx_flatcg, scx_qmap) and selftests (select_cpu_vtime, maximal) to use the new APIs, keeping them in sync with current best practices.

Patch 1 uses bpf_ksym_exists() to fall back to direct assignment on older kernels that don't have scx_bpf_task_set_dsq_vtime(), preserving backwards compatibility.

Patch 2 removes the cpu_acquire/release stubs and the __COMPAT_scx_bpf_reenqueue_local_from_anywhere() compat guard from scx_qmap, unconditionally relying on the sched_switch TP.

Thanks,
Cheng-Yang

---

Cheng-Yang Chou (2):
sched_ext: Update demo schedulers and selftests to use
scx_bpf_task_set_dsq_vtime()
sched_ext: Update demo schedulers and selftests to drop
ops.cpu_acquire/release()

 tools/sched_ext/scx_flatcg.bpf.c              | 21 ++++++++++++++-----
 tools/sched_ext/scx_qmap.bpf.c                | 15 ++-----------
 tools/sched_ext/scx_simple.bpf.c              | 12 +++++++++--
 .../testing/selftests/sched_ext/maximal.bpf.c | 15 ++++++-------
 .../sched_ext/select_cpu_vtime.bpf.c          | 13 ++++++++++--
 5 files changed, 45 insertions(+), 31 deletions(-)
Signature · 1 line
2.48.1
#1 lore raw

PATCH 1/2 sched_ext: Update demo schedulers and selftests to use scx_bpf_task_set_dsq_vtime()

Direct writes to p->scx.dsq_vtime are deprecated in favor of scx_bpf_task_set_dsq_vtime(). Update scx_simple, scx_flatcg, and select_cpu_vtime selftest to use the new kfunc.

Use bpf_ksym_exists() to fall back to direct assignment on older kernels that don't have the new kfunc, preserving backwards compatibility.

---
 tools/sched_ext/scx_flatcg.bpf.c              | 21 ++++++++++++++-----
 tools/sched_ext/scx_simple.bpf.c              | 12 +++++++++--
 .../sched_ext/select_cpu_vtime.bpf.c          | 13 ++++++++++--
 3 files changed, 37 insertions(+), 9 deletions(-)
tools/sched_ext/scx_flatcg.bpf.c +16 -5
index a8a9234bb41e..27d99bb1e60f 100644
@@ -551,9 +551,14 @@ void BPF_STRUCT_OPS(fcg_stopping, struct task_struct *p, bool runnable)
 	 * too much, determine the execution time by taking explicit timestamps
 	 * instead of depending on @p->scx.slice.
 	 */
-	if (!fifo_sched)
-		p->scx.dsq_vtime +=
-			(SCX_SLICE_DFL - p->scx.slice) * 100 / p->scx.weight;
+	u64 delta = (SCX_SLICE_DFL - p->scx.slice) * 100 / p->scx.weight;
+
+	if (!fifo_sched) {
+		if (bpf_ksym_exists(scx_bpf_task_set_dsq_vtime___new))
+			scx_bpf_task_set_dsq_vtime___new(p, p->scx.dsq_vtime + delta);
+		else
+			p->scx.dsq_vtime += delta;
+	}
 
 	taskc = bpf_task_storage_get(&task_ctx, p, 0, 0);
 	if (!taskc) {
@@ -822,7 +827,10 @@ s32 BPF_STRUCT_OPS(fcg_init_task, struct task_struct *p,
 	if (!(cgc = find_cgrp_ctx(args->cgroup)))
 		return -ENOENT;
 
-	p->scx.dsq_vtime = cgc->tvtime_now;
+	if (bpf_ksym_exists(scx_bpf_task_set_dsq_vtime___new))
+		scx_bpf_task_set_dsq_vtime___new(p, cgc->tvtime_now);
+	else
+		p->scx.dsq_vtime = cgc->tvtime_now;
 
 	return 0;
 }
@@ -924,7 +932,10 @@ void BPF_STRUCT_OPS(fcg_cgroup_move, struct task_struct *p,
 		return;
 
 	delta = time_delta(p->scx.dsq_vtime, from_cgc->tvtime_now);
-	p->scx.dsq_vtime = to_cgc->tvtime_now + delta;
+	if (bpf_ksym_exists(scx_bpf_task_set_dsq_vtime___new))
+		scx_bpf_task_set_dsq_vtime___new(p, to_cgc->tvtime_now + delta);
+	else
+		p->scx.dsq_vtime = to_cgc->tvtime_now + delta;
 }
 
 s32 BPF_STRUCT_OPS_SLEEPABLE(fcg_init)
tools/sched_ext/scx_simple.bpf.c +10 -2
index b456bd7cae77..61d3bcf54ce7 100644
@@ -121,12 +121,20 @@ void BPF_STRUCT_OPS(simple_stopping, struct task_struct *p, bool runnable)
 	 * too much, determine the execution time by taking explicit timestamps
 	 * instead of depending on @p->scx.slice.
 	 */
-	p->scx.dsq_vtime += (SCX_SLICE_DFL - p->scx.slice) * 100 / p->scx.weight;
+	u64 delta = (SCX_SLICE_DFL - p->scx.slice) * 100 / p->scx.weight;
+
+	if (bpf_ksym_exists(scx_bpf_task_set_dsq_vtime___new))
+		scx_bpf_task_set_dsq_vtime___new(p, p->scx.dsq_vtime + delta);
+	else
+		p->scx.dsq_vtime += delta;
 }
 
 void BPF_STRUCT_OPS(simple_enable, struct task_struct *p)
 {
-	p->scx.dsq_vtime = vtime_now;
+	if (bpf_ksym_exists(scx_bpf_task_set_dsq_vtime___new))
+		scx_bpf_task_set_dsq_vtime___new(p, vtime_now);
+	else
+		p->scx.dsq_vtime = vtime_now;
 }
 
 s32 BPF_STRUCT_OPS_SLEEPABLE(simple_init)
tools/testing/selftests/sched_ext/select_cpu_vtime.bpf.c +11 -2
index bfcb96cd4954..17ed515c3e25 100644
@@ -66,12 +66,21 @@ void BPF_STRUCT_OPS(select_cpu_vtime_running, struct task_struct *p)
 void BPF_STRUCT_OPS(select_cpu_vtime_stopping, struct task_struct *p,
 		    bool runnable)
 {
-	p->scx.dsq_vtime += (SCX_SLICE_DFL - p->scx.slice) * 100 / p->scx.weight;
+	u64 delta = (SCX_SLICE_DFL - p->scx.slice) * 100 / p->scx.weight;
+
+	if (bpf_ksym_exists(scx_bpf_task_set_dsq_vtime___new))
+		scx_bpf_task_set_dsq_vtime___new(p, p->scx.dsq_vtime + delta);
+	else
+		p->scx.dsq_vtime += delta;
+
 }
 
 void BPF_STRUCT_OPS(select_cpu_vtime_enable, struct task_struct *p)
 {
-	p->scx.dsq_vtime = vtime_now;
+	if (bpf_ksym_exists(scx_bpf_task_set_dsq_vtime___new))
+		scx_bpf_task_set_dsq_vtime___new(p, vtime_now);
+	else
+		p->scx.dsq_vtime = vtime_now;
 }
 
 s32 BPF_STRUCT_OPS_SLEEPABLE(select_cpu_vtime_init)
Signature · 1 line
2.48.1
reviewer
#2 lore raw

Re: [PATCH 1/2] sched_ext: Update demo schedulers and selftests to use scx_bpf_task_set_dsq_vtime()

Hi Cheng-Yang,

Quoted 19 lines · Cheng-Yang Chou

Direct writes to p->scx.dsq_vtime are deprecated in favor of scx_bpf_task_set_dsq_vtime(). Update scx_simple, scx_flatcg, and select_cpu_vtime selftest to use the new kfunc.

Use bpf_ksym_exists() to fall back to direct assignment on older kernels that don't have the new kfunc, preserving backwards compatibility.

---
 tools/sched_ext/scx_flatcg.bpf.c              | 21 ++++++++++++++-----
 tools/sched_ext/scx_simple.bpf.c              | 12 +++++++++--
 .../sched_ext/select_cpu_vtime.bpf.c          | 13 ++++++++++--
 3 files changed, 37 insertions(+), 9 deletions(-)
tools/sched_ext/scx_flatcg.bpf.c +0 -0
index a8a9234bb41e..27d99bb1e60f 100644

tools/sched_ext/scx_flatcg.bpf.c void BPF_STRUCT_OPS(fcg_stopping, struct task_struct *p, bool runnable) · line 554

Quoted 7 lines
tools/sched_ext/scx_flatcg.bpf.c +1 -3
@@ -551,9 +551,14 @@ void BPF_STRUCT_OPS(fcg_stopping, struct task_struct *p, bool runnable)
 	 * too much, determine the execution time by taking explicit timestamps
 	 * instead of depending on @p->scx.slice.
 	 */
-	if (!fifo_sched)
-		p->scx.dsq_vtime +=
-			(SCX_SLICE_DFL - p->scx.slice) * 100 / p->scx.weight;
+	u64 delta = (SCX_SLICE_DFL - p->scx.slice) * 100 / p->scx.weight;

While at it, can we use:

u64 delta = scale_by_task_weight(p, SCX_SLICE_DFL - p->scx.slice);

tools/sched_ext/scx_flatcg.bpf.c void BPF_STRUCT_OPS(fcg_stopping, struct task_struct *p, bool runnable) · line 561

Quoted 7 lines
tools/sched_ext/scx_flatcg.bpf.c +7 -0
+
+	if (!fifo_sched) {
+		if (bpf_ksym_exists(scx_bpf_task_set_dsq_vtime___new))
+			scx_bpf_task_set_dsq_vtime___new(p, p->scx.dsq_vtime + delta);
+		else
+			p->scx.dsq_vtime += delta;
+	}

No, let's just use:

scx_bpf_task_set_dsq_vtime(p, p->scx.dsq_vtime + delta);

It's already doing the bpf_ksym_exists() logic internally, see tools/sched_ext/include/scx/compat.bpf.h.

tools/sched_ext/scx_flatcg.bpf.c s32 BPF_STRUCT_OPS(fcg_init_task, struct task_struct *p, · line 833

Quoted 12 lines
tools/sched_ext/scx_flatcg.bpf.c +4 -1
 	taskc = bpf_task_storage_get(&task_ctx, p, 0, 0);
 	if (!taskc) {
@@ -822,7 +827,10 @@ s32 BPF_STRUCT_OPS(fcg_init_task, struct task_struct *p,
 	if (!(cgc = find_cgrp_ctx(args->cgroup)))
 		return -ENOENT;
 
-	p->scx.dsq_vtime = cgc->tvtime_now;
+	if (bpf_ksym_exists(scx_bpf_task_set_dsq_vtime___new))
+		scx_bpf_task_set_dsq_vtime___new(p, cgc->tvtime_now);
+	else
+		p->scx.dsq_vtime = cgc->tvtime_now;

Ditto.

tools/sched_ext/scx_flatcg.bpf.c void BPF_STRUCT_OPS(fcg_cgroup_move, struct task_struct *p, · line 938

Quoted 12 lines
tools/sched_ext/scx_flatcg.bpf.c +4 -1
 	return 0;
 }
@@ -924,7 +932,10 @@ void BPF_STRUCT_OPS(fcg_cgroup_move, struct task_struct *p,
 		return;
 
 	delta = time_delta(p->scx.dsq_vtime, from_cgc->tvtime_now);
-	p->scx.dsq_vtime = to_cgc->tvtime_now + delta;
+	if (bpf_ksym_exists(scx_bpf_task_set_dsq_vtime___new))
+		scx_bpf_task_set_dsq_vtime___new(p, to_cgc->tvtime_now + delta);
+	else
+		p->scx.dsq_vtime = to_cgc->tvtime_now + delta;

Ditto.

Quoted 8 lines
tools/sched_ext/scx_flatcg.bpf.c +0 -0
 }
 
 s32 BPF_STRUCT_OPS_SLEEPABLE(fcg_init)
tools/sched_ext/scx_simple.bpf.c +0 -0
index b456bd7cae77..61d3bcf54ce7 100644

tools/sched_ext/scx_simple.bpf.c void BPF_STRUCT_OPS(simple_stopping, struct task_struct *p, bool runnable) · line 129

Quoted 10 lines
tools/sched_ext/scx_simple.bpf.c +6 -1
@@ -121,12 +121,20 @@ void BPF_STRUCT_OPS(simple_stopping, struct task_struct *p, bool runnable)
 	 * too much, determine the execution time by taking explicit timestamps
 	 * instead of depending on @p->scx.slice.
 	 */
-	p->scx.dsq_vtime += (SCX_SLICE_DFL - p->scx.slice) * 100 / p->scx.weight;
+	u64 delta = (SCX_SLICE_DFL - p->scx.slice) * 100 / p->scx.weight;
+
+	if (bpf_ksym_exists(scx_bpf_task_set_dsq_vtime___new))
+		scx_bpf_task_set_dsq_vtime___new(p, p->scx.dsq_vtime + delta);
+	else
+		p->scx.dsq_vtime += delta;

Ditto.

tools/sched_ext/scx_simple.bpf.c void BPF_STRUCT_OPS(simple_stopping, struct task_struct *p, bool runnable) · line 137

Quoted 9 lines
tools/sched_ext/scx_simple.bpf.c +4 -1
 }
 
 void BPF_STRUCT_OPS(simple_enable, struct task_struct *p)
 {
-	p->scx.dsq_vtime = vtime_now;
+	if (bpf_ksym_exists(scx_bpf_task_set_dsq_vtime___new))
+		scx_bpf_task_set_dsq_vtime___new(p, vtime_now);
+	else
+		p->scx.dsq_vtime = vtime_now;

Ditto.

tools/testing/selftests/sched_ext/select_cpu_vtime.bpf.c void BPF_STRUCT_OPS(select_cpu_vtime_running, struct task_struct *p) · line 69

Quoted 13 lines
tools/sched_ext/scx_simple.bpf.c +0 -0
 }
 
 s32 BPF_STRUCT_OPS_SLEEPABLE(simple_init)
tools/testing/selftests/sched_ext/select_cpu_vtime.bpf.c +1 -1
index bfcb96cd4954..17ed515c3e25 100644
@@ -66,12 +66,21 @@ void BPF_STRUCT_OPS(select_cpu_vtime_running, struct task_struct *p)
 void BPF_STRUCT_OPS(select_cpu_vtime_stopping, struct task_struct *p,
 		    bool runnable)
 {
-	p->scx.dsq_vtime += (SCX_SLICE_DFL - p->scx.slice) * 100 / p->scx.weight;
+	u64 delta = (SCX_SLICE_DFL - p->scx.slice) * 100 / p->scx.weight;

Ditto (scale_by_task_weight).

tools/testing/selftests/sched_ext/select_cpu_vtime.bpf.c void BPF_STRUCT_OPS(select_cpu_vtime_running, struct task_struct *p) · line 75

Quoted 6 lines
tools/testing/selftests/sched_ext/select_cpu_vtime.bpf.c +6 -0
+
+	if (bpf_ksym_exists(scx_bpf_task_set_dsq_vtime___new))
+		scx_bpf_task_set_dsq_vtime___new(p, p->scx.dsq_vtime + delta);
+	else
+		p->scx.dsq_vtime += delta;
+

Ditto.

tools/testing/selftests/sched_ext/select_cpu_vtime.bpf.c void BPF_STRUCT_OPS(select_cpu_vtime_running, struct task_struct *p) · line 83

Quoted 9 lines
tools/testing/selftests/sched_ext/select_cpu_vtime.bpf.c +4 -1
 }
 
 void BPF_STRUCT_OPS(select_cpu_vtime_enable, struct task_struct *p)
 {
-	p->scx.dsq_vtime = vtime_now;
+	if (bpf_ksym_exists(scx_bpf_task_set_dsq_vtime___new))
+		scx_bpf_task_set_dsq_vtime___new(p, vtime_now);
+	else
+		p->scx.dsq_vtime = vtime_now;

Ditto.

Quoted 6 lines
tools/testing/selftests/sched_ext/select_cpu_vtime.bpf.c +0 -0
 }
 
 s32 BPF_STRUCT_OPS_SLEEPABLE(select_cpu_vtime_init)
Signature · 1 line
2.48.1

Thanks,
-Andrea

#3 lore raw

PATCH 2/2 sched_ext: Update demo schedulers and selftests to drop ops.cpu_acquire/release()

In reply to Cheng-Yang Chou

ops.cpu_acquire() and ops.cpu_release() are deprecated in favor of handling CPU preemption via the sched_switch tracepoint. Update scx_qmap and the maximal selftest to use the new approach.

In scx_qmap, remove the cpu_release fallback and the __COMPAT_scx_bpf_reenqueue_local_from_anywhere() compat guard from qmap_sched_switch(), unconditionally handling preemption via the TP.

In the maximal selftest, replace the cpu_acquire and cpu_release stubs with a minimal sched_switch TP program.

---
 tools/sched_ext/scx_qmap.bpf.c                  | 15 ++-------------
 tools/testing/selftests/sched_ext/maximal.bpf.c | 15 ++++++---------
 2 files changed, 8 insertions(+), 22 deletions(-)
tools/sched_ext/scx_qmap.bpf.c +2 -13
index a4a1b84fe359..a11e27c8de77 100644
@@ -11,8 +11,8 @@
  *
  * - BPF-side queueing using PIDs.
  * - Sleepable per-task storage allocation using ops.prep_enable().
- * - Using ops.cpu_release() to handle a higher priority scheduling class taking
- *   the CPU away.
+ * - Using the sched_switch tracepoint to handle a higher priority scheduling
+ *   class taking the CPU away.
  * - Core-sched support.
  *
  * This scheduler is primarily for demonstration and testing of sched_ext
@@ -562,9 +562,6 @@ SEC("tp_btf/sched_switch")
 int BPF_PROG(qmap_sched_switch, bool preempt, struct task_struct *prev,
 	     struct task_struct *next, unsigned long prev_state)
 {
-	if (!__COMPAT_scx_bpf_reenqueue_local_from_anywhere())
-		return 0;
-
 	/*
 	 * If @cpu is taken by a higher priority scheduling class, it is no
 	 * longer available for executing sched_ext tasks. As we don't want the
@@ -586,13 +583,6 @@ int BPF_PROG(qmap_sched_switch, bool preempt, struct task_struct *prev,
 	return 0;
 }
 
-void BPF_STRUCT_OPS(qmap_cpu_release, s32 cpu, struct scx_cpu_release_args *args)
-{
-	/* see qmap_sched_switch() to learn how to do this on newer kernels */
-	if (!__COMPAT_scx_bpf_reenqueue_local_from_anywhere())
-		scx_bpf_reenqueue_local();
-}
-
 s32 BPF_STRUCT_OPS(qmap_init_task, struct task_struct *p,
 		   struct scx_init_task_args *args)
 {
@@ -999,7 +989,6 @@ SCX_OPS_DEFINE(qmap_ops,
 	       .dispatch		= (void *)qmap_dispatch,
 	       .tick			= (void *)qmap_tick,
 	       .core_sched_before	= (void *)qmap_core_sched_before,
-	       .cpu_release		= (void *)qmap_cpu_release,
 	       .init_task		= (void *)qmap_init_task,
 	       .dump			= (void *)qmap_dump,
 	       .dump_cpu		= (void *)qmap_dump_cpu,
tools/testing/selftests/sched_ext/maximal.bpf.c +6 -9
index 01cf4f3da4e0..5858f64313e9 100644
@@ -67,13 +67,12 @@ void BPF_STRUCT_OPS(maximal_set_cpumask, struct task_struct *p,
 void BPF_STRUCT_OPS(maximal_update_idle, s32 cpu, bool idle)
 {}
 
-void BPF_STRUCT_OPS(maximal_cpu_acquire, s32 cpu,
-		    struct scx_cpu_acquire_args *args)
-{}
-
-void BPF_STRUCT_OPS(maximal_cpu_release, s32 cpu,
-		    struct scx_cpu_release_args *args)
-{}
+SEC("tp_btf/sched_switch")
+int BPF_PROG(maximal_sched_switch, bool preempt, struct task_struct *prev,
+	     struct task_struct *next, unsigned long prev_state)
+{
+	return 0;
+}
 
 void BPF_STRUCT_OPS(maximal_cpu_online, s32 cpu)
 {}
@@ -150,8 +149,6 @@ struct sched_ext_ops maximal_ops = {
 	.set_weight		= (void *) maximal_set_weight,
 	.set_cpumask		= (void *) maximal_set_cpumask,
 	.update_idle		= (void *) maximal_update_idle,
-	.cpu_acquire		= (void *) maximal_cpu_acquire,
-	.cpu_release		= (void *) maximal_cpu_release,
 	.cpu_online		= (void *) maximal_cpu_online,
 	.cpu_offline		= (void *) maximal_cpu_offline,
 	.init_task		= (void *) maximal_init_task,
Signature · 1 line
2.48.1
reviewer
#4 lore raw

Re: [PATCH 2/2] sched_ext: Update demo schedulers and selftests to drop ops.cpu_acquire/release()

Hi Cheng-Yang,

Quoted 3 lines · Cheng-Yang Chou

ops.cpu_acquire() and ops.cpu_release() are deprecated in favor of handling CPU preemption via the sched_switch tracepoint. Update scx_qmap and the maximal selftest to use the new approach.

We could mention that commit a3f5d4822253 ("sched_ext: Allow scx_bpf_reenqueue_local() to be called from anywhere") is deprecating ops.cpu_acquire/relese().

Quoted 72 lines

In scx_qmap, remove the cpu_release fallback and the __COMPAT_scx_bpf_reenqueue_local_from_anywhere() compat guard from qmap_sched_switch(), unconditionally handling preemption via the TP.

In the maximal selftest, replace the cpu_acquire and cpu_release stubs with a minimal sched_switch TP program.

---
 tools/sched_ext/scx_qmap.bpf.c                  | 15 ++-------------
 tools/testing/selftests/sched_ext/maximal.bpf.c | 15 ++++++---------
 2 files changed, 8 insertions(+), 22 deletions(-)
tools/sched_ext/scx_qmap.bpf.c +2 -13
index a4a1b84fe359..a11e27c8de77 100644
@@ -11,8 +11,8 @@
  *
  * - BPF-side queueing using PIDs.
  * - Sleepable per-task storage allocation using ops.prep_enable().
- * - Using ops.cpu_release() to handle a higher priority scheduling class taking
- *   the CPU away.
+ * - Using the sched_switch tracepoint to handle a higher priority scheduling
+ *   class taking the CPU away.
  * - Core-sched support.
  *
  * This scheduler is primarily for demonstration and testing of sched_ext
@@ -562,9 +562,6 @@ SEC("tp_btf/sched_switch")
 int BPF_PROG(qmap_sched_switch, bool preempt, struct task_struct *prev,
 	     struct task_struct *next, unsigned long prev_state)
 {
-	if (!__COMPAT_scx_bpf_reenqueue_local_from_anywhere())
-		return 0;
-
 	/*
 	 * If @cpu is taken by a higher priority scheduling class, it is no
 	 * longer available for executing sched_ext tasks. As we don't want the
@@ -586,13 +583,6 @@ int BPF_PROG(qmap_sched_switch, bool preempt, struct task_struct *prev,
 	return 0;
 }
 
-void BPF_STRUCT_OPS(qmap_cpu_release, s32 cpu, struct scx_cpu_release_args *args)
-{
-	/* see qmap_sched_switch() to learn how to do this on newer kernels */
-	if (!__COMPAT_scx_bpf_reenqueue_local_from_anywhere())
-		scx_bpf_reenqueue_local();
-}
-
 s32 BPF_STRUCT_OPS(qmap_init_task, struct task_struct *p,
 		   struct scx_init_task_args *args)
 {
@@ -999,7 +989,6 @@ SCX_OPS_DEFINE(qmap_ops,
 	       .dispatch		= (void *)qmap_dispatch,
 	       .tick			= (void *)qmap_tick,
 	       .core_sched_before	= (void *)qmap_core_sched_before,
-	       .cpu_release		= (void *)qmap_cpu_release,
 	       .init_task		= (void *)qmap_init_task,
 	       .dump			= (void *)qmap_dump,
 	       .dump_cpu		= (void *)qmap_dump_cpu,
tools/testing/selftests/sched_ext/maximal.bpf.c +0 -3
index 01cf4f3da4e0..5858f64313e9 100644
@@ -67,13 +67,12 @@ void BPF_STRUCT_OPS(maximal_set_cpumask, struct task_struct *p,
 void BPF_STRUCT_OPS(maximal_update_idle, s32 cpu, bool idle)
 {}
 
-void BPF_STRUCT_OPS(maximal_cpu_acquire, s32 cpu,
-		    struct scx_cpu_acquire_args *args)
-{}

tools/testing/selftests/sched_ext/maximal.bpf.c void BPF_STRUCT_OPS(maximal_set_cpumask, struct task_struct *p, · line 75

Quoted 10 lines
tools/testing/selftests/sched_ext/maximal.bpf.c +6 -4
-
-void BPF_STRUCT_OPS(maximal_cpu_release, s32 cpu,
-		    struct scx_cpu_release_args *args)
-{}
+SEC("tp_btf/sched_switch")
+int BPF_PROG(maximal_sched_switch, bool preempt, struct task_struct *prev,
+	     struct task_struct *next, unsigned long prev_state)
+{
+	return 0;
+}

I think this tracepoint is never attached. You can verify it by adding a bpf_printk("hello") here and check if you see any message in /sys/kernel/tracing/trace_pipe.

To attach this TP you need to do something like this:

tools/testing/selftests/sched_ext/maximal.c +3 -0
index c6be50a9941d5..1dc3692246705 100644
@@ -19,6 +19,9 @@ static enum scx_test_status setup(void **ctx)
 	SCX_ENUM_INIT(skel);
 	SCX_FAIL_IF(maximal__load(skel), "Failed to load skel");
 
+	bpf_map__set_autoattach(skel->maps.maximal_ops, false);
+	SCX_FAIL_IF(maximal__attach(skel), "Failed to attach skel");
+
 	*ctx = skel;
 
 	return SCX_TEST_PASS;
tools/testing/selftests/sched_ext/reload_loop.c +3 -0
index 308211d804364..49297b83d748d 100644
@@ -23,6 +23,9 @@ static enum scx_test_status setup(void **ctx)
 	SCX_ENUM_INIT(skel);
 	SCX_FAIL_IF(maximal__load(skel), "Failed to load skel");
 
+	bpf_map__set_autoattach(skel->maps.maximal_ops, false);
+	SCX_FAIL_IF(maximal__attach(skel), "Failed to attach skel");
+
 	return SCX_TEST_PASS;
 }
 
Quoted 15 lines
tools/testing/selftests/sched_ext/maximal.bpf.c +0 -2
 void BPF_STRUCT_OPS(maximal_cpu_online, s32 cpu)
 {}
@@ -150,8 +149,6 @@ struct sched_ext_ops maximal_ops = {
 	.set_weight		= (void *) maximal_set_weight,
 	.set_cpumask		= (void *) maximal_set_cpumask,
 	.update_idle		= (void *) maximal_update_idle,
-	.cpu_acquire		= (void *) maximal_cpu_acquire,
-	.cpu_release		= (void *) maximal_cpu_release,
 	.cpu_online		= (void *) maximal_cpu_online,
 	.cpu_offline		= (void *) maximal_cpu_offline,
 	.init_task		= (void *) maximal_init_task,
Signature · 1 line
2.48.1

Thanks,
-Andrea