
hulk inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I8T2RT -------------------------------- To support the MB monitoring feature, provide mbm_total_bytes interface under the resctrl fs to monitor the MATA memory bandwidth. In fact, resctrl does not mandate that MBM should work in the mode of free running, so even if the number of monitor instances doesn't meet the number of resctrl has control/monitor groups, it will not affect the monitoring function. Fixes: dc2005d467b3 ("untested: arm_mpam: resctrl: Add support for mbm counters") Signed-off-by: Zeng Heng <zengheng4@huawei.com> --- drivers/platform/mpam/mpam_resctrl.c | 8 ------ fs/resctrl/monitor.c | 42 ++++++++++++++++++++-------- 2 files changed, 30 insertions(+), 20 deletions(-) diff --git a/drivers/platform/mpam/mpam_resctrl.c b/drivers/platform/mpam/mpam_resctrl.c index 38e53c46a9ec..4e5e54c90388 100644 --- a/drivers/platform/mpam/mpam_resctrl.c +++ b/drivers/platform/mpam/mpam_resctrl.c @@ -473,14 +473,6 @@ static bool class_has_usable_mbwu(struct mpam_class *class) if (!mpam_has_feature(mpam_feat_msmon_mbwu, cprops)) return false; - /* - * resctrl expects the bandwidth counters to be free running, - * which means we need as many monitors as resctrl has - * control/monitor groups. - */ - if (cprops->num_mbwu_mon < resctrl_arch_system_num_rmid_idx()) - return false; - return (mpam_partid_max > 1) || (mpam_pmg_max != 0); } diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c index 68401ca0827a..cecd98fdb85e 100644 --- a/fs/resctrl/monitor.c +++ b/fs/resctrl/monitor.c @@ -817,29 +817,30 @@ static void l3_mon_evt_init(struct rdt_resource *r) { INIT_LIST_HEAD(&r->evt_list); - if (resctrl_arch_is_llc_occupancy_enabled()) + if ((r->rid == RDT_RESOURCE_L3) && + resctrl_arch_is_llc_occupancy_enabled()) { list_add_tail(&llc_occupancy_event.list, &r->evt_list); - if (resctrl_arch_is_mbm_total_enabled()) + + if (resctrl_arch_is_mbm_local_enabled()) + list_add_tail(&mbm_local_event.list, &r->evt_list); + } + + if ((r->rid == RDT_RESOURCE_MBA) && + resctrl_arch_is_mbm_total_enabled()) list_add_tail(&mbm_total_event.list, &r->evt_list); - if (resctrl_arch_is_mbm_local_enabled()) - list_add_tail(&mbm_local_event.list, &r->evt_list); } -int resctrl_mon_resource_init(void) +static int __resctrl_mon_resource_init(enum resctrl_res_level res) { - struct rdt_resource *r = resctrl_arch_get_resource(RDT_RESOURCE_L3); - int ret; + struct rdt_resource *r = resctrl_arch_get_resource(res); if (!r->mon_capable) return 0; - ret = dom_data_init(r); - if (ret) - return ret; - l3_mon_evt_init(r); - if (resctrl_arch_is_evt_configurable(QOS_L3_MBM_TOTAL_EVENT_ID)) { + if ((r->rid == RDT_RESOURCE_MBA) && + resctrl_arch_is_evt_configurable(QOS_L3_MBM_TOTAL_EVENT_ID)) { mbm_total_event.configurable = true; mbm_config_rftype_init("mbm_total_bytes_config"); } @@ -851,6 +852,23 @@ int resctrl_mon_resource_init(void) return 0; } +int resctrl_mon_resource_init(void) +{ + struct rdt_resource *r = resctrl_arch_get_resource(RDT_RESOURCE_L3); + int ret; + + if (!r->mon_capable) + return 0; + + ret = dom_data_init(r); + if (ret) + return ret; + + __resctrl_mon_resource_init(RDT_RESOURCE_L3); + __resctrl_mon_resource_init(RDT_RESOURCE_MBA); + return 0; +} + void resctrl_mon_resource_exit(void) { struct rdt_resource *r = resctrl_arch_get_resource(RDT_RESOURCE_L3); -- 2.25.1