From nobody Fri Dec 19 13:09:42 2025 Received: from CH1PR05CU001.outbound.protection.outlook.com (mail-northcentralusazon11010040.outbound.protection.outlook.com [52.101.193.40]) (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 E1D9E32B9A0 for ; Mon, 8 Dec 2025 09:36:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.193.40 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765186568; cv=fail; b=Q01UXRKEiuqe8T0uAFh55nE2wdNj/ZsscxRCxvMQGixW38H8SIgcAV3f5Kkutu3dPbxoVL41V7PMNGTKiIMDI6kfXJZ7wloQwL5dI+wTPAPzzfUqFqMBpFwZ6aLr48EQAl+QYLq091TUCtOSQ+wt+IbQ5DqH45/MZzMba0ZPBJI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765186568; c=relaxed/simple; bh=2+X1reRtF8/g41KwNmYTMgvV3Gs9w9feS6xXxiiNkys=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=fwJW61HvVieW5NLxk0+exR4WBa0VlfLC3qIA2xM+LGxUFxpoblRegYr++JAqrzx5jOZDNEam2QpD8lsklPTTOx3EoNLKMMKKrT4ReNW5tBaj+3tE9oZC/Wev0/rRSIDDXp8DbuM+aXZLuFf45Eisx1zKtsf9GDh+PxAAk8TI1Lo= 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=ukNDOg5b; arc=fail smtp.client-ip=52.101.193.40 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="ukNDOg5b" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=xSsdcDwoc1StlMOuTwIwqb6NgoTpOpAjkycOjG0BxGock9SZkN0AZXNjVzzYcRkkNR87KtmlIQWUUwbVxkZwA6mrZ4C7XwSf/EEwI0TVf7Rl7lCqUBRSk3fLnvb5RLsMI8N9YTQUT0JyV7s+CilTgC4eir7kI7obW0Imf2y/SHont8So/B58UP0PqahlAaLc2adDa60hCmk21TxukysnJXjYflAa2HCLw2grDMGcWj7mRFnO94C4lfdaQaAGVerv6IYySv9mDsSW0iPDBzS+RHeQHFRUUisSoiYm5+9KliBNNMGoVFahflZEUGYwzHmrHY3iD/aaQSvgMa8vCe3tpA== 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=B6xSUgTXgeDf69DR+JCVM+vEImy1GuNGQ83SeNEzXYA=; b=YVI8wz6RJCr84AEt94VIOCG/qwqfidBu0eEDVFAMkSZA7pcbBtqqKAZ7Xv9tbr25dQJG+Uw4rcpCzHFMjowvu74iQenptF7Aa4QdPpT21J0mSGW2yBT/svM9FNHR1XgRrJJ4mgCkTcpHTUPj5E4WFOKrYkaJL5brFVEzT3FmpVXoyk0Ca4qKGuN+29G7H9dFlgwLfZogr44bblMxluLIFs/YDEWdQdC2CPtTxY+vBnw5AfM1+AARe1VqOcboVcJ6TpUB2tQLyJr0EO7B1VCsOgppdqAbGsHX4XCOLC0eeOOGXRtdp1K+yCIPdjJCsgJJtLkT9xxSeea/Iz28R03rRA== 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=B6xSUgTXgeDf69DR+JCVM+vEImy1GuNGQ83SeNEzXYA=; b=ukNDOg5b/aNgM6c36M50C2RS4K7eILvEsQAIQkRBTohXWc+Hl3TGKTGhEyOhOs9EdzPwZ7GomkZTPsBRKNzGesmuR/2r43VSnAWzh4Ou4M5T5PY5aUUPWbEuh2TL/LtphXkNf/4MPH0wwx2qzGFNSAPL3iOKSgaJQCcTMnOqXt0= Received: from CH0PR03CA0305.namprd03.prod.outlook.com (2603:10b6:610:118::7) by IA1PR12MB6305.namprd12.prod.outlook.com (2603:10b6:208:3e7::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9388.14; Mon, 8 Dec 2025 09:36:00 +0000 Received: from DS3PEPF0000C37E.namprd04.prod.outlook.com (2603:10b6:610:118:cafe::42) by CH0PR03CA0305.outlook.office365.com (2603:10b6:610:118::7) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9388.14 via Frontend Transport; Mon, 8 Dec 2025 09:35:31 +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 DS3PEPF0000C37E.mail.protection.outlook.com (10.167.23.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9412.4 via Frontend Transport; Mon, 8 Dec 2025 09:35:59 +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.17; Mon, 8 Dec 2025 03:35:54 -0600 From: K Prateek Nayak To: Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Anna-Maria Behnsen , Frederic Weisbecker , Thomas Gleixner CC: , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Valentin Schneider , K Prateek Nayak , "Gautham R. Shenoy" , Swapnil Sapkal , Shrikanth Hegde , Chen Yu Subject: [RESEND RFC PATCH v2 28/29] [EXPERIMENTAL] sched/fair: Add a local counter to rate limit task push Date: Mon, 8 Dec 2025 09:27:14 +0000 Message-ID: <20251208092744.32737-28-kprateek.nayak@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251208083602.31898-1-kprateek.nayak@amd.com> References: <20251208083602.31898-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: quoted-printable 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: DS3PEPF0000C37E:EE_|IA1PR12MB6305:EE_ X-MS-Office365-Filtering-Correlation-Id: ed2c1ece-467c-47d1-ed17-08de363d3262 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|7416014|82310400026|36860700013|376014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?IHoWBMu5YkO8fHQLmsQf36ZugR62pz5pE/pI63OZtM1Mp0yMAQ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QaEye4NtYp1TwlebgMvjY2fNqj4ThdGxgDDpVkL8Dw6UZ?= =?us-ascii?Q?JyiFwLi9vul/I88dgLbhaVPu/6YAYzIYUOc7a0cTvx9+hs/rtlaO7MsIYVli?= =?us-ascii?Q?MGPBWTGORCwDnSHyevr+uEvWwpqIUtXNhY4DU0LynyZQWtwFaPIaxPJVtEf9?= =?us-ascii?Q?WUJcUL17t8jlRTs3h0uXvzD9e5wy83SA8z1PRs8jiwRNqVmPitAQYiKGJWag?= =?us-ascii?Q?6TZmDWzeO4f2vt3/tVB3yrhFjmAww1xjwuFaARmqRkSRoyoTBI11ULeQjWFT?= =?us-ascii?Q?XDPBWS7Hc0YkW9fonXf+PPgoEHb0OFlr3ABispJRKCvOXCkysn+oPa3xv77f?= =?us-ascii?Q?6dZzCpD+LYFr7MXsutfAAJD9lCXkB/qSMj16e+vstMwWiWTakjAq/HzDOorY?= =?us-ascii?Q?hD9v6PBU+m6D8TJP4hPOggGihdFhLkRCZqHmGG+mzhniC+DWrFnyUlEcpohu?= =?us-ascii?Q?PHYbQdwesAP4hubAMqv2Qqqi/1gHBnVjBUS2HPLttPpu1J0fNbx4GM/Viclo?= =?us-ascii?Q?0ExBaJ9PXArO6dfGpPUnHpa2neHaFUUfK88fPOT+hNXjPui3L9uAOW1ptBF6?= =?us-ascii?Q?mT9A7BqzTsqYMTXTgAtOT6vUGZZNyTKOdjGc3hvxW0dXIhLedYVnEIzulneD?= =?us-ascii?Q?IsJjU6n8A4k7o+QATcs=3D?= 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)(7416014)(82310400026)(36860700013)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Dec 2025 09:35:59.8639 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ed2c1ece-467c-47d1-ed17-08de363d3262 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: DS3PEPF0000C37E.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6305 Content-Type: text/plain; charset="utf-8" Pushing tasks can fail for multitude of reasons - task affinity, the unavailability of an idle CPUs by the time balance callback is executed, etc. Maintain a CPU local counter in sched_domain to rate limit push attempts if the failures build up. This counter is reset at the time of periodic balance to the value in "nr_idle_scan". Since "nr_idle_scan" is only computed for SIS_UTIL, rate limiting has been guarded behind the same sched_feat(). Signed-off-by: K Prateek Nayak --- include/linux/sched/topology.h | 4 ++++ kernel/sched/fair.c | 23 +++++++++++++++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/include/linux/sched/topology.h b/include/linux/sched/topology.h index 074ee2980cdf..ebe26ce82c1a 100644 --- a/include/linux/sched/topology.h +++ b/include/linux/sched/topology.h @@ -122,6 +122,10 @@ struct sched_domain { unsigned int alb_failed; unsigned int alb_pushed; =20 + /* Push load balancing */ + unsigned long last_nr_push_update; + int nr_push_attempt; + /* SD_BALANCE_EXEC stats */ unsigned int sbe_count; unsigned int sbe_balanced; diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 34aeb8e58e0b..46d33ab63336 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -12356,6 +12356,16 @@ static void sched_balance_domains(struct rq *rq, e= num cpu_idle_type idle) rq->max_idle_balance_cost =3D max((u64)sysctl_sched_migration_cost, max_cost); } + if (sched_feat(SIS_UTIL)) { + sd =3D rcu_dereference(per_cpu(sd_llc, cpu)); + + if (sd && sd->shared && + time_after_eq(jiffies, sd->last_nr_push_update + sd->min_interval)) { + sd->nr_push_attempt =3D READ_ONCE(sd->shared->nr_idle_scan); + sd->last_nr_push_update =3D jiffies; + } + } + rcu_read_unlock(); =20 /* @@ -13110,8 +13120,6 @@ static inline bool should_push_tasks(struct rq *rq) struct sched_domain *sd; int cpu =3D cpu_of(rq); =20 - /* TODO: Add a CPU local failure counter. */ - /* CPU doesn't have any fair task to push. */ if (!has_pushable_tasks(rq)) return false; @@ -13126,6 +13134,10 @@ static inline bool should_push_tasks(struct rq *rq) if (!sd) return false; =20 + /* We've failed to push task too many times. */ + if (sched_feat(SIS_UTIL) && sd->nr_push_attempt <=3D 0) + return false; + /* * We may not be able to find a push target. * Skip for this tick and depend on the periodic @@ -13176,6 +13188,13 @@ static bool push_fair_task(struct rq *rq) return true; } =20 + /* + * If the push failed after a full search, decrement the + * attempt counter to dicourage further attempts. Periodic + * balancer will reset the "nr_push_attempt" after a while. + */ + sd->nr_push_attempt--; + return false; } =20 --=20 2.43.0