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 8134B315785; Mon, 4 May 2026 14:22:30 +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=1777904550; cv=none; b=IKZwwzmtLEokt4lSWFsI/BKUQ0MCX2sBYisgeNyNEbnLsYLRfMPZrqm2nHQLKIcH6ub0lG3lQMHrZqMMaCc4NES+hwTZ1Pa2MUSKxGR+/HJHu8CuuCkabw5hnetAznXB/QcmuwKxBWXF5pzzgzLvzuF+XCk99vuF7e4XnnMhCm8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777904550; c=relaxed/simple; bh=y+DYwidX/MKQp0Mb+2Rk0eYPrg+y1Eiyd4dKHOz4HJc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Yp1bPMQyevYX7TRplvjiST6RdnzaIQidFMXITAeYMhxrA2toBY31293pUG8JoK77BEIJ24EOoTOnFPoEZly7g11F2r9EHpuz6ReRMCkvMX1K9bz/5tfwPsHSQJ62EKIBiKUmuV4rLlKnzyq5TFwViw+M+L0GDh7/AsWWYBe6ZFc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=FmlRMqCK; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="FmlRMqCK" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 186FFC2BCB8; Mon, 4 May 2026 14:22:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1777904550; bh=y+DYwidX/MKQp0Mb+2Rk0eYPrg+y1Eiyd4dKHOz4HJc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FmlRMqCKaa9fLHgL+qaNDYdtyDi2oApM1Nm7xGtVjyFpZb4klvD62OonYbbZ4zHBa 1NanRRZm75yO5UhYgvAg7E4CLL4Ub8yD9Z+KBYkhQ2xN8pW7r7IzG8mzWMm5xlbKTj WAS++UetssB5V9CWtRkyHT8L8uGGCHygYuRaR9j8= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Joseph Salisbury , "Peter Zijlstra (Intel)" Subject: [PATCH 6.12 065/215] sched: Use u64 for bandwidth ratio calculations Date: Mon, 4 May 2026 15:51:24 +0200 Message-ID: <20260504135132.545354226@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260504135130.169210693@linuxfoundation.org> References: <20260504135130.169210693@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Joseph Salisbury commit c6e80201e057dfb7253385e60bf541121bf5dc33 upstream. 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 Signed-off-by: Greg Kroah-Hartman --- kernel/sched/core.c | 2 +- kernel/sched/rt.c | 2 +- kernel/sched/sched.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -4794,7 +4794,7 @@ void sched_post_fork(struct task_struct scx_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; --- a/kernel/sched/rt.c +++ b/kernel/sched/rt.c @@ -2707,7 +2707,7 @@ static int tg_rt_schedulable(struct task { 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); --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -2698,7 +2698,7 @@ extern void init_dl_entity(struct sched_ #define MAX_BW_BITS (64 - BW_SHIFT) #define MAX_BW ((1ULL << MAX_BW_BITS) - 1) -extern unsigned long to_ratio(u64 period, u64 runtime); +extern 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);