From nobody Mon Apr 6 19:59:39 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 327D4379999; Wed, 18 Mar 2026 08:08:36 +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=1773821317; cv=none; b=UZ7a+GQzD9mrjhXIWwSq7ax0o2cwG4V6GTn1mY9qDjmbHpve61M1uOSs9UHqyuqRRmO2Um4O7dEFKrrWkGbbXRTf9/DXayNuQbXuRuPz67bkgo/PdnZc6KniVktARBnuOUrtMLeB5axA+h1oIo9V9aocpQFUNZDeFSNvU5Kd3uQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773821317; c=relaxed/simple; bh=CMLIA5KRiiOR11XGBD19sHdqkt6Us+RAvps0SpZQeBU=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=GBzp923e4p6VRWaRgtr8faj/Y9pkHha/Id5i4Maew4d3F0+YIhDpPgVpKGXTiRbLM/x26y98DPlzH5wE4/goCr9hEl4pFCjJdNq7+AchJihPK/pksWqwoseYKl52Gj0EkeuqX6+A+M82/gobOwAXmJQVt1eeX4fBQdsyNAkuEjI= 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=dkYvA9P6; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=U459kL5O; 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="dkYvA9P6"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="U459kL5O" Date: Wed, 18 Mar 2026 08:08:32 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1773821314; 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=N8wbjlDt1nROSgkRMk0ZA3V5gsIs5brhapCG4dSDb/Y=; b=dkYvA9P6eGUjIq83GqngMlJt3TMkfcHFDM428bnm4w21lB3bBl9N7loudTTdNzgCp9Rghy nYCr7BViAEb3Dz3kCSbtAD47VkuFL/VUWRgsYShg96238LAP5Z1tKWPbIFY//8kkJSh5od Efe5T9cnJCp/IL+wtguSh8zVvOtH7Bw9FXexdJnukMJmVufIm2Pgiq/YU/yTBFPsscUXB5 63L4y3YA/WshqWUcnbuelwFoeBleYtMzHinkmzEzRHlRHHDwJXc9kLsGAbyftjmaF7KqsW WIBAXIrJxvcgTuGeg5OCCEOJbqLs9PKSC+sqreb7/p5gAqPgq5BWOB7Fh6H9YA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1773821314; 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=N8wbjlDt1nROSgkRMk0ZA3V5gsIs5brhapCG4dSDb/Y=; b=U459kL5O45Sz+JVUykkVc4Ao0TL5N8XJW8/rOwg2H7Nt0a0DJM/YCT7Q8lKUW0Wd7n1OsG mUorVwqgHvbdM7DA== 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: Simplify SIS_UTIL handling in select_idle_cpu() Cc: K Prateek Nayak , "Peter Zijlstra (Intel)" , Chen Yu , Shrikanth Hegde , Dietmar Eggemann , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20260312044434.1974-10-kprateek.nayak@amd.com> References: <20260312044434.1974-10-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: <177382131293.1647592.13947570075052572383.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: fe7171d0d5dfbe189e41db99580ebacafc3c09ce Gitweb: https://git.kernel.org/tip/fe7171d0d5dfbe189e41db99580ebacaf= c3c09ce Author: K Prateek Nayak AuthorDate: Thu, 12 Mar 2026 04:44:34=20 Committer: Peter Zijlstra CommitterDate: Wed, 18 Mar 2026 09:06:50 +01:00 sched/fair: Simplify SIS_UTIL handling in select_idle_cpu() Use the "sd_llc" passed to select_idle_cpu() to obtain the "sd_llc_shared" instead of dereferencing the per-CPU variable. Since "sd->shared" is always reclaimed at the same time as "sd" via call_rcu() and update_top_cache_domain() always ensures a valid "sd->shared" assignment when "sd_llc" is present, "sd_llc->shared" can always be dereferenced without needing an additional check. While at it move the cpumask_and() operation after the SIS_UTIL bailout check to avoid unnecessarily computing the cpumask. Signed-off-by: K Prateek Nayak Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Chen Yu Reviewed-by: Shrikanth Hegde Reviewed-by: Dietmar Eggemann Tested-by: Dietmar Eggemann Link: https://patch.msgid.link/20260312044434.1974-10-kprateek.nayak@amd.com --- kernel/sched/fair.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 85c22f0..0a35a82 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -7876,21 +7876,26 @@ static int select_idle_cpu(struct task_struct *p, s= truct sched_domain *sd, bool=20 { struct cpumask *cpus =3D this_cpu_cpumask_var_ptr(select_rq_mask); int i, cpu, idle_cpu =3D -1, nr =3D INT_MAX; - struct sched_domain_shared *sd_share; - - cpumask_and(cpus, sched_domain_span(sd), p->cpus_ptr); =20 if (sched_feat(SIS_UTIL)) { - sd_share =3D rcu_dereference_all(per_cpu(sd_llc_shared, target)); - if (sd_share) { - /* because !--nr is the condition to stop scan */ - nr =3D READ_ONCE(sd_share->nr_idle_scan) + 1; - /* overloaded LLC is unlikely to have idle cpu/core */ - if (nr =3D=3D 1) - return -1; - } + /* + * Increment because !--nr is the condition to stop scan. + * + * Since "sd" is "sd_llc" for target CPU dereferenced in the + * caller, it is safe to directly dereference "sd->shared". + * Topology bits always ensure it assigned for "sd_llc" abd it + * cannot disappear as long as we have a RCU protected + * reference to one the associated "sd" here. + */ + nr =3D READ_ONCE(sd->shared->nr_idle_scan) + 1; + /* overloaded LLC is unlikely to have idle cpu/core */ + if (nr =3D=3D 1) + return -1; } =20 + if (!cpumask_and(cpus, sched_domain_span(sd), p->cpus_ptr)) + return -1; + if (static_branch_unlikely(&sched_cluster_active)) { struct sched_group *sg =3D sd->groups; =20