From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from BN8PR05CU002.outbound.protection.outlook.com (mail-eastus2azon11011053.outbound.protection.outlook.com [52.101.57.53]) (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 2DE2B39021A for ; Thu, 28 May 2026 09:49:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.57.53 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779961767; cv=fail; b=dyDgJfr8bwMT8oZrwbJPQPdF606jK4Wxv0uCrHj6MWgbsVs6zXoeU0sXb3BCzYg/Ap45sm7u8q79JXAoKZ6cMZfK1KHSov8NjXi6lJVfqxPGvzxyjRGjq2ZlHEvfL3LCdl9SxU+3SfyiQze45VgiWaiytqV+jHfkwRMHvj0BECw= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779961767; c=relaxed/simple; bh=iz24sVnYnNkEHLQZrCYf5Y8JWjPtwfcb6qA6u6JLCuw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=uUzJXcQFKeqEbuTcyls5bO7RIcQC/ZkMIE+7S5+jfy4CpTtHZkbjBrI5kTrx8oTdv+aEt4cWyvBP64CPrBBs5PfzLf92cVj0N01arSl+YXJBaRPZRZZ2++ZUDU6lLOdV07Qs3OwG0c5jacFbyQzBfj0JAcW9t5mb1P1d93PqKOY= 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=YvnQie1x; arc=fail smtp.client-ip=52.101.57.53 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="YvnQie1x" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=n6CzQfPDu2zNcb1QB3TtN48ebZRGzE4Z8BIvUsG8uI2sDk2HngKvWgvGLqzaReKMQLjnKkwWRe+HZUJBcTzIu1GhlwaY3sXNN8rJWf9qHHXoFxhA8RROpQ8QCk36sEJM5qPgUpDoEPVrQIISGIs06WIPWPCOWByZ1RFj0isAqwfg+yaZ+dpAB1e6n0u7EyckCY4AM+yyuoPiguqE8UMkVwslOcG6yaxguwG4cZyL2ZIwIW6OrNh4TS+5c/A4TwlTBAAHRO1vpEVjypmqJGmQBbrrm+XEcvgNzbs9ykBttvtnXA8EE1AZ+VtaYFTffhYbjqlYFIrilohLVZYjJRpllA== 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=YVK8ZkUwXx2G/wajSOm8wmHbyVM0k0MTtn6YV3V0G5o=; b=WKi8NZ1caUet4YIVgLnbXiqPYclqqiwyU6oDczC1C2MCD47UPDEFzkJvG/Ym8MdoLOkXng/X8qLLnkWwnW+ezMqks/sDpxfBUjg2f4ta499fhzvI8LoztWTUPE4NSppUwXpKVyDcP4cbCIazgVU/xsH9vSDoqyBiYT7/6WwvwkhAoOzUnux1M5gBcfei1+ThBikwsy3rCm468xEvezV1UcLmZWBzPFyGiuKKgCrDqE3zi6vgGRs6ticXVZ8xr9YSbFu9W3I0yogQlS8l9N3WQaCilZsGqpupJFZ8WwM8MV06Vuno4OjZh12VZSUSkq8tPs38gYfF2XOE97bwiTJAHQ== 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=YVK8ZkUwXx2G/wajSOm8wmHbyVM0k0MTtn6YV3V0G5o=; b=YvnQie1xuqD+l//3SotrlYCLMAfmUezNX0UAbK7wrDODrdUAdulhB/wd4aQMPD6JmBgB1bR3f8VR/7CWDIk7qDCtuwh2+otCihBw+ki1YQH3Z6zewbuSD1MsxymqEpTa2dPqKhIPg9sVfsf0bAze+IbqZVLMF3UBksUnOX0fA2s= Received: from MN0PR05CA0016.namprd05.prod.outlook.com (2603:10b6:208:52c::15) by CY1PR12MB9625.namprd12.prod.outlook.com (2603:10b6:930:106::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.48.16; Thu, 28 May 2026 09:49:22 +0000 Received: from BN2PEPF00004FBC.namprd04.prod.outlook.com (2603:10b6:208:52c:cafe::a7) by MN0PR05CA0016.outlook.office365.com (2603:10b6:208:52c::15) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.92.5 via Frontend Transport; Thu, 28 May 2026 09:49:21 +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 BN2PEPF00004FBC.mail.protection.outlook.com (10.167.243.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.71.7 via Frontend Transport; Thu, 28 May 2026 09:49:21 +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; Thu, 28 May 2026 04:49:17 -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 2/5] sched/fair: Use throttled_csd_list for local unthrottle Date: Thu, 28 May 2026 09:48:27 +0000 Message-ID: <20260528094830.13291-3-kprateek.nayak@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260528094830.13291-1-kprateek.nayak@amd.com> References: <20260528094830.13291-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: BN2PEPF00004FBC:EE_|CY1PR12MB9625:EE_ X-MS-Office365-Filtering-Correlation-Id: 042d1782-9c0d-41f2-0ff6-08debc9e64db X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|7416014|36860700016|82310400026|11063799006|22082099003|18002099003|56012099006; X-Microsoft-Antispam-Message-Info: K0F2kXLTq1cT3Ceh0WUZS4yplWyqSNYzsxWERBVaLbJZ0gbf716EE4eXSXxa9gE0/2h1kWlHStsRognc8qmuHurzPFKyBeQ2nV6vqIn6RVmDo46C0qP0Fdx1wkSWGsp2s8g6i/lJ2w9R5HfeJCD2hm4iWIZL08qCMmefQuIH5C9JKt2TDcH8lTcKyY1J899h4AUF5u2VtUeYjGl2Lga99gMohdY5P9zLBq9nCQylypmsPB5it3z0MTECwPHQNe3OyR4ZdOZBDbOSZiJUCAspSHWfPAet+6ZGT3R+ThaL6l4YlSXdgI0x3tfgXCWwQAegvQwysV5bY6psQ0VqEoG4JeZeTGOL9+2xbGR3fMcg5DNpIN5GO0K9JwwexH+CY1op8VwcJz1jxj7HdYKzeilKVO+Rbo9bDFt7SzoiuRhUtAQgvgn6o+BulsbVVc492EZxEJ2b1qVA+8G7RRT936VZzg5vE3VOUCnEkY/GJ2h7jUBIe7m0PL98lWniWM44kY61Sdj4eTBfw4U9XSBeJ+HFrohXdxRfI4GLMuwq4xE/53IiGzjzYL5RR+6E2CJ52VxTgdKwY3dnz5i6SxkCBkv2a7Y1An2mSdSfZ1bY3dThtzEMUJf4++OpM7jIm9de1fhwGbeazkmggnvRZ9r1LMh15NaWBQC2XAwsEqahs13V3cUsP6RnXGjQ9OWjtdHBfRRmjgCuYigA0lz/nGCMozNfwIpZf2nY/AwwQVoO7fUKm+I= 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)(376014)(7416014)(36860700016)(82310400026)(11063799006)(22082099003)(18002099003)(56012099006);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: cgFU62tlcXkFQcOeHoMHDASDQ+c7wvD6DC6UfGZMYH4FfwJZ0q7qYVUoKqQPQW4vi9F2oax6UGNv23N1Zllkd94DCujDpI+ZnwjVHr+SymLard/fveJ/t66xthCx532R8vSpVP2itdKM5OelOyP4y/8QjY8LySi7ysCnZ/8smKLMjo/I0l2v/FDOvAZffrqkNwezdVUIvIBrQkeGw0LmPcG405ww+mqEVi1sbnJ+tNU/+sjajfDT3XbdzIdBi4nnxKGMqHVeE71O2BPwgMOArgN1+wYxHYZgnkF2syG2JhLWjX0NuwMWmxIYfhllzRXEmf/1GpRSsIrcJkAyPz8Gh+Mn27wYUVxIVWZcKRk6jfyk4OOIaxoMwnCJv/tto6AmyQbpSy8fwU3YPxthIeeC5AZLfsMmETqhaTh4kjyGPuNRry3r3fd0Bq5cDztoB4c/ X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 May 2026 09:49:21.5701 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 042d1782-9c0d-41f2-0ff6-08debc9e64db 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: BN2PEPF00004FBC.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR12MB9625 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. Signed-off-by: K Prateek Nayak --- 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 8c2a5a2f046d..23742d928b51 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)(); @@ -7010,28 +7009,27 @@ 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); continue; } throttled = true; } - 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.43.0