Skip to content

Commit 0ecc988

Browse files
aeglbp3tk0v
authored andcommitted
x86,fs/resctrl: Compute number of RMIDs as minimum across resources
resctrl assumes that only the L3 resource supports monitor events, so it simply takes the rdt_resource::num_rmid from RDT_RESOURCE_L3 as the system's number of RMIDs. The addition of telemetry events in a different resource breaks that assumption. Compute the number of available RMIDs as the minimum value across all mon_capable resources (analogous to how the number of CLOSIDs is computed across alloc_capable resources). Note that mount time enumeration of the telemetry resource means that this number can be reduced. If this happens, then some memory will be wasted as the allocations for rdt_l3_mon_domain::mbm_states[] and rdt_l3_mon_domain::rmid_busy_llc created during resctrl initialization will be larger than needed. 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/20251217172121.12030-1-tony.luck@intel.com
1 parent ee7f6af commit 0ecc988

2 files changed

Lines changed: 19 additions & 2 deletions

File tree

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

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,23 @@ struct rdt_hw_resource rdt_resources_all[RDT_NUM_RESOURCES] = {
110110
},
111111
};
112112

113+
/**
114+
* resctrl_arch_system_num_rmid_idx - Compute number of supported RMIDs
115+
* (minimum across all mon_capable resource)
116+
*
117+
* Return: Number of supported RMIDs at time of call. Note that mount time
118+
* enumeration of resources may reduce the number.
119+
*/
113120
u32 resctrl_arch_system_num_rmid_idx(void)
114121
{
115-
struct rdt_resource *r = &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl;
122+
u32 num_rmids = U32_MAX;
123+
struct rdt_resource *r;
124+
125+
for_each_mon_capable_rdt_resource(r)
126+
num_rmids = min(num_rmids, r->mon.num_rmid);
116127

117128
/* RMID are independent numbers for x86. num_rmid_idx == num_rmid */
118-
return r->mon.num_rmid;
129+
return num_rmids == U32_MAX ? 0 : num_rmids;
119130
}
120131

121132
struct rdt_resource *resctrl_arch_get_resource(enum resctrl_res_level l)

fs/resctrl/rdtgroup.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4353,6 +4353,12 @@ void resctrl_offline_mon_domain(struct rdt_resource *r, struct rdt_domain_hdr *h
43534353
* During boot this may be called before global allocations have been made by
43544354
* resctrl_l3_mon_resource_init().
43554355
*
4356+
* Called during CPU online that may run as soon as CPU online callbacks
4357+
* are set up during resctrl initialization. The number of supported RMIDs
4358+
* may be reduced if additional mon_capable resources are enumerated
4359+
* at mount time. This means the rdt_l3_mon_domain::mbm_states[] and
4360+
* rdt_l3_mon_domain::rmid_busy_llc allocations may be larger than needed.
4361+
*
43564362
* Return: 0 for success, or -ENOMEM.
43574363
*/
43584364
static int domain_setup_l3_mon_state(struct rdt_resource *r, struct rdt_l3_mon_domain *d)

0 commit comments

Comments
 (0)