From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=158.69.130.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796309950; b=JczRNPIzfH3FG19TSJoHWSzPdZZ7nhp0jprAb5KO1SWR0RCqughz2DqA1p8U3fXpSQBj FHQmVHO5+veuGfclzNs1jkT+d8khZPvsS1vmjXn9BDamzuzX5yWkQMoEGsCSjMnyegbLS uCWzshcVf3XCxemUkfYM6o70qYdaJ26TpXcerWJynTLY8vxVFsfI8m1IlLPAwNR05PJIl VHb/dKe4SgR8R9iVyfYHFzVAn60KG2mz5VNCH59RYMgFBqpqzUb9ke6g6joxToV9j/XnB HNIfwpwFfbe3H7iw0ipVVw4ytSKf9HD7d1a1WfU2jaiwiBXEin3dEAFWZPr08FHSvFg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796309950; h=DMARC-Filter:DKIM-Signature:Received:From:To:Cc:Subject:Date: Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; bh=BlItISFMpM6oCLe/GgDd1su9442V6QpJvPEzZQnTX9o=; b=vCBrjQYo3zGi1CrOsVrEHsQ1Rg3PpGDO+IDGslz+fzWU5zhP9L3l4UrqoYWt5Zhrw7m5 NCnU0IukFMNT8la0X6sK4B3aMOyLdq9aYHvGJJZ/tOFTMGWFDAm6J9/Vwteirea+j2Ko+ ffrCYCeTdQ7A38OyPcqL6JYGOJ0FazU8jathzzh3W2q8YLlSIul8nw3xR9RwvJxp7blJX 8eYt1mWqanBgqp+p1j10oMXpqjpUx8bJAtlxUWI9nTZpjDqRb4pIAPDm+SUnW7S6ve59w IqGX3IWiQ4Txk0u6qVlzfVEUr7EBECWEE8hOGNXvgtgRvPfl4Eh5iEig0TECG0NA4Hw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=efficios.com; spf=pass smtp.mailfrom=efficios.com; dkim=pass header.d=efficios.com header.i=@efficios.com header.a=rsa-sha256 header.s=smtpout1 header.b=FREszs4e; arc=none smtp.remote-ip=158.69.130.18 Received: from smtpout.efficios.com (smtpout.efficios.com [158.69.130.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B89BF606A689; Thu, 3 Dec 2026 14:59:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org B89BF606A689 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=efficios.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=efficios.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=efficios.com header.i=@efficios.com header.a=rsa-sha256 header.s=smtpout1 header.b=FREszs4e DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficios.com; s=smtpout1; t=1796309943; bh=BlItISFMpM6oCLe/GgDd1su9442V6QpJvPEzZQnTX9o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FREszs4e596yQssDHFh945ienTr4hBTCOuo5ix0geyk4+JpBkvpgcp3Qlb7ryWjNC /ZGbY0878GBvP/wdjkOxcU38GA2er6SNSYEW3f1/l7CY7BYeKs4Z9UgfO+B1LfVvgX 9JzzmCuYm4vLSEah3EKb8+UoZ2/QkiPL8rZlZFopgPDSYSbPZxuEkrrBCBDiDI5UG3 mvb7rJ/ivjlR1S/7oTZVMAhPGQZClWPR0Ce8mrIUKrozUP37KkjCayCkdEicC8lQVH xYFuXClMkYKLZnVKq53w5cL6TQszLhsKyUnY+9x9BfDKQ3Ci0ZU7YTvW+UPP+iRLfQ a8Xd0E6bHROcQ== Received: from thinkos.internal.efficios.com (unknown [IPv6:2605:8d80:7180:6739:ac39:5d4:4093:61c6]) by smtpout.efficios.com (Postfix) with ESMTPSA id 4jgHnx4lmHzZhT; Thu, 03 Dec 2026 09:59:01 -0500 (EST) From: Mathieu Desnoyers To: juri.lelli@redhat.com, peterz@infradead.org, mingo@redhat.com, vincent.guittot@linaro.org Cc: Mathieu Desnoyers , tglx@kernel.org, anna-maria@linutronix.de, frederic@kernel.org, will@kernel.org, boqun@kernel.org, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, vschneid@redhat.com, kprateek.nayak@amd.com, luca.abeni@santannapisa.it, tommaso.cucinotta@gmail.com, mathieu.poirier@linaro.org, longman@redhat.com, ridong.chen@linux.dev, tj@kernel.org, hannes@cmpxchg.org, mkoutny@suse.com, shuah@kernel.org, bigeasy@linutronix.de, clrkwllms@kernel.org, parri.andrea@gmail.com, m.szyprowski@samsung.com, kayracizmeci@gmail.com, weihengqiuu@gmail.com, linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-rt-devel@lists.linux.dev, oleg@redhat.com, brauner@kernel.org, stable@vger.kernel.org Subject: [PATCH v14 02/39] sched/deadline: Replenish a throttled task boosted while asleep Date: Thu, 3 Dec 2026 09:58:16 -0500 Message-ID: <820b6a522c53eef14d41b0893f72e090ad8da92e.1796296313.git.mathieu.desnoyers@efficios.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: References: X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit A deadline task can be throttled as it blocks, with an rt_mutex held. Its replenishment timer is then armed. A deadline waiter can boost the task while it sleeps. Commit feff2e65efd8 ("sched/deadline: Unthrottle PI boosted threads while enqueuing") lets a boost override the throttle. enqueue_task_dl() lifts the throttle of a boosted task, and dl_task_timer() ignores a boosted task. This covers a task that is enqueued while boosted. But a boost of a sleeping task does not enqueue it. T is a SCHED_DEADLINE task that holds the rt_mutex L. W is a SCHED_DEADLINE task with an earlier deadline: T W T's timer uses up its runtime, sleeps dl_throttled = 1 start_dl_timer() pthread_mutex_timedlock(L) rt_mutex_setprio(T, W) T sleeps: no enqueue dl_task_timer() T is boosted: returns times out rt_mutex_setprio(T, NULL) wakes up enqueue_dl_entity() dl_throttled: waits for the timer The timer has already fired. T would never run again, not even to die of SIGKILL. Every later waiter on L would hang too. This was found by reading. Fix this by returning early in dl_task_timer() only for a boosted task that is queued. A boosted task that sleeps then takes the existing path for a throttled task that is not queued: it is replenished. The timer refills the task from the parameters of its donor. After the deboost, the task keeps the runtime and the deadline of that refill. Its wakeup then checks them against its own parameters, as any wakeup does. On v7.4-rc2, a queued boosted task also keeps the values of its donor after the deboost. The priority inheritance series gives the task its own values back. The refill relies on two earlier patches: - "sched/deadline: Hold a reference on the deadline donor of a boosted task" is earlier in this series. It keeps the donor from being freed while the task points to it. A chain walk that has not reached the task yet leaves it on an old donor. The refill then uses the parameters of that old donor, as for a queued boosted task. - "sched/deadline: Do not replenish a boost from cleared parameters" is in the first series. It keeps the refill from looping on the parameters of a donor that left the class. The Sashiko AI review of this series found this. Fixes: feff2e65efd8 ("sched/deadline: Unthrottle PI boosted threads while enqueuing") Signed-off-by: Mathieu Desnoyers Reviewed-by: Juri Lelli Cc: stable@vger.kernel.org --- kernel/sched/deadline.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c index ac96885796bd..e137eb7efa1f 100644 --- a/kernel/sched/deadline.c +++ b/kernel/sched/deadline.c @@ -1364,10 +1364,13 @@ static enum hrtimer_restart dl_task_timer(struct hrtimer *timer) } /* - * The task might have been boosted by someone else and might be in the - * boosting/deboosting path, its not throttled. + * A boost overrides the throttle. enqueue_task_dl() lifts it when the + * boost enqueues the task, or when the task wakes up boosted. So a + * queued task needs nothing here. A boost of a sleeping task does not + * enqueue it, and it can end before the wakeup. Nothing would lift the + * throttle then. So let a sleeping task reach the !queued case below. */ - if (is_dl_boosted(dl_se)) + if (is_dl_boosted(dl_se) && task_on_rq_queued(p)) goto unlock; /* -- 2.47.3