lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aVKoHUp9KblXVEo2@gpd4>
Date: Mon, 29 Dec 2025 17:11:09 +0100
From: Andrea Righi <arighi@...dia.com>
To: Emil Tsalapatis <emil@...alapatis.com>
Cc: Tejun Heo <tj@...nel.org>, David Vernet <void@...ifault.com>,
	Changwoo Min <changwoo@...lia.com>,
	Daniel Hodges <hodgesd@...a.com>, sched-ext@...ts.linux.dev,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH 2/2] selftests/sched_ext: Add test to validate
 ops.dequeue()

Hi Emil,

On Sat, Dec 27, 2025 at 10:28:11PM -0500, Emil Tsalapatis wrote:
> On Fri Dec 19, 2025 at 5:43 PM EST, Andrea Righi wrote:
> > Add a kselftest to validate ops.dequeue() semantics with direct
> > dispatch, user DSQ dispatch, affinity changes and verify that any
> > ops.enqueue() is balanced by a corresponding ops.dequeue().
> >
> > Cc: Emil Tsalapatis <emil@...alapatis.com>
> > Signed-off-by: Andrea Righi <arighi@...dia.com>
> > ---
> 
> Reviewed-by: Emil Tsalapatis <emil@...alapatis.com>
> 
> Hi Andrea,
> 
> >  tools/testing/selftests/sched_ext/Makefile    |   1 +
> >  .../testing/selftests/sched_ext/dequeue.bpf.c | 139 ++++++++++++++
> >  tools/testing/selftests/sched_ext/dequeue.c   | 172 ++++++++++++++++++
> >  3 files changed, 312 insertions(+)
> >  create mode 100644 tools/testing/selftests/sched_ext/dequeue.bpf.c
> >  create mode 100644 tools/testing/selftests/sched_ext/dequeue.c
> >
> > diff --git a/tools/testing/selftests/sched_ext/Makefile b/tools/testing/selftests/sched_ext/Makefile
> > index 5fe45f9c5f8fd..764e91edabf93 100644
> > --- a/tools/testing/selftests/sched_ext/Makefile
> > +++ b/tools/testing/selftests/sched_ext/Makefile
> > @@ -161,6 +161,7 @@ all_test_bpfprogs := $(foreach prog,$(wildcard *.bpf.c),$(INCLUDE_DIR)/$(patsubs
> >  
> >  auto-test-targets :=			\
> >  	create_dsq			\
> > +	dequeue				\
> >  	enq_last_no_enq_fails		\
> >  	ddsp_bogus_dsq_fail		\
> >  	ddsp_vtimelocal_fail		\
> > diff --git a/tools/testing/selftests/sched_ext/dequeue.bpf.c b/tools/testing/selftests/sched_ext/dequeue.bpf.c
> > new file mode 100644
> > index 0000000000000..aae19bfd42f04
> > --- /dev/null
> > +++ b/tools/testing/selftests/sched_ext/dequeue.bpf.c
> > @@ -0,0 +1,139 @@
> > +// SPDX-License-Identifier: GPL-2.0
> > +/*
> > + * A scheduler that validates ops.dequeue() is called correctly:
> > + * - For tasks on BPF data structures (not yet dispatched)
> > + * - For tasks already on DSQs (local or shared)
> > + * - That every ops.enqueue() is followed by ops.dequeue()
> > + *
> > + * Copyright (c) 2025 NVIDIA Corporation.
> > + */
> > +
> > +#include <scx/common.bpf.h>
> > +
> > +#define SHARED_DSQ	0
> > +
> > +char _license[] SEC("license") = "GPL";
> > +
> > +UEI_DEFINE(uei);
> > +
> > +/*
> > + * Counters to track the lifecycle of tasks:
> > + * - enqueue_cnt: Number of times ops.enqueue() was called
> > + * - dequeue_cnt: Number of times ops.dequeue() was called
> > + */
> > +u64 enqueue_cnt, dequeue_cnt;
> > +
> > +/*
> > + * Test scenarios:
> > + * - 0: Dispatch to local DSQ
> > + * - 1: Dispatch to shared DSQ
> > + */
> > +u32 test_scenario;
> > +
> > +/* Per-task state */
> > +struct task_ctx {
> > +	u64 enqueued;	/* was this task enqueued? */
> 
> Do we use this for anything? If not, can we remove it?
> We can also just do an extra sanity check with it during
> enqueues/dequeues to ensure we have no double operations.

Oh yes, the intention was to use this to detect duplicate ops.enqueue()
calls, but I forgot to add the actual check in ops.enqueue(). I'll add that
in the next version.

Thanks!
-Andrea

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ