Re: [PATCH v4 2/3] sched_ext: Fix cpu_released while RT task and SCX task are scheduled concurrently
From: 'Tejun Heo'
Date: Wed Aug 20 2025 - 12:54:27 EST
Hello,
On Wed, Aug 20, 2025 at 11:18:10AM +0200, Peter Zijlstra wrote:
> > This guarantee changes if we add @rf to pick_task() and let it unlock and
> > relock. A higher priority task may get queued while the rq lock is
> > released and then the lower priority pick_task() may still return a task
> > of its own.
>
> No, this would be broken. This guarantee must not change.
>
> What you can do however is something like:
>
> again:
> p = pick_local_task();
> if (!p) {
> unlock(rq, rf);
> // get yourself a local task
> lock(rq, rf);
> if (higher-class-task-available(rq)) {
> // roll back whatever state
> return RETRY_TASK;
> }
> goto again;
> }
>
> return p;
Isn't that kinda nasty as we'd have to do that in every pick_task(). What'd
be equivalent but in a central location would be making sure that
wakeup_preempt() asserts a resched event if it hits a race window like that.
I haven't thought too much about how that should be done exactly but the
races should be pretty rare, so it'd be surprising if the behavior
difference is noticeable.
Thanks.
--
tejun