From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (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 EC96F1A5B84 for ; Fri, 20 Feb 2026 19:31:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.92.199 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771615872; cv=none; b=dXw2sXKpS+8bvaVX4pj4MX/l1cLOW5GEsjoxJa3gzGM2YTShjv4L4UrQNxK6zv3Vard/F7myr3fEHoFtc69o2F9kk5N9c8fZscj5OJAhCZrPjMKi77Y9kGSvlt8hlbMHU/GFz/PyDnjx2QAyx2uYxsoI68CnY3Jkd/4JrV4t0II= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771615872; c=relaxed/simple; bh=NFUDUcl3Wc2RFqQPE4+RTm+gtoMfwlCq0G7rZyupHMU=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=mdSSWa0jtPeLUZmBVSC9pIyxMykl5z+c3NnBJuj05czKVbayaAIobzRwSoAhEWIhHdp+/5Pt3vRMiuS2PT/qRp0ulwH8iOj6F7MHYe8WVXQ6xDsKU4LC8hYjP6KxeWX0h4uRaTGCSMGWI4yF0rCQQ6gTxiaI2ZinRnJP0hA8IZo= 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=PYfza44E; arc=none smtp.client-ip=90.155.92.199 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="PYfza44E" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; 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=DWubfrgm8WKe2OCZ8x8fpMFNzGtTdf3cpV7cU6fily8=; b=PYfza44EhNTbf60S8AiyGkap6A QnIPPJzENMH1NKxohrKmdoyhcVelTOt+2K4nW05coxmcbWo2Ml1tQWT7IuYmw6Kk5Kmxdur7g3mhq dMhvLdxfBEXvsVUB6aLZR3kK1eRHgbZP6/eheGyw+cCF5S7aB/Yi6sNHtfVF2SvQA1tdyIsGD5MkY b7OWqBXN0x8UMzNKZ4kQ0zJ+rrp7KgO6/aSPJi57Vj5LxDjs6spv2k0lG9ujg8X4zhvRXbxF8SEia 0h+xHZB+RSOxOLJ4/mUplzZlKISFOdUJaBggai2KBeLWNForgy/bqHXPfwZob05i1/vAm08cDPahn aoemWNFA==; Received: from 77-249-17-252.cable.dynamic.v4.ziggo.nl ([77.249.17.252] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.98.2 #2 (Red Hat Linux)) id 1vtWCv-00000002zD3-1caV; Fri, 20 Feb 2026 19:30:33 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id 388FF300CDE; Fri, 20 Feb 2026 20:30:27 +0100 (CET) Date: Fri, 20 Feb 2026 20:30:27 +0100 From: Peter Zijlstra To: Tim Chen Cc: "Chen, Yu C" , Ingo Molnar , "Gautham R . Shenoy" , Vincent Guittot , 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, K Prateek Nayak Subject: Re: [PATCH v3 04/21] sched/cache: Make LLC id continuous Message-ID: <20260220193027.GT1395266@noisy.programming.kicks-ass.net> References: <60a05a3f50d14a7bf3b968f62cca87893c5c552c.1770760558.git.tim.c.chen@linux.intel.com> <79755f7d-cc68-4189-b6d8-850378e54017@amd.com> <20260219154007.GI1395266@noisy.programming.kicks-ass.net> <2ffbceaa-f9ab-461a-8324-3f500fcf8786@intel.com> <20260220160300.GH2995752@noisy.programming.kicks-ass.net> 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: On Fri, Feb 20, 2026 at 11:24:11AM -0800, Tim Chen wrote: > +static int __sched_domains_alloc_llc_id(void) > +{ > + int lid, max_lid; > + > + lockdep_assert_held(&sched_domains_mutex); > + > + lid = cpumask_first_zero(sched_domains_llc_id_allocmask); > + /* > + * llc_id space should never grow larger than the > + * possible number of CPUs in the system. > + */ > + BUG_ON(lid >= nr_cpu_ids); __cpumask_set_cpu(lid, sched_domains_llc_is_allocmask); > + max_lid = cpumask_last(sched_domains_llc_id_allocmask); > + /* size is one more than max index */ > + tl_max_llcs = max(lid, max_lid) + 1; > + > + return lid; > +} > + > +static void __sched_domains_free_llc_id(int cpu) > +{ > + int i, lid, last_lid; > + > + lockdep_assert_held(&sched_domains_mutex); > + > + lid = per_cpu(sd_llc_id, cpu); > + if (lid == -1) > + return; > + > + BUG_ON(lid >= nr_cpu_ids); > + per_cpu(sd_llc_id, cpu) = -1; > + > + for_each_cpu(i, cpu_coregroup_mask(cpu)) { > + /* An online CPU owns the llc_id. */ > + if (per_cpu(sd_llc_id, i) == lid) > + return; > + } > + __cpumask_clear_cpu(lid, sched_domains_llc_id_allocmask); > + > + last_lid = cpumask_last(sched_domains_llc_id_allocmask); > + /* shrink max LLC size to save memory */ > + if (last_lid < tl_max_llcs - 1) > + tl_max_llcs = last_lid + 1; > +} Might be simpler to just track max_lid, and do the +1 at the alloc site?