Skip to content

Commit d81826f

Browse files
James Morsebp3tk0v
authored andcommitted
x86/resctrl: Add resctrl_arch_is_evt_configurable() to abstract BMEC
When BMEC is supported the resctrl event can be configured in a number of ways. This depends on architecture support. rdt_get_mon_l3_config() modifies the struct mon_evt and calls resctrl_file_fflags_init() to create the files that allow the configuration. Splitting this into separate architecture and filesystem parts would require the struct mon_evt and resctrl_file_fflags_init() to be exposed. Instead, add resctrl_arch_is_evt_configurable(), and use this from resctrl_mon_resource_init() to initialise struct mon_evt and call resctrl_file_fflags_init(). resctrl_arch_is_evt_configurable() calls rdt_cpu_has() so it doesn't obviously benefit from being inlined. Putting it in core.c will allow rdt_cpu_has() to eventually become static. Signed-off-by: James Morse <[email protected]> Signed-off-by: Borislav Petkov (AMD) <[email protected]> Reviewed-by: Shaopeng Tan <[email protected]> Reviewed-by: Tony Luck <[email protected]> Reviewed-by: Fenghua Yu <[email protected]> Reviewed-by: Reinette Chatre <[email protected]> Reviewed-by: Babu Moger <[email protected]> Tested-by: Carl Worth <[email protected]> # arm64 Tested-by: Shaopeng Tan <[email protected]> Tested-by: Peter Newman <[email protected]> Tested-by: Amit Singh Tomar <[email protected]> # arm64 Tested-by: Shanker Donthineni <[email protected]> # arm64 Tested-by: Babu Moger <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent d012b66 commit d81826f

File tree

3 files changed

+28
-11
lines changed

3 files changed

+28
-11
lines changed

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -830,6 +830,21 @@ bool __init rdt_cpu_has(int flag)
830830
return ret;
831831
}
832832

833+
__init bool resctrl_arch_is_evt_configurable(enum resctrl_event_id evt)
834+
{
835+
if (!rdt_cpu_has(X86_FEATURE_BMEC))
836+
return false;
837+
838+
switch (evt) {
839+
case QOS_L3_MBM_TOTAL_EVENT_ID:
840+
return rdt_cpu_has(X86_FEATURE_CQM_MBM_TOTAL);
841+
case QOS_L3_MBM_LOCAL_EVENT_ID:
842+
return rdt_cpu_has(X86_FEATURE_CQM_MBM_LOCAL);
843+
default:
844+
return false;
845+
}
846+
}
847+
833848
static __init bool get_mem_config(void)
834849
{
835850
struct rdt_hw_resource *hw_res = &rdt_resources_all[RDT_RESOURCE_MBA];

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1202,6 +1202,17 @@ int __init resctrl_mon_resource_init(void)
12021202

12031203
l3_mon_evt_init(r);
12041204

1205+
if (resctrl_arch_is_evt_configurable(QOS_L3_MBM_TOTAL_EVENT_ID)) {
1206+
mbm_total_event.configurable = true;
1207+
resctrl_file_fflags_init("mbm_total_bytes_config",
1208+
RFTYPE_MON_INFO | RFTYPE_RES_CACHE);
1209+
}
1210+
if (resctrl_arch_is_evt_configurable(QOS_L3_MBM_LOCAL_EVENT_ID)) {
1211+
mbm_local_event.configurable = true;
1212+
resctrl_file_fflags_init("mbm_local_bytes_config",
1213+
RFTYPE_MON_INFO | RFTYPE_RES_CACHE);
1214+
}
1215+
12051216
return 0;
12061217
}
12071218

@@ -1245,17 +1256,6 @@ int __init rdt_get_mon_l3_config(struct rdt_resource *r)
12451256
/* Detect list of bandwidth sources that can be tracked */
12461257
cpuid_count(0x80000020, 3, &eax, &ebx, &ecx, &edx);
12471258
hw_res->mbm_cfg_mask = ecx & MAX_EVT_CONFIG_BITS;
1248-
1249-
if (rdt_cpu_has(X86_FEATURE_CQM_MBM_TOTAL)) {
1250-
mbm_total_event.configurable = true;
1251-
resctrl_file_fflags_init("mbm_total_bytes_config",
1252-
RFTYPE_MON_INFO | RFTYPE_RES_CACHE);
1253-
}
1254-
if (rdt_cpu_has(X86_FEATURE_CQM_MBM_LOCAL)) {
1255-
mbm_local_event.configurable = true;
1256-
resctrl_file_fflags_init("mbm_local_bytes_config",
1257-
RFTYPE_MON_INFO | RFTYPE_RES_CACHE);
1258-
}
12591259
}
12601260

12611261
r->mon_capable = true;

include/linux/resctrl.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,8 @@ u32 resctrl_arch_get_num_closid(struct rdt_resource *r);
309309
u32 resctrl_arch_system_num_rmid_idx(void);
310310
int resctrl_arch_update_domains(struct rdt_resource *r, u32 closid);
311311

312+
__init bool resctrl_arch_is_evt_configurable(enum resctrl_event_id evt);
313+
312314
/*
313315
* Update the ctrl_val and apply this config right now.
314316
* Must be called on one of the domain's CPUs.

0 commit comments

Comments
 (0)