Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit 21b362c

Browse files
aeglbp3tk0v
authored andcommitted
x86/resctrl: Enable shared RMID mode on Sub-NUMA Cluster (SNC) systems
Hardware has two RMID configuration options for SNC systems. The default mode divides RMID counters between SNC nodes. E.g. with 200 RMIDs and two SNC nodes per L3 cache RMIDs 0..99 are used on node 0, and 100..199 on node 1. This isn't compatible with Linux resctrl usage. On this example system a process using RMID 5 would only update monitor counters while running on SNC node 0. The other mode is "RMID Sharing Mode". This is enabled by clearing bit 0 of the RMID_SNC_CONFIG (0xCA0) model specific register. In this mode the number of logical RMIDs is the number of physical RMIDs (from CPUID leaf 0xF) divided by the number of SNC nodes per L3 cache instance. A process can use the same RMID across different SNC nodes. See the "Intel Resource Director Technology Architecture Specification" for additional details. When SNC is enabled, update the MSR when a monitor domain is marked online. Technically this is overkill. It only needs to be done once per L3 cache instance rather than per SNC domain. But there is no harm in doing it more than once, and this is not in a critical path. Signed-off-by: Tony Luck <tony.luck@intel.com> Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de> Reviewed-by: Reinette Chatre <reinette.chatre@intel.com> Link: https://lore.kernel.org/r/20240702173820.90368-3-tony.luck@intel.com
1 parent 9fbb303 commit 21b362c

File tree

4 files changed

+25
-0
lines changed

4 files changed

+25
-0
lines changed

arch/x86/include/asm/msr-index.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1164,6 +1164,7 @@
11641164
#define MSR_IA32_QM_CTR 0xc8e
11651165
#define MSR_IA32_PQR_ASSOC 0xc8f
11661166
#define MSR_IA32_L3_CBM_BASE 0xc90
1167+
#define MSR_RMID_SNC_CONFIG 0xca0
11671168
#define MSR_IA32_L2_CBM_BASE 0xd10
11681169
#define MSR_IA32_MBA_THRTL_BASE 0xd50
11691170

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -615,6 +615,8 @@ static void domain_add_cpu_mon(int cpu, struct rdt_resource *r)
615615
}
616616
cpumask_set_cpu(cpu, &d->hdr.cpu_mask);
617617

618+
arch_mon_domain_online(r, d);
619+
618620
if (arch_domain_mbm_alloc(r->num_rmid, hw_dom)) {
619621
mon_domain_free(hw_dom);
620622
return;

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,8 @@ static inline bool resctrl_arch_get_cdp_enabled(enum resctrl_res_level l)
534534

535535
int resctrl_arch_set_cdp_enabled(enum resctrl_res_level l, bool enable);
536536

537+
void arch_mon_domain_online(struct rdt_resource *r, struct rdt_mon_domain *d);
538+
537539
/*
538540
* To return the common struct rdt_resource, which is contained in struct
539541
* rdt_hw_resource, walk the resctrl member of struct rdt_hw_resource.

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1090,6 +1090,26 @@ static void l3_mon_evt_init(struct rdt_resource *r)
10901090
list_add_tail(&mbm_local_event.list, &r->evt_list);
10911091
}
10921092

1093+
/*
1094+
* The power-on reset value of MSR_RMID_SNC_CONFIG is 0x1
1095+
* which indicates that RMIDs are configured in legacy mode.
1096+
* This mode is incompatible with Linux resctrl semantics
1097+
* as RMIDs are partitioned between SNC nodes, which requires
1098+
* a user to know which RMID is allocated to a task.
1099+
* Clearing bit 0 reconfigures the RMID counters for use
1100+
* in RMID sharing mode. This mode is better for Linux.
1101+
* The RMID space is divided between all SNC nodes with the
1102+
* RMIDs renumbered to start from zero in each node when
1103+
* counting operations from tasks. Code to read the counters
1104+
* must adjust RMID counter numbers based on SNC node. See
1105+
* logical_rmid_to_physical_rmid() for code that does this.
1106+
*/
1107+
void arch_mon_domain_online(struct rdt_resource *r, struct rdt_mon_domain *d)
1108+
{
1109+
if (snc_nodes_per_l3_cache > 1)
1110+
msr_clear_bit(MSR_RMID_SNC_CONFIG, 0);
1111+
}
1112+
10931113
int __init rdt_get_mon_l3_config(struct rdt_resource *r)
10941114
{
10951115
unsigned int mbm_offset = boot_cpu_data.x86_cache_mbm_width_offset;

0 commit comments

Comments
 (0)