From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from BN1PR04CU002.outbound.protection.outlook.com (mail-eastus2azon11010006.outbound.protection.outlook.com [52.101.56.6]) (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 5EC4F24A06A for ; Tue, 2 Jun 2026 05:01:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.56.6 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780376474; cv=fail; b=IkfilgtY8LQ3DYGZUYx48oHA02EYCsMTBjVe5WWKPpS8o/pYRaAe2ZRDBc64Yje30vsSMpHfSc6H9x+pcwdhisccElVOfcjha+E0jlDkB+p47lvrBEFZfNlNnAnma9Hb7/yWfnhkaRihfY0hu2RS1k7xICPD9FabYwKZp4cy/0s= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780376474; c=relaxed/simple; bh=PDSmk4xsAvldkUqhuzxc3C4/LeFqfOYGGek8wXyTVpk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Jcsfgyvn11vSADuYVUOVZYqqSYDh5a6JwTP3gPfa72su2VwhsUyzSvi1NtrQKlyhlEMXpaKK+eCDowmdGPJIAwki5Or4Wi24dJZtCi/eLo35Itf8YYpgosL1XBrNg8iXw2zLuNeLh135NUD3xJrYUu7dmAWl9IIi9UOROp81NLA= 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=jpemriwr; arc=fail smtp.client-ip=52.101.56.6 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="jpemriwr" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=CMXIbB1/Sq19FRKs7Mp30LhNVMVx4KkKehJbHFFXzrKFQgBLo0H5ahiGCLentzgrDZ8QIvDJejcZ+KEW830B0lsyHWz7uIBNjcwqGZaw4jfAJNqWPxYrKN30OOINfpXgwG99sSpNNxsDPRRgkt3CC/nlW01ybzeZsvBZHCtiOXdB9esGgAa63ZxPbufs3KF3xSihp63HQD8beYXCEo54mm9twoyH9YK69T4N/pGPLgXuvw01imnGkEjuZ2qvMwVJ5OLeOYH0Tz8KGWSjNdgmzBqsA3ttz3FJJw494o+zyN4LodcDoye01CtPFjVwUax4KtDcSmMzpKqdTgzfw4QCTg== 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=li7fs0JvGGPzV6xXbp861/3hg1pqzFRGX0HgOXTHyVU=; b=O0aYfDlMTTqdY0erdPstSve4B/2T17o9wH0zPE2lH8JdRfAVGyg4eYNX8JZ8ZVStOg8Nb+Ip36Bdd7HcQZulRHqdSSr8iBYM3ytGzncGOBbc+UuNyPTj5fnvZoGlNRWvX+tD/mXzhjRUI9KzIHBHdDDkEFkQm+p7oM93Z3hhz3yB+sQL1L0Y42aBvaNyIrIh+czh1Hyq1bWDJ+MCbDKuArf3fyCwbQiM4+Kk2ABWUPynKaV9J3dG7PUFsewk+9ghz5kx13CxO8cZlNGCYpAtdyGXsDrFmYTxPk1Y/kPysVP0u3Hzk1IJ0AUUky7ae4J6m35FxjR1KaHJDBhV+UvdbA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com 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=li7fs0JvGGPzV6xXbp861/3hg1pqzFRGX0HgOXTHyVU=; b=jpemriwrz9b7qK/D6270lpVMlu6aihlfnz1B15DrsJIGPtDwWqDKv3h1P4raACuIKMcGX97c8hOLktmrGdM857O3uFp+fpomPnNa3QmGn49WON+f6I263uFDCSYXipwPxZLXyZK4yb9vqJdqXaO4QgC5WYW4IDTGW6AIe8oTFG0= Received: from SJ0PR03CA0192.namprd03.prod.outlook.com (2603:10b6:a03:2ef::17) by PH7PR12MB7113.namprd12.prod.outlook.com (2603:10b6:510:1ec::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.71.14; Tue, 2 Jun 2026 05:01:01 +0000 Received: from SJ5PEPF000001D2.namprd05.prod.outlook.com (2603:10b6:a03:2ef:cafe::8a) by SJ0PR03CA0192.outlook.office365.com (2603:10b6:a03:2ef::17) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.71.16 via Frontend Transport; Tue, 2 Jun 2026 05:01:01 +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 SJ5PEPF000001D2.mail.protection.outlook.com (10.167.242.54) 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 05:01:01 +0000 Received: from BLRKPRNAYAK.amd.com (10.180.168.240) 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 00:00:57 -0500 From: K Prateek Nayak To: Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot CC: Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Valentin Schneider , Aaron Lu , Josh Don , K Prateek Nayak , Subject: [PATCH v2 2/5] sched/fair: Use throttled_csd_list for local unthrottle Date: Tue, 2 Jun 2026 05:00:02 +0000 Message-ID: <20260602050005.11160-3-kprateek.nayak@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260602050005.11160-1-kprateek.nayak@amd.com> References: <20260602050005.11160-1-kprateek.nayak@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: satlexmb07.amd.com (10.181.42.216) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ5PEPF000001D2:EE_|PH7PR12MB7113:EE_ X-MS-Office365-Filtering-Correlation-Id: ac54589c-d75f-46c1-9ec2-08dec063f156 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|82310400026|376014|7416014|36860700016|56012099006|11063799006|22082099003|18002099003; X-Microsoft-Antispam-Message-Info: Wq56665KAQR5Cxcg39OT1AaciTgybmAsNj3UlwDI5lK3XhJiNDSXq7HQvDxCk5nHDloWDgawr1WtsOJ2Kaq2CqVDcfpvaxMMKvuyNScg7ptufpLpgsvWfmz026xgPP7EebiZOgV4qbNlen2YACuL8/tyN4KyzHwsOek2QX16iT+lTbrN7BvSMNsMx7znazhrEkJD2tKumGT5WIAkBBcOf7umpsP9hQb0EB/B90Dvfov1Hx8f9k1eVEhJ7ss6td/vXeciUEs0wPVyId6eLn3/CZIQP27iacPJuQNdanCb9tcYdd8OpWMIMRPRtpK7wEDaDXae4hn0n0wF+5VsFsYXsbPeexNdNEIUvp94VzfKzw0VoAPoa1aQiXAu7KQw5CvLaTE0+ccpWhJnfQs9Hr177ZmrDvfb8VSWgAKStnRo9dW9Ato7bwGywjEcJWMmFqhPYiAn/HZgiEgmMnbmHDJLieFMlbc4TC403mPt1lfxsePB7xiqaCKnVnjVKOF3ev1maFx3+Xltv77LwQ3QWneGh6en5MaUA0zIQO+KIO2IeBJdVQ+vhUz2QNFmeghq625G8PAeSGwWWDOsi562sH8WEnRT+NI/yorNLMdEETmGYdxSxFYsZ/9J6DzpoY/j8qibuzCQmTQvnOz9D69ZDMywkzsV+DVYf7zc5oiXWn+C9dS+CmJbmOg4muCnFGw8789FZvDkY8+TUYp4sQacur1Dr9uEC+w7+LBNBSrF6gr7luc= 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)(1800799024)(82310400026)(376014)(7416014)(36860700016)(56012099006)(11063799006)(22082099003)(18002099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: qZjXHNqsf5zqYtlI+WnZ9oo8ZYSf9XFY2bx1TBO0Vs2nsiceCLoMDPD0ki2rWx3bQMs10htQTm01LP/hnwMcj3YlVJNdGr4bPs3u2S8Nbco/kkiCWJbda8DEUdcgIroyMcjb+L3rkl/L8dt2hNpUgTiXBg7CWMb8qKrNpK1tMPSjeVAjr40zG74om6oS972xrBzUq/5LMlZpZ1y+dDweYB1J+VFGjhfIR7IiAk+Ol1WWYm1zju6OWXTthnEBUUCNtugeMaHQG5kbo8QHZn5LNMpUWg1tINlkGxqJ2lgijal1tdlQdgD3DCqFBZLb760q8k/YQ2A70+U81mAkPqG1WTNI2NaCjce8QDBU1+B7KKDr+l5Iygl4Sb8D8sAaKDaGD7ug9OJ2oT+Ywzz9B8mkpdWSn9KeG2w15ChTEQRIeZFZJuzj/+TotAyfei7Iotof X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Jun 2026 05:01:01.5616 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ac54589c-d75f-46c1-9ec2-08dec063f156 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: SJ5PEPF000001D2.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB7113 When distribute_cfs_runtime() encounters a local cfs_rq, it adds it to a local list and unthrottles it at the end, when it is done unthrottling other cfs_rq(s) on cfs_b->throttled_cfs_rq until the bandwidth runs out. Instead of using a local list, reuse the local CPU's rq->throttled_csd_list and the __cfsb_csd_unthrottle() path for unthrottle. If this is the first cfs_rq to be queued on the "throttled_csd_list", it prevents the need for a remote CPUs to interrupt this local CPU if they themselves are performing async unthrottle. If this is not the first cfs_rq on the list, there is an async unthrottle operation pending on this local CPU and the unthrottle can be batched together. No functional changes intended. Reviewed-by: Benjamin Segall Signed-off-by: K Prateek Nayak Tested-by: Aaron Lu --- changelog v1..v2: o Collected tags from Ben, and Aaron (Thanks a ton!) --- kernel/sched/fair.c | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 766cd4395e6c..825393d3f039 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -6962,12 +6962,11 @@ static void unthrottle_cfs_rq_async(struct cfs_rq *cfs_rq) static bool distribute_cfs_runtime(struct cfs_bandwidth *cfs_b) { + bool throttled = false, unthrottle_local = false; int this_cpu = smp_processor_id(); u64 runtime, remaining = 1; - bool throttled = false; - struct cfs_rq *cfs_rq, *tmp; + struct cfs_rq *cfs_rq; struct rq *rq; - LIST_HEAD(local_unthrottle); guard(rcu)(); @@ -7018,24 +7017,23 @@ static bool distribute_cfs_runtime(struct cfs_bandwidth *cfs_b) } /* - * We currently only expect to be unthrottling - * a single cfs_rq locally. + * Allow a parallel async unthrottle to unthrottle + * this cfs_rq too via __cfsb_csd_unthrottle(). + * If we are first, do it ourselves at the end and + * save on an IPI from remote CPUs. */ - WARN_ON_ONCE(!list_empty(&local_unthrottle)); - list_add_tail(&cfs_rq->throttled_csd_list, &local_unthrottle); + unthrottle_local = list_empty(&rq->cfsb_csd_list); + list_add_tail(&cfs_rq->throttled_csd_list, &rq->cfsb_csd_list); } - list_for_each_entry_safe(cfs_rq, tmp, &local_unthrottle, - throttled_csd_list) { - struct rq *rq = rq_of(cfs_rq); - - guard(rq_lock_irqsave)(rq); - - list_del_init(&cfs_rq->throttled_csd_list); - if (cfs_rq_throttled(cfs_rq)) - unthrottle_cfs_rq(cfs_rq); + if (unthrottle_local) { + /* + * Protect against an IPI that is also trying to flush + * the unthrottled cfs_rq(s) from this CPU's csd_list. + */ + scoped_guard(irqsave) + __cfsb_csd_unthrottle(cpu_rq(this_cpu)); } - WARN_ON_ONCE(!list_empty(&local_unthrottle)); return throttled; } -- 2.34.1