Re: kmemleak: sched_domain_shared leaked on asymmetric-capacity + SCHED_CACHE
From: K Prateek Nayak
Date: Tue Jul 07 2026 - 00:11:48 EST
Hello Dietmar, Breno,
On 7/6/2026 8:08 PM, Dietmar Eggemann wrote:
>> Is this the defualt topology before the cpuset? Because
>> min_interval of 8 means there are 8 cPUs in the span and
>> you have 8 CPUs in your machine so there seems to be a
>> single root partition when you captured this.
>
> +1
>
>> Also does your dmesg have any warnings from topology.c?
>>
>> The only way I can see this triggering is there is a single
>> cpu SD_SHARE_LLC at top which claims all the sd->shared and
>> then you get a SD_ASYM_CPUCAPACITY_FULL on top which too
>> tries to claim a sd->shared but all are already gone.
>
> ?
I may have found what might be happening. Since the last SD_SHARE_LLC
and the first SD_ASYM_CPUCAPACITY_FULL overlap,
init_sched_domain_shared() for SD_SHARE_LLC might just be overwriting
the assignment from claim_asym_sched_domain_shared() and we are left
with a non-zero refcounted shared that evades claim_allocations() but
is not used anywhere either.
Breno, could you try the below diff:
(Only build tested)
diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c
index 622e2e01974c..07e5a2c08132 100644
--- a/kernel/sched/topology.c
+++ b/kernel/sched/topology.c
@@ -2942,6 +2942,16 @@ init_sched_domain_shared(struct s_data *d, struct sched_domain *sd, int flags)
struct sched_domain_shared *sds = NULL;
int cpu;
+ /*
+ * If sd->shared is already assigned, there is an overlap in the
+ * flags (For example: last SD_SHARE_LLC domain, is also the
+ * first SD_ASYM_CPUCAPACITY_FULL domain).
+ *
+ * Return early to prevent overriding the sd->shared already
+ * assigned which can lead to dangling reference.
+ */
+ if (sd->shared)
+ return;
/*
* Multiple domains can try to claim a shared object like
* SD_ASYM_CPUCAPACITY and SD_SHARE_LLC which can alias to
---
It is prepared on top of tip:sched/core but should apply cleanly
on any tree after v7.2-rc1 since nothing else has changed in
these parts since the merge window.
--
Thanks and Regards,
Prateek