From nobody Mon Apr 6 19:59:52 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 1283F37F017; Wed, 18 Mar 2026 08:08:46 +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=1773821327; cv=none; b=T5YCtirxtjYep+zVpR6w2mBVjyqP2C1hUtUwSJf8bHKrDqTGW4TuFJoBoycB50dGvqvzWpEMvPHNdPskuO6AKf2EDd4TDlOfMZF3J5ID6AVbiggkRur4UP8geQDr3ezaYeZgzDJCtKJS+8gzW5+1N2XQ7+FXdJE7d48rMwo8MRU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773821327; c=relaxed/simple; bh=JTo36pLXZZSQkkCLSb62uFt0piEnnkcdwo2BbNU/Mc4=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=q9q0JdnaWRUknwNdem0Z1vZLkPGA3pBteECL7KeRVeJX3odO84CHAM28a9q3liLeq+qUN+9dBcwruz+1HU6Kl2oUk3I+2pg6I40s4sHnp1JDJmg3oUZLZ///kwaqZrDbz93Pi+2t1h8nHh0SWHSGYtPGj7RJqGmkgdvrn0JCbKg= 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=pcaK3g6H; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=cvjT4vEr; 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="pcaK3g6H"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="cvjT4vEr" Date: Wed, 18 Mar 2026 08:08:41 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1773821323; 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=q44joeyEXxy5tRJB51RPwGHagROmdEPMWoOyYNcmVBU=; b=pcaK3g6H3A51HHVErcH0lWx59FAfBCfR7aECMoM/AZE+WjrDRSugE2IxWPKxE1YOGPmJcj udtpuenmz3WSgYW5qZhCXsHCwHrULSHdU5y5oTQHozWFkHDkRNQjXOEcvV4FtGSEdG+hRs NyQurWrhbbhqaTRmBwsGJBGlCw82s2kv/3jSaO3AEysfKweQr+Z36d6nPBO8HUhGma0Tu1 EG9N2eNUkcL+bPv4cl/Mnoid7MAh7WHTlQTWw3bmT5dqgzHMtCZxZ4nb0NOdHgyL1GleW2 rYLsh1/6ZcEM9WV/4F3virwDZWWJje2TTNW5EQLRXwBdZe9vgZ3lRzOWPjkFSg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1773821323; 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=q44joeyEXxy5tRJB51RPwGHagROmdEPMWoOyYNcmVBU=; b=cvjT4vErFSLU9Zel5t5+lx7dULYdJL6ngnbUeNqt/HzZDq2q+8936ReM9iwVg/lJqMGMdE wNlZ7srgtVCuZXDg== 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/topology: Allocate per-CPU sched_domain_shared in s_data Cc: K Prateek Nayak , "Peter Zijlstra (Intel)" , Valentin Schneider , Chen Yu , Dietmar Eggemann , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20260312044434.1974-4-kprateek.nayak@amd.com> References: <20260312044434.1974-4-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: <177382132177.1647592.11505685085746599419.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: 1cc8a33ca7e8d38f962b64ece2a42c411a67bc76 Gitweb: https://git.kernel.org/tip/1cc8a33ca7e8d38f962b64ece2a42c411= a67bc76 Author: K Prateek Nayak AuthorDate: Thu, 12 Mar 2026 04:44:28=20 Committer: Peter Zijlstra CommitterDate: Wed, 18 Mar 2026 09:06:48 +01:00 sched/topology: Allocate per-CPU sched_domain_shared in s_data The "sched_domain_shared" object is allocated for every topology level in __sdt_alloc() and is freed post sched domain rebuild if they aren't assigned during sd_init(). "sd->shared" is only assigned for SD_SHARE_LLC domains and out of all the assigned objects, only "sd_llc_shared" is ever used by the scheduler. Since only "sd_llc_shared" is ever used, and since SD_SHARE_LLC domains never overlap, allocate only a single range of per-CPU "sched_domain_shared" object with s_data instead of doing it per topology level. The subsequent commit uses the degeneration path to correctly assign the "sd->shared" to the topmost SD_SHARE_LLC domain. No functional changes are expected at this point. Signed-off-by: K Prateek Nayak Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Valentin Schneider Reviewed-by: Chen Yu Reviewed-by: Dietmar Eggemann Tested-by: Dietmar Eggemann Link: https://patch.msgid.link/20260312044434.1974-4-kprateek.nayak@amd.com --- kernel/sched/topology.c | 48 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c index 6303790..9006586 100644 --- a/kernel/sched/topology.c +++ b/kernel/sched/topology.c @@ -782,6 +782,7 @@ cpu_attach_domain(struct sched_domain *sd, struct root_= domain *rd, int cpu) } =20 struct s_data { + struct sched_domain_shared * __percpu *sds; struct sched_domain * __percpu *sd; struct root_domain *rd; }; @@ -789,6 +790,7 @@ struct s_data { enum s_alloc { sa_rootdomain, sa_sd, + sa_sd_shared, sa_sd_storage, sa_none, }; @@ -1535,6 +1537,9 @@ static void set_domain_attribute(struct sched_domain = *sd, static void __sdt_free(const struct cpumask *cpu_map); static int __sdt_alloc(const struct cpumask *cpu_map); =20 +static void __sds_free(struct s_data *d, const struct cpumask *cpu_map); +static int __sds_alloc(struct s_data *d, const struct cpumask *cpu_map); + static void __free_domain_allocs(struct s_data *d, enum s_alloc what, const struct cpumask *cpu_map) { @@ -1546,6 +1551,9 @@ static void __free_domain_allocs(struct s_data *d, en= um s_alloc what, case sa_sd: free_percpu(d->sd); fallthrough; + case sa_sd_shared: + __sds_free(d, cpu_map); + fallthrough; case sa_sd_storage: __sdt_free(cpu_map); fallthrough; @@ -1561,9 +1569,11 @@ __visit_domain_allocation_hell(struct s_data *d, con= st struct cpumask *cpu_map) =20 if (__sdt_alloc(cpu_map)) return sa_sd_storage; + if (__sds_alloc(d, cpu_map)) + return sa_sd_shared; d->sd =3D alloc_percpu(struct sched_domain *); if (!d->sd) - return sa_sd_storage; + return sa_sd_shared; d->rd =3D alloc_rootdomain(); if (!d->rd) return sa_sd; @@ -2464,6 +2474,42 @@ static void __sdt_free(const struct cpumask *cpu_map) } } =20 +static int __sds_alloc(struct s_data *d, const struct cpumask *cpu_map) +{ + int j; + + d->sds =3D alloc_percpu(struct sched_domain_shared *); + if (!d->sds) + return -ENOMEM; + + for_each_cpu(j, cpu_map) { + struct sched_domain_shared *sds; + + sds =3D kzalloc_node(sizeof(struct sched_domain_shared), + GFP_KERNEL, cpu_to_node(j)); + if (!sds) + return -ENOMEM; + + *per_cpu_ptr(d->sds, j) =3D sds; + } + + return 0; +} + +static void __sds_free(struct s_data *d, const struct cpumask *cpu_map) +{ + int j; + + if (!d->sds) + return; + + for_each_cpu(j, cpu_map) + kfree(*per_cpu_ptr(d->sds, j)); + + free_percpu(d->sds); + d->sds =3D NULL; +} + static struct sched_domain *build_sched_domain(struct sched_domain_topolog= y_level *tl, const struct cpumask *cpu_map, struct sched_domain_attr *attr, struct sched_domain *child, int cpu)