From nobody Mon Apr 6 19:59:13 2026 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 713F037AA81; Wed, 18 Mar 2026 08:08:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773821319; cv=none; b=cY/FYfFm5/oPyQAmNSS3+CaVgjb8BZavj+IFooW4KvSITPXEedFpDtAK4H6Rbz7iKjCtg56VSnJoITREHjlJHB3iPvG4Q+x0EGm0qSZ80tufypZ7RkmI2fhtgbSLogAf8EhVFcnJlzGZv1IISQZgW1zWEebfKcsNZYOfLgSiC2o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773821319; c=relaxed/simple; bh=m+8oFhVYwANqlUBL2MHbeiy0jKaU5T+0Viy1B6HItzw=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=LbPNAv/p7h+RqnGx8CZP8hQPHXmOPzI0jS7kOVcU+O/3Bm4QdXlglG2iGfSQE0EfzFTScV0Ok7bK3L9LN9luPxAEKYIqJ/nNd0ObUwloCvBxysGP9kuWBf8CHVsNsX0wrmxeMInKw1ilLgca8uxjvg8bDTNlyWCZuBADjp1Yo2A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=tgdOLaoG; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=eF1KtICG; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="tgdOLaoG"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="eF1KtICG" Date: Wed, 18 Mar 2026 08:08:35 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1773821316; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Sx7S0EcUJydCY6chnVJobZM7O/XX2+EYdWRcL+LFlbg=; b=tgdOLaoGX/mRQ+0HsMxTdRFcbYiAyT5SyjhQNjkn3lcnBrU5mTAlF+ifr3XcSpIDrUa8e1 i0D7fw8UYf7BphajdX2zFW/ENfpk+/9R3v/7ARDL4DwiLzLl2uZeq3485EfLSxNS1OLv0o WfiYfGicTfGIGd++wQJGubBOv1qKfADAqXnyLHh2miVjMgtQLh7mHWtN0M6cWKAo5gg8uR jWxtrkeq8b3UO/f1lJ+XMnp+0+/d0wJzdZPFOADaeHYAwW9B3dOnqHu6uI9Q4auuQEqMel BFPGAxB3LAHCgY0LAGUDBe7+SERhQO5e77Cq9frnv9hYXe/c5EcLr8xNnbmERA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1773821316; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Sx7S0EcUJydCY6chnVJobZM7O/XX2+EYdWRcL+LFlbg=; b=eF1KtICG04M/dSmNoYVbzoofky6cSkCE+LW7/9H8AZSI+2UUMh9MeKDl8PV8S21oeOA/Nr ekwWU/LWKaAK73Bw== From: "tip-bot2 for K Prateek Nayak" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: sched/core] sched/fair: Remove superfluous rcu_read_lock() in the wakeup path Cc: K Prateek Nayak , "Peter Zijlstra (Intel)" , Dietmar Eggemann , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20260312044434.1974-8-kprateek.nayak@amd.com> References: <20260312044434.1974-8-kprateek.nayak@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <177382131541.1647592.8660794408766878941.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The following commit has been merged into the sched/core branch of tip: Commit-ID: fa6874dfeee06352ce7c4c271be6a25d84a38b54 Gitweb: https://git.kernel.org/tip/fa6874dfeee06352ce7c4c271be6a25d8= 4a38b54 Author: K Prateek Nayak AuthorDate: Thu, 12 Mar 2026 04:44:32=20 Committer: Peter Zijlstra CommitterDate: Wed, 18 Mar 2026 09:06:50 +01:00 sched/fair: Remove superfluous rcu_read_lock() in the wakeup path 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 Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Dietmar Eggemann Tested-by: Dietmar Eggemann Link: https://patch.msgid.link/20260312044434.1974-8-kprateek.nayak@amd.com --- 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 c1e5c82..3e24d3e 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; }