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=1796147082; b=lW0mNiMsJFsTzqDTUxHi4nPCQmiCaJY+Pa30dG56XTZQaAL0lLiqiWqu2Piae2QYdV3K D89n11Z8hziBSaZYWm/jol//n4q3Uc2SGoG7OsUEOwXE6koEZL0UVdJk9ksXHHdRxapl/ 3nULRJFhShg1QpQKBhUb1wlWpEKnWBvUXR9LqiQjL3rqNrFQCywfhADMpGv2cvuEYnRmd B8AaWJ82cKCmQEA+mZJGFaqEKvzJRtHam/h+BM6ltrdVykwpANFe8au6V0Q+nm8fEelRb 8ktDO+m2hO6Sp1QZuGxbJbHsFBp91+E67ZvefiFVj3EOdQTk3M/3T7GX3wbAd5jHGJA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796147082; 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=hMk94wml3BoCapNPm1UGhA3o/Qo+qRZNPZ3hzuD6MgQ=; b=oqQy3MxbT2sHjX9yWXBpLz9i5LEMXpWlOusM6A5a5b2hAwp/uEf4Fq++w7qQNGqSZ2dz L5ULXzcA6A5Q7Gz9dYvyux9+rY/vF483BvWBiDIneeDs5z2mAtZfpWJdZtiY6pUDYy6mk PbpH2rFOKRbYlE3rr11HMXw1DuzDc0SS4n7MIgAkfCalfWxh0OCC61Gch7Ypac3SZrjc0 7ah7RA0xyj81qyougkkNtDLcYXvsn5sVnObdPHD8r+8YfaGOMuXw8q3/Tbo+szGqlaB0w llOCYxu/zgs757eCuqw40fFmyNYlO5ede4oqR4cLf2jXHoiq88e1pV8n+sAHy/7dtjg== 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=gwW9J0i6; 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 6096D606A6B9; Tue, 1 Dec 2026 17:44:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 6096D606A6B9 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=gwW9J0i6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficios.com; s=smtpout1; t=1796147078; bh=hMk94wml3BoCapNPm1UGhA3o/Qo+qRZNPZ3hzuD6MgQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gwW9J0i6AUABxYs9m88DwzHEXyffFw0cGRXcVyP/aV5QvGwoIn7fAoEWggI6NDceA uBVVus6LXfugfgizr3DBqOPnCRirqEP/PbrpgKCj+8/euFYBkWxN7S2ROJ7RTNdEhg ifrOgrsSijELKQjhTNGx4JpeIIUR3j7pKNSFtfmVc1sBXX7kHqhvE9zbuaFOIrorfD Q28MqMJ+PBxyYUgS8Xiy7jN7xLSKEwhk0JgHfbVWcEZGFZ/PPu2zEXeJc6i5Aei3LN pwOUbwB/xGbVuO0KzU8lXL9HzFzOEUcfFN6hRkohwUo3b+0+QB/XflmhIdNj0C3/6a 5yA2DSzD/ZyQw== Received: from thinkos.internal.efficios.com (mtl.efficios.com [216.120.195.104]) by smtpout.efficios.com (Postfix) with ESMTPSA id 4jf7Yx6txdzYwB; Tue, 01 Dec 2026 12:44:37 -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, 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 v13 26/36] sched/deadline: Cap the runtime left of a constrained task at dl_runtime Date: Tue, 1 Dec 2026 12:44:20 -0500 Message-ID: <1a7a6efdcf1abbf31ed7f8a3fed2072a4a42719b.1796146461.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 After sched_setattr() shortens the dl_deadline of a constrained SCHED_DEADLINE task, its next wakeup can leave it more runtime than its new dl_runtime. sched_setattr() keeps the runtime and the absolute deadline of the task: the new parameters take effect at the next period. At the next wakeup, update_dl_entity() checks the runtime left against the new parameters. For a constrained task, that check uses the density, dl_runtime / dl_deadline: - Commit 2317d5f1c349 ("sched/deadline: Use deadline instead of period when calculating overflow") made dl_entity_overflow() compare with it: "We care about if the runtime can make its deadline, not its period." - Commit 3effcb4247e7 ("sched/deadline: Use the revised wakeup rule for suspending constrained dl tasks") cut the runtime of a constrained task that overflows to density * laxity. Both bound the runtime by dl_runtime only while the deadline is at most dl_deadline ahead. After a change to a shorter dl_deadline, the old deadline can be farther ahead. The check then keeps more runtime than the new dl_runtime, or computes more. For example, take a task of 50ms every 100ms, with 49ms left and its deadline 99ms ahead. Changed to 8ms in 20ms every 100ms, it would wake with 0.4 * 99ms = 39.6ms. Admission control already counts the new, smaller bandwidth. So other deadline tasks could miss their deadlines. An implicit task is not affected. Its check compares with its bandwidth, which bounds the runtime for any deadline. Fix this by keeping no more than dl_runtime before the check, for a constrained task. A boosted task runs on the parameters of its donor, and is left alone. The runtime is signed and can be negative there, so compare it as signed. The cases change_constrained_new_params and wake_constrained_new_params, added to deadline_bw_test later in this series, test this. The first changes a running task, the second a sleeping one. wake_constrained_new_params fails without this patch, and passes with it. change_constrained_new_params also needs "sched/deadline: Keep the debt of a task across a change of parameters". The Sashiko AI review of this series found this. Fixes: 2317d5f1c349 ("sched/deadline: Use deadline instead of period when calculating overflow") Fixes: 3effcb4247e7 ("sched/deadline: Use the revised wakeup rule for suspending constrained dl tasks") Signed-off-by: Mathieu Desnoyers Cc: stable@vger.kernel.org --- kernel/sched/deadline.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c index 2a2e6e321fec..b65e5bfec2f4 100644 --- a/kernel/sched/deadline.c +++ b/kernel/sched/deadline.c @@ -1488,6 +1488,19 @@ static void update_dl_entity(struct sched_dl_entity *dl_se) { struct rq *rq = rq_of_dl_se(dl_se); + /* + * The checks below let a constrained task keep up to its density + * times the time left to its deadline. After a change to a shorter + * dl_deadline, the deadline can be more than dl_deadline ahead, and + * that allows more than dl_runtime. So cap the runtime at dl_runtime + * first. An implicit task is checked against its bandwidth, which + * keeps it within its reservation for any deadline. A boosted task + * runs on the parameters of its donor. + */ + if (!dl_is_implicit(dl_se) && !is_dl_boosted(dl_se) && + dl_se->runtime > (s64)dl_se->dl_runtime) + dl_se->runtime = dl_se->dl_runtime; + if (dl_time_before(dl_se->deadline, rq_clock(rq)) || dl_entity_overflow(dl_se, rq_clock(rq))) { -- 2.47.3