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=1796309953; b=JYRkeJ5QdhISQlwWwFmCS9wOhxBKpKiwsbDpL+jYbqQIoi9mFrF9YbtmDO8UCe6AGTFt ZOQmHZX9TEUlcYybyfFeVi18nWIu81FMQhQRcE3rtWya8v0bkZX9V69cj26cTL6FCJpKD i4kA09FPWPt9lemQP4ksJnPNOcX5SLH9FCDaae6up5FOueGZF+dxlR8IsPmsRezqpuX6V MFf/OOof2E5irFLHc3p9EYpsQgq8MWv5BLeq2QlUppTiYE0y9iRzM005xNqb2MxYB9kp5 Fny8xNEHYGvGtChUyhUjDWc9gPEauGXEh21yGJQqcaAuNXmHlk2jnuCSknPMvZ/pj9g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796309953; 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=h9nmKUNf26OTsKBhfo2N+k4k44f8u1GdvL/XQO5B1uo=; b=0s9/R2p6CnFKkwR/4FgZA8t38Or3yxEoy/WEcKwXN6tNWbMOEfhZMvSzUBugZgaQWDey h/Gf2ptvw98lzGDIC2opSGAf4a0ruOeIg0HYg+oZmKoH0ZoPX93hER2LzXS586dvFC60y msFWP1SgbzuUvULweyU4noK8EmQ9d7tzMZZVBTq36RuAD8jFWq/B/GqnL29WNqc/pVx76 icfrAwCLhDEA1ueLfC2BiMbd+QcHlhKkiaKjKOsnjimG6eBYCye2oTTCkp+4PAg8thw6S bhDanE58ZfhaW6TSp18RCQNds9PA+W0AoUhWHZyk6Y9D5VUB80vQ+R/pCysObz/A28Q== 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=HapiJgGH; 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 82AEA60A2605; Thu, 3 Dec 2026 14:59:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 82AEA60A2605 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=HapiJgGH DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficios.com; s=smtpout1; t=1796309951; bh=h9nmKUNf26OTsKBhfo2N+k4k44f8u1GdvL/XQO5B1uo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HapiJgGHlZtD58R3R259eUFxugValieOmZFy/kx5ghDlSaUmqIqsSOpZc+eVnl665 nKAoxf/EBaLz1tDbqFkYsq139oVdaxmi1gqlD27YaYQuCpyVMtTTShsYFetaoceWzZ bXfq/N1gqTSzr70RBuk1PB0wvuBm4A6011MChz5+9dgKmUvUvPhsM+z2FeozI8Gr4l hX9qYwC1bCPa8tMP1a5+SkmqnppfQsE5oi43PFw8da371W8AvSsEp/PHWxoD2VclSO Dr7teVJApYdQMa4U6JxLb6q4XPlgo1wjSwEmGIkH7bW17qaYMQXx+a5KgINRusUA6V OYT2A1kCc6Cug== Received: from thinkos.internal.efficios.com (unknown [IPv6:2605:8d80:7180:6739:ac39:5d4:4093:61c6]) by smtpout.efficios.com (Postfix) with ESMTPSA id 4jgHp55mbgzZBQ; Thu, 03 Dec 2026 09:59:09 -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 06/39] sched/deadline: Admit a returning task without the bandwidth it holds Date: Thu, 3 Dec 2026 09:58:20 -0500 Message-ID: <16136cf033633c7051410b4eb683afe857d32b15.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 task that leaves SCHED_DEADLINE keeps its bandwidth in total_bw until its 0-lag time. If it comes back before then, sched_dl_overflow() removes that old bandwidth and adds the new one. But its admission check passes 0 as the old bandwidth: if (dl_policy(policy) && !task_has_dl_policy(p) && !__dl_overflow(dl_b, cap, 0, new_bw)) { So the new bandwidth must fit on top of the old one. The check for a task that stays in the class does leave the old bandwidth out. When the root domain has no room for both, sched_setattr() returns EBUSY to a task that leaves and comes back with the same parameters. Fix this by passing the old bandwidth to __dl_overflow() when the inactive timer is active. This is the same condition as the one for removing it. The params_return_full case, which "selftests/sched: Test parameter changes in deadline_bw_test" adds later in this series, tests this. Fixes: 387e31300b57 ("sched/deadline: Fix the update of the total -deadline utilization") Reported-by: Juri Lelli Closes: https://lore.kernel.org/all/axAxdNEE1Q2OuxNQ@jlelli-thinkpadt14gen4.remote.csb/ Signed-off-by: Mathieu Desnoyers Cc: stable@vger.kernel.org --- kernel/sched/deadline.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c index 0afcb7b53bc4..26b02ae8683a 100644 --- a/kernel/sched/deadline.c +++ b/kernel/sched/deadline.c @@ -3959,6 +3959,7 @@ int sched_dl_overflow(struct task_struct *p, int policy, u64 period = attr->sched_period ?: attr->sched_deadline; u64 runtime = attr->sched_runtime; u64 new_bw = dl_policy(policy) ? to_ratio(period, runtime) : 0; + u64 old_bw; int cpus, err = -1, cpu = task_cpu(p); struct dl_bw *dl_b = dl_bw_of(cpu); unsigned long cap; @@ -3979,10 +3980,18 @@ int sched_dl_overflow(struct task_struct *p, int policy, cpus = dl_bw_cpus(cpu); cap = dl_bw_capacity(cpu); + /* + * A task that comes back before its 0-lag time still holds the + * bandwidth it left with. The new bandwidth replaces it, so leave + * the old one out of the check, as for a task that stays in the + * class. + */ + old_bw = hrtimer_active(&p->dl.inactive_timer) ? p->dl.dl_bw : 0; + if (dl_policy(policy) && !task_has_dl_policy(p) && - !__dl_overflow(dl_b, cap, 0, new_bw)) { - if (hrtimer_active(&p->dl.inactive_timer)) - __dl_sub(dl_b, p->dl.dl_bw, cpus); + !__dl_overflow(dl_b, cap, old_bw, new_bw)) { + if (old_bw) + __dl_sub(dl_b, old_bw, cpus); __dl_add(dl_b, new_bw, cpus); err = 0; } else if (dl_policy(policy) && task_has_dl_policy(p) && -- 2.47.3