Re: [PATCH v14 01/39] sched/deadline: Hold a reference on the deadline donor of a boosted task
From: Mathieu Desnoyers
Date: Fri Dec 04 2026 - 13:06:20 EST
On Fri, Dec 04, 2026 at 06:26:48PM +0100, Peter Zijlstra wrote:
> On Thu, Dec 03, 2026 at 09:58:15AM -0500, Mathieu Desnoyers wrote:
>
>> + for (tries = 0; tries < DL_DONOR_TRIES; tries++) {
>> + pi_se = READ_ONCE(pi_task->dl.pi_se);
>> + if (pi_se == dl_se->pi_se)
>> + return;
>> + if (pi_se == dl_se ||
>> + tryget_task_struct(container_of(pi_se, struct task_struct, dl)))
>> + goto set;
>> + /* Pairs with the ordering of refcount_dec_and_test(). */
>> + smp_rmb();
>> + }
>> + WARN_ON_ONCE(1);
>
> *groan*, so it feels like this WARN is something that could be
> constructed to trigger, which would be bad.
>
> All this takes is for a high frequency pthread_cancel() or somesuch, no?
> Create a ton of high prio tasks, get them involved in a boost chain and
> cancel them.
>
> Or am I missing soemthing?
No, you are right. Correct writers can trigger it. Each failed
tryget_task_struct() is a donor that a writer replaced, and that then
exited. If enough donors join the chain and exit quickly, 8 reads in a
row can fail. A slow reader makes it easier, for example a preempted
vCPU.
The fallback itself is safe. The top waiter is blocked, so it cannot
exit. The boosted task then runs on the parameters of the top waiter.
They are not those of the head of the chain, but they come from a live
task.
The planned next version will drop the WARN_ON_ONCE() and keep the
bound of 8 reads. The comment and the changelog will describe the
fallback as a rare but normal path.
Thanks,
Mathieu
--
Mathieu Desnoyers
EfficiOS Inc.
https://www.efficios.com