mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2 0/2] x86/cacheinfo: Make cache IDs unique on hybrid processors
@ 2026-12-03  4:58 Ricardo Neri
  2026-12-03  4:58 ` [PATCH v2 1/2] x86/cacheinfo: Fix cache ID collisions " Ricardo Neri
  2026-12-03  4:58 ` [PATCH v2 2/2] x86/cacheinfo: Use calc_cache_topo_id() in __cache_cpumap_setup() Ricardo Neri
  0 siblings, 2 replies; 3+ messages in thread
From: Ricardo Neri @ 2026-12-03  4:58 UTC (permalink / raw)
  To: x86
  Cc: Reinette Chatre, Tony Luck, K Prateek Nayak, Ahmed S. Darwish,
	Len Brown, Javid Rzayev, Ricardo Neri, linux-kernel,
	Ricardo Neri

get_cache_id() computes the cache IDs in
/sys/devices/system/cpu/cpuX/cache/index*/id by right-shifting the APIC
ID by an amount that depends on the CPU. On hybrid processors, cores of
different types use different shifts, and caches that are not shared
end up with the same ID. Since v6.4, the generic cacheinfo code rebuilds
shared_cpu_map from these IDs when a CPU comes back online, including
after suspend to RAM and hibernation. shared_cpu_list then also reports
a P-core and an E-core as sharing their L1 cache.

Patch 1 is the fix and can be applied on its own. On hybrid processors,
it computes the exposed IDs with calc_cache_topo_id(), which masks the
APIC ID instead. All other processors keep their IDs: they do not
collide there. Changing them would break userspace that stored them,
such as libvirt's <cachetune>.

Patch 2 uses calc_cache_topo_id() for the boot-time sharing masks as
well. It does not change which CPUs are matched.

Testing:

- Lenovo ThinkPad X1 Carbon Gen 12 (Meteor Lake): without the series,
  offlining and onlining an E-core, or a hibernate/resume cycle, makes
  shared_cpu_list report the E-core as sharing its L1 cache with a
  P-core. With the series, the lists stay correct.
- AMD Ryzen AI 9 HX 370 (Zen 5 + Zen 5c), 2-socket EPYC 9555 (Zen 5) and
  2-socket EPYC 9354 (Zen 4): none of them sets X86_FEATURE_HYBRID_CPU.
  The Ryzen mixes core types, but its IDs do not collide. The series
  changes nothing userspace sees: every cache ID, resctrl domain ID and
  shared_cpu_list stays the same. This also holds across 20
  offline/online cycles of each of three CPUs per machine (the first CPU
  of an L3, another CPU in it and the first CPU's SMT sibling), and
  across a hibernate/resume cycle on the Ryzen.
- On the EPYC 9354, a libvirt domain with a stored <cachetune> cache ID
  keeps starting with the series.
- Javid tested v1 on an Arrow Lake-S Core Ultra 7 265: unique L1 IDs,
  and shared_cpu_list stays correct across CPU hotplug. Len tested v1 on
  a Meteor Lake-based Lenovo ThinkPad T16 Gen 3. The hybrid code path is
  the same in v2.
- Patch 1 alone was build-tested only.

Signed-off-by: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
---
Changes in v2:
- Change the IDs only on hybrid processors, so that stored IDs keep
  working on all others (patch 1).
- Move the no-op __cache_cpumap_setup() change into patch 2.
- Changelog: CPU hotplug effect, Fixes: tag, resctrl IDs.
- Link to v1: https://lore.kernel.org/r/20260319-rneri-x86-cacheinfoid-bug-v1-1-5875849dd0e5@linux.intel.com

---
Ricardo Neri (2):
      x86/cacheinfo: Fix cache ID collisions on hybrid processors
      x86/cacheinfo: Use calc_cache_topo_id() in __cache_cpumap_setup()

 arch/x86/kernel/cpu/cacheinfo.c | 28 +++++++++++++++++++++++-----
 1 file changed, 23 insertions(+), 5 deletions(-)
---
base-commit: 782a14f283513f52785f7f9c207b0af2ba4aecb6
change-id: 20260220-rneri-x86-cacheinfoid-bug-71e3f7e28e94

Best regards,
-- 
Ricardo Neri <ricardo.neri-calderon@linux.intel.com>


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-12-03  4:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-12-03  4:58 [PATCH v2 0/2] x86/cacheinfo: Make cache IDs unique on hybrid processors Ricardo Neri
2026-12-03  4:58 ` [PATCH v2 1/2] x86/cacheinfo: Fix cache ID collisions " Ricardo Neri
2026-12-03  4:58 ` [PATCH v2 2/2] x86/cacheinfo: Use calc_cache_topo_id() in __cache_cpumap_setup() Ricardo Neri

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®