From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (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 001E3341058 for ; Thu, 19 Feb 2026 14:59:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.50.34 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771513191; cv=none; b=R/8IiJOaWs3vt/Mh5AR29b+8vDYCWg1VYCBxqQ0VQOcAdrRctuvMf6CIIoa1pZ9IKxqjSXQanekxLGBI0E61OFdjMGyP7p7sVPyKN+1S2IapS4g3fAR43Dz/6oi0oPAoL0aT9rrT6BV6gDtR2Wt4hcnEcynqCyuaeNmc21vy7cc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771513191; c=relaxed/simple; bh=AkKgtlIseiFGqH5EJZ8C1kKEmFj6HzGsvuTOS2NUvoI=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=O4uyv7oknpA16P/jSZ2PT3SgsYNqVT7KtJ8ayWIKXnHKallECvhSO6OwGkY/t3gMx/xaI76+AdEjVlF8VGsEFZMTC8SdbJHsUlsZO7/iKABgWRBHuLHjtYI9+AJfRjMjsVIeO6Cf3yOgzvKiDqp7KqKOL6lcKqePx9XkEB9F+8A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=TLvwJEO3; arc=none smtp.client-ip=90.155.50.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="TLvwJEO3" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=YBlsjNUwQ8f+E6fvEhMofIOerbYMxWF33mSVnk6exWc=; b=TLvwJEO3BsyS1NIS7076xMQ3ZS bFThCvh3WKX54zJU6Vx35Vau2mY7v+z4wRZO210UgmYa9aEjdMGM6MR1GIw2P/H9QxjHwvY1sUaeL TZoq3dNlLDZNZHf6kqOF5x8rBX0RP4ke7R5UZh0U42JlAsB7dpJgYQg8174ZYSD0syPnBdu1PgQ9X emN+tlOfSslKMmUhTe5TPKGeTpNa4DpOHGQgAyTiIUXPH7X823ASJva2SEV8povPnZEcMzzYHMLyE DPE47vQzkkGnuYoH72qluWmExa0GJ5U97nCg3wUWKP69Gb5NrnfXfUVnqVTdiNkn771TF2HmufcOR bd4eschQ==; Received: from 2001-1c00-8d85-5700-266e-96ff-fe07-7dcc.cable.dynamic.v6.ziggo.nl ([2001:1c00:8d85:5700:266e:96ff:fe07:7dcc] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.98.2 #2 (Red Hat Linux)) id 1vt5Ul-00000007l0U-2BKW; Thu, 19 Feb 2026 14:59:11 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id 366D3300CDE; Thu, 19 Feb 2026 15:59:08 +0100 (CET) Date: Thu, 19 Feb 2026 15:59:08 +0100 From: Peter Zijlstra To: Tim Chen Cc: Ingo Molnar , K Prateek Nayak , "Gautham R . Shenoy" , Vincent Guittot , Chen Yu , Juri Lelli , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Valentin Schneider , Madadi Vineeth Reddy , Hillf Danton , Shrikanth Hegde , Jianyong Wu , Yangyu Chen , Tingyin Duan , Vern Hao , Vern Hao , Len Brown , Aubrey Li , Zhao Liu , Chen Yu , Adam Li , Aaron Lu , Tim Chen , Josh Don , Gavin Guo , Qais Yousef , Libo Chen , linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 04/21] sched/cache: Make LLC id continuous Message-ID: <20260219145908.GH1395266@noisy.programming.kicks-ass.net> References: <60a05a3f50d14a7bf3b968f62cca87893c5c552c.1770760558.git.tim.c.chen@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <60a05a3f50d14a7bf3b968f62cca87893c5c552c.1770760558.git.tim.c.chen@linux.intel.com> On Tue, Feb 10, 2026 at 02:18:44PM -0800, Tim Chen wrote: > diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c > index cf643a5ddedd..ca46b5cf7f78 100644 > --- a/kernel/sched/topology.c > +++ b/kernel/sched/topology.c > @@ -20,6 +20,7 @@ void sched_domains_mutex_unlock(void) > /* Protected by sched_domains_mutex: */ > static cpumask_var_t sched_domains_tmpmask; > static cpumask_var_t sched_domains_tmpmask2; > +static int tl_max_llcs; > > static int __init sched_debug_setup(char *str) > { > @@ -658,7 +659,7 @@ static void destroy_sched_domains(struct sched_domain *sd) > */ > DEFINE_PER_CPU(struct sched_domain __rcu *, sd_llc); > DEFINE_PER_CPU(int, sd_llc_size); > -DEFINE_PER_CPU(int, sd_llc_id); > +DEFINE_PER_CPU(int, sd_llc_id) = -1; > DEFINE_PER_CPU(int, sd_share_id); > DEFINE_PER_CPU(struct sched_domain_shared __rcu *, sd_llc_shared); > DEFINE_PER_CPU(struct sched_domain __rcu *, sd_numa); > @@ -684,7 +685,6 @@ static void update_top_cache_domain(int cpu) > > rcu_assign_pointer(per_cpu(sd_llc, cpu), sd); > per_cpu(sd_llc_size, cpu) = size; > - per_cpu(sd_llc_id, cpu) = id; > rcu_assign_pointer(per_cpu(sd_llc_shared, cpu), sds); > > sd = lowest_flag_domain(cpu, SD_CLUSTER); > @@ -2567,10 +2567,18 @@ build_sched_domains(const struct cpumask *cpu_map, struct sched_domain_attr *att > > /* Set up domains for CPUs specified by the cpu_map: */ > for_each_cpu(i, cpu_map) { > - struct sched_domain_topology_level *tl; > + struct sched_domain_topology_level *tl, *tl_llc = NULL; > + int lid; > > sd = NULL; > for_each_sd_topology(tl) { > + int flags = 0; > + > + if (tl->sd_flags) > + flags = (*tl->sd_flags)(); > + > + if (flags & SD_SHARE_LLC) > + tl_llc = tl; > > sd = build_sched_domain(tl, cpu_map, attr, sd, i); > > @@ -2581,6 +2589,39 @@ build_sched_domains(const struct cpumask *cpu_map, struct sched_domain_attr *att > if (cpumask_equal(cpu_map, sched_domain_span(sd))) > break; > } > + > + lid = per_cpu(sd_llc_id, i); > + if (lid == -1) { > + int j; > + > + /* > + * Assign the llc_id to the CPUs that do not > + * have an LLC. > + */ Where does this happen? Is this for things like Atom that don't have an L3 and so we don't set up a LLC domain? > + if (!tl_llc) { > + per_cpu(sd_llc_id, i) = tl_max_llcs++; > + > + continue; > + } > + > + /* try to reuse the llc_id of its siblings */ > + for_each_cpu(j, tl_llc->mask(tl_llc, i)) { > + if (i == j) > + continue; > + > + lid = per_cpu(sd_llc_id, j); > + > + if (lid != -1) { > + per_cpu(sd_llc_id, i) = lid; > + > + break; > + } > + } > + > + /* a new LLC is detected */ > + if (lid == -1) > + per_cpu(sd_llc_id, i) = tl_max_llcs++; > + } > } > > if (WARN_ON(!topology_span_sane(cpu_map))) > -- > 2.32.0 >