From nobody Mon Sep 28 17:48:03 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.19]) (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 C35CF483800 for ; Wed, 19 Aug 2026 16:13:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.19 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787156017; cv=none; b=jULl9Wagik+1YGqOZZ9Wt5PFyJXIs0CZLbLyGCGQsFFC3xvMtQA50EUPB5vVsOihYVZtwSBvX7h3kwz5rnMQLIOk3LVgKlUIpoyT+D78aMsdOJFr9mNaGqcAwfeCr35q/JYQldFPY/WC2xJ/f0Ty/5vH8DF8POe9ddr0IhynCEM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787156017; c=relaxed/simple; bh=WuDNhkqq00kjVqYmDtHZU0GQSxxyzh5NoYhjctJowrU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fZbur8CM8PNyzKH2lmGhih9cCOrUFAXRv2E7rMjDIElgpzexBhFUMdFIvGMbRY8DgPgeq+DCZhAVf/f76cXEHUjnX7CvHmRZxoU5rxvaU5ihGN8NyI2y4wkMf2YKvGle3RJAuQnXPzJ9oDwNdu9pJ+nnAgBvTTsqTxNcvJVnnl4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=DzpvWFlk; arc=none smtp.client-ip=198.175.65.19 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="DzpvWFlk" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1787156015; x=1818692015; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=WuDNhkqq00kjVqYmDtHZU0GQSxxyzh5NoYhjctJowrU=; b=DzpvWFlka5D0z8q3KFaWptALtwSD4on9HpMzFH/CAgrGs8+/cw/RrjZU psBkLMU/7j2mbg5pFkFFrZW5UtnG68WPQvQi6F/eOoatYtP8RuC4HV39Z tKQ+17NVevF02atVaDMks7yPhNm5HFvgCcluMjs16znGM8mYVnQtAFDgG ckWLrOQcUIYIs/S1sF8Y3duB+5M+9m6YQxVXvGOfb1oSEBRjEIwzqcbT3 tbRm5qIAZWIW/YLziBR3PL1Vmr8TRoKFjEY5Q0eNTJ27VB0VYt7yG/zmP tScwkkoc4f89Q8wojUN1RN7SPQ0Rqpu2OULDotNxfMielPWymswXrFa82 g==; X-CSE-ConnectionGUID: y9L2tQatRPqmv5whrnza6A== X-CSE-MsgGUID: vTmvDzc8S1OKdly5XewQhQ== X-IronPort-AV: E=McAfee;i="6800,10657,11880"; a="87598046" X-IronPort-AV: E=Sophos;i="6.25,231,1779174000"; d="scan'208";a="87598046" Received: from fmviesa001.fm.intel.com ([10.60.135.141]) by orvoesa111.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Aug 2026 09:13:33 -0700 X-CSE-ConnectionGUID: TpOGlf1RQ+G1990Ts1zCpw== X-CSE-MsgGUID: p29TT35EQbWv46FuIQDk3A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.25,231,1779174000"; d="scan'208";a="290391841" Received: from rodrigoa-mobl1.amr.corp.intel.com (HELO agluck-desk3.intel.com) ([10.124.221.31]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Aug 2026 09:13:33 -0700 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Maciej Wieczor-Retman , Peter Newman , James Morse , Babu Moger , Drew Fustini , Dave Martin , Chen Yu , x86@kernel.org Cc: linux-kernel@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [RFC PATCH 1/4] x86/resctrl: Check if monitoring features are enabled Date: Wed, 19 Aug 2026 09:13:19 -0700 Message-ID: <20260819161323.11587-2-tony.luck@intel.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260819161323.11587-1-tony.luck@intel.com> References: <20260819161323.11587-1-tony.luck@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Both Intel and AMD manuals say that software must first check CPUID(0x7,0x0).EBX[12] to see if any monitoring features are enabled before checking for specific features enabled in subleaves. Add the check for X86_FEATURE_CQM. Fixes: cbc82b172638 ("x86: Add support for Intel Cache QoS Monitoring (CQM)= detection") Signed-off-by: Tony Luck --- arch/x86/kernel/cpu/resctrl/core.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resct= rl/core.c index 55214d6fdc49..2677b8a6c15b 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -968,6 +968,9 @@ static __init bool get_rdt_mon_resources(void) struct rdt_resource *r =3D &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl; bool ret =3D false; =20 + if (!cpu_feature_enabled(X86_FEATURE_CQM)) + return false; + if (rdt_cpu_has(X86_FEATURE_CQM_OCCUP_LLC)) { resctrl_enable_mon_event(QOS_L3_OCCUP_EVENT_ID, false, 0, NULL); ret =3D true; --=20 2.55.0 From nobody Mon Sep 28 17:48:03 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.19]) (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 E9C9548665E for ; Wed, 19 Aug 2026 16:13:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.19 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787156017; cv=none; b=oANKDV4j1cVOsztdtdadRU3pAOR3XnvgbKXXtGfnzH1+G9YBmlhcIZz9zuD2TYKWAuBUMQHhLetM+nkhE+C7W5pKnRnP9Mk7UoLN4gUyxP0LhOV3ffhtFWt3UxWK0Ba+GABorhaqTDnHiDfks1OjH4i5flrqhc98Fc8dkRedlVk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787156017; c=relaxed/simple; bh=IXRrDceqzOhX8M6QyZuJwyUegKGxImEtimTfeHQceDI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XgQVO5Q9o+FKWCTzdQx+02+2l/zP+wfDl2yfcVG7N5MnCUxgfw4Wjyf+gzW5Jjtka+17ZD6Q0AKV4lD/DHPNHlYheuwxpKcVOO6Zn64tG0Wq3Y2F6zuZL7wtNjIwVpM/rg4GgATUyOWBi0EksLorRu2VR5+CnMKlDRv1n2ffX0o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=jEprRKOf; arc=none smtp.client-ip=198.175.65.19 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="jEprRKOf" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1787156016; x=1818692016; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=IXRrDceqzOhX8M6QyZuJwyUegKGxImEtimTfeHQceDI=; b=jEprRKOfmawof1L19ltjSLiCgjd1BxCbBNlImvj1+5GbfvOm8D7Q2dDU oDrAscW+Qcn5uByCS/5t+bD5CxTOAJ47L3XpmtS8sjuYxpqFUmBnpP3BQ L/7JVdHdaKLxMemXpSejzxdcFu5uY6Tjr+S5LbsY1awGxMfE24pXhF8ac +8bRq16zM1PKK6855eHOFWLNqsia47NgJFv1R/I1wp6J1D+GxGi9p8826 KidfY14gKC2qoF602/lsrcBkLt/658ML2l5qUEPJmBjZCmi8rCOhRQkLe 1Jijy4bz9XUlA/xcbckXdkSk28en6Y/60Eob3C0z8Xe8V4lDjJyvsjrg9 A==; X-CSE-ConnectionGUID: qUohfXHjQ72EoNhLW0EL+w== X-CSE-MsgGUID: thOfyRHeQnO80YFGah3ifg== X-IronPort-AV: E=McAfee;i="6800,10657,11880"; a="87598054" X-IronPort-AV: E=Sophos;i="6.25,231,1779174000"; d="scan'208";a="87598054" Received: from fmviesa001.fm.intel.com ([10.60.135.141]) by orvoesa111.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Aug 2026 09:13:33 -0700 X-CSE-ConnectionGUID: p+R+a11QQeyj9+ax8wtWjw== X-CSE-MsgGUID: lTqtgbnOS9e6wf6KcGOLsg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.25,231,1779174000"; d="scan'208";a="290391844" Received: from rodrigoa-mobl1.amr.corp.intel.com (HELO agluck-desk3.intel.com) ([10.124.221.31]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Aug 2026 09:13:33 -0700 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Maciej Wieczor-Retman , Peter Newman , James Morse , Babu Moger , Drew Fustini , Dave Martin , Chen Yu , x86@kernel.org Cc: linux-kernel@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [RFC PATCH 2/4] x86/resctrl: Enumerate monitor features in rdt_get_l3_mon_config() Date: Wed, 19 Aug 2026 09:13:20 -0700 Message-ID: <20260819161323.11587-3-tony.luck@intel.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260819161323.11587-1-tony.luck@intel.com> References: <20260819161323.11587-1-tony.luck@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The original implementation of Intel Cache QoS Monitoring (CQM) planned to integrate with the "perf" and "cgroup" subsystems. With that plan it made sense for parameters from CPUID to be stored in fields of the cpuinfo_x86 structure. But that plan was abandoned and the resctrl file system user interface replaced it. Enumerate the L3 monitoring features in rdt_get_l3_mon_config(). Signed-off-by: Tony Luck --- arch/x86/include/asm/resctrl.h | 9 ++++---- arch/x86/kernel/cpu/resctrl/monitor.c | 32 ++++++++++++++++++++++++--- 2 files changed, 33 insertions(+), 8 deletions(-) diff --git a/arch/x86/include/asm/resctrl.h b/arch/x86/include/asm/resctrl.h index 8f6edcdcfd87..9bfa9b14002b 100644 --- a/arch/x86/include/asm/resctrl.h +++ b/arch/x86/include/asm/resctrl.h @@ -44,6 +44,7 @@ DECLARE_PER_CPU(struct resctrl_pqr_state, pqr_state); =20 extern bool rdt_alloc_capable; extern bool rdt_mon_capable; +extern unsigned int __ro_after_init rdt_l3_mon_scale; =20 DECLARE_STATIC_KEY_FALSE(rdt_enable_key); DECLARE_STATIC_KEY_FALSE(rdt_alloc_enable_key); @@ -132,11 +133,9 @@ static inline void __resctrl_sched_in(struct task_stru= ct *tsk) =20 static inline unsigned int resctrl_arch_round_mon_val(unsigned int val) { - unsigned int scale =3D boot_cpu_data.x86_cache_occ_scale; - - /* h/w works in units of "boot_cpu_data.x86_cache_occ_scale" */ - val /=3D scale; - return val * scale; + /* Round down to nearest h/w monitoring unit */ + val /=3D rdt_l3_mon_scale; + return val * rdt_l3_mon_scale; } =20 static inline void resctrl_arch_set_cpu_default_closid_rmid(int cpu, u32 c= losid, diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/re= sctrl/monitor.c index 3838e0a13d36..0c2aa20148a1 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -32,6 +32,11 @@ */ bool rdt_mon_capable; =20 +/* + * Scale factor to convert L3 monitor events to bytes. + */ +unsigned int __ro_after_init rdt_l3_mon_scale; + #define CF(cf) ((unsigned long)(1048576 * (cf) + 0.5)) =20 static int snc_nodes_per_l3_cache =3D 1; @@ -418,16 +423,37 @@ static __init int snc_get_config(void) =20 int __init rdt_get_l3_mon_config(struct rdt_resource *r) { - unsigned int mbm_offset =3D boot_cpu_data.x86_cache_mbm_width_offset; struct rdt_hw_resource *hw_res =3D resctrl_to_arch_res(r); + unsigned int mbm_offset; unsigned int threshold; u32 eax, ebx, ecx, edx; + u32 num_rmid; + + /* QoS sub-leaf, EAX=3D0Fh, ECX=3D1 */ + cpuid_count(0xf, 1, &eax, &ebx, &ecx, &edx); + mbm_offset =3D eax & 0xff; + rdt_l3_mon_scale =3D ebx; + num_rmid =3D ecx + 1; + + if (!mbm_offset) { + switch (boot_cpu_data.x86_vendor) { + case X86_VENDOR_AMD: + mbm_offset =3D MBM_CNTR_WIDTH_OFFSET_AMD; + break; + case X86_VENDOR_HYGON: + mbm_offset =3D MBM_CNTR_WIDTH_OFFSET_HYGON; + break; + default: + /* Leave mbm_offset as 0 */ + break; + } + } =20 snc_nodes_per_l3_cache =3D snc_get_config(); =20 resctrl_rmid_realloc_limit =3D boot_cpu_data.x86_cache_size * 1024; - hw_res->mon_scale =3D boot_cpu_data.x86_cache_occ_scale / snc_nodes_per_l= 3_cache; - r->mon.num_rmid =3D (boot_cpu_data.x86_cache_max_rmid + 1) / snc_nodes_pe= r_l3_cache; + hw_res->mon_scale =3D rdt_l3_mon_scale / snc_nodes_per_l3_cache; + r->mon.num_rmid =3D num_rmid / snc_nodes_per_l3_cache; hw_res->mbm_width =3D MBM_CNTR_WIDTH_BASE; =20 if (mbm_offset > 0 && mbm_offset <=3D MBM_CNTR_WIDTH_OFFSET_MAX) --=20 2.55.0 From nobody Mon Sep 28 17:48:03 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.19]) (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 2B85B486E78 for ; Wed, 19 Aug 2026 16:13:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.19 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787156018; cv=none; b=kPUKa51eOGWb2suCT0lTMUnsVqzriq19mthgfnEn3bg4rH1aEda4CbDy0pbWfbtLsNY96fl7G4I1D8SggRIJfv97ftyv7Ec5SoeefIwNSfYm1rP15elN/r2YbKv0U0cHEGl/fqppqSMkHwWiBlCCuJm0bZierx750SKKszrB/bI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787156018; c=relaxed/simple; bh=bpDrxydPeJMWiQw6rPyKf5fH9m3VQzJgQysqTivh0QM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NiupfKqxnvdqnyJWRQHpZT81WrZoHZ+a9RmqYyLenMql+4ffQ5EXqYx90Idi3sebazy8ja+8vo5lRn9oytSPcTK25hKkdoO92NJS+qECKNOKCIqw3KJwpmPmkkOVUO/VvUkRFFKOG3ztZtQ7U7+kDe5IBvKN1tn6Wq9YrLoLP40= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=OsKXyFMa; arc=none smtp.client-ip=198.175.65.19 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="OsKXyFMa" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1787156017; x=1818692017; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=bpDrxydPeJMWiQw6rPyKf5fH9m3VQzJgQysqTivh0QM=; b=OsKXyFMaH9t+o9ZRXhp9H3GxmnPtDnI9QFWb8KLvXlUr2ukI/JAtT2Ma FrW3ikJbBOMmOAh1WHzLnlA81LmzkbXLXS4yZFh06LyTTV7FKdbXsZoEW 1BIy59hRfZIbMNwDGNb0BYTO1KU/QlGPSfT130I6p8RSjLNCyoPRVU0Sq j1GsWpYmW+i9mZBfv/M6+5cmfwEGk/56vURIFLvjNHgJ5RyTUPA7lIz07 84nmxP4HHdmP6GeaWIeKU1zw4mnFjUeTkUyMg7PN9QXkGDyOXzNUx/INc MPYY2HQ/CPWaWyD3RiT/Z00qSsz3Td5RxQl4idL21/khvpzonu0H6UZv/ w==; X-CSE-ConnectionGUID: OX5J2v3JTgOuyfqtOF59qQ== X-CSE-MsgGUID: A3IZkJpORBiRuRlOLsRM+Q== X-IronPort-AV: E=McAfee;i="6800,10657,11880"; a="87598062" X-IronPort-AV: E=Sophos;i="6.25,231,1779174000"; d="scan'208";a="87598062" Received: from fmviesa001.fm.intel.com ([10.60.135.141]) by orvoesa111.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Aug 2026 09:13:33 -0700 X-CSE-ConnectionGUID: LD0TjyS9T2+/efPb9VPizw== X-CSE-MsgGUID: K5KIg28ySWmP0dvX3Haa6g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.25,231,1779174000"; d="scan'208";a="290391848" Received: from rodrigoa-mobl1.amr.corp.intel.com (HELO agluck-desk3.intel.com) ([10.124.221.31]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Aug 2026 09:13:33 -0700 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Maciej Wieczor-Retman , Peter Newman , James Morse , Babu Moger , Drew Fustini , Dave Martin , Chen Yu , x86@kernel.org Cc: linux-kernel@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [RFC PATCH 3/4] x86/resctrl: Apply Intel MBM quirk from rdt_get_l3_mon_config() Date: Wed, 19 Aug 2026 09:13:21 -0700 Message-ID: <20260819161323.11587-4-tony.luck@intel.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260819161323.11587-1-tony.luck@intel.com> References: <20260819161323.11587-1-tony.luck@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The Intel quirk to adjust Memory Bandwidth Monitoring (MBM) values on certain CPUs is applied early, before discovering if MBM is supported. Move the call to rdt_get_l3_mon_config(), but keep the decision on whether it is needed in __check_quirks_intel() with all the other model specific tests. Signed-off-by: Tony Luck --- arch/x86/kernel/cpu/resctrl/internal.h | 4 +-- arch/x86/kernel/cpu/resctrl/core.c | 2 +- arch/x86/kernel/cpu/resctrl/monitor.c | 35 +++++++++++++++----------- 3 files changed, 23 insertions(+), 18 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/r= esctrl/internal.h index e3cfa0c10e92..e46eb9a4c725 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -151,6 +151,8 @@ static inline struct rdt_hw_resource *resctrl_to_arch_r= es(struct rdt_resource *r =20 extern struct rdt_hw_resource rdt_resources_all[]; =20 +extern bool __initdata intel_rdt_mbm_need_quirk; + void arch_mon_domain_online(struct rdt_resource *r, struct rdt_l3_mon_doma= in *d); =20 /* CPUID.(EAX=3D10H, ECX=3DResID=3D1).EAX */ @@ -228,8 +230,6 @@ int rdt_get_l3_mon_config(struct rdt_resource *r); =20 bool rdt_cpu_has(int flag); =20 -void __init intel_rdt_mbm_apply_quirk(void); - void rdt_domain_reconfigure_cdp(struct rdt_resource *r); void resctrl_arch_mbm_cntr_assign_set_one(struct rdt_resource *r); =20 diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resct= rl/core.c index 2677b8a6c15b..da94a12f9256 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -1006,7 +1006,7 @@ static __init void __check_quirks_intel(void) set_rdt_options("!l3cat"); fallthrough; case INTEL_BROADWELL_X: - intel_rdt_mbm_apply_quirk(); + intel_rdt_mbm_need_quirk =3D true; break; } } diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/re= sctrl/monitor.c index 0c2aa20148a1..0bce199a5f7b 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -37,6 +37,8 @@ bool rdt_mon_capable; */ unsigned int __ro_after_init rdt_l3_mon_scale; =20 +bool __initdata intel_rdt_mbm_need_quirk; + #define CF(cf) ((unsigned long)(1048576 * (cf) + 0.5)) =20 static int snc_nodes_per_l3_cache =3D 1; @@ -51,7 +53,7 @@ static int snc_nodes_per_l3_cache =3D 1; * 1. The threshold 0 is changed to rmid count - 1 so don't do correction * for the case. * 2. MBM total and local correction table indexed by core counter which is - * equal to (x86_cache_max_rmid + 1) / 8 - 1 and is from 0 up to 27. + * equal to r->mon.num_rmid / 8 - 1 and is from 0 up to 27. * 3. The correction factor is normalized to 2^20 (1048576) so it's faster * to calculate corrected value by shifting: * corrected_value =3D (original_value * correction_factor) >> 20 @@ -421,6 +423,20 @@ static __init int snc_get_config(void) return ret; } =20 +static void __init intel_rdt_mbm_apply_quirk(u32 num_rmid) +{ + int cf_index; + + cf_index =3D num_rmid / 8 - 1; + if (cf_index >=3D ARRAY_SIZE(mbm_cf_table)) { + pr_info("No MBM correction factor available\n"); + return; + } + + mbm_cf_rmidthreshold =3D mbm_cf_table[cf_index].rmidthreshold; + mbm_cf =3D mbm_cf_table[cf_index].cf; +} + int __init rdt_get_l3_mon_config(struct rdt_resource *r) { struct rdt_hw_resource *hw_res =3D resctrl_to_arch_res(r); @@ -500,25 +516,14 @@ int __init rdt_get_l3_mon_config(struct rdt_resource = *r) hw_res->mbm_cntr_assign_enabled =3D true; } =20 + if (intel_rdt_mbm_need_quirk) + intel_rdt_mbm_apply_quirk(r->mon.num_rmid); + r->mon_capable =3D true; =20 return 0; } =20 -void __init intel_rdt_mbm_apply_quirk(void) -{ - int cf_index; - - cf_index =3D (boot_cpu_data.x86_cache_max_rmid + 1) / 8 - 1; - if (cf_index >=3D ARRAY_SIZE(mbm_cf_table)) { - pr_info("No MBM correction factor available\n"); - return; - } - - mbm_cf_rmidthreshold =3D mbm_cf_table[cf_index].rmidthreshold; - mbm_cf =3D mbm_cf_table[cf_index].cf; -} - static void resctrl_abmc_set_one_amd(void *arg) { bool *enable =3D arg; --=20 2.55.0 From nobody Mon Sep 28 17:48:03 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.19]) (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 85DEE488762 for ; Wed, 19 Aug 2026 16:13:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.19 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787156019; cv=none; b=BalK9s0BtYMdCcu+YMqr3T8YPxz88KNyTYnEF/90cWG39108QwrKHT9c0+Y0qb9adK+WQSBR7CR2dx4a7oC7bQr9/9OiVxvM1j7uF2u3H+nLfwtSNCb5Lyio6qgEoVD8hyPceKhTyDqURGBZDP2yP107yiBiIm+EuwowJEmQX2I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787156019; c=relaxed/simple; bh=jIEscGel+bFptW/MzzQctO/3HTgWIzQRSvRdBQsABbQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mCOTB4TZxci3psgU6Skt4WnD3NFFcYGCnJ5MtlHeLeiolUqeSw7z7AIuRep2kD2zIXFL/d973W7Diw1thmmctgRvxm+I+JSPPtA3w7CQXcoOlHFfyYgFCE6YDr67XpUakedKIhjk6M7LJqx/0wDh/jhYpcesTRUYyRDeis69z3U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=f4WfWjTe; arc=none smtp.client-ip=198.175.65.19 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="f4WfWjTe" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1787156017; x=1818692017; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=jIEscGel+bFptW/MzzQctO/3HTgWIzQRSvRdBQsABbQ=; b=f4WfWjTeFLQq7xuyIyhR/kqJmtIZPJ5Prkx6I5neccxoikRC//KUQvnC W6sNWXbdtFdqP5Jsf2zwIqQkXV6tBWuoMrPtN/2jMM0i0NxP+2FLRtJJZ Cnjuh1O7syW+GDbV6stL2UnDJZ32MpZysP0rCnBjjiMgct4uWgdzB9q+5 fi2qHRa6/ea1vx7fqo+Nr2RsVnk1vws/ff6UVprg9YqUjR71KyyLebWJC zAHcN/EvbTmYtqHlTqcFa1EPVktSV/73VbAdr/fuGVEkNp6Yn9mkXoNOB heBDuAOu58ATK64QLqaXaEWfhhJ1EyRdtKhEVU6JNdDKO4zkGsxdc9LS0 g==; X-CSE-ConnectionGUID: KZK0ts0uQ6CTOy8jWJ0s7w== X-CSE-MsgGUID: WS+fqnCWS0iEJtPjNQqaXw== X-IronPort-AV: E=McAfee;i="6800,10657,11880"; a="87598067" X-IronPort-AV: E=Sophos;i="6.25,231,1779174000"; d="scan'208";a="87598067" Received: from fmviesa001.fm.intel.com ([10.60.135.141]) by orvoesa111.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Aug 2026 09:13:33 -0700 X-CSE-ConnectionGUID: sZDbsV55QJ6/9y2B4C47+g== X-CSE-MsgGUID: Y61bPEmASp6JVu72sFVHnQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.25,231,1779174000"; d="scan'208";a="290391852" Received: from rodrigoa-mobl1.amr.corp.intel.com (HELO agluck-desk3.intel.com) ([10.124.221.31]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Aug 2026 09:13:33 -0700 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Maciej Wieczor-Retman , Peter Newman , James Morse , Babu Moger , Drew Fustini , Dave Martin , Chen Yu , x86@kernel.org Cc: linux-kernel@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [RFC PATCH 4/4] x86/resctrl: Delete resctrl_cpu_detect() Date: Wed, 19 Aug 2026 09:13:22 -0700 Message-ID: <20260819161323.11587-5-tony.luck@intel.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260819161323.11587-1-tony.luck@intel.com> References: <20260819161323.11587-1-tony.luck@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" cpuinfo_x86::x86_cache_{max_rmid,occ_scale,mbm_width_offset} are no longer used. Delete resctrl_cpu_detect() and the fields from struct cpuinfo_x86. Signed-off-by: Tony Luck Acked-by: Borislav Petkov (AMD) --- arch/x86/include/asm/processor.h | 4 --- arch/x86/include/asm/resctrl.h | 3 --- arch/x86/kernel/cpu/amd.c | 3 --- arch/x86/kernel/cpu/hygon.c | 3 --- arch/x86/kernel/cpu/intel.c | 7 ----- arch/x86/kernel/cpu/resctrl/core.c | 42 ------------------------------ 6 files changed, 62 deletions(-) diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/proces= sor.h index ec9db0dfa0df..4deb88c61c94 100644 --- a/arch/x86/include/asm/processor.h +++ b/arch/x86/include/asm/processor.h @@ -185,10 +185,6 @@ struct cpuinfo_x86 { /* in KB - valid for CPUS which support this call: */ unsigned int x86_cache_size; int x86_cache_alignment; /* In bytes */ - /* Cache QoS architectural values, valid only on the BSP: */ - int x86_cache_max_rmid; /* max index */ - int x86_cache_occ_scale; /* scale to bytes */ - int x86_cache_mbm_width_offset; int x86_power; unsigned long loops_per_jiffy; /* protected processor identification number */ diff --git a/arch/x86/include/asm/resctrl.h b/arch/x86/include/asm/resctrl.h index 9bfa9b14002b..ab7f6ccd149e 100644 --- a/arch/x86/include/asm/resctrl.h +++ b/arch/x86/include/asm/resctrl.h @@ -193,12 +193,9 @@ static inline void resctrl_arch_mon_ctx_free(struct rd= t_resource *r, enum resctrl_event_id evtid, void *ctx) { } =20 -void resctrl_cpu_detect(struct cpuinfo_x86 *c); - #else =20 static inline void resctrl_arch_sched_in(struct task_struct *tsk) {} -static inline void resctrl_cpu_detect(struct cpuinfo_x86 *c) {} =20 #endif /* CONFIG_X86_CPU_RESCTRL */ =20 diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c index 54e14ed276b5..dd82a11084f4 100644 --- a/arch/x86/kernel/cpu/amd.c +++ b/arch/x86/kernel/cpu/amd.c @@ -23,7 +23,6 @@ #include #include #include -#include #include #include =20 @@ -475,8 +474,6 @@ static void bsp_init_amd(struct cpuinfo_x86 *c) } } =20 - resctrl_cpu_detect(c); - /* Figure out Zen generations: */ switch (c->x86) { case 0x17: diff --git a/arch/x86/kernel/cpu/hygon.c b/arch/x86/kernel/cpu/hygon.c index ec51c2b9a257..0f226335dd9a 100644 --- a/arch/x86/kernel/cpu/hygon.c +++ b/arch/x86/kernel/cpu/hygon.c @@ -17,7 +17,6 @@ #include #include #include -#include =20 #include "cpu.h" =20 @@ -119,8 +118,6 @@ static void bsp_init_hygon(struct cpuinfo_x86 *c) x86_amd_ls_cfg_ssbd_mask =3D 1ULL << 10; } } - - resctrl_cpu_detect(c); } =20 static void early_init_hygon(struct cpuinfo_x86 *c) diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c index 4297ceb2cb24..2f09710e863c 100644 --- a/arch/x86/kernel/cpu/intel.c +++ b/arch/x86/kernel/cpu/intel.c @@ -22,7 +22,6 @@ #include #include #include -#include #include #include =20 @@ -371,11 +370,6 @@ static void early_init_intel(struct cpuinfo_x86 *c) detect_tme_early(c); } =20 -static void bsp_init_intel(struct cpuinfo_x86 *c) -{ - resctrl_cpu_detect(c); -} - #ifdef CONFIG_X86_32 /* * Early probe support logic for ppro memory erratum #50 @@ -804,7 +798,6 @@ static const struct cpu_dev intel_cpu_dev =3D { #endif .c_detect_tlb =3D intel_detect_tlb, .c_early_init =3D early_init_intel, - .c_bsp_init =3D bsp_init_intel, .c_init =3D init_intel, .c_x86_vendor =3D X86_VENDOR_INTEL, }; diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resct= rl/core.c index da94a12f9256..1e36630c5da7 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -1078,48 +1078,6 @@ static __init void rdt_init_res_defs(void) =20 static enum cpuhp_state rdt_online; =20 -/* Runs once on the BSP during boot. */ -void resctrl_cpu_detect(struct cpuinfo_x86 *c) -{ - if (!cpu_has(c, X86_FEATURE_CQM_LLC) && !cpu_has(c, X86_FEATURE_ABMC)) { - c->x86_cache_max_rmid =3D -1; - c->x86_cache_occ_scale =3D -1; - c->x86_cache_mbm_width_offset =3D -1; - return; - } - - /* will be overridden if occupancy monitoring exists */ - c->x86_cache_max_rmid =3D cpuid_ebx(0xf); - - if (cpu_has(c, X86_FEATURE_CQM_OCCUP_LLC) || - cpu_has(c, X86_FEATURE_CQM_MBM_TOTAL) || - cpu_has(c, X86_FEATURE_CQM_MBM_LOCAL) || - cpu_has(c, X86_FEATURE_ABMC)) { - u32 eax, ebx, ecx, edx; - - /* QoS sub-leaf, EAX=3D0Fh, ECX=3D1 */ - cpuid_count(0xf, 1, &eax, &ebx, &ecx, &edx); - - c->x86_cache_max_rmid =3D ecx; - c->x86_cache_occ_scale =3D ebx; - c->x86_cache_mbm_width_offset =3D eax & 0xff; - - if (!c->x86_cache_mbm_width_offset) { - switch (c->x86_vendor) { - case X86_VENDOR_AMD: - c->x86_cache_mbm_width_offset =3D MBM_CNTR_WIDTH_OFFSET_AMD; - break; - case X86_VENDOR_HYGON: - c->x86_cache_mbm_width_offset =3D MBM_CNTR_WIDTH_OFFSET_HYGON; - break; - default: - /* Leave c->x86_cache_mbm_width_offset as 0 */ - break; - } - } - } -} - static int __init resctrl_arch_late_init(void) { struct rdt_resource *r; --=20 2.55.0