With the narrow PARTID feature, each control group is assigned multiple (req)PARTIDs to expand monitoring capacity. When a control group's configuration is updated, all associated sub-monitoring groups (each identified by a unique reqPARTID) should be synchronized. In __write_config(), iterate over all reqPARTIDs belonging to the control group and propagate the configuration to each sub-monitoring group: 1. For MSCs supporting narrow PARTID, establish the reqPARTID to intPARTID mapping. 2. For MSCs without narrow PARTID support, synchronize the configuration to new PARTIDs directly. Signed-off-by: Zeng Heng <zengheng4@huawei.com> --- drivers/resctrl/mpam_devices.c | 33 +++++++++++++++++++++++++++------ drivers/resctrl/mpam_internal.h | 2 ++ drivers/resctrl/mpam_resctrl.c | 2 +- 3 files changed, 30 insertions(+), 7 deletions(-) diff --git a/drivers/resctrl/mpam_devices.c b/drivers/resctrl/mpam_devices.c index c5b3812e86ab..52533ee0e6ce 100644 --- a/drivers/resctrl/mpam_devices.c +++ b/drivers/resctrl/mpam_devices.c @@ -1541,6 +1541,7 @@ static void mpam_reprogram_ris_partid(struct mpam_msc_ris *ris, u16 partid, { u32 pri_val = 0; u16 cmax = MPAMCFG_CMAX_CMAX; + u16 intpartid = req2intpartid(partid); struct mpam_msc *msc = ris->vmsc->msc; struct mpam_props *rprops = &ris->props; u16 dspri = GENMASK(rprops->dspri_wd, 0); @@ -1550,15 +1551,17 @@ static void mpam_reprogram_ris_partid(struct mpam_msc_ris *ris, u16 partid, __mpam_part_sel(ris->ris_idx, partid, msc); if (mpam_has_feature(mpam_feat_partid_nrw, rprops)) { - /* Update the intpartid mapping */ mpam_write_partsel_reg(msc, INTPARTID, - MPAMCFG_INTPARTID_INTERNAL | partid); + MPAMCFG_INTPARTID_INTERNAL | intpartid); /* - * Then switch to the 'internal' partid to update the - * configuration. + * Mapping from reqpartid to intpartid already established. + * Sub-monitoring groups share the parent's configuration. */ - __mpam_intpart_sel(ris->ris_idx, partid, msc); + if (partid != intpartid) + goto out; + + __mpam_intpart_sel(ris->ris_idx, intpartid, msc); } if (mpam_has_feature(mpam_feat_cpor_part, rprops) && @@ -1630,6 +1633,7 @@ static void mpam_reprogram_ris_partid(struct mpam_msc_ris *ris, u16 partid, mpam_quirk_post_config_change(ris, partid, cfg); +out: mutex_unlock(&msc->part_sel_lock); } @@ -1764,11 +1768,28 @@ struct mpam_write_config_arg { u16 partid; }; +static u32 get_num_reqpartid_per_intpartid(void) +{ + return (mpam_partid_max + 1) / (mpam_intpartid_max + 1); +} + static int __write_config(void *arg) { + int closid_num = resctrl_arch_get_num_closid(NULL); struct mpam_write_config_arg *c = arg; + u32 reqpartid, req_idx; - mpam_reprogram_ris_partid(c->ris, c->partid, &c->comp->cfg[c->partid]); + /* c->partid should be within the range of intPARTIDs */ + WARN_ON_ONCE(c->partid >= closid_num); + + /* Synchronize the configuration to each sub-monitoring group. */ + for (req_idx = 0; req_idx < get_num_reqpartid_per_intpartid(); + req_idx++) { + reqpartid = req_idx * closid_num + c->partid; + + mpam_reprogram_ris_partid(c->ris, reqpartid, + &c->comp->cfg[c->partid]); + } return 0; } diff --git a/drivers/resctrl/mpam_internal.h b/drivers/resctrl/mpam_internal.h index 0b19742d8660..013162faf37f 100644 --- a/drivers/resctrl/mpam_internal.h +++ b/drivers/resctrl/mpam_internal.h @@ -478,6 +478,8 @@ void mpam_msmon_reset_mbwu(struct mpam_component *comp, struct mon_cfg *ctx); int mpam_get_cpumask_from_cache_id(unsigned long cache_id, u32 cache_level, cpumask_t *affinity); +u16 req2intpartid(u16 reqpartid); + #ifdef CONFIG_RESCTRL_FS int mpam_resctrl_setup(void); void mpam_resctrl_exit(void); diff --git a/drivers/resctrl/mpam_resctrl.c b/drivers/resctrl/mpam_resctrl.c index 6cbca21096f7..bb2fdfc03b75 100644 --- a/drivers/resctrl/mpam_resctrl.c +++ b/drivers/resctrl/mpam_resctrl.c @@ -296,7 +296,7 @@ static u8 rmid2pmg(u32 rmid) return rmid % (mpam_pmg_max + 1); } -static u16 req2intpartid(u16 reqpartid) +u16 req2intpartid(u16 reqpartid) { return reqpartid % (mpam_intpartid_max + 1); } -- 2.25.1