Re: [PATCH 2/2] selftests/sched_ext: Add lazy preemption tests
From: Andrea Righi
Date: Tue Sep 15 2026 - 11:02:09 EST
On Mon, Sep 14, 2026 at 10:55:56PM +0800, Cheng-Yang Chou wrote:
> Hi Andrea,
>
> On Mon, Sep 14, 2026 at 10:47:46AM +0200, Andrea Righi wrote:
> > Add trace-based coverage for immediate and lazy preemption. An fexit
> > probe on __resched_curr() records the requested TIF and the current task
> > slice, while the stopping callback verifies that the task reaches a
> > scheduling boundary.
> >
> > Exercise kick requests individually, in both orders and combined in one
> > call. Verify that immediate preemption and WAIT take precedence over
> > lazy preemption, and that combining immediate and lazy enqueue
> > preemption follows the same rule. Also test overriding the expiry
> > default in both directions through scx_bpf_task_set_slice_expiry().
> >
> > Extend the NO_HZ_FULL test with infinite-slice victims. Verify that lazy
> > enqueue and kick requests restart a stopped tick and make forward
> > progress. Keep invalid kick flag coverage and skip modes not exposed by
> > the running kernel.
> >
> > Signed-off-by: Andrea Righi <arighi@xxxxxxxxxx>
>
> [...]
>
> Didn't have time to go through the whole series, but I applied it on
> for-next and built with PREEMPT_LAZY=y and PREEMPT_DYNAMIC=n:
>
> INFO: preemption mode unavailable; lazy TIF was 5, immediate TIF was 4
> ok 2 kick_lazy #
> INFO: preemption mode unavailable; lazy TIF was 5, immediate TIF was 4
> ok 4 kick_tick #
> PASSED: 6
>
> > +static int active_lazy_mode(void)
> > +{
> > + char buf[128];
> > + FILE *file;
> > +
> > + file = fopen("/sys/kernel/debug/sched/preempt", "r");
> > + if (!file)
> > + return -1;
>
> sched_init_debug() only creates that file under CONFIG_PREEMPT_DYNAMIC,
> and PREEMPT_LAZY can be built without it ("select PREEMPT_BUILD if
> !PREEMPT_DYNAMIC"), so the two tests pass without comparing the TIFs.
>
> Would something like this work?
>
> if (!file) {
> #if defined(CONFIG_PREEMPT_LAZY) && !defined(CONFIG_PREEMPT_DYNAMIC)
> return 1;
> #else
> return -1;
> #endif
Ah yes, makes sense, we can include autoconf.h and check that.
I'll include this fix in the next version.
Thanks,
-Andrea
> }
>
> Thanks.
>
> > + if (!fgets(buf, sizeof(buf), file)) {
> > + fclose(file);
> > + return -1;
> > + }
> > + fclose(file);
> > +
> > + if (strstr(buf, "(lazy)"))
> > + return 1;
> > + if (strstr(buf, "(full)"))
> > + return 0;
> > + return -1;
> > +}
> > +
>
> --
> Cheers,
> Cheng-Yang