
From: Jason Zeng <jason.zeng@intel.com> maillist inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/IAG93D -------------------------------- The newly added resctrl_feat_type are all about ARM-specific, meaning they are architecture-specific. If more architectures support more features in the future, the staged_config array inside struct rdt_domain will become larger. Moreover, this array is a waste of space for other architectures. Here we introduce the arch-specific resctrl_arch_staged_config struct to solve it. Signed-off-by: Jason Zeng <jason.zeng@intel.com> Signed-off-by: Zeng Heng <zengheng4@huawei.com> --- arch/x86/include/asm/resctrl.h | 4 +++ arch/x86/kernel/cpu/resctrl/ctrlmondata.c | 41 +++++++++++++---------- drivers/platform/mpam/mpam_resctrl.c | 10 +++++- fs/resctrl/ctrlmondata.c | 6 ++-- fs/resctrl/rdtgroup.c | 4 +-- include/linux/arm_mpam.h | 4 +++ include/linux/resctrl.h | 19 +++++------ include/linux/resctrl_types.h | 10 ++++++ 8 files changed, 63 insertions(+), 35 deletions(-) diff --git a/arch/x86/include/asm/resctrl.h b/arch/x86/include/asm/resctrl.h index b0cb9d283a2b..829c87f928c4 100644 --- a/arch/x86/include/asm/resctrl.h +++ b/arch/x86/include/asm/resctrl.h @@ -9,6 +9,10 @@ #include <linux/sched.h> #include <linux/resctrl_types.h> +struct resctrl_arch_staged_config { + struct resctrl_staged_config config; +}; + /* * This value can never be a valid CLOSID, and is used when mapping a * (closid, rmid) pair to an index and back. On x86 only the RMID is diff --git a/arch/x86/kernel/cpu/resctrl/ctrlmondata.c b/arch/x86/kernel/cpu/resctrl/ctrlmondata.c index 30b57c88e3bf..f86c43fbacfb 100644 --- a/arch/x86/kernel/cpu/resctrl/ctrlmondata.c +++ b/arch/x86/kernel/cpu/resctrl/ctrlmondata.c @@ -61,13 +61,20 @@ int resctrl_arch_update_one(struct rdt_resource *r, struct rdt_domain *d, return 0; } +struct resctrl_staged_config * +resctrl_arch_get_staged_config(struct rdt_domain *domain, + enum resctrl_conf_type conf_type, + enum resctrl_feat_type feat_type) +{ + return &domain->staged_config[conf_type].config; +} + int resctrl_arch_update_domains(struct rdt_resource *r, u32 closid) { struct resctrl_staged_config *cfg; struct rdt_hw_domain *hw_dom; struct msr_param msr_param; enum resctrl_conf_type t; - enum resctrl_feat_type f; cpumask_var_t cpu_mask; struct rdt_domain *d; u32 idx; @@ -82,23 +89,21 @@ int resctrl_arch_update_domains(struct rdt_resource *r, u32 closid) list_for_each_entry(d, &r->domains, list) { hw_dom = resctrl_to_arch_dom(d); for (t = 0; t < CDP_NUM_TYPES; t++) { - for (f = 0; f < FEAT_NUM_TYPES; f++) { - cfg = &hw_dom->d_resctrl.staged_config[t][f]; - if (!cfg->have_new_ctrl) - continue; - - idx = resctrl_get_config_index(closid, t); - if (!apply_config(hw_dom, cfg, idx, cpu_mask)) - continue; - - if (!msr_param.res) { - msr_param.low = idx; - msr_param.high = msr_param.low + 1; - msr_param.res = r; - } else { - msr_param.low = min(msr_param.low, idx); - msr_param.high = max(msr_param.high, idx + 1); - } + cfg = resctrl_arch_get_staged_config(&hw_dom->d_resctrl, t, 0); + if (!cfg->have_new_ctrl) + continue; + + idx = resctrl_get_config_index(closid, t); + if (!apply_config(hw_dom, cfg, idx, cpu_mask)) + continue; + + if (!msr_param.res) { + msr_param.low = idx; + msr_param.high = msr_param.low + 1; + msr_param.res = r; + } else { + msr_param.low = min(msr_param.low, idx); + msr_param.high = max(msr_param.high, idx + 1); } } } diff --git a/drivers/platform/mpam/mpam_resctrl.c b/drivers/platform/mpam/mpam_resctrl.c index d3dc628f9fec..64f6cbb86061 100644 --- a/drivers/platform/mpam/mpam_resctrl.c +++ b/drivers/platform/mpam/mpam_resctrl.c @@ -312,6 +312,14 @@ struct rdt_resource *resctrl_arch_get_resource(enum resctrl_res_level l) return &mpam_resctrl_exports[l].resctrl_res; } +struct resctrl_staged_config * +resctrl_arch_get_staged_config(struct rdt_domain *domain, + enum resctrl_conf_type conf_type, + enum resctrl_feat_type feat_type) +{ + return &domain->staged_config[conf_type].config[feat_type]; +} + static void *resctrl_arch_mon_ctx_alloc_no_wait(struct rdt_resource *r, int evtid) { @@ -1235,7 +1243,7 @@ int resctrl_arch_update_domains(struct rdt_resource *r, u32 closid) list_for_each_entry(d, &r->domains, list) { for (t = 0; t < CDP_NUM_TYPES; t++) { for (f = 0; f < FEAT_NUM_TYPES; f++) { - cfg = &d->staged_config[t][f]; + cfg = resctrl_arch_get_staged_config(d, t, f); if (!cfg->have_new_ctrl) continue; diff --git a/fs/resctrl/ctrlmondata.c b/fs/resctrl/ctrlmondata.c index ec27c7cc12e3..67e1faed70fd 100644 --- a/fs/resctrl/ctrlmondata.c +++ b/fs/resctrl/ctrlmondata.c @@ -140,7 +140,7 @@ static int parse_bw_conf_type(struct rdt_parse_data *data, struct resctrl_schema struct rdt_resource *r = s->res; unsigned long bw_val; - cfg = &d->staged_config[conf_type][s->feat_type]; + cfg = resctrl_arch_get_staged_config(d, conf_type, s->feat_type); if (cfg->have_new_ctrl) { rdt_last_cmd_printf("Duplicate domain %d\n", d->id); return -EINVAL; @@ -257,7 +257,7 @@ static int parse_cbm(struct rdt_parse_data *data, struct resctrl_schema *s, struct rdt_resource *r = s->res; u32 cbm_val; - cfg = &d->staged_config[s->conf_type][s->feat_type]; + cfg = resctrl_arch_get_staged_config(d, s->conf_type, s->feat_type); if (cfg->have_new_ctrl) { rdt_last_cmd_printf("Duplicate domain %d\n", d->id); return -EINVAL; @@ -361,7 +361,7 @@ static int parse_line(char *line, struct resctrl_schema *s, if (parse_ctrlval(&data, s, d)) return -EINVAL; if (rdtgrp->mode == RDT_MODE_PSEUDO_LOCKSETUP) { - cfg = &d->staged_config[t][f]; + cfg = resctrl_arch_get_staged_config(d, t, f); /* * In pseudo-locking setup mode and just * parsed a valid CBM that should be diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c index 2d0a349caadf..8a44c839b69d 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -3088,7 +3088,7 @@ static int __init_one_rdt_domain(struct rdt_domain *d, struct resctrl_schema *s, u32 peer_ctl, ctrl_val; int i; - cfg = &d->staged_config[t][feat]; + cfg = resctrl_arch_get_staged_config(d, t, feat); cfg->have_new_ctrl = false; cfg->new_ctrl = r->cache.shareable_bits; used_b = r->cache.shareable_bits; @@ -3181,7 +3181,7 @@ static void rdtgroup_init_mba(struct rdt_resource *r, u32 closid) continue; } - cfg = &d->staged_config[CDP_NONE][FEAT_MAX]; + cfg = resctrl_arch_get_staged_config(d, CDP_NONE, FEAT_MAX); cfg->new_ctrl = r->default_ctrl; cfg->have_new_ctrl = true; } diff --git a/include/linux/arm_mpam.h b/include/linux/arm_mpam.h index afc7445f09e1..d8782452a46f 100644 --- a/include/linux/arm_mpam.h +++ b/include/linux/arm_mpam.h @@ -31,6 +31,10 @@ enum mpam_class_types { MPAM_CLASS_UNKNOWN, /* Everything else, e.g. SMMU */ }; +struct resctrl_arch_staged_config { + struct resctrl_staged_config config[FEAT_NUM_TYPES]; +}; + #ifdef CONFIG_ACPI_MPAM /* Parse the ACPI description of resources entries for this MSC. */ int acpi_mpam_parse_resources(struct mpam_msc *msc, diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index 0dbee80f7211..fb5d0da4168d 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -78,16 +78,6 @@ struct pseudo_lock_region { struct list_head pm_reqs; }; -/** - * struct resctrl_staged_config - parsed configuration to be applied - * @new_ctrl: new ctrl value to be loaded - * @have_new_ctrl: whether the user provided new_ctrl is valid - */ -struct resctrl_staged_config { - u32 new_ctrl; - bool have_new_ctrl; -}; - /** * struct rdt_domain - group of CPUs sharing a resctrl resource * @list: all instances of this resource @@ -118,7 +108,9 @@ struct rdt_domain { int mbm_work_cpu; int cqm_work_cpu; struct pseudo_lock_region *plr; - struct resctrl_staged_config staged_config[CDP_NUM_TYPES][FEAT_NUM_TYPES]; +#ifdef CONFIG_ARCH_HAS_CPU_RESCTRL + struct resctrl_arch_staged_config staged_config[CDP_NUM_TYPES]; +#endif u32 *mbps_val; }; @@ -222,6 +214,11 @@ struct rdt_resource { */ struct rdt_resource *resctrl_arch_get_resource(enum resctrl_res_level l); +struct resctrl_staged_config * +resctrl_arch_get_staged_config(struct rdt_domain *domain, + enum resctrl_conf_type conf_type, + enum resctrl_feat_type feat_type); + /** * struct resctrl_schema - configuration abilities of a resource presented to * user-space diff --git a/include/linux/resctrl_types.h b/include/linux/resctrl_types.h index f6a0d8142fde..ed17e672690d 100644 --- a/include/linux/resctrl_types.h +++ b/include/linux/resctrl_types.h @@ -105,4 +105,14 @@ enum resctrl_event_id { QOS_L3_MBM_LOCAL_EVENT_ID = 0x03, }; +/** + * struct resctrl_staged_config - parsed configuration to be applied + * @new_ctrl: new ctrl value to be loaded + * @have_new_ctrl: whether the user provided new_ctrl is valid + */ +struct resctrl_staged_config { + u32 new_ctrl; + bool have_new_ctrl; +}; + #endif /* __LINUX_RESCTRL_TYPES_H */ -- 2.25.1