From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7B3D75474F for ; Sat, 2 May 2026 23:58:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777766295; cv=none; b=jjvLF8kUY7a8Rdg5wjdxCM/iszGKtDBCs8jf7oDqeEA2YdwHlUpo8Yoa5IiAAA548VaQ46rd/+4x3p/DjoV3izqwjMaKmTUrnzJdgeOQfb35WCqBiB0AJnlohH/SL4U8O3l9GBrLLPWTGcFHm3vqzoNuePszBZT1CIS/eMRlneQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777766295; c=relaxed/simple; bh=JNjzz6+izX1Yk5EDvjl5tI0NE6lEFbCpi+liD5ko5ic=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=c3m51KBQcyfqPZqB6jnf0fAQCxxJfT2zB0AciFtGIe/cZhefDo8SWR73nFMpiICz/SaRH4iF1ckHYAJp0/bnhiAfSdOXrjh0RQ1V1Uj58zvCGOysp5Yp+WJNfr/hyzBQP+jo5BRFl15Yg+t3EG07ePDjU97UCmvAp1i1QnIwIy0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Ao5MqEUl; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Ao5MqEUl" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 25BD3C2BCB8; Sat, 2 May 2026 23:58:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1777766295; bh=JNjzz6+izX1Yk5EDvjl5tI0NE6lEFbCpi+liD5ko5ic=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ao5MqEUl3AOKtOuqJxMtk+78GVUHapLnlHNuXPVwp0NnKepQQ7g0D45vEHvSI3D7l DBj81FxyPYntyeFHOt8Xfb7YsEWR2tpdjj2rqenN1/57DMbYZiFt5M8kPg6WTyL22i vSXWwyHrMTmIhMrgCc9lwa7M45BPDHS/ScJ4y9PIfxlZtMFZJKu6sgJ3eImiWYIK7z CrU52obycjaYxoPN4vPlSsm+2SeHwqk6vPnwUu1ze74+awFovwIchPW3gGo3OoMw0e ber0UkXFdEmmEdshXPuPW9xvD7SBY3/7jG72l++B0FxoDLcjYtFi6hqnSyT4OoO14x 61d591TQmRxKQ== From: Sasha Levin To: stable@vger.kernel.org Cc: Joseph Salisbury , "Peter Zijlstra (Intel)" , Sasha Levin Subject: [PATCH 6.1.y] sched: Use u64 for bandwidth ratio calculations Date: Sat, 2 May 2026 19:58:03 -0400 Message-ID: <20260502235803.921618-1-sashal@kernel.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <2026050100-bonded-fled-538b@gregkh> References: <2026050100-bonded-fled-538b@gregkh> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Joseph Salisbury [ Upstream commit c6e80201e057dfb7253385e60bf541121bf5dc33 ] to_ratio() computes BW_SHIFT-scaled bandwidth ratios from u64 period and runtime values, but it returns unsigned long. tg_rt_schedulable() also stores the current group limit and the accumulated child sum in unsigned long. On 32-bit builds, large bandwidth ratios can be truncated and the RT group sum can wrap when enough siblings are present. That can let an overcommitted RT hierarchy pass the schedulability check, and it also narrows the helper result for other callers. Return u64 from to_ratio() and use u64 for the RT group totals so bandwidth ratios are preserved and compared at full width on both 32-bit and 64-bit builds. Fixes: b40b2e8eb521 ("sched: rt: multi level group constraints") Assisted-by: Codex:GPT-5 Signed-off-by: Joseph Salisbury Signed-off-by: Peter Zijlstra (Intel) Cc: stable@vger.kernel.org Link: https://patch.msgid.link/20260403210014.2713404-1-joseph.salisbury@oracle.com [ dropped `extern` keyword from `to_ratio()` declaration ] Signed-off-by: Sasha Levin --- kernel/sched/core.c | 2 +- kernel/sched/rt.c | 2 +- kernel/sched/sched.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 09ffe1b966431..56111b42da2a9 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -4692,7 +4692,7 @@ void sched_post_fork(struct task_struct *p) uclamp_post_fork(p); } -unsigned long to_ratio(u64 period, u64 runtime) +u64 to_ratio(u64 period, u64 runtime) { if (runtime == RUNTIME_INF) return BW_UNIT; diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c index 99e5d37b3f6eb..49e19ed896f8c 100644 --- a/kernel/sched/rt.c +++ b/kernel/sched/rt.c @@ -2768,7 +2768,7 @@ static int tg_rt_schedulable(struct task_group *tg, void *data) { struct rt_schedulable_data *d = data; struct task_group *child; - unsigned long total, sum = 0; + u64 total, sum = 0; u64 period, runtime; period = ktime_to_ns(tg->rt_bandwidth.rt_period); diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index 6f66a9b1aaa98..a6c2b8f3045ee 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -2371,7 +2371,7 @@ extern void init_dl_inactive_task_timer(struct sched_dl_entity *dl_se); #define RATIO_SHIFT 8 #define MAX_BW_BITS (64 - BW_SHIFT) #define MAX_BW ((1ULL << MAX_BW_BITS) - 1) -unsigned long to_ratio(u64 period, u64 runtime); +u64 to_ratio(u64 period, u64 runtime); extern void init_entity_runnable_average(struct sched_entity *se); extern void post_init_entity_util_avg(struct task_struct *p); -- 2.53.0