From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from BN8PR05CU002.outbound.protection.outlook.com (mail-eastus2azon11011027.outbound.protection.outlook.com [52.101.57.27]) (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 16B4937883C for ; Tue, 2 Jun 2026 07:01:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.57.27 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780383717; cv=fail; b=a5B59nfXbeju8iXZ85AVqXsr7kMpfMnTuhTVdM7FjBVYqC3MdvijROSEd5hT+nVp2Du1bQfcYYhC10CDbQc6hqGll8xVgLRZW8jcBoNIPBj32yZo2q1+S4ufi3Hf6zwO7iczQmkCy8s1bBOi48aOsEE9uHg6XYce5BCc6VKr/NE= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780383717; c=relaxed/simple; bh=rmo39JTzDZKuLPcp7HCxZGicabeGIM6NISFnhHqiQLs=; h=Message-ID:Date:MIME-Version:Subject:To:CC:References:From: In-Reply-To:Content-Type; b=B4fwhbXbP7srWTK/cEzpMwHRq1mREyhby1HfSU/lEfougMEbA+YluJANyyvZJfLdOWyA9GMv8/2SVUcMJjb93+WC1p0atoloN7WCnmgl/kOjx7Yh3d7Rr39nomcUMCQgz1UxsdTzdQeHUV+i3Dx59t0ZvETgNcho0c5A6GlxmqI= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=DOqGO3/9; arc=fail smtp.client-ip=52.101.57.27 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="DOqGO3/9" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=jec0GHzxADKt4JirTFl1nhlDttN1QHfAZO74RVRiUadYnwvYpActgc5zTERshuDxIrAdPZ6qP3Oe+7mWZMB+XWo/MD90KxwStFTJ3VfzDgCG+luae48BDJ0X+3ZcTDNxEuBoWTBNrGZJ0khyhXaOCmBUSPQ6Xj/RgxgYu8s6F48HVmbkVuuAeFeWziEt7kEKnZwLD++zasZBhH1Ou4HNzm+dG2XEtFngWDKSI1ourIs3xWS1fAut3yjOykdnXElF9gKcxsRs3ckjZp5oO0DpOyHPw8HZDqAOXTrFAvWqdOHVmBRprqVe8+1QId19qwngoLDDU3mz8Fg9irlEYMFqbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=G8E5QdeWX1HDQx6gVK9poA9vzrWSRwQwddOb93/TsWQ=; b=zLyoZPTOgYoSNFFpVyr4wGQX9cmSobFiFr9cbGtKYzeSHNQEP4Pnat9DM+ZOc8I8mha4NPbiJ5WpBYm7+dFXG8UFftdu6T1lFnW0lPi53Rfsal6c0SWPP7M/ewqSsf75ExTTzFOIRgI0L2cuNBhjtoaa+sM/ENws42LOppt7sJtELi3Dtus7f/uvzjC4BP2FTJ4VajSSL8mOv4+3yhd0PnZeeyRfkqlp9EtRwomXyaraV+LT3MPDrOo1C8arwlxas4MAPY0HzDaA+0jHuyFfchYBQ5CcsuuTUIBSEwxfcomiWSDCQ6CaXlnE0XcsZVW+eSU5TlO+VUXpfbtCb2sGAg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=infradead.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=G8E5QdeWX1HDQx6gVK9poA9vzrWSRwQwddOb93/TsWQ=; b=DOqGO3/9M6mTzhbwVEwRC4kMJtdqySpqbKbSvwaShAHUjtnJOqRvQRhtZOCBJhTlAVz43f++/ua7ya02c2UqaGQ3EMBhBOw7mg7aqatnHDXMnSYDWGRiCpKFEFQRTl9VafHcbbalSri/Bf4B10OEnWijtfHxUvRDhMFzeGQ/HM0= Received: from BY1P220CA0049.NAMP220.PROD.OUTLOOK.COM (2603:10b6:a03:59e::15) by MN2PR12MB4254.namprd12.prod.outlook.com (2603:10b6:208:1d0::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.71.17; Tue, 2 Jun 2026 07:01:50 +0000 Received: from SJ1PEPF00001CDF.namprd05.prod.outlook.com (2603:10b6:a03:59e:cafe::89) by BY1P220CA0049.outlook.office365.com (2603:10b6:a03:59e::15) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.71.11 via Frontend Transport; Tue, 2 Jun 2026 07:01:50 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=satlexmb07.amd.com; pr=C Received: from satlexmb07.amd.com (165.204.84.17) by SJ1PEPF00001CDF.mail.protection.outlook.com (10.167.242.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.92.5 via Frontend Transport; Tue, 2 Jun 2026 07:01:50 +0000 Received: from satlexmb07.amd.com (10.181.42.216) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.41; Tue, 2 Jun 2026 02:01:45 -0500 Received: from [10.136.34.155] (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server id 15.2.2562.41 via Frontend Transport; Tue, 2 Jun 2026 02:01:42 -0500 Message-ID: <20cc9820-35b2-4d97-bbc2-84af56802dfd@amd.com> Date: Tue, 2 Jun 2026 12:31:36 +0530 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 5/5] sched/fair: Unify cfs_rq throttling via account_cfs_rq_runtime() To: Peter Zijlstra CC: Ingo Molnar , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Valentin Schneider , Aaron Lu , Josh Don , References: <20260528094830.13291-1-kprateek.nayak@amd.com> <20260528094830.13291-6-kprateek.nayak@amd.com> <20260601134842.GP343181@noisy.programming.kicks-ass.net> Content-Language: en-US From: K Prateek Nayak In-Reply-To: <20260601134842.GP343181@noisy.programming.kicks-ass.net> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF00001CDF:EE_|MN2PR12MB4254:EE_ X-MS-Office365-Filtering-Correlation-Id: 2b49ce33-43f3-4ca3-2f4d-08dec074d1e3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700016|82310400026|376014|7416014|1800799024|13003099007|18002099003|22082099003|6133799003|56012099006|4143699003|11063799006; X-Microsoft-Antispam-Message-Info: emOpC7CRLmWCzP3XmE8/5Bm77GenQkFmf5CvNF+iz/PBb9Aj3yUTIZ1LIMaOIOXVlRwmsSRDKFr+NrynpzTBHWZC/fG4qQdCa4iJc7rVxsvYS3JKo4C0ne03we3GaZhQWVkwRKBQ8oocsIlC+lOVjaHXbg4gX7WjDzpVTzGlxDAokxK9N4QPQTj2UyhXB9w4jrYrjxAFDutf08+BKlUkLpmWKBFAajA/kbOsFZ8ITUVqveoVweqWT5Bh2qgaKw+xzcipqfONiHtaW3kLENENkR33gcoKsX+s2YW1HzP9HHZ4xI2TaQSipfXie/DRgFPG8UtoKk75cwe4qhT66iir03v3apqwjviX5kVMJjPP8hAxbVe0TyNSCK8IJ3wm36jts1qz2Q7mccwIdgit0dXWiNj7i1+tuhQwfRL94rwvmfvK37O2kfVAuZywUHXrVxxwXTZLqNbO0eBlSSfRpPfp5I1jeLH94oyR2ITGy11gb2HoFa7qy7XMWC2ryJLbo2eCysIt+uKaWD6vqtJBuzM/S3xRBofBAT2Ab/HXCVnk3CGUXWaijfLvBCCv4/FJW1Up1IwaZ7svUCsLkjPGKw1eogjR6LNmXiYlJw8tnyoYQb4i8/JxRDCYRJUxqAknjyfftM8vDcH1Sn3Fb/v2/KbgbE0BopFuxTLzN2imq/6xG/vMJX5nezeZJ29yd0VpT1yO4yygf10k6EVY2y+bSh7Faqrfu0Ho9OaM2Q8j+n38KWo= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:satlexmb07.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700016)(82310400026)(376014)(7416014)(1800799024)(13003099007)(18002099003)(22082099003)(6133799003)(56012099006)(4143699003)(11063799006);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 2svzISDqfy3gkAjCyuClpzaTuM5P4T+tV6fbUt4NSeAXiQbHfa5fflSmeTj8PeZLEzlixRssFdEWPSYffjiUnJvM4SW69vvAaXEjHHOcipwPNmCVaYI30OGif1R1zg1JyHl4z8JF/SmkgDeUa2kfEmrFM2QkrfLXjXoiR8ED5ax6Ea8PAInFNBjm5xtOPmRKGGQcAq1CVhm9GuXuKSYT6lGrxTJpO8quMUCXO3DuUTgEl9ERqQylhriwpVvgZ1Drh1LMHYsHPqGiKqHW51NVbsXMMTZS/wLdl+WlzyMxZSBktjJBuoKLjg5ELJoAHe3Y89L1c+7VFI+MSpg8F5PVA0tj5PXjzUunR0hdrr/tvBExGt/l8HqPafaqVJWt4o0unISYalgXhvoM7KzIILKBy1sqx0hRsRkNBNFLe9QIs4IvdzVCESwzUaHBmmuk3b9t X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Jun 2026 07:01:50.2518 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2b49ce33-43f3-4ca3-2f4d-08dec074d1e3 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SJ1PEPF00001CDF.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4254 Hello Peter, On 6/1/2026 7:18 PM, Peter Zijlstra wrote: > On Thu, May 28, 2026 at 09:48:30AM +0000, K Prateek Nayak wrote: > >> @@ -9893,8 +9882,15 @@ static struct task_struct *pick_task_fair(struct rq *rq, struct rq_flags *rf) >> /* Might not have done put_prev_entity() */ >> if (cfs_rq->curr && cfs_rq->curr->on_rq) >> update_curr(cfs_rq); >> - >> - throttled |= check_cfs_rq_runtime(cfs_rq); >> + /* >> + * For the current hierarchy, update_curr() above would >> + * have set the throttle indicators if the cfs_rq has >> + * run out of bandwidth. For others, enqueue / last >> + * update_curr() for the cfs_rq would have ensured the >> + * throttle indicators are set if bandwidth was not >> + * available. >> + */ >> + throttled |= cfs_rq_throttled(cfs_rq); >> >> se = pick_next_entity(rq, cfs_rq, true); >> if (!se) > >> @@ -15074,15 +15070,19 @@ static void __set_next_task_fair(struct rq *rq, struct task_struct *p, bool firs >> static void set_next_task_fair(struct rq *rq, struct task_struct *p, bool first) >> { >> struct sched_entity *se = &p->se; >> + bool throttled = false; >> >> for_each_sched_entity(se) { >> struct cfs_rq *cfs_rq = cfs_rq_of(se); >> >> set_next_entity(cfs_rq, se, first); >> /* ensure bandwidth has been allocated on our new cfs_rq */ >> - account_cfs_rq_runtime(cfs_rq, 0); >> + throttled |= account_cfs_rq_runtime(cfs_rq, 0); >> } >> >> + if (throttled) >> + task_throttle_setup_work(p); >> + >> __set_next_task_fair(rq, p, first); >> } > > (noticed while trying to rebase flat on top) > > Why do we have both? Isn't just set_next_task_fair(.first=true) > sufficient? I misread this bit and only called account_cfs_rq_runtime() for !first in my v2 [1] but even the following changes on top of my v2 [1] yields similar results in my testing (slightly better on performance) so feel free to squash this bit into the last patch: diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index ce5cf494b934..fa8c0b1a1cf1 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -9892,15 +9892,6 @@ struct task_struct *pick_task_fair(struct rq *rq, struct rq_flags *rf) /* Might not have done put_prev_entity() */ if (cfs_rq->curr && cfs_rq->curr->on_rq) update_curr(cfs_rq); - /* - * For the current hierarchy, update_curr() above would - * have set the throttle indicators if the cfs_rq has - * run out of bandwidth. For others, enqueue / last - * update_curr() for the cfs_rq would have ensured the - * throttle indicators are set if bandwidth was not - * available. - */ - throttled |= cfs_rq_throttled(cfs_rq); se = pick_next_entity(rq, cfs_rq, true); if (!se) @@ -15012,12 +15003,8 @@ static void set_next_task_fair(struct rq *rq, struct task_struct *p, bool first) break; set_next_entity(cfs_rq, se, first); - /* - * Ensure bandwidth has been allocated on our new cfs_rq - * if we've reached here for reasons other than pick. - */ - if (!first) - throttled |= account_cfs_rq_runtime(cfs_rq, 0); + /* ensure bandwidth has been allocated on our new cfs_rq */ + throttled |= account_cfs_rq_runtime(cfs_rq, 0); } if (throttled) --- My mind is taking a while to grasp the ->pick_next_task() removal. [1] https://lore.kernel.org/lkml/20260602050005.11160-1-kprateek.nayak@amd.com/ -- Thanks and Regards, Prateek