Re: [PATCH] sched/topology: don't claim sched_domain_shared twice on the same domain

From: K Prateek Nayak

Date: Sun Nov 29 2026 - 23:38:08 EST


Hello Breno,

On 8/10/2026 5:16 PM, Breno Leitao wrote:
> diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c
> index 5a29e506c25d5..206552d51ce2e 100644
> --- a/kernel/sched/topology.c
> +++ b/kernel/sched/topology.c
> @@ -3169,7 +3169,13 @@ build_sched_domains(const struct cpumask *cpu_map, struct sched_domain_attr *att
> sd = sd->parent;
>
> if (sd->flags & SD_SHARE_LLC) {
> - init_sched_domain_shared(&d, sd, SD_SHARE_LLC);
> + /*
> + * The asym path above may have claimed a shared object
> + * on this very domain; claiming it again overwrites
> + * sd->shared and leaks the first reference.
> + */
> + if (!sd->shared)
> + init_sched_domain_shared(&d, sd, SD_SHARE_LLC);

I would prefer pushing that as an early return into
init_sched_domain_shared() but this works too. Feel free to include:

Tested-by: K Prateek Nayak <kprateek.nayak@xxxxxxx>

P.S. I think you should also add a
Closes: https://lore.kernel.org/lkml/akeMbyZGmbjWSZqp@xxxxxxxxx/
for the record.

>
> /*
> * In presence of higher domains, adjust the
>
> ---

--
Thanks and Regards,
Prateek