From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 1F3E83C65F2; Tue, 16 Jun 2026 17:48:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781632104; cv=none; b=KfsqEKCczm9Yck1/5JVZEP+8HLWfK04W2cd0OsoKgrQ3DG52alMVEs149sh8LLUuFjH8ja04n3Zu5S77b58MhKDQT4Ca1B2tw+1XqkTD1uqRWevPUuvnLGiONuSPPlbLcwTlDIkLxRUCUliVmBpcISpflkC+xyqbrhw2qYzrd+c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781632104; c=relaxed/simple; bh=KO2Q9sRIZvAoW0eaQBoMFBwCfN5zEVCRlhm5jfzoLMk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=utotbBKBAESFvNq50xODtt+A2t2z6ekF64n0Uz5Nq7F1AHLSicAmzNRjZud9z1KjIZXWFL8kNB3/h2/DTW1cVBx4QVtiJeqiyhnqUHRh+X41s6DpixTB9nYEsAaiyyYlnZhwCawLxfO7r+vmxVlh2OAV+bK2cxIKp4HXhsDovXw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=pTXGMIVu; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="pTXGMIVu" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E2E081F000E9; Tue, 16 Jun 2026 17:48:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1781632102; bh=Q4yqtHeBN3nyTrVVi0gmEzBpU8yr2WXO23lPkhTfo+8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=pTXGMIVukDLDgeOx1yQZA2bSEiuG1UTzIskI8t2K2zqDU4jZjQAtSf55jR3957ml2 CxzA6D7Zd+puZmDTGGnEpwiCI/hxBuZNbHGaPYKPF55+WGqmtbcryT9j9MQV6/+d9F 08LmJMsETN3XpDg9imWe9LIoVG4GCcRsJzL/BNM4= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Joseph Salisbury , "Peter Zijlstra (Intel)" , Sasha Levin Subject: [PATCH 6.1 348/522] sched: Use u64 for bandwidth ratio calculations Date: Tue, 16 Jun 2026 20:28:15 +0530 Message-ID: <20260616145142.083256164@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260616145125.307082728@linuxfoundation.org> References: <20260616145125.307082728@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.1-stable review patch. If anyone has any objections, please let me know. ------------------ 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 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 @@ -4692,7 +4692,7 @@ void sched_post_fork(struct task_struct 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; --- a/kernel/sched/rt.c +++ b/kernel/sched/rt.c @@ -2768,7 +2768,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 @@ -2371,7 +2371,7 @@ extern void init_dl_inactive_task_timer( #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);