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=1795182969; b=orbmhGqk16HCesA7XIp4ReW2HGYdlLq6QXRE6K9fyd81kZEhK6LbEh1+HSt4xNRT853o U1bR3wjlWvUo5VYU3lATUvEKsGfYGjRMdXI/9k5aueFvfVRES2WROycvOFQBz2cpJKGTc Kt3NQOSBJsBsLa6fQdSdsQuxG2GhIE62r72fzwj+/xm0EEuNyUQ9XDTZboea4GNHNM7+6 7PlJxvXKNYdCfTHpMmPCGHVTnl70gVxGqcEQxsBITgpexSlkVk0nHRVAWk+SxEB7aampG MWrOsEqd7832/DF+Vs6TSOSFuExD1gdrmQcvNx4n0M8+rJaXJvx+kunnm4WXse/IPsw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795182969; 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=iACgllQ3ZkGMlQeEJCWHiJ//rfYUUp/tCqGtBbCFmJk=; b=GU37SbHlY2FxsfsSmyt3r6Uy9/DPYpijGoDiVa9t6mV+XItNxbfF+uRTcLZhHKJBxEJ9 Zb6Qxz9GHd9d/gIr1YNRtu8RX7vdC9dSrqdpZORNDjlraM2rSL3v8zhPzik4oZilpBvNy 3UNjGZAUkjl7BKK8hqn8R6Jy6v2PvS2mV5DdVKfVk8igl/rcoF6azHhWqnqoCHxo+W1cJ hZFdMd8hwKWudG9FymO+p4SlW6SzC230UzbmESiYBPD8E0AMovRcm2EtJ/zVOwE6iNJ8i rqvpA5ZXKxSm83mlg6N++etb08I/1XjyyGuoBlecMS9/kfHn5/15hm9S4We8i46TnxQ== 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=cl8Y8PvD; 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 C4A36606DF64; Fri, 20 Nov 2026 13:56:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org C4A36606DF64 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=cl8Y8PvD DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficios.com; s=smtpout1; t=1795182964; bh=iACgllQ3ZkGMlQeEJCWHiJ//rfYUUp/tCqGtBbCFmJk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cl8Y8PvDfmUgqu0peENk7J/8dhBWTen8ddqkElS087m49HvcgQPiYjwBmrkGaZZVk 222s8gVvoVyfUUBIjCbx0wxlkv5FCDkiQfqho48ZnbnCww++Ou26Rh59hXnnM+L3Cy oTdoRiwgQcN2vCsKfWmj2EMOZl+F8uRDbBKbA4kDlg2v+Gf2UrWXVHM8nGy//tQDFm 0Cj2DRvyR03vEkRE7yHIM3YC504leRUkMmtsUMyE7rFK0XH7YrS+d+wKzrijsuLFtr o7qEKfnaptRHox3bun5RUmN4iE3oc8QvSwYCZT0KqzAfBJZ8CCS7ftHjPGrzbSTFRT mGdFO4+4a7yDw== Received: from thinkos.internal.efficios.com (mtl.efficios.com [216.120.195.104]) by smtpout.efficios.com (Postfix) with ESMTPSA id 4jWH1J49zzzV4V; Fri, 20 Nov 2026 08:56:04 -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, 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, stable@vger.kernel.org Subject: [PATCH v9 30/33] sched/deadline: Cap the runtime left of a constrained task at dl_runtime Date: Fri, 20 Nov 2026 08:55:53 -0500 Message-Id: <6ef835b086e49e8413748569fb183d8ffbc04e7b.1795181240.git.mathieu.desnoyers@efficios.com> X-Mailer: git-send-email 2.39.5 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 sched_setattr() can change the parameters of a SCHED_DEADLINE task. The task keeps its runtime and its absolute deadline: 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") then 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. A change to a shorter dl_deadline breaks that. 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. Changed to 8ms in 20ms every 100ms, it would wake with 39.6ms. It would then run far more than its new runtime in this period. 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. Both fail without this patch. 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 | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c index a76982c59bae..27a746c2f81a 100644 --- a/kernel/sched/deadline.c +++ b/kernel/sched/deadline.c @@ -1516,6 +1516,25 @@ static void update_dl_entity(struct sched_dl_entity *dl_se) { struct rq *rq = rq_of_dl_se(dl_se); + /* + * The checks below compare the runtime left with the density, + * dl_runtime / dl_deadline. That bounds the runtime by dl_runtime + * only while the deadline is at most dl_deadline ahead. After a + * change to a shorter dl_deadline, the deadline can be farther + * ahead, and the runtime left larger than dl_runtime. A constrained + * task would then run more than dl_runtime in a period. Keep no + * more than dl_runtime. + * + * An implicit task is checked against its bandwidth, which holds + * for any deadline. A boosted task runs on the parameters of its + * donor. Leave both alone. + * + * The runtime is signed, and can be negative here. + */ + 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