From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from SJ2PR03CU001.outbound.protection.outlook.com (mail-westusazon11012045.outbound.protection.outlook.com [52.101.43.45]) (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 7C1E33B4EA1 for ; Thu, 28 May 2026 09:49:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.43.45 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779961783; cv=fail; b=gN/a4wlIdOmhyS6jd5K/KzkXtZhj3ANmIySKOW2lzhPMZivE4QRL+dNuLZYB53xJc7CP6jvKEn3QrtYSmsVmv8qQlp1EytXa2vHsd0Uuvj6V67WmhDAAp1F/TbE7MbDmubj8KTJyEJluHOKd1PtLKFfaaB4QkWzTSOKh+OHKe4o= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779961783; c=relaxed/simple; bh=0WsFXZml2AkaqzWRrV6YFdJPO443clouKlp/xZI71Us=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=XwSxaihkk66ZXUHJMPLVBq3aLWAs9LuVD6aYYloYUBZmHAGIEcVqFoXkC0QMk5WaaCdVaWVkwHVngo9kkquATINd4j3X9fbzL+gF7b/pUcjup7A/k6o+VTjwQiOMmB/Kjvs9OOXTHiRVnRKv6cMe2HGFAejay4xcnzGJ8hFc5CA= 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=vyw1Jcjs; arc=fail smtp.client-ip=52.101.43.45 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="vyw1Jcjs" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=BYHXeqcH8pfz1Mz8ZsUwzcYN7mkELONPYtUiRt4GuW4L+Qgn85TQ2PYeLLxXNzh7g58z7L4pVkhGvSGb/JfK+T0guBedoLqXWVEoRmi68l1s8C3l39DkDfxMcFswrXimU8F2QysOv9a7dRxCezmyGVogk5n7I2hy/pDQFlBYmp3Cc+3beQUCkNBnvIJ+AhTuNLuQFQ2YobrZSptjx+DHQ6lWAMQHWO0ozFa7ws5b4c4nb7PWICq5Mfi9QuNsMQrBsYeV11kxhBzesPJHMttzpxE2Er4SI5f34xd/zYW10a4d3o/4yA3YjPW54oe7SeUgJXk9XtpZW99dSP084F71Zg== 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=CwmQZ1+hU4j30Imu20mYXvxm06JZCNz+J4P8q75180s=; b=Q2BFRHOZw5u+QMFbJg/Bql3ey7D9UImJioojBR3wyWbdy5yxLhGIJDgavY0tUPv/dv0J548lDdVN7wbs93Gf4q1KVrtnsC0gOu/Erj9yA99Yn1xu7UEtI6VlKD/dElWzgv3ugiTOshw8sN776EdIBsA4BHmB7t3QqAPFUARQZ3ih2Nm/7uT0sWG7CbERTO3EJKR5FNZT4CLIfDwWLJwwWZ3AQH5fSi1bFKRAAeBiOwq7tYYCN1GQniIr9GGiHl9ATGuez4xSDhxP8n1dAh2K1M8+0JRTWAUWp2QS9Qvq5oYdWzxqUKEYROGNMFG6B8rnXnvh5FkfWT503T2e++VOSQ== 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=CwmQZ1+hU4j30Imu20mYXvxm06JZCNz+J4P8q75180s=; b=vyw1Jcjs3hF5IQWdYbt76IFuvaAFh3oXBe+GQGN5Wk9rmW7PIEi2oqZNqOF0nh1Q4swYcXk9Pr1WOqJ4AcfZsN7C1UEgbEYsHzHDPBBn2R+XIlzYq66uGjdrSRElrTzgfgwDwj5NGbqrUbt0hIaYpEEe4O4/ijYpiLE6tW7ZTsk= Received: from BN0PR10CA0006.namprd10.prod.outlook.com (2603:10b6:408:143::32) by SA5PPF37951B1C9.namprd12.prod.outlook.com (2603:10b6:80f:fc04::8c6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.71.15; Thu, 28 May 2026 09:49:38 +0000 Received: from BN2PEPF00004FC1.namprd04.prod.outlook.com (2603:10b6:408:143:cafe::1b) by BN0PR10CA0006.outlook.office365.com (2603:10b6:408:143::32) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.71.13 via Frontend Transport; Thu, 28 May 2026 09:49:38 +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 BN2PEPF00004FC1.mail.protection.outlook.com (10.167.243.187) 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:38 +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:34 -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 3/5] sched/fair: Call update_curr() before unthrottling the hierarchy Date: Thu, 28 May 2026 09:48:28 +0000 Message-ID: <20260528094830.13291-4-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: BN2PEPF00004FC1:EE_|SA5PPF37951B1C9:EE_ X-MS-Office365-Filtering-Correlation-Id: b7f7e28b-ebe2-4841-acda-08debc9e6ed6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700016|82310400026|376014|7416014|1800799024|6133799003|10063799003|11063799006|5023799004|18002099003|22082099003|56012099006; X-Microsoft-Antispam-Message-Info: z98BJAapQbGjnQWpDVukuoYPfhs37B+gXqRv8JIEwgFli8nCpfzXF+UEKWlVL7otHk20w3nULdEm6kRzPs/h/YSqYvIej4gTgrhGK1tQ+8ZLkc19x8qUCyQQr206XHYMRVTrpnq1bDbEiwVa46iAOtVJAtBgMua6lXuKjcBg3dkDtlVlITCc7FXRhJsCnV2zMmCplTsCoQbbpT41zIU4jVaPovo3N8LnspDDbU88pXpFYsx0Iu9nbQykJIK1kHMp0g5e5lPgrtAdIlKA7ClWpsS+5l/Xw0N73ks7O5Zo2wvEyq2HDmt29s/b+xfJhBDL3RdODUJzp9C9JrDJt9Y5Y271hOY113HPyei2FUA/smhMxDNToDitEtCzaoUiWTXbQX4inMKRokzuqeDX5rRlBRqVAaaA79WxsFsGfzXTk4Uw4JeY7yMDlr8eRoC0K50Hp8R9ujY1SPhQhWKgmDBSnbe3Pfin2PorFniUBrDDHA15cNwwxXSnh2PjqV852StpM87dA+o1/Boatt23EDqFhtLnIZztw/BH+2NKB7N34hf1HEaSE98pLRXGYNPHSUKewTLOESTZzQq/dpoTALp3PDc8Mk/2VYPNjCIrIWvVoZllDTD5/m3SOt2gApCPfJ3OKbwKiGnnX0Qa/tg8XbkJRdLgS5Bn1F8T9uJhVTzyHnBMwYV0Ej4UIPl1RWfeIWhz+NqJfrJTPsfyHMSO7E1nP8KyPTD7rGkD+r2iRuPSvGI= 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)(6133799003)(10063799003)(11063799006)(5023799004)(18002099003)(22082099003)(56012099006);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: GANFnpz4/XLfJzynU1Wgk7c3zPS15GuGbc253MY0DG3oEZQ2c7FrA9qJ2H4uITkMnRRL3391ck71tBXYwEnMYp/xf13Cqgez/59wn9W39HTOg/LKlIdgPAUTKAYmUhEUah1+n0uGERhALYZ+l9kXbZ1EFopQgJJmRZ07Pq8QvtIPd4c8Y8VOfHTitPa+kmzI7RTX3zvNnQBO1LcqwXhH4iw9s42TN3C8VEZAtmMPhjXwcLxh4vnLpeKcGny4Qv/NUNfACJdFp4OjP8CiowlqE/L1KlLaEYiWIAb1lifTLb930Vr/5qsZ03QteKg1bfzJ8/jnMAUycabQ8n5El/WdrYxcJbn92mDQ4RRlOVzue4PS8dxWe46mLDf3Sn2eUlkbVN4bKHWtAnc3+iqYZlUxlLMFMZyfFO9m9F6AAVACaKGdcJoGw3uiQl54Kf0MI9vZ X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 May 2026 09:49:38.3180 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b7f7e28b-ebe2-4841-acda-08debc9e6ed6 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: BN2PEPF00004FC1.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA5PPF37951B1C9 Subsequent commits will allow update_curr() to throttle the hierarchy when the runtime accounting exceeds allocated quota. Call update_curr() before the unthrottle event, and in tg_unthrottle_up() to catch up on any remaining runtime and stabilize the "runtime_remaining" and "throttle_count" for that cfs_rq. Doing an update_curr() early ensures the cfs_rq is not throttled right back up again when the unthrottle is in progress. Since all callers of unthrottle_cfs_rq(), except one, already update the rq_clock and call rq_clock_start_loop_update(), move the update_rq_clock() in unthrottle_cfs_rq() to the lonely caller that doesn't update the rq_clock. Signed-off-by: K Prateek Nayak --- kernel/sched/fair.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 23742d928b51..b3b3172702a9 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -6711,6 +6711,15 @@ static int tg_unthrottle_up(struct task_group *tg, void *data) struct cfs_rq *cfs_rq = tg->cfs_rq[cpu_of(rq)]; struct task_struct *p, *tmp; + /* + * If cfs_rq->curr is set, the cfs_rq might not have caught up + * since the last clock update. Do it now before we begin + * queueing task onto it to save the need for unnecessarily + * unthrottle the hierarchy for this cfs_rq to be throttled + * right back again. + */ + update_curr(cfs_rq); + if (--cfs_rq->throttle_count) return 0; @@ -6853,14 +6862,16 @@ void unthrottle_cfs_rq(struct cfs_rq *cfs_rq) * We can't unthrottle this cfs_rq without any runtime remaining because * any enqueue in tg_unthrottle_up() will immediately trigger a throttle, * which is not supposed to happen on unthrottle path. + * + * Catch up on the remaining runtime since last clock update before + * checking runtime remaining. */ + update_curr(cfs_rq); if (cfs_rq->runtime_enabled && cfs_rq->runtime_remaining <= 0) return; cfs_rq->throttled = 0; - update_rq_clock(rq); - scoped_guard(raw_spinlock, &cfs_b->lock) { list_del_rcu(&cfs_rq->throttled_list); @@ -6935,6 +6946,7 @@ static inline void __unthrottle_cfs_rq_async(struct cfs_rq *cfs_rq) bool first; if (rq == this_rq()) { + update_rq_clock(rq); unthrottle_cfs_rq(cfs_rq); return; } -- 2.43.0