[PATCH OLK-6.6 0/2] arm64/mpam: Fix wrong closid config access when CDP is enabled
Zeng Heng (2): Revert "fs/resctrl: Fix configuration to wrong control group when CDP is enabled" arm64/mpam: Fix wrong closid config access when CDP is enabled arch/x86/include/asm/resctrl.h | 4 ---- drivers/platform/mpam/mpam_resctrl.c | 35 +++++++++++++++++++++------- fs/resctrl/ctrlmondata.c | 28 +++------------------- include/linux/arm_mpam.h | 1 - 4 files changed, 29 insertions(+), 39 deletions(-) -- 2.25.1
hulk inclusion category: cleanup bugzilla: https://atomgit.com/openeuler/kernel/issues/902 -------------------------------- This reverts commit 5e0e3aa64e83dff9703e3f887a2be3271801ed22. The original fix introduced unnecessary modifications to the resctrl common layer, adding undesirable complexity to the generic code. A better solution is being prepared that confines all changes within the ARM MPAM architecture-specific code, eliminating the need for common layer changes. Revert this patch to pave the way for the cleaner fix. Signed-off-by: Zeng Heng <zengheng4@huawei.com> --- arch/x86/include/asm/resctrl.h | 4 ---- drivers/platform/mpam/mpam_resctrl.c | 31 +++++++++++++++++----------- fs/resctrl/ctrlmondata.c | 28 +++---------------------- include/linux/arm_mpam.h | 1 - 4 files changed, 22 insertions(+), 42 deletions(-) diff --git a/arch/x86/include/asm/resctrl.h b/arch/x86/include/asm/resctrl.h index 406b4cf301bb..db70543123e9 100644 --- a/arch/x86/include/asm/resctrl.h +++ b/arch/x86/include/asm/resctrl.h @@ -224,10 +224,6 @@ void resctrl_cpu_detect(struct cpuinfo_x86 *c); bool resctrl_arch_get_cdp_enabled(enum resctrl_res_level l); int resctrl_arch_set_cdp_enabled(enum resctrl_res_level l, bool enable); -static inline bool resctrl_arch_hide_cdp(enum resctrl_res_level rid) -{ - return false; -}; #else diff --git a/drivers/platform/mpam/mpam_resctrl.c b/drivers/platform/mpam/mpam_resctrl.c index 8ee0857f9a93..773ab763d1bb 100644 --- a/drivers/platform/mpam/mpam_resctrl.c +++ b/drivers/platform/mpam/mpam_resctrl.c @@ -136,7 +136,7 @@ int resctrl_arch_set_cdp_enabled(enum resctrl_res_level ignored, bool enable) return 0; } -bool resctrl_arch_hide_cdp(enum resctrl_res_level rid) +static bool mpam_resctrl_hide_cdp(enum resctrl_res_level rid) { return cdp_enabled && !resctrl_arch_get_cdp_enabled(rid); } @@ -1244,16 +1244,7 @@ u32 resctrl_arch_get_config(struct rdt_resource *r, struct rdt_domain *d, dom = container_of(d, struct mpam_resctrl_dom, resctrl_dom); cprops = &res->class->props; - /* - * When CDP is enabled, but the resource doesn't support it, we - * need to get the configuration from the CDP_CODE resctrl_conf_type - * which is same as the CDP_DATA one. - */ - if (resctrl_arch_hide_cdp(r->rid)) - partid = resctrl_get_config_index(closid, CDP_CODE); - else - partid = resctrl_get_config_index(closid, type); - + partid = resctrl_get_config_index(closid, type); cfg = &dom->comp->cfg[partid]; switch (r->rid) { @@ -1328,6 +1319,7 @@ u32 resctrl_arch_get_config(struct rdt_resource *r, struct rdt_domain *d, int resctrl_arch_update_one(struct rdt_resource *r, struct rdt_domain *d, u32 closid, enum resctrl_conf_type t, u32 cfg_val) { + int err; u32 partid; struct mpam_config cfg; struct mpam_props *cprops; @@ -1398,7 +1390,22 @@ int resctrl_arch_update_one(struct rdt_resource *r, struct rdt_domain *d, return -EINVAL; } - return mpam_apply_config(dom->comp, partid, &cfg); + /* + * When CDP is enabled, but the resource doesn't support it, we need to + * apply the same configuration to the other partid. + */ + if (mpam_resctrl_hide_cdp(r->rid)) { + partid = resctrl_get_config_index(closid, CDP_CODE); + err = mpam_apply_config(dom->comp, partid, &cfg); + if (err) + return err; + + partid = resctrl_get_config_index(closid, CDP_DATA); + return mpam_apply_config(dom->comp, partid, &cfg); + + } else { + return mpam_apply_config(dom->comp, partid, &cfg); + } } /* TODO: this is IPI heavy */ diff --git a/fs/resctrl/ctrlmondata.c b/fs/resctrl/ctrlmondata.c index 547048f7bee7..cf4895b41fc4 100644 --- a/fs/resctrl/ctrlmondata.c +++ b/fs/resctrl/ctrlmondata.c @@ -73,15 +73,15 @@ static bool bw_validate(char *buf, unsigned long *data, struct rdt_resource *r) return true; } -static int parse_bw_conf_type(struct rdt_parse_data *data, struct resctrl_schema *s, - struct rdt_domain *d, enum resctrl_conf_type conf_type) +static int parse_bw(struct rdt_parse_data *data, struct resctrl_schema *s, + struct rdt_domain *d) { struct resctrl_staged_config *cfg; u32 closid = data->rdtgrp->closid; struct rdt_resource *r = s->res; unsigned long bw_val; - cfg = &d->staged_config[conf_type]; + cfg = &d->staged_config[s->conf_type]; if (cfg->have_new_ctrl) { rdt_last_cmd_printf("Duplicate domain %d\n", d->id); return -EINVAL; @@ -101,28 +101,6 @@ static int parse_bw_conf_type(struct rdt_parse_data *data, struct resctrl_schema return 0; } -static int parse_bw(struct rdt_parse_data *data, struct resctrl_schema *s, - struct rdt_domain *d) -{ - struct rdt_resource *r = s->res; - int err; - - /* - * When CDP is enabled, but the resource doesn't support it, we - * need to apply the same configuration to both of the CDP_CODE - * and CDP_DATA resctrl_conf_type. - */ - if (resctrl_arch_hide_cdp(r->rid)) { - err = parse_bw_conf_type(data, s, d, CDP_CODE); - if (err) - return err; - - return parse_bw_conf_type(data, s, d, CDP_DATA); - } - - return parse_bw_conf_type(data, s, d, s->conf_type); -} - /* * Check whether a cache bit mask is valid. * On Intel CPUs, non-contiguous 1s value support is indicated by CPUID: diff --git a/include/linux/arm_mpam.h b/include/linux/arm_mpam.h index 3a06a8afad7c..5d60e1c6ca6c 100644 --- a/include/linux/arm_mpam.h +++ b/include/linux/arm_mpam.h @@ -75,7 +75,6 @@ void resctrl_arch_reset_resources(void); bool resctrl_arch_get_cdp_enabled(enum resctrl_res_level ignored); int resctrl_arch_set_cdp_enabled(enum resctrl_res_level ignored, bool enable); -bool resctrl_arch_hide_cdp(enum resctrl_res_level rid); bool resctrl_arch_match_closid(struct task_struct *tsk, u32 closid); bool resctrl_arch_match_rmid(struct task_struct *tsk, u32 closid, u32 rmid); void resctrl_arch_set_cpu_default_closid(int cpu, u32 closid); -- 2.25.1
hulk inclusion category: bugfix bugzilla: https://atomgit.com/openeuler/kernel/issues/902 ------------------ For resources that hide CDP support, using the staged_config's type directly results in incorrect partid calculation, causing access to the wrong configuration (comp->cfg[partid]). Since CDP_CODE and CDP_DATA map to the same underlying configuration for these resources, force the use of CDP_DATA type to ensure correct partid indexing in resctrl_arch_get_config() and resctrl_arch_update_one(). Fixes: 58db5c68e84a ("untested: arm_mpam: resctrl: Add support for MB resource") Signed-off-by: Zeng Heng <zengheng4@huawei.com> --- drivers/platform/mpam/mpam_resctrl.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/platform/mpam/mpam_resctrl.c b/drivers/platform/mpam/mpam_resctrl.c index 773ab763d1bb..94bb46c0f633 100644 --- a/drivers/platform/mpam/mpam_resctrl.c +++ b/drivers/platform/mpam/mpam_resctrl.c @@ -1244,6 +1244,13 @@ u32 resctrl_arch_get_config(struct rdt_resource *r, struct rdt_domain *d, dom = container_of(d, struct mpam_resctrl_dom, resctrl_dom); cprops = &res->class->props; + /* + * For resources that don't support CDP, both CDP_CODE and + * CDP_DATA map to the same configuration. + */ + if (mpam_resctrl_hide_cdp(r->rid)) + type = CDP_DATA; + partid = resctrl_get_config_index(closid, type); cfg = &dom->comp->cfg[partid]; @@ -1335,6 +1342,9 @@ int resctrl_arch_update_one(struct rdt_resource *r, struct rdt_domain *d, dom = container_of(d, struct mpam_resctrl_dom, resctrl_dom); cprops = &res->class->props; + if (mpam_resctrl_hide_cdp(r->rid)) + t = CDP_DATA; + partid = resctrl_get_config_index(closid, t); if (!r->alloc_capable || partid >= resctrl_arch_get_num_closid(r)) return -EINVAL; -- 2.25.1
反馈: 您发送到kernel@openeuler.org的补丁/补丁集,已成功转换为PR! PR链接地址: https://atomgit.com/openeuler/kernel/merge_requests/21205 邮件列表地址:https://mailweb.openeuler.org/archives/list/kernel@openeuler.org/message/X4V... FeedBack: The patch(es) which you have sent to kernel@openeuler.org mailing list has been converted to a pull request successfully! Pull request link: https://atomgit.com/openeuler/kernel/merge_requests/21205 Mailing list address: https://mailweb.openeuler.org/archives/list/kernel@openeuler.org/message/X4V...
participants (2)
-
patchwork bot -
Zeng Heng