From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.15]) (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 2AF902F39BE for ; Thu, 19 Feb 2026 21:04:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.15 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771535059; cv=none; b=cHGUhhSbep9GGyPnQHbyjtH66x4M3MiIBegfEc+Ec8tJPMN194sJbQHiZSrCeXphhwocJbosz/6cQzv+zPZqp7/LYeQC5IpDIeYAavztmrk9xoSWfOgJpZWpitCvxhmnHZlt/U5ljkDljEvrjaeuwUiZi/rahte2ftyN2lpt+Lw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771535059; c=relaxed/simple; bh=QaJmg2fi4uFoUtdNI3hod4FZe1CEktcmH0UMtjIvnMM=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=XRbE59cHaMHLyUTByC9QV/UhfKcdLP102M85yrVVp3jIMpSTwLAGLjqRy8jC0aJHolIa4jn4JAANrHX6tfKGOW8E75uKZXpVdPeU5vkf3CTdDanYibz0D+aHfBYpt0xokF0/JsmYZdFTScw50E26S1RMw2U9/7RR6oiH08aAXjY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=ENWqVa8y; arc=none smtp.client-ip=192.198.163.15 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="ENWqVa8y" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1771535058; x=1803071058; h=message-id:subject:from:to:cc:date:in-reply-to: references:content-transfer-encoding:mime-version; bh=QaJmg2fi4uFoUtdNI3hod4FZe1CEktcmH0UMtjIvnMM=; b=ENWqVa8yjuKc6rQIxF0xCpevXH4BauuSKAcuBZOrGj/fuuDJfFAro3NJ qGSTfHgsgsZ4MqNk9BjTez0HwZQCE1IX8GbP7JFWB8ePktVxSVzed8Grj 2FbQhgVxcAcwg1asX33GSrydSlPU2JulhHBuGyliL3dY98KhK5OYtgkvY HTcRF4P/0hHci18idyGpkk/tqp/2ffUopiTa7tw4UlYCp3xtp/xdwQaYr 7N5anOhepoV/4ukHMNiSdlCcVS13gCuMnFMKotOkpZIp++0w0LFEDlVAe aSeTgX4khBRnNLrNiAU7ylwHSx1Zu5VNl3GeBRxIt0yK11VrWEMQL6XzA g==; X-CSE-ConnectionGUID: 3Q6LzENSTp2847wNeNK8lw== X-CSE-MsgGUID: l+NaYTCsTg6Z8PQ/LUL11w== X-IronPort-AV: E=McAfee;i="6800,10657,11706"; a="72732364" X-IronPort-AV: E=Sophos;i="6.21,300,1763452800"; d="scan'208";a="72732364" Received: from orviesa007.jf.intel.com ([10.64.159.147]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Feb 2026 13:04:17 -0800 X-CSE-ConnectionGUID: oTFDnN5uQKCn8x0wyY45/A== X-CSE-MsgGUID: bWQyKPKwRZ+8hEI/SLOKLg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.21,300,1763452800"; d="scan'208";a="214769674" Received: from unknown (HELO [10.241.243.83]) ([10.241.243.83]) by orviesa007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Feb 2026 13:04:17 -0800 Message-ID: <2f4cad403dc4d290c0c58cfcddd66bc7ac116b81.camel@linux.intel.com> Subject: Re: [PATCH v3 04/21] sched/cache: Make LLC id continuous From: Tim Chen To: "Chen, Yu C" , Peter Zijlstra Cc: Ingo Molnar , K Prateek Nayak , "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 Date: Thu, 19 Feb 2026 13:04:16 -0800 In-Reply-To: <8f558b1d8743be75e6d033e6217b8ddf95ea91b8.camel@linux.intel.com> References: <60a05a3f50d14a7bf3b968f62cca87893c5c552c.1770760558.git.tim.c.chen@linux.intel.com> <20260219145908.GH1395266@noisy.programming.kicks-ass.net> <8f558b1d8743be75e6d033e6217b8ddf95ea91b8.camel@linux.intel.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.58.1 (3.58.1-1.fc43) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 On Thu, 2026-02-19 at 11:20 -0800, Tim Chen wrote: > On Thu, 2026-02-19 at 23:20 +0800, Chen, Yu C wrote: > > On 2/19/2026 10:59 PM, Peter Zijlstra wrote: > > > On Tue, Feb 10, 2026 at 02:18:44PM -0800, Tim Chen wrote: > > >=20 > > > > 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; > > > > =20 > > > > 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) =3D -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) > > > > =20 > > > > rcu_assign_pointer(per_cpu(sd_llc, cpu), sd); > > > > per_cpu(sd_llc_size, cpu) =3D size; > > > > - per_cpu(sd_llc_id, cpu) =3D id; > > > > rcu_assign_pointer(per_cpu(sd_llc_shared, cpu), sds); > > > > =20 > > > > sd =3D lowest_flag_domain(cpu, SD_CLUSTER); > > > > @@ -2567,10 +2567,18 @@ build_sched_domains(const struct cpumask *c= pu_map, struct sched_domain_attr *att > > > > =20 > > > > /* 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 =3D NULL; > > > > + int lid; > > > > =20 > > > > sd =3D NULL; > > > > for_each_sd_topology(tl) { > > > > + int flags =3D 0; > > > > + > > > > + if (tl->sd_flags) > > > > + flags =3D (*tl->sd_flags)(); > > > > + > > > > + if (flags & SD_SHARE_LLC) > > > > + tl_llc =3D tl; > > > > =20 > > > > sd =3D build_sched_domain(tl, cpu_map, attr, sd, i); > > > > =20 > > > > @@ -2581,6 +2589,39 @@ build_sched_domains(const struct cpumask *cp= u_map, struct sched_domain_attr *att > > > > if (cpumask_equal(cpu_map, sched_domain_span(sd))) > > > > break; > > > > } > > > > + > > > > + lid =3D per_cpu(sd_llc_id, i); > > > > + if (lid =3D=3D -1) { > > > > + int j; > > > > + > > > > + /* > > > > + * Assign the llc_id to the CPUs that do not > > > > + * have an LLC. > > > > + */ > > >=20 > > > 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? > > >=20 > >=20 > > Yes, for some hybrid platforms, some CPUs on that platforms might not= =20 > > have L3, > > Tim might correct me if I=E2=80=99m wrong. Above code is derived from t= he=20 > > update_top_cache_domain(), > > if there is no sched domain with SD_SHARE_LLC, per_cpu(sd_llc_id, cpu= )=20 > > is set to the > > CPU number directly. > >=20 >=20 > That's correct. One example is Meteor Lake where some Atom CPUs don't ha= ve > L3 but have only L2. And some Ampere CPUs also have no shared L3. >=20 > https://www.spinics.net/lists/kernel/msg5863118.html?utm_source=3Dchatgpt= .com >=20 > This also reminded me that if we rely on cpu_coregroup_mask for LLC id > assignment, we may be missing out such platforms which need to treat=C2= =A0 > L2 as the last level cache. So we may need to fallback to cpu_clustergro= up_mask > or cpu_smt_mask where applicable. On further inspection of the code, cpu_coregroup_mask will just be the same as cpu_clustergroup_mask for that case so we should be okay. Tim >=20 > Tim=20 >=20 > > thanks, > > Chenyu > >=20