Re: [PATCH v12 23/43] sched/deadline: Hold a reference on the deadline donor of a boosted task

From: Mathieu Desnoyers

Date: Mon Nov 30 2026 - 10:27:49 EST


On 2026-11-30 09:25, Juri Lelli wrote:
>> Cc: stable@xxxxxxxxxxxxxxx # 6.16.x and older: 8671bad873eb: sched: Do not call __put_task_struct() on rt if pi_blocked_on is set
>> Cc: stable@xxxxxxxxxxxxxxx
>
> Nit: the second line looks redundant. Also, tryget_task_struct() is only
> there since v6.12, so older trees need something else on top of
> 8671bad873eb.

Right on both counts. The next version drops the second Cc line. Its
changelog also says that trees older than v6.12 need
tryget_task_struct(). Commit a8532fac7b5d ("sched_ext: TASK_DEAD tasks
must be switched into SCX on ops_enable") added it. Those trees need
only the helper it adds to include/linux/sched/task.h.

> Would it make sense to give up after a few tries, warn, and fall back to
> the top waiter itself? It is blocked, so it cannot go away, and a waiter
> with no parameters of its own is what "sched/deadline: Do not replenish
> a boost from cleared parameters" already handles. The boost is then less
> accurate in a case that should never happen, which looks better to me
> than a silent lockup. Giving up also puts a hard limit on the time spent
> here with interrupts off.

Yes. In the next version, dl_set_donor() reads the donor of the top
waiter at most 8 times. If tryget_task_struct() fails each time, it
warns. It then makes the top waiter itself the donor, with a reference
on it. Later patches move the loop to dl_top_donor() and keep the
bound.

> One more thing. Since this fixes a use after free and seems to stand on
> its own, can we move it ahead of the rest of the series?

Yes. It applies and compiles on top of the first series, without the
rest of this one. In the next version, it is patch 1. Patch 27 follows
it as patch 2, as you asked in your reply to 27.

Thanks,

Mathieu


--
Mathieu Desnoyers
EfficiOS Inc.
https://www.efficios.com