Skip to content

Commit 0c4d5ba

Browse files
rchatresuryasaimadhu
authored andcommitted
x86/resctrl: Support wider MBM counters
The original Memory Bandwidth Monitoring (MBM) architectural definition defines counters of up to 62 bits in the IA32_QM_CTR MSR while the first-generation MBM implementation uses statically defined 24 bit counters. The MBM CPUID enumeration properties have been expanded to include the MBM counter width, encoded as an offset from 24 bits. While eight bits are available for the counter width offset IA32_QM_CTR MSR only supports 62 bit counters. Add a sanity check, with warning printed when encountered, to ensure counters cannot exceed the 62 bit limit. Signed-off-by: Reinette Chatre <[email protected]> Signed-off-by: Borislav Petkov <[email protected]> Link: https://lkml.kernel.org/r/69d52abd5b14794d3a0f05ba7c755ed1f4c0d5ed.1588715690.git.reinette.chatre@intel.com
1 parent f3d44f1 commit 0c4d5ba

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

arch/x86/kernel/cpu/resctrl/internal.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
#define CQM_LIMBOCHECK_INTERVAL 1000
3333

34-
#define MBM_CNTR_WIDTH 24
34+
#define MBM_CNTR_WIDTH_BASE 24
3535
#define MBM_OVERFLOW_INTERVAL 1000
3636
#define MAX_MBA_BW 100u
3737
#define MBA_IS_LINEAR 0x4
@@ -40,6 +40,12 @@
4040

4141
#define RMID_VAL_ERROR BIT_ULL(63)
4242
#define RMID_VAL_UNAVAIL BIT_ULL(62)
43+
/*
44+
* With the above fields in use 62 bits remain in MSR_IA32_QM_CTR for
45+
* data to be returned. The counter width is discovered from the hardware
46+
* as an offset from MBM_CNTR_WIDTH_BASE.
47+
*/
48+
#define MBM_CNTR_WIDTH_OFFSET_MAX (62 - MBM_CNTR_WIDTH_BASE)
4349

4450

4551
struct rdt_fs_context {

arch/x86/kernel/cpu/resctrl/monitor.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -618,12 +618,18 @@ static void l3_mon_evt_init(struct rdt_resource *r)
618618

619619
int rdt_get_mon_l3_config(struct rdt_resource *r)
620620
{
621+
unsigned int mbm_offset = boot_cpu_data.x86_cache_mbm_width_offset;
621622
unsigned int cl_size = boot_cpu_data.x86_cache_size;
622623
int ret;
623624

624625
r->mon_scale = boot_cpu_data.x86_cache_occ_scale;
625626
r->num_rmid = boot_cpu_data.x86_cache_max_rmid + 1;
626-
r->mbm_width = MBM_CNTR_WIDTH;
627+
r->mbm_width = MBM_CNTR_WIDTH_BASE;
628+
629+
if (mbm_offset > 0 && mbm_offset <= MBM_CNTR_WIDTH_OFFSET_MAX)
630+
r->mbm_width += mbm_offset;
631+
else if (mbm_offset > MBM_CNTR_WIDTH_OFFSET_MAX)
632+
pr_warn("Ignoring impossible MBM counter offset\n");
627633

628634
/*
629635
* A reasonable upper limit on the max threshold is the number

0 commit comments

Comments
 (0)