From mboxrd@z Thu Jan 1 00:00:00 1970 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 C96C03D75BE for ; Tue, 28 Apr 2026 08:34:10 +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=1777365252; cv=fail; b=mTQtEFDXXvClKfXlcnSTocrbiE7Yt3f+Tw0joi1d9BH5xgC2caMwlGoEKFmiHikMWcMmor22J35MGBQdhecZ+baqjSANtetnVeteBk3VBg4GPjnGb3DKR/4O4P0DKvlMY0/ZYclqPgbBnktgTPhl4+Mc8cbdp38QmsTPA0M2y7w= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777365252; c=relaxed/simple; bh=2cNTQ3CzVDq3yWMBgUaOHnpIrvdX4VJlHZY9onieWt4=; h=Message-ID:Date:MIME-Version:Subject:To:CC:References:From: In-Reply-To:Content-Type; b=KmnHkrddDD1euHud3SHSHTVm6ZQa5ehLJ0xv2rmc+lJuikJslY/Wn5EADzS5Ha0KywRIHhlGnf5x1CGqcXcdZ8vzR3jWtNLQuKRQfGlIw/92LUHSNJwsCY5JadVD94iinGAJzZsqk4xq5JEnYxGafh6khAPTrU+LivTjOQP+oYE= 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=4IFO7wvf; 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="4IFO7wvf" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=EHAuI9UWH3hph4D34+JULKCFsRPEaHlmyNh9vg0h5QQoXFJojq9t2X9dVAU+EMk6nHrGXT5wTOpGIfpcBwv+dTOiNSoCLSkrnBSlE1A6GUuQILl1wJOxDbTYsPY97oiw+xMvNxa31qclR/KyNcgx6jTTV8fli/uoBsPSYoBE2BxU2gH1kZRSpRGwOy2D4UuS9ip/Or5wFPvwzSjGsp1oiEqvDOBZQQMHj4MDyLBsZijnjXUlSgIXT51PazKHS3N2BzC2d3NpExTkEmWX/8RNZg+zTxk5N1sgZury8RobH0PkoivBvECmSQXBnEn5/bZlD9cI/sj8XubyaUGnybGMWg== 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=Ln/RfaxDrpt2gAFLC6TRgiFeUNkOk94yvQo3yJIEZo4=; b=QmPUzoY2kr5C5bDPKrY01tq6wo9+HRyrXXZOYbvCyo4Sgx4ArekvqlwzIKFvX5ZMQ/YXe2umZ/LXD9D9IkR8W8u8lTaDESW6BEJITQM2iUdRMSrpWEagbPqu6UtHRroiKeBWjEzHVPk50rzYp4xQ99yVvAQEYQtJ89XM+WyWDYEZLGg4mMw64NQAZuzSBXw24Q22uqm7fKOFWteM5kl23Qzm0YoGM6Fe2YaNX6Xsc5O7LWIN3f6YGb1snVSjYpbzpEGKGPgwMsAxZ5T7zLvpHndxQLOfk8fEtU0q22BEMZUN9yhdwSNT1dvsIAZjtNLnSz7YJsoR+CGZR3SLmhGn+A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=nvidia.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=Ln/RfaxDrpt2gAFLC6TRgiFeUNkOk94yvQo3yJIEZo4=; b=4IFO7wvfBLDoh8SbRIN9XBn/zcq5hPTdLYTUDB8GMa/EKCu1gW0BBFQMz9sUyFnJ5+ukNdxCUWBTf6QPlldKhQsOogxQMPMwn59aNt6RCflO91ocEqlPkT38dVcWXdDkvfZGZle4OWwee8MjLfakZ14sKE53Bw2bjOlPnWQgJ9g= Received: from BN9PR03CA0624.namprd03.prod.outlook.com (2603:10b6:408:106::29) by LV2PR12MB5871.namprd12.prod.outlook.com (2603:10b6:408:174::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9870.17; Tue, 28 Apr 2026 08:34:06 +0000 Received: from BN3PEPF0000B072.namprd04.prod.outlook.com (2603:10b6:408:106:cafe::f0) by BN9PR03CA0624.outlook.office365.com (2603:10b6:408:106::29) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9846.27 via Frontend Transport; Tue, 28 Apr 2026 08:34:06 +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 BN3PEPF0000B072.mail.protection.outlook.com (10.167.243.117) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9846.18 via Frontend Transport; Tue, 28 Apr 2026 08:34:06 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.2.2562.17; Tue, 28 Apr 2026 03:34:06 -0500 Received: from satlexmb07.amd.com (10.181.42.216) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 28 Apr 2026 03:34:05 -0500 Received: from [10.136.41.76] (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server id 15.2.2562.17 via Frontend Transport; Tue, 28 Apr 2026 03:34:00 -0500 Message-ID: <0882ce78-a51f-4317-a1b4-624e39e65507@amd.com> Date: Tue, 28 Apr 2026 14:03:59 +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 1/6] sched/fair: Use guard(rcu) for sched_domain RCU sections To: Andrea Righi , Ingo Molnar , "Peter Zijlstra" , Juri Lelli , "Vincent Guittot" CC: Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Valentin Schneider , Christian Loehle , Koba Ko , Felix Abecassis , Balbir Singh , Joel Fernandes , Shrikanth Hegde , References: <20260428051720.3180182-1-arighi@nvidia.com> <20260428051720.3180182-2-arighi@nvidia.com> Content-Language: en-US From: K Prateek Nayak In-Reply-To: <20260428051720.3180182-2-arighi@nvidia.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Received-SPF: None (SATLEXMB04.amd.com: kprateek.nayak@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN3PEPF0000B072:EE_|LV2PR12MB5871:EE_ X-MS-Office365-Filtering-Correlation-Id: c24512b5-8cd4-4293-9211-08dea500e93a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|36860700016|376014|7416014|1800799024|56012099003|18002099003|22082099003; X-Microsoft-Antispam-Message-Info: PLfNJjiOl+YBqARZsAZ6iXDp69vvE5rZvypIiFWQiiCyyS1ewrgvVQXOSX1l/RoUpFNwcU5s9Z7ebq2dK9nJGkVySDFuT6+0A22LbJPSnhvbPVFYK3vgHks1GEMDuuMhXLmLtnogaVUVuf1vgDBg9Q8JL44osJSr+7R8zBgFF7XBfHmuOicvRiEo14+9OvLO+ZLZUkEKhw7Sq84j24EHmClASI+ppWLruTShiX17jz4amWb5Pcuunfz0KG6B0+m7QklV8+2Bg3km+mrA9f1hxY2k+8LdjirWpfC0xtY756CBud/ldGeqYrJOdleJMLn6zUDTxcellhq2jTUq1I/wVdxK4pIFrnhzaj4VW1K9b0sX3t7thIB0uDUYreVc1Fv0tOhyAgqRbD7LTv6A21by+r+/L/MaIJAUR9qiTfb76lkX0qnmxiZVB7lf+1P4L5irOd45CTRm+2apF6fVMVWSGW1mFi2z14+GD+DbKTEaKdtcxfzX4mJxTOD/D9bsbsWYNtGRhPoHwyHhvaOJjv+zKzg/SYRY0QwXWYCJhgCGP8Yp/kCW5D+VQ6x/a9sIGRKff4yepVLQOmcS6wkyQm6HrlyjBmH9mgTzP24yAdXL0v3c0ZhPRUJU0Ej1yj2ui4feSbRqk7GObyKl6Bu9OQKvSoRnwMof8SuFhOH/wUjNmYxwZcHe/TTvEOszxuBZVFvVvEMk/sEj1CkH9ylU78E1xota5W6eH1fQASdjbbEutaiFXcn/2RbR7iFgAXZbXwGDbJbUijU3CNrOLE4+cqtWKA== 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)(82310400026)(36860700016)(376014)(7416014)(1800799024)(56012099003)(18002099003)(22082099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 8xaGXnjRL6gFTr30AU7rLEBomSScWE1vZcCmIXSwQHhfjb90NIZWqoIC+h+Vg166jh82LyFh0sP7By0zNcRaNs6r8LRbJoMGYik+60ZVH4+8tJUINKCDF/FyzWe3MYEu7aOGer3hebcIoTGVU/D2839j4AF1OLB+1q5AgnjMYd43mdjz4y61q4LDWzswK4K/K7B4KG6Jysb3NGisSeaSGZX893IMqyG33QuqKkDMXvQmM0cdeqMWkBYoXGskkrv4JIHJJzLaMJVHAuKB0/VB7AlOeWWcC4SEJQGjzKJ/UxXCTgHAaqnqnvOX4JTAPnAOY0dSpalgJJVifBb9VbBAugIKmJDtdZzkdyRaXP7bWJXGUEGDo0tzT6diXup8wrKHLiSUEsjYQF6O0+8+52oIgaCZHtU5U7RGlZkLeqySQQ0uTol7VD9tkGXMcX9fvc2z X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Apr 2026 08:34:06.4276 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c24512b5-8cd4-4293-9211-08dea500e93a 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: BN3PEPF0000B072.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV2PR12MB5871 Hello Andrea, On 4/28/2026 10:46 AM, Andrea Righi wrote: > Use the scoped guard(rcu)() helper to safely access sched_domain > pointers. > > No functional change intended, this is preparation for topology work > where sched_domain lifetimes are easier to reason about with explicit, > scope-bounded RCU critical sections. > > Suggested-by: K Prateek Nayak > Signed-off-by: Andrea Righi > --- > kernel/sched/fair.c | 141 ++++++++++++++++++++++---------------------- > 1 file changed, 71 insertions(+), 70 deletions(-) > > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c > index 69361c63353ad..fc0828150c780 100644 > --- a/kernel/sched/fair.c > +++ b/kernel/sched/fair.c > @@ -8083,6 +8083,8 @@ static int select_idle_sibling(struct task_struct *p, int prev, int target) > */ > lockdep_assert_irqs_disabled(); > > + guard(rcu)(); Since IRQs are disabled, we don't need an addition RCU read lock here. See a03fee333a2f ("sched/fair: Remove superfluous rcu_read_lock()") > + > if (choose_idle_cpu(target, p) && > asym_fits_cpu(task_util, util_min, util_max, target)) > return target; > @@ -12701,55 +12703,16 @@ static void kick_ilb(unsigned int flags) > } > > /* > - * Current decision point for kicking the idle load balancer in the presence > - * of idle CPUs in the system. > + * Decide whether the ILB needs a stats and/or balance kick based on > + * sched_domain state. > */ > -static void nohz_balancer_kick(struct rq *rq) > +static bool nohz_balancer_needs_kick(struct rq *rq) > { > - unsigned long now = jiffies; > struct sched_domain_shared *sds; > struct sched_domain *sd; > int nr_busy, i, cpu = rq->cpu; > - unsigned int flags = 0; > - > - if (unlikely(rq->idle_balance)) > - return; > - > - /* > - * We may be recently in ticked or tickless idle mode. At the first > - * busy tick after returning from idle, we will update the busy stats. > - */ > - nohz_balance_exit_idle(rq); > - > - if (READ_ONCE(nohz.has_blocked_load) && > - time_after(now, READ_ONCE(nohz.next_blocked))) > - flags = NOHZ_STATS_KICK; > - > - /* > - * Most of the time system is not 100% busy. i.e nohz.nr_cpus > 0 > - * Skip the read if time is not due. > - * > - * If none are in tickless mode, there maybe a narrow window > - * (28 jiffies, HZ=1000) where flags maybe set and kick_ilb called. > - * But idle load balancing is not done as find_new_ilb fails. > - * That's very rare. So read nohz.nr_cpus only if time is due. > - */ > - if (time_before(now, nohz.next_balance)) > - goto out; > > - /* > - * None are in tickless mode and hence no need for NOHZ idle load > - * balancing > - */ > - if (unlikely(cpumask_empty(nohz.idle_cpus_mask))) > - return; > - > - if (rq->nr_running >= 2) { > - flags = NOHZ_STATS_KICK | NOHZ_BALANCE_KICK; > - goto out; > - } > - > - rcu_read_lock(); > + guard(rcu)(); and since this is only called from: sched_tick() /* IRQs disabled */ sched_balance_trigger() nohz_balancer_kick() with IRQs disabled, we can get rid of that rcu_read_lock() entirely. > > sd = rcu_dereference_all(rq->sd); > if (sd) { -- Thanks and Regards, Prateek