Re: [PATCH 2/2] selftests/sched_ext: Add test to validate ops.dequeue() semantics

From: Andrea Righi

Date: Thu Feb 12 2026 - 13:25:50 EST


On Thu, Feb 12, 2026 at 05:15:28PM +0000, Christian Loehle wrote:
> On 2/10/26 21:26, Andrea Righi wrote:
...
> > +void BPF_STRUCT_OPS(dequeue_enqueue, struct task_struct *p, u64 enq_flags)
> > +{
> > + struct task_ctx *tctx;
> > + s32 pid = p->pid;
>
> unused

This one is used, but the one in dequeue_select_cpu() is not. I'll remove
that. :)

> > +static enum scx_test_status run_scenario(struct dequeue *skel, u32 scenario,
> > + const char *scenario_name)
> > +{
> > + struct bpf_link *link;
> > + pid_t pids[NUM_WORKERS];
> > + pthread_t hammer;
> > +
> > + int i, status;
> > + u64 enq_start, deq_start,
> > + dispatch_deq_start, change_deq_start, bpf_queue_full_start;
> > + u64 enq_delta, deq_delta,
> > + dispatch_deq_delta, change_deq_delta, bpf_queue_full_delta;
> > +
> > + /* Set the test scenario */
> > + skel->bss->test_scenario = scenario;
> > +
> > + /* Record starting counts */
> > + enq_start = skel->bss->enqueue_cnt;
> > + deq_start = skel->bss->dequeue_cnt;
> > + dispatch_deq_start = skel->bss->dispatch_dequeue_cnt;
> > + change_deq_start = skel->bss->change_dequeue_cnt;
> > + bpf_queue_full_start = skel->bss->bpf_queue_full;
> > +
> > + link = bpf_map__attach_struct_ops(skel->maps.dequeue_ops);
> > + SCX_FAIL_IF(!link, "Failed to attach struct_ops for scenario %s", scenario_name);
> > +
> > + /* Fork worker processes to generate enqueue/dequeue events */
> > + for (i = 0; i < NUM_WORKERS; i++) {
> > + pids[i] = fork();
> > + SCX_FAIL_IF(pids[i] < 0, "Failed to fork worker %d", i);
> > +
> > + if (pids[i] == 0) {
> > + worker_fn(i);
> > + /* Should not reach here */
> > + exit(1);
> > + }
> > + }
> > +
> > + /*
> > + * Run an "affinity hammer" so that some property changes hit tasks
> > + * while they are still in BPF custody (e.g. in user DSQ or BPF queue),
> > + * triggering SCX_DEQ_SCHED_CHANGE dequeues in scenarios 2, 3, 6 and 7.
>
> Not true for 3, right?

Oh yes, this selftest has been changed so many times that I was sure I
forgot to update some comments (also, scenario 7 doesn't exist anymore).

Thanks!
-Andrea