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=1796147075; b=rtcuNB98FpiWUCTW+NP6GiYb6uxiQDSeJxOl6GgW3AZcDqOvgom9HdlaJ4oUoEvzh5Ih x5uzFqOf/Z8EcdjXjLqrDSNgC37P71Na9hGHU53YXeukg0Gk9w9COLdmP8oTYwMn36gW2 qA3wMLPIaAoTczU+pLaMh6QkF2QbuW5IrJ8pm9YbUvvzEZFiARnKaf18mGHJwvcL0s9Z2 BayzQ71FT7NUJU2M0f5I13AUOO8Ces5vq1zikfZomx5lHpPmuxrwQV6vKXSHDoQqPGzKY 3A8pvy8mvlRN0UeFTvmG9itNrzZtl05lg95SyA1+c/2oJmY3BMp0aecAT4vo76vo/SA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796147075; 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=u65wGEkq5173aBCkoBIwIbnE/mdUiY3hd9M8h69N2Jk=; b=Gsid4qJ8k3TbB9KWGUUR89tRhDiYBbNcfzGr/86wuhoNYo+xOkF5mjXTG05okxb6Wgm4 YWa3RXplthg3U9gQNh+jwpSz/SBAhqkUAw3p//0zSZdwxdGRGsQkSrQc4RBpGa8nrme6Y hqzVwCOP0ZK/JjM55L/a/ZeKS67LFAicmt0Q7F/WY3GSC1OHvDjhUqZA51w0yG8JYTQbh sFqsm+pNI7teo1qH+eT4QMI/Xy7t3WYxgidhT3Ui7Nj7hMC19ndftMWeSKp7lphaRs724 azKUqFSvK/PUQMSIfXBj8BkRqCknTpQEt38kfAF1Udeu5rOYwvzmx4coKb/6DOn9blA== 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=DmzioGGq; 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 99378606A32D; Tue, 1 Dec 2026 17:44:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 99378606A32D 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=DmzioGGq DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficios.com; s=smtpout1; t=1796147073; bh=u65wGEkq5173aBCkoBIwIbnE/mdUiY3hd9M8h69N2Jk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DmzioGGqkpSJTw0ahMCVOVk8wxcRiW3nBk9i2sKNCPNUxMyuUKCwvgQNoxNAs5Chn 7kwoWvG+m88zSyro32t9fCWyAr1aQRcHN3NBmZ/qV95A9VX89Wc8jsmZrURLG5zuYw hOgvvt2gwtW6+1+Uy5hiGtfp06vyKhiuA2DL6ij2tW9AwDaZbAfgvf0t1IJKNwZVmL XL9Syl/Qm5o9V0Z2kn1RTOuy9OEnWv0+0WVfth5ns36Tya53T6gEiwogEgn7gtox7W BhRuz45bK8DYY5BqllebWaABpTN1Q1LZCv9xxhhSkXdgx73KWA780iGA6I13+dwdrG VM0hSc1PqdixA== Received: from thinkos.internal.efficios.com (mtl.efficios.com [216.120.195.104]) by smtpout.efficios.com (Postfix) with ESMTPSA id 4jf7Ys5QMhzYy9; Tue, 01 Dec 2026 12:44:33 -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 03/36] sched/deadline: Do not truncate a bandwidth to 32 bits in __dl_add/sub() Date: Tue, 1 Dec 2026 12:43:57 -0500 Message-ID: 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 __dl_add() and __dl_sub() spread a change of total_bw over the extra_bw of the active CPUs of the root domain. Commit daec57983670 ("sched/deadline: Reclaim bandwidth not used by dl tasks") added this, for the bandwidth of one task. That is at most 1 << 20, the bandwidth of one CPU. But cpuset_can_attach() reserves the sum of the bandwidths of all the deadline tasks it moves, with dl_bw_alloc(). __dl_add() and __dl_sub() cast the bandwidth to s32 before the division. Past S32_MAX, more than 2048 CPUs of deadline bandwidth, the cast flips its sign. The extra_bw of each CPU then moves the wrong way. GRUB lets reclaiming tasks run more than the free bandwidth, or less. This was found by reading. It needs a machine with more than 2048 CPUs, so no case tests it. Fix this by dividing on 64 bits, with div_u64(). The Sashiko AI review of the first series found this. Fixes: daec57983670 ("sched/deadline: Reclaim bandwidth not used by dl tasks") Signed-off-by: Mathieu Desnoyers Reviewed-by: Juri Lelli Cc: stable@vger.kernel.org --- kernel/sched/deadline.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c index e137eb7efa1f..a12b26b94642 100644 --- a/kernel/sched/deadline.c +++ b/kernel/sched/deadline.c @@ -199,7 +199,7 @@ void __dl_sub(struct dl_bw *dl_b, u64 tsk_bw, int cpus) { dl_b->total_bw -= tsk_bw; if (cpus) - __dl_update(dl_b, (s32)tsk_bw / cpus); + __dl_update(dl_b, div_u64(tsk_bw, cpus)); } static inline @@ -207,7 +207,7 @@ void __dl_add(struct dl_bw *dl_b, u64 tsk_bw, int cpus) { dl_b->total_bw += tsk_bw; if (cpus) - __dl_update(dl_b, -((s32)tsk_bw / cpus)); + __dl_update(dl_b, -(s64)div_u64(tsk_bw, cpus)); } static inline bool -- 2.47.3