hulk inclusion category: feature bugzilla: https://atomgit.com/openeuler/kernel/issues/9840 ------------------ Replace the global resctrl_is_mbm_enabled() with a resource-specific resctrl_arch_is_mbm_enabled(rid) that allows architectures to determine MBM support based on the resource level (L2/L3/MBA). This change is necessary because: * x86 supports MBM only on L3 (total and local) * ARM MPAM supports MBM on L2 (core), L3 (local), and MBA (total) * The previous global check can't aggregate all MBM types, leading to false positives when only specific resources support MBM Update all call sites to pass the appropriate rid. Signed-off-by: Zeng Heng <zengheng4@huawei.com> --- drivers/platform/mpam/mpam_resctrl.c | 14 ++++++++++++++ fs/resctrl/rdtgroup.c | 15 ++++----------- include/linux/arm_mpam.h | 1 + 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/drivers/platform/mpam/mpam_resctrl.c b/drivers/platform/mpam/mpam_resctrl.c index a16f1318799c1..9c1d98791e225 100644 --- a/drivers/platform/mpam/mpam_resctrl.c +++ b/drivers/platform/mpam/mpam_resctrl.c @@ -85,6 +85,20 @@ bool resctrl_arch_is_mbm_core_enabled(void) return mbm_core_class; } +bool resctrl_arch_is_mbm_enabled(enum resctrl_res_level rid) +{ + switch (rid) { + case RDT_RESOURCE_L2: + return resctrl_arch_is_mbm_core_enabled(); + case RDT_RESOURCE_L3: + return resctrl_arch_is_mbm_local_enabled(); + case RDT_RESOURCE_MBA: + return resctrl_arch_is_mbm_total_enabled(); + default: + return false; + } +} + bool resctrl_arch_get_cdp_enabled(enum resctrl_res_level rid) { switch (rid) { diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c index 16c4f9311111d..139ea6bc446cd 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -111,13 +111,6 @@ void rdt_staged_configs_clear(void) } } -static bool resctrl_is_mbm_enabled(void) -{ - return (resctrl_arch_is_mbm_total_enabled() || - resctrl_arch_is_mbm_local_enabled() || - resctrl_arch_is_mbm_core_enabled()); -} - static bool resctrl_is_mbm_event(int e) { return (e == QOS_L3_MBM_TOTAL_EVENT_ID || @@ -2765,7 +2758,7 @@ static int rdt_get_tree(struct fs_context *fc) if (resctrl_arch_alloc_capable() || resctrl_arch_mon_capable()) resctrl_mounted = true; - if (resctrl_is_mbm_enabled() && resctrl_arch_would_mbm_overflow()) { + if (resctrl_arch_is_mbm_enabled(l3->rid) && resctrl_arch_would_mbm_overflow()) { list_for_each_entry(dom, &l3->domains, list) mbm_setup_overflow_handler(dom, MBM_OVERFLOW_INTERVAL, RESCTRL_PICK_ANY_CPU); @@ -4072,7 +4065,7 @@ void resctrl_offline_domain(struct rdt_resource *r, struct rdt_domain *d) if (resctrl_mounted && resctrl_arch_mon_capable()) rmdir_mondata_subdir_allrdtgrp(r, d->id); - if (resctrl_is_mbm_enabled() && resctrl_arch_would_mbm_overflow()) + if (resctrl_arch_is_mbm_enabled(r->rid) && resctrl_arch_would_mbm_overflow()) cancel_delayed_work(&d->mbm_over); if (resctrl_arch_is_llc_occupancy_enabled() && has_busy_rmid(d)) { /* @@ -4153,7 +4146,7 @@ int resctrl_online_domain(struct rdt_resource *r, struct rdt_domain *d) if (err) goto out_unlock; - if (resctrl_is_mbm_enabled() && resctrl_arch_would_mbm_overflow()) { + if (resctrl_arch_is_mbm_enabled(r->rid) && resctrl_arch_would_mbm_overflow()) { INIT_DELAYED_WORK(&d->mbm_over, mbm_handle_overflow); mbm_setup_overflow_handler(d, MBM_OVERFLOW_INTERVAL, RESCTRL_PICK_ANY_CPU); @@ -4214,7 +4207,7 @@ void resctrl_offline_cpu(unsigned int cpu) d = resctrl_get_domain_from_cpu(cpu, l3); if (d) { - if (resctrl_is_mbm_enabled() && cpu == d->mbm_work_cpu && + if (resctrl_arch_is_mbm_enabled(l3->rid) && cpu == d->mbm_work_cpu && resctrl_arch_would_mbm_overflow()) { cancel_delayed_work(&d->mbm_over); mbm_setup_overflow_handler(d, 0, cpu); diff --git a/include/linux/arm_mpam.h b/include/linux/arm_mpam.h index a1a511d07eec1..25c62a42bd2c2 100644 --- a/include/linux/arm_mpam.h +++ b/include/linux/arm_mpam.h @@ -68,6 +68,7 @@ bool resctrl_arch_is_l2c_occupancy_enabled(void); bool resctrl_arch_is_mbm_core_enabled(void); bool resctrl_arch_is_mbm_local_enabled(void); bool resctrl_arch_is_mbm_total_enabled(void); +bool resctrl_arch_is_mbm_enabled(enum resctrl_res_level rid); bool resctrl_arch_would_mbm_overflow(void); /* reset cached configurations, then all devices */ -- 2.43.0