* [PATCH v3 0/2] x86/resctrl: Fix Platform QoS issues for Hygon
@ 2025-12-09 6:26 Xiaochen Shen
2025-12-09 6:26 ` [PATCH v3 1/2] x86/resctrl: Add missing resctrl initialization " Xiaochen Shen
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Xiaochen Shen @ 2025-12-09 6:26 UTC (permalink / raw)
To: tony.luck, reinette.chatre, bp, fenghuay
Cc: babu.moger, james.morse, Dave.Martin, x86, linux-kernel, shenxiaochen
This patch series fixes two issues regarding Platform QoS (resctrl)
support on Hygon CPUs.
The first patch adds the missing initialization sequence required for
proper resctrl functionality. The second patch corrects the bit-width
configuration for the Memory Bandwidth Monitoring (MBM) counter.
Changelog:
v3:
- Remove the "Fixes: 923f3a2b48bd..." tag in two patches because this
commit itself doesn't have an issue (Fenghua).
v2:
- Add "Reviewed-by:" tag in patch 1/2:
"Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>"
- Add "Reviewed-by:" tags in patch 2/2:
"Reviewed-by: Tony Luck <tony.luck@intel.com>"
"Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>"
- Move the "Cc: stable@vger.kernel.org" tag to be after the author's SoB
to comply with tip tree rules (Reinette)
Xiaochen Shen (2):
x86/resctrl: Add missing resctrl initialization for Hygon
x86/resctrl: Fix memory bandwidth counter width for Hygon
arch/x86/kernel/cpu/resctrl/core.c | 21 +++++++++++++++++----
arch/x86/kernel/cpu/resctrl/internal.h | 3 +++
2 files changed, 20 insertions(+), 4 deletions(-)
--
2.47.3
^ permalink raw reply [flat|nested] 6+ messages in thread* [PATCH v3 1/2] x86/resctrl: Add missing resctrl initialization for Hygon
2025-12-09 6:26 [PATCH v3 0/2] x86/resctrl: Fix Platform QoS issues for Hygon Xiaochen Shen
@ 2025-12-09 6:26 ` Xiaochen Shen
2026-01-13 16:14 ` [tip: x86/urgent] " tip-bot2 for Xiaochen Shen
2025-12-09 6:26 ` [PATCH v3 2/2] x86/resctrl: Fix memory bandwidth counter width " Xiaochen Shen
2026-01-08 16:02 ` [PATCH v3 0/2] x86/resctrl: Fix Platform QoS issues " Reinette Chatre
2 siblings, 1 reply; 6+ messages in thread
From: Xiaochen Shen @ 2025-12-09 6:26 UTC (permalink / raw)
To: tony.luck, reinette.chatre, bp, fenghuay
Cc: babu.moger, james.morse, Dave.Martin, x86, linux-kernel, shenxiaochen
Hygon CPUs supporting Platform QoS features currently undergo partial
resctrl initialization through resctrl_cpu_detect() in the Hygon BSP
init helper and AMD/Hygon common initialization code. However, several
critical data structures remain uninitialized for Hygon CPUs in the
following paths:
- get_mem_config()-> __rdt_get_mem_config_amd():
rdt_resource::membw,alloc_capable
hw_res::num_closid
- rdt_init_res_defs()->rdt_init_res_defs_amd():
rdt_resource::cache
hw_res::msr_base,msr_update
Add the missing AMD/Hygon common initialization to ensure proper
Platform QoS functionality on Hygon CPUs.
Fixes: d8df126349da ("x86/cpu/hygon: Add missing resctrl_cpu_detect() in bsp_init helper")
Signed-off-by: Xiaochen Shen <shenxiaochen@open-hieco.net>
Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
Cc: stable@vger.kernel.org
---
arch/x86/kernel/cpu/resctrl/core.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resctrl/core.c
index 3792ab4819dc..10de1594d328 100644
--- a/arch/x86/kernel/cpu/resctrl/core.c
+++ b/arch/x86/kernel/cpu/resctrl/core.c
@@ -825,7 +825,8 @@ static __init bool get_mem_config(void)
if (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL)
return __get_mem_config_intel(&hw_res->r_resctrl);
- else if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD)
+ else if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD ||
+ boot_cpu_data.x86_vendor == X86_VENDOR_HYGON)
return __rdt_get_mem_config_amd(&hw_res->r_resctrl);
return false;
@@ -987,7 +988,8 @@ static __init void rdt_init_res_defs(void)
{
if (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL)
rdt_init_res_defs_intel();
- else if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD)
+ else if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD ||
+ boot_cpu_data.x86_vendor == X86_VENDOR_HYGON)
rdt_init_res_defs_amd();
}
--
2.47.3
^ permalink raw reply [flat|nested] 6+ messages in thread* [tip: x86/urgent] x86/resctrl: Add missing resctrl initialization for Hygon
2025-12-09 6:26 ` [PATCH v3 1/2] x86/resctrl: Add missing resctrl initialization " Xiaochen Shen
@ 2026-01-13 16:14 ` tip-bot2 for Xiaochen Shen
0 siblings, 0 replies; 6+ messages in thread
From: tip-bot2 for Xiaochen Shen @ 2026-01-13 16:14 UTC (permalink / raw)
To: linux-tip-commits
Cc: Xiaochen Shen, Borislav Petkov (AMD),
Reinette Chatre, stable, x86, linux-kernel
The following commit has been merged into the x86/urgent branch of tip:
Commit-ID: 6ee98aabdc700b5705e4f1833e2edc82a826b53b
Gitweb: https://git.kernel.org/tip/6ee98aabdc700b5705e4f1833e2edc82a826b53b
Author: Xiaochen Shen <shenxiaochen@open-hieco.net>
AuthorDate: Tue, 09 Dec 2025 14:26:49 +08:00
Committer: Borislav Petkov (AMD) <bp@alien8.de>
CommitterDate: Tue, 13 Jan 2026 16:20:01 +01:00
x86/resctrl: Add missing resctrl initialization for Hygon
Hygon CPUs supporting Platform QoS features currently undergo partial resctrl
initialization through resctrl_cpu_detect() in the Hygon BSP init helper and
AMD/Hygon common initialization code. However, several critical data
structures remain uninitialized for Hygon CPUs in the following paths:
- get_mem_config()-> __rdt_get_mem_config_amd():
rdt_resource::membw,alloc_capable
hw_res::num_closid
- rdt_init_res_defs()->rdt_init_res_defs_amd():
rdt_resource::cache
hw_res::msr_base,msr_update
Add the missing AMD/Hygon common initialization to ensure proper Platform QoS
functionality on Hygon CPUs.
Fixes: d8df126349da ("x86/cpu/hygon: Add missing resctrl_cpu_detect() in bsp_init helper")
Signed-off-by: Xiaochen Shen <shenxiaochen@open-hieco.net>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/20251209062650.1536952-2-shenxiaochen@open-hieco.net
---
arch/x86/kernel/cpu/resctrl/core.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resctrl/core.c
index 3792ab4..10de159 100644
--- a/arch/x86/kernel/cpu/resctrl/core.c
+++ b/arch/x86/kernel/cpu/resctrl/core.c
@@ -825,7 +825,8 @@ static __init bool get_mem_config(void)
if (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL)
return __get_mem_config_intel(&hw_res->r_resctrl);
- else if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD)
+ else if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD ||
+ boot_cpu_data.x86_vendor == X86_VENDOR_HYGON)
return __rdt_get_mem_config_amd(&hw_res->r_resctrl);
return false;
@@ -987,7 +988,8 @@ static __init void rdt_init_res_defs(void)
{
if (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL)
rdt_init_res_defs_intel();
- else if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD)
+ else if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD ||
+ boot_cpu_data.x86_vendor == X86_VENDOR_HYGON)
rdt_init_res_defs_amd();
}
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v3 2/2] x86/resctrl: Fix memory bandwidth counter width for Hygon
2025-12-09 6:26 [PATCH v3 0/2] x86/resctrl: Fix Platform QoS issues for Hygon Xiaochen Shen
2025-12-09 6:26 ` [PATCH v3 1/2] x86/resctrl: Add missing resctrl initialization " Xiaochen Shen
@ 2025-12-09 6:26 ` Xiaochen Shen
2026-01-13 16:13 ` [tip: x86/urgent] " tip-bot2 for Xiaochen Shen
2026-01-08 16:02 ` [PATCH v3 0/2] x86/resctrl: Fix Platform QoS issues " Reinette Chatre
2 siblings, 1 reply; 6+ messages in thread
From: Xiaochen Shen @ 2025-12-09 6:26 UTC (permalink / raw)
To: tony.luck, reinette.chatre, bp, fenghuay
Cc: babu.moger, james.morse, Dave.Martin, x86, linux-kernel, shenxiaochen
The memory bandwidth calculation relies on reading the hardware counter
and measuring the delta between samples. To ensure accurate measurement,
the software reads the counter frequently enough to prevent it from
rolling over twice between reads.
The default Memory Bandwidth Monitoring (MBM) counter width is 24 bits.
Hygon CPUs provide a 32-bit width counter, but they do not support the
MBM capability CPUID leaf (0xF.[ECX=1]:EAX) to report the width offset
(from 24 bits).
Consequently, the kernel falls back to the 24-bit default counter width,
which causes incorrect overflow handling on Hygon CPUs.
Fix this by explicitly setting the counter width offset to 8 bits
(resulting in a 32-bit total counter width) for Hygon CPUs.
Fixes: d8df126349da ("x86/cpu/hygon: Add missing resctrl_cpu_detect() in bsp_init helper")
Signed-off-by: Xiaochen Shen <shenxiaochen@open-hieco.net>
Reviewed-by: Tony Luck <tony.luck@intel.com>
Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
Cc: stable@vger.kernel.org
---
arch/x86/kernel/cpu/resctrl/core.c | 15 +++++++++++++--
arch/x86/kernel/cpu/resctrl/internal.h | 3 +++
2 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resctrl/core.c
index 10de1594d328..6ebff44a3f75 100644
--- a/arch/x86/kernel/cpu/resctrl/core.c
+++ b/arch/x86/kernel/cpu/resctrl/core.c
@@ -1021,8 +1021,19 @@ void resctrl_cpu_detect(struct cpuinfo_x86 *c)
c->x86_cache_occ_scale = ebx;
c->x86_cache_mbm_width_offset = eax & 0xff;
- if (c->x86_vendor == X86_VENDOR_AMD && !c->x86_cache_mbm_width_offset)
- c->x86_cache_mbm_width_offset = MBM_CNTR_WIDTH_OFFSET_AMD;
+ if (!c->x86_cache_mbm_width_offset) {
+ switch (c->x86_vendor) {
+ case X86_VENDOR_AMD:
+ c->x86_cache_mbm_width_offset = MBM_CNTR_WIDTH_OFFSET_AMD;
+ break;
+ case X86_VENDOR_HYGON:
+ c->x86_cache_mbm_width_offset = MBM_CNTR_WIDTH_OFFSET_HYGON;
+ break;
+ default:
+ /* Leave c->x86_cache_mbm_width_offset as 0 */
+ break;
+ }
+ }
}
}
diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/resctrl/internal.h
index 4a916c84a322..79c18657ede0 100644
--- a/arch/x86/kernel/cpu/resctrl/internal.h
+++ b/arch/x86/kernel/cpu/resctrl/internal.h
@@ -14,6 +14,9 @@
#define MBM_CNTR_WIDTH_OFFSET_AMD 20
+/* Hygon MBM counter width as an offset from MBM_CNTR_WIDTH_BASE */
+#define MBM_CNTR_WIDTH_OFFSET_HYGON 8
+
#define RMID_VAL_ERROR BIT_ULL(63)
#define RMID_VAL_UNAVAIL BIT_ULL(62)
--
2.47.3
^ permalink raw reply [flat|nested] 6+ messages in thread* [tip: x86/urgent] x86/resctrl: Fix memory bandwidth counter width for Hygon
2025-12-09 6:26 ` [PATCH v3 2/2] x86/resctrl: Fix memory bandwidth counter width " Xiaochen Shen
@ 2026-01-13 16:13 ` tip-bot2 for Xiaochen Shen
0 siblings, 0 replies; 6+ messages in thread
From: tip-bot2 for Xiaochen Shen @ 2026-01-13 16:13 UTC (permalink / raw)
To: linux-tip-commits
Cc: Xiaochen Shen, Borislav Petkov (AMD),
Tony Luck, Reinette Chatre, stable, x86, linux-kernel
The following commit has been merged into the x86/urgent branch of tip:
Commit-ID: 7517e899e1b87b4c22a92c7e40d8733c48e4ec3c
Gitweb: https://git.kernel.org/tip/7517e899e1b87b4c22a92c7e40d8733c48e4ec3c
Author: Xiaochen Shen <shenxiaochen@open-hieco.net>
AuthorDate: Tue, 09 Dec 2025 14:26:50 +08:00
Committer: Borislav Petkov (AMD) <bp@alien8.de>
CommitterDate: Tue, 13 Jan 2026 16:44:26 +01:00
x86/resctrl: Fix memory bandwidth counter width for Hygon
The memory bandwidth calculation relies on reading the hardware counter
and measuring the delta between samples. To ensure accurate measurement,
the software reads the counter frequently enough to prevent it from
rolling over twice between reads.
The default Memory Bandwidth Monitoring (MBM) counter width is 24 bits.
Hygon CPUs provide a 32-bit width counter, but they do not support the
MBM capability CPUID leaf (0xF.[ECX=1]:EAX) to report the width offset
(from 24 bits).
Consequently, the kernel falls back to the 24-bit default counter width,
which causes incorrect overflow handling on Hygon CPUs.
Fix this by explicitly setting the counter width offset to 8 bits (resulting
in a 32-bit total counter width) for Hygon CPUs.
Fixes: d8df126349da ("x86/cpu/hygon: Add missing resctrl_cpu_detect() in bsp_init helper")
Signed-off-by: Xiaochen Shen <shenxiaochen@open-hieco.net>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Reviewed-by: Tony Luck <tony.luck@intel.com>
Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/20251209062650.1536952-3-shenxiaochen@open-hieco.net
---
arch/x86/kernel/cpu/resctrl/core.c | 15 +++++++++++++--
arch/x86/kernel/cpu/resctrl/internal.h | 3 +++
2 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resctrl/core.c
index 10de159..6ebff44 100644
--- a/arch/x86/kernel/cpu/resctrl/core.c
+++ b/arch/x86/kernel/cpu/resctrl/core.c
@@ -1021,8 +1021,19 @@ void resctrl_cpu_detect(struct cpuinfo_x86 *c)
c->x86_cache_occ_scale = ebx;
c->x86_cache_mbm_width_offset = eax & 0xff;
- if (c->x86_vendor == X86_VENDOR_AMD && !c->x86_cache_mbm_width_offset)
- c->x86_cache_mbm_width_offset = MBM_CNTR_WIDTH_OFFSET_AMD;
+ if (!c->x86_cache_mbm_width_offset) {
+ switch (c->x86_vendor) {
+ case X86_VENDOR_AMD:
+ c->x86_cache_mbm_width_offset = MBM_CNTR_WIDTH_OFFSET_AMD;
+ break;
+ case X86_VENDOR_HYGON:
+ c->x86_cache_mbm_width_offset = MBM_CNTR_WIDTH_OFFSET_HYGON;
+ break;
+ default:
+ /* Leave c->x86_cache_mbm_width_offset as 0 */
+ break;
+ }
+ }
}
}
diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/resctrl/internal.h
index 4a916c8..79c1865 100644
--- a/arch/x86/kernel/cpu/resctrl/internal.h
+++ b/arch/x86/kernel/cpu/resctrl/internal.h
@@ -14,6 +14,9 @@
#define MBM_CNTR_WIDTH_OFFSET_AMD 20
+/* Hygon MBM counter width as an offset from MBM_CNTR_WIDTH_BASE */
+#define MBM_CNTR_WIDTH_OFFSET_HYGON 8
+
#define RMID_VAL_ERROR BIT_ULL(63)
#define RMID_VAL_UNAVAIL BIT_ULL(62)
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v3 0/2] x86/resctrl: Fix Platform QoS issues for Hygon
2025-12-09 6:26 [PATCH v3 0/2] x86/resctrl: Fix Platform QoS issues for Hygon Xiaochen Shen
2025-12-09 6:26 ` [PATCH v3 1/2] x86/resctrl: Add missing resctrl initialization " Xiaochen Shen
2025-12-09 6:26 ` [PATCH v3 2/2] x86/resctrl: Fix memory bandwidth counter width " Xiaochen Shen
@ 2026-01-08 16:02 ` Reinette Chatre
2 siblings, 0 replies; 6+ messages in thread
From: Reinette Chatre @ 2026-01-08 16:02 UTC (permalink / raw)
To: Xiaochen Shen, tony.luck, bp, fenghuay
Cc: babu.moger, james.morse, Dave.Martin, x86, linux-kernel
Dear x86 maintainers,
Could you please consider this series for inclusion?
Thank you very much.
Reinette
On 12/8/25 10:26 PM, Xiaochen Shen wrote:
> This patch series fixes two issues regarding Platform QoS (resctrl)
> support on Hygon CPUs.
>
> The first patch adds the missing initialization sequence required for
> proper resctrl functionality. The second patch corrects the bit-width
> configuration for the Memory Bandwidth Monitoring (MBM) counter.
>
> Changelog:
> v3:
> - Remove the "Fixes: 923f3a2b48bd..." tag in two patches because this
> commit itself doesn't have an issue (Fenghua).
>
> v2:
> - Add "Reviewed-by:" tag in patch 1/2:
> "Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>"
> - Add "Reviewed-by:" tags in patch 2/2:
> "Reviewed-by: Tony Luck <tony.luck@intel.com>"
> "Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>"
> - Move the "Cc: stable@vger.kernel.org" tag to be after the author's SoB
> to comply with tip tree rules (Reinette)
>
> Xiaochen Shen (2):
> x86/resctrl: Add missing resctrl initialization for Hygon
> x86/resctrl: Fix memory bandwidth counter width for Hygon
>
> arch/x86/kernel/cpu/resctrl/core.c | 21 +++++++++++++++++----
> arch/x86/kernel/cpu/resctrl/internal.h | 3 +++
> 2 files changed, 20 insertions(+), 4 deletions(-)
>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-01-13 16:14 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-12-09 6:26 [PATCH v3 0/2] x86/resctrl: Fix Platform QoS issues for Hygon Xiaochen Shen
2025-12-09 6:26 ` [PATCH v3 1/2] x86/resctrl: Add missing resctrl initialization " Xiaochen Shen
2026-01-13 16:14 ` [tip: x86/urgent] " tip-bot2 for Xiaochen Shen
2025-12-09 6:26 ` [PATCH v3 2/2] x86/resctrl: Fix memory bandwidth counter width " Xiaochen Shen
2026-01-13 16:13 ` [tip: x86/urgent] " tip-bot2 for Xiaochen Shen
2026-01-08 16:02 ` [PATCH v3 0/2] x86/resctrl: Fix Platform QoS issues " Reinette Chatre
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®