From nobody Tue Apr 7 20:08:12 2026 Received: from BL0PR03CU003.outbound.protection.outlook.com (mail-eastusazon11012023.outbound.protection.outlook.com [52.101.53.23]) (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 0387333344A for ; Thu, 12 Mar 2026 04:46:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.53.23 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773290819; cv=fail; b=uUBmR7MgvzJVDQjW5QFgRJO2VdVt52nhKD4SHb+qSe1HK/dnKUlxEc35Cqvupp9/niislk6qymjHWWY6WJe5T+6hbBnll2d/t44nZ0sQiY4W2k+Qw+gKw4lStNBCUHDbs5EBqEzrm/mJTbQL/tK1lHpwQBc1rSchnrIdVtfTBLs= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773290819; c=relaxed/simple; bh=r8XAAf/ioU9miosWvJ8wWy+KrfT69TejIwFb4b5HtDk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ePpk1JPLM4J4xr3eNt6l4CInemX30n57Y1QfhP3CVbW0VhCPZFUE/lPnfdHqWIggJDpVXXr8zB7RoRm/MD0wBnweUB3nnxEZJGs4hw5bEk9V6NrlKlPrwxSpzNe78y+7L1vC1Vn0zKyDfX9Ghj1e13T9WEPKvNbZF8/GUfZ96iI= 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=x+vq9W9N; arc=fail smtp.client-ip=52.101.53.23 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="x+vq9W9N" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ipmtgEuLvNpwlrlqcC8UeyjnmUEfSerrGXUW0QooW9do+IncDJCbtig+5uFB2yoLFaSKfngTebF5VZNxFHcOimFlm3tBAryI877O25L5solmhur50ofCBrPmIIvGxV10XOTtw9FPDV5dS27SMGm7ZQAKvX9mqBzWOvqClpT91q8sez06amcwO5DdTxljAQD23qnc81EPHMlxMKEvM0xoDJn9S5xBXfBPLJeODeuE4GJVWcK2gTUvmnSxORdfgJroqyk7EyGeoqAMfswG13T/pDex2PIdPr9tXBSMbAqSbYeVCPYywO/e5r/bGsHTCzG1wgp2miw+BMfEeMKHJ0u0WQ== 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=jJscSzlCikEMvRD3ay3lAUM1k1CKBMjQT9Bp5uipPDs=; b=yZgVqHQATXR2tOgbw/y+tCZMYsO/oUZujNgImWvbM12wqQ3z6lZrd3Oz524RGKnLBCRuFwCgqCjOyngFQGS47i/4QbChsNV+StoZ2bTqHF/pGpiVLXIbeip3eQc7gWcbQ9848LfChvCbMZAGh/B1FB6XzmMgYancg/PgZVZjlXq0mlZth+xoG6yefvoZJSGoZPg6WZmj4d+evtLAli1Wfs3BBJEO3Tla3K+TQfH5ruaZEgMYCDNu7feF8S76Q/u4JKp3p4bew+3kiAbdnhiLPIDulYoqJgygqgUwTOVmEiqxMSnLp2p90iEDIDExavW9qXV1sUX4Mx7IPf0m/VInmg== 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=jJscSzlCikEMvRD3ay3lAUM1k1CKBMjQT9Bp5uipPDs=; b=x+vq9W9Nn0LcmeqopdtpH2I+uRBjfbRoClHF7I8ojKuAthghoIBoICmdcidhyTzMJHuXVT8T1MKH9fWJe7tpEV1Dc/0XOcXhndz392gCtgYhCcZhHJf+dUBTgdCIMON0zjlZtYmDUJMmuE0j047OygQLNog+FVi7HvlO1aBVaeg= Received: from SJ0PR05CA0085.namprd05.prod.outlook.com (2603:10b6:a03:332::30) by MW5PR12MB5598.namprd12.prod.outlook.com (2603:10b6:303:193::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9700.11; Thu, 12 Mar 2026 04:46:54 +0000 Received: from MWH0EPF000C6185.namprd02.prod.outlook.com (2603:10b6:a03:332:cafe::b1) by SJ0PR05CA0085.outlook.office365.com (2603:10b6:a03:332::30) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9678.25 via Frontend Transport; Thu, 12 Mar 2026 04:46:54 +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 MWH0EPF000C6185.mail.protection.outlook.com (10.167.249.117) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9678.18 via Frontend Transport; Thu, 12 Mar 2026 04:46:53 +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; Wed, 11 Mar 2026 23:46:48 -0500 From: K Prateek Nayak To: Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Valentin Schneider , CC: Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Chen Yu , Shrikanth Hegde , Li Chen , "Gautham R. Shenoy" , K Prateek Nayak Subject: [PATCH v4 7/9] sched/fair: Remove superfluous rcu_read_lock() in the wakeup path Date: Thu, 12 Mar 2026 04:44:32 +0000 Message-ID: <20260312044434.1974-8-kprateek.nayak@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260312044434.1974-1-kprateek.nayak@amd.com> References: <20260312044434.1974-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: MWH0EPF000C6185:EE_|MW5PR12MB5598:EE_ X-MS-Office365-Filtering-Correlation-Id: 6a0a3ae7-d66f-46d9-0117-08de7ff2623a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|82310400026|36860700016|7416014|376014|22082099003|18002099003|56012099003; X-Microsoft-Antispam-Message-Info: xBCEIIIFSJAJvadqPJnH2EFtpn/kOomvGnZTyvxEBnr4Df0yR0zGTNNNukoa0qOvx/VmqoXgkvSPCwlX6gbmY5hEDqA5CT3MMaYAi2M28hDlgfyQ9MyroZfhA8SNzPrca6eEyBbMTB8tlnI5XijLxVPkNCadW/z7ysv0Z3j/B3NftjFdGFYCbonHv7kaWweOk2+evEOMhS8d1jEj4t/fciofozOhvUYC8nMJYAutPXC5Ux9DXC0czMo3mNBEn5QJsW7RJIPEffb1jQywAYGHPDVLxDkpMoeBolF7991wexoaox/GsLuTpGLcjR7GyurXkn00y7tWRCaj3LLArbUjS5yQfIdbnLQ+KJ2h8gh0YSQr90HrUluhOVTI6+eCEXuZnPjP8Y+hOmS5Zo++4uab2Fhmc4rUSQMw8QNsbREvhUYm1BV5tMQnaSpWToZmAKacYlkUixvGeiJRIvQecMp7rdi0hjcQb07SoMN7HsrArKkqOcii8lnnyv32E9cE1kHFZnXLgmhvolcEmP+19gOM9D8V4BnoMe2F/E+5W6NbheOHrw6YjPbVSkWu5U1E4Mpt1oUkPYWp99VoZWTs6n+3Yp3nhRbP9/rp2dj0HczrVqOs25DpGhjalfofSp3jUtKDT6vxUBrqQeGC3VHjBaro2TOVjkAxnbu22oYxsWfNVw6JBvfOAteZ1ybyRKLkewM7/qthl89SboCvaLowL2HyW8mNkQQQh0oWIBm6lWYv7xnaAEY8Lx9qzTX59kshNCYigHlFY9T7OI7MJKzpNXkhsw== 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)(36860700016)(7416014)(376014)(22082099003)(18002099003)(56012099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: cpaaZkJhxYL8yoU7QHFEGux6d4tLAktf3rHpTrqA6p+8KEBCN8WK0VuyxFDendJ2SFoscB8cw32GrjvoVcvWDcLgRnn5lzazqaAiu293q8R6YgSAh4jSfaV15QUxen4QGjxLaX9Gn1FqxKVDqyCGGKz3mbW3CZ95JnHJkCO52GPKPi1TLMHCwRPUBVRtYHcNkPES0lAp0LRXfsVWBKnP5CxK14N65LmV9aseuJ/ncoXgcjUQt0Jx5NeaZnw8e85EcbbA58Cr8fuufVnxbqj9Ac6pJe/hBvyhXt1NBBKnnKcIgZlsvDhGxVdSt6WsSuBZOs8u1XIqBBNfmKrSIowv9ZzOPrAuDulwAh6TjrPsr18lFLGFpldVT5FOFz6AX71JUe7tdrXstF9fYqo/34qudfCB0N0HnotpMClJcJ6LSbMoMWOmkyrT7QLWuQjRpwSv X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Mar 2026 04:46:53.8615 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6a0a3ae7-d66f-46d9-0117-08de7ff2623a 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: MWH0EPF000C6185.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW5PR12MB5598 Content-Type: text/plain; charset="utf-8" select_task_rq_fair() is always called with p->pi_lock held and IRQs disabled which makes it equivalent of an RCU read-side. Since commit 71fedc41c23b ("sched/fair: Switch to rcu_dereference_all()") switched to using rcu_dereference_all() in the wakeup path, drop the explicit rcu_read_{lock,unlock}() in the fair task's wakeup path. Future plans to reuse select_task_rq_fair() / find_energy_efficient_cpu() in the fair class' balance callback will do so with IRQs disabled and will comply with the requirements of rcu_dereference_all() which makes this safe keeping in mind future development plans too. Signed-off-by: K Prateek Nayak Reviewed-by: K Prateek Nayak --- Changelog v3..v4: o No changes. --- kernel/sched/fair.c | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index d57c02e82f3a..28853c0abb83 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -8570,10 +8570,9 @@ static int find_energy_efficient_cpu(struct task_str= uct *p, int prev_cpu) struct perf_domain *pd; struct energy_env eenv; =20 - rcu_read_lock(); pd =3D rcu_dereference_all(rd->pd); if (!pd) - goto unlock; + return target; =20 /* * Energy-aware wake-up happens on the lowest sched_domain starting @@ -8583,13 +8582,13 @@ static int find_energy_efficient_cpu(struct task_st= ruct *p, int prev_cpu) while (sd && !cpumask_test_cpu(prev_cpu, sched_domain_span(sd))) sd =3D sd->parent; if (!sd) - goto unlock; + return target; =20 target =3D prev_cpu; =20 sync_entity_load_avg(&p->se); if (!task_util_est(p) && p_util_min =3D=3D 0) - goto unlock; + return target; =20 eenv_task_busy_time(&eenv, p, prev_cpu); =20 @@ -8684,7 +8683,7 @@ static int find_energy_efficient_cpu(struct task_stru= ct *p, int prev_cpu) prev_cpu); /* CPU utilization has changed */ if (prev_delta < base_energy) - goto unlock; + return target; prev_delta -=3D base_energy; prev_actual_cap =3D cpu_actual_cap; best_delta =3D min(best_delta, prev_delta); @@ -8708,7 +8707,7 @@ static int find_energy_efficient_cpu(struct task_stru= ct *p, int prev_cpu) max_spare_cap_cpu); /* CPU utilization has changed */ if (cur_delta < base_energy) - goto unlock; + return target; cur_delta -=3D base_energy; =20 /* @@ -8725,7 +8724,6 @@ static int find_energy_efficient_cpu(struct task_stru= ct *p, int prev_cpu) best_actual_cap =3D cpu_actual_cap; } } - rcu_read_unlock(); =20 if ((best_fits > prev_fits) || ((best_fits > 0) && (best_delta < prev_delta)) || @@ -8733,11 +8731,6 @@ static int find_energy_efficient_cpu(struct task_str= uct *p, int prev_cpu) target =3D best_energy_cpu; =20 return target; - -unlock: - rcu_read_unlock(); - - return target; } =20 /* @@ -8782,7 +8775,6 @@ select_task_rq_fair(struct task_struct *p, int prev_c= pu, int wake_flags) want_affine =3D !wake_wide(p) && cpumask_test_cpu(cpu, p->cpus_ptr); } =20 - rcu_read_lock(); for_each_domain(cpu, tmp) { /* * If both 'cpu' and 'prev_cpu' are part of this domain, @@ -8808,14 +8800,13 @@ select_task_rq_fair(struct task_struct *p, int prev= _cpu, int wake_flags) break; } =20 - if (unlikely(sd)) { - /* Slow path */ - new_cpu =3D sched_balance_find_dst_cpu(sd, p, cpu, prev_cpu, sd_flag); - } else if (wake_flags & WF_TTWU) { /* XXX always ? */ - /* Fast path */ - new_cpu =3D select_idle_sibling(p, prev_cpu, new_cpu); - } - rcu_read_unlock(); + /* Slow path */ + if (unlikely(sd)) + return sched_balance_find_dst_cpu(sd, p, cpu, prev_cpu, sd_flag); + + /* Fast path */ + if (wake_flags & WF_TTWU) + return select_idle_sibling(p, prev_cpu, new_cpu); =20 return new_cpu; } --=20 2.34.1