Skip to content

Commit a547a58

Browse files
Peter Newmanbp3tk0v
authored andcommitted
x86/resctrl: Fix arch_mbm_* array overrun on SNC
When using resctrl on systems with Sub-NUMA Clustering enabled, monitoring groups may be allocated RMID values which would overrun the arch_mbm_{local,total} arrays. This is due to inconsistencies in whether the SNC-adjusted num_rmid value or the unadjusted value in resctrl_arch_system_num_rmid_idx() is used. The num_rmid value for the L3 resource is currently: resctrl_arch_system_num_rmid_idx() / snc_nodes_per_l3_cache As a simple fix, make resctrl_arch_system_num_rmid_idx() return the SNC-adjusted, L3 num_rmid value on x86. Fixes: e13db55 ("x86/resctrl: Introduce snc_nodes_per_l3_cache") Signed-off-by: Peter Newman <[email protected]> Signed-off-by: Borislav Petkov (AMD) <[email protected]> Reviewed-by: Reinette Chatre <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent b6fb565 commit a547a58

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

arch/x86/include/asm/resctrl.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -156,12 +156,6 @@ static inline void resctrl_sched_in(struct task_struct *tsk)
156156
__resctrl_sched_in(tsk);
157157
}
158158

159-
static inline u32 resctrl_arch_system_num_rmid_idx(void)
160-
{
161-
/* RMID are independent numbers for x86. num_rmid_idx == num_rmid */
162-
return boot_cpu_data.x86_cache_max_rmid + 1;
163-
}
164-
165159
static inline void resctrl_arch_rmid_idx_decode(u32 idx, u32 *closid, u32 *rmid)
166160
{
167161
*rmid = idx;

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,14 @@ struct rdt_hw_resource rdt_resources_all[] = {
119119
},
120120
};
121121

122+
u32 resctrl_arch_system_num_rmid_idx(void)
123+
{
124+
struct rdt_resource *r = &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl;
125+
126+
/* RMID are independent numbers for x86. num_rmid_idx == num_rmid */
127+
return r->num_rmid;
128+
}
129+
122130
/*
123131
* cache_alloc_hsw_probe() - Have to probe for Intel haswell server CPUs
124132
* as they do not have CPUID enumeration support for Cache allocation.

include/linux/resctrl.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@ struct resctrl_schema {
248248

249249
/* The number of closid supported by this resource regardless of CDP */
250250
u32 resctrl_arch_get_num_closid(struct rdt_resource *r);
251+
u32 resctrl_arch_system_num_rmid_idx(void);
251252
int resctrl_arch_update_domains(struct rdt_resource *r, u32 closid);
252253

253254
/*

0 commit comments

Comments
 (0)