From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=198.175.65.11 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796273907; b=aXCyVN9r0jEUfiUpIY8OCIxi4+5nNnXd7iiNIXkBTsX4HVCwNhJiXafgpWFp/i4JY1ct vaSVfbRKgqrpfO5KnRkPQNBBdt+A62HqED/v6pBDtCQcmExbBU+M2k/Ip7NZXeWGCuSEW 0p7WnXHMtdEpIMzeTtyPuxRFQxiQTb2JvmkKQkagTO4SmSl/9FOw1LRPZprJfVuY1Tgnt KF+3SYHgHN1r4V9sftTjfwEhJEQmcVke0kEGSXXwI2ScY5hhYHax/6eCh7byOVL9LiDTX yc+yhlmAr/yRWN/pnAZtCXUYhQPCXoxdW24QZ+CiXCf+mft6qJt1ZkE3HYq67rItHJA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796273907; h=DMARC-Filter:DKIM-Signature:X-CSE-ConnectionGUID:X-CSE-MsgGUID: X-IronPort-AV:X-IronPort-AV:Received:X-CSE-ConnectionGUID: X-CSE-MsgGUID:X-ExtLoop1:X-IronPort-AV:Received:From:Subject:Date: Message-Id:MIME-Version:Content-Type:Content-Transfer-Encoding: X-B4-Tracking:To:Cc:X-Mailer:X-Developer-Signature:X-Developer-Key; bh=KYugjPaJkVWoXiWAELvEInfDakTYVypoBCzJk4hkiHQ=; b=L+f1zqpcEqDF3KzVPgkUdLKIbPymE2Ylw4Ot1LcJORIzGppQi8QnZKDCcamc3JBQfqeZ sdU7Y6RPVSXAKDI0vxQIxPze5OeFio9LI2UCmtliIdyUwc9dSzMfSiHU/etKrnUxwlBAP DmeH0l6xA1BTKMrm9RKi7zGZHPwHqhV7qQAkZ5F/tUlVmQaM23dFf1hRQqK2aX07Wcz5a UUwRHhxwLAzV9jS1V45UR949D6sGwf5h49gr8zdKatVwIvXD5HjcZ6oK0kMFBPLVsdEPz iKSgeAw9vvPDxjnbjoFvq1lmOsb/igzjj7uYdXAp360O2873duQmm4UJy5WZ62N1mAg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=mJeATJYo; arc=none smtp.remote-ip=198.175.65.11 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.11]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CA7D4606A330 for ; Thu, 3 Dec 2026 04:58:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org CA7D4606A330 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, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=mJeATJYo DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1796273907; x=1827809907; h=from:subject:date:message-id:mime-version: content-transfer-encoding:to:cc; bh=KYugjPaJkVWoXiWAELvEInfDakTYVypoBCzJk4hkiHQ=; b=mJeATJYoe+36YpVyiF8ZPlR/pU3VGhHX6VirnJt6uldbOjaq2zimEYa5 QchHi6cY221LNpYkikEpnSjupZyRwaOTASo3meTLoz24iuqX1xS//J+gi 73jq1HFqkI+VqQnq6Go6ipSEIXzGkk2LDY4v30a85JKGe9stBCNtKczbm 1B3Sne6Q8v3usisl8jMl4BqzpobkVojtLAsJgEjKihWXceNze2D55f8OP dlO/gW1EJe3gOK1x+8xS93eSoNgHbGo7Gtzbo5rhFszRfxZ3CsYIzrjVe 01Uznud2bUdt0Itb++U5gT48Oyk4QkQgo/AkNminB3hMfZsbc+A/XN+Og Q==; X-CSE-ConnectionGUID: NyUUjisPRp+OMTGLb9nTgA== X-CSE-MsgGUID: uKrWq+OrRsa1aSmwGSBhNQ== X-IronPort-AV: E=McAfee;i="6800,10657,11984"; a="5115260" X-IronPort-AV: E=Sophos;i="6.27,247,1787036400"; d="scan'208";a="5115260" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Dec 2026 20:58:27 -0800 X-CSE-ConnectionGUID: AwIrbaD1RLaYGo81U7tc0A== X-CSE-MsgGUID: 5dxWzDwaR1+d0lF1Ez95mg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,247,1787036400"; d="scan'208";a="13534970" Received: from unknown (HELO [172.25.112.21]) ([172.25.112.21]) by orviesa004.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Dec 2026 20:58:26 -0800 From: Ricardo Neri Subject: [PATCH v2 0/2] x86/cacheinfo: Make cache IDs unique on hybrid processors Date: Wed, 02 Dec 2026 20:58:03 -0800 Message-Id: <20261202-rneri-x86-cacheinfoid-bug-v2-0-a00d768927f2@linux.intel.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-B4-Tracking: v=1; b=H4sIANv2EGsC/32Nyw6DIBBFf8Ww7hjAF3bV/2hcWBh1EgsNKLEx/ nup3Xd5bnLO3VlATxjYNduZx0iBnE0gLxnTU29HBDKJmeSy5lJy8DYJsKkadK8nJDs4MvBYR2g EFkODUmFbsuS/PA60ne17l3iisDj/Pq+i+K6/aiHaP9UoQEClmkqVrTEcq9tMdt1ysgvOuXZP1 h3H8QEY38koyAAAAA== To: x86@kernel.org Cc: Reinette Chatre , Tony Luck , K Prateek Nayak , "Ahmed S. Darwish" , Len Brown , Javid Rzayev , Ricardo Neri , linux-kernel@vger.kernel.org, Ricardo Neri X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1796273905; l=3082; i=ricardo.neri-calderon@linux.intel.com; s=20250602; h=from:subject:message-id; bh=6sNDO0BzFVwM4CC60OQl8jZnExTMBmVo7hK8kRjsJX8=; b=WcogQ6SQqU0J0d2cR6ea8P3Nd4VxnfDDaRcWuTxWEbtMChOgi+FBoPjs99wDkBXA4qkGqZccU B0QmJ+1scOcAaCrOKiDX0UZ/9Lw5qY+CQjJ9IzvsckL/R8HPxpLdIfX X-Developer-Key: i=ricardo.neri-calderon@linux.intel.com; a=ed25519; pk=NfZw5SyQ2lxVfmNMaMR6KUj3+0OhcwDPyRzFDH9gY2w= 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 . 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 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 --- 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