diff --git a/arch/arm64/include/asm/resctrl.h b/arch/arm64/include/asm/resctrl.h index af2388a43990b158f41061cc7f664472ebb7285d..15310ad1b2872f862a0492b22c889390f669b72e 100644 --- a/arch/arm64/include/asm/resctrl.h +++ b/arch/arm64/include/asm/resctrl.h @@ -195,6 +195,8 @@ struct resctrl_ctrl_feature { int default_ctrl; bool capable; bool enabled; + + const char *ctrl_suffix; }; struct msr_param { diff --git a/arch/arm64/kernel/mpam/mpam_ctrlmon.c b/arch/arm64/kernel/mpam/mpam_ctrlmon.c index 368cedcded1f74c803c0059782d9318066720e8e..90416179bad2912acb94230b47502e14e905bd16 100644 --- a/arch/arm64/kernel/mpam/mpam_ctrlmon.c +++ b/arch/arm64/kernel/mpam/mpam_ctrlmon.c @@ -46,12 +46,9 @@ static int add_schema(enum resctrl_conf_type t, struct resctrl_resource *r) { int ret = 0; char *suffix = ""; - char *ctrl_suffix = ""; struct resctrl_schema *s; struct raw_resctrl_resource *rr; - struct resctrl_schema_ctrl *sc, *sc_tmp; - struct resctrl_schema_ctrl *sc_pri = NULL; - struct resctrl_schema_ctrl *sc_hdl = NULL; + struct resctrl_schema_ctrl *sc, *tmp; enum resctrl_ctrl_type type; s = kzalloc(sizeof(*s), GFP_KERNEL); @@ -97,6 +94,9 @@ static int add_schema(enum resctrl_conf_type t, struct resctrl_resource *r) rr = r->res; INIT_LIST_HEAD(&s->schema_ctrl_list); for_each_extend_ctrl_type(type) { + struct resctrl_ctrl_feature *feature = + &rr->ctrl_features[type]; + if (!rr->ctrl_features[type].enabled || !rr->ctrl_features[type].max_wd) continue; @@ -107,25 +107,19 @@ static int add_schema(enum resctrl_conf_type t, struct resctrl_resource *r) goto err; } sc->ctrl_type = type; - if (type == SCHEMA_PRI) { - sc_pri = sc; - ctrl_suffix = "PRI"; - } else if (type == SCHEMA_HDL) { - sc_hdl = sc; - ctrl_suffix = "HDL"; - } WARN_ON_ONCE(strlen(r->name) + strlen(suffix) + - strlen(ctrl_suffix) + 1 > RESCTRL_NAME_LEN); - snprintf(sc->name, sizeof(sc->name), "%s%s%s", - r->name, suffix, ctrl_suffix); + strlen(feature->ctrl_suffix) + 1 > RESCTRL_NAME_LEN); + snprintf(sc->name, sizeof(sc->name), "%s%s%s", r->name, + suffix, feature->ctrl_suffix); + list_add_tail(&sc->list, &s->schema_ctrl_list); } return 0; err: - list_for_each_entry_safe(sc, sc_tmp, &s->schema_ctrl_list, list) { + list_for_each_entry_safe(sc, tmp, &s->schema_ctrl_list, list) { list_del(&sc->list); kfree(sc); } diff --git a/arch/arm64/kernel/mpam/mpam_resctrl.c b/arch/arm64/kernel/mpam/mpam_resctrl.c index 004be508459ec261a1748fd6a41a9747e5574c6a..6e251ef90c363873156e0ff72e757f8fe982154d 100644 --- a/arch/arm64/kernel/mpam/mpam_resctrl.c +++ b/arch/arm64/kernel/mpam/mpam_resctrl.c @@ -1053,17 +1053,28 @@ static void basic_ctrl_enable(void) } } -static int extend_ctrl_enable(enum resctrl_ctrl_type type) +static int extend_ctrl_enable(char *tok) { bool match = false; + struct resctrl_resource *r; struct raw_resctrl_resource *rr; struct mpam_resctrl_res *res; + struct resctrl_ctrl_feature *feature; + enum resctrl_ctrl_type type; for_each_supported_resctrl_exports(res) { - rr = res->resctrl_res.res; - if (rr->ctrl_features[type].capable) { - rr->ctrl_features[type].enabled = true; - match = true; + r = &res->resctrl_res; + if (!r->alloc_capable) + continue; + rr = r->res; + for_each_ctrl_type(type) { + feature = &rr->ctrl_features[type]; + if (strcmp(feature->name, tok)) + continue; + if (rr->ctrl_features[type].capable) { + rr->ctrl_features[type].enabled = true; + match = true; + } } } @@ -1108,17 +1119,10 @@ int parse_rdtgroupfs_options(char *data) ret = cdpl2_enable(); if (ret) goto out; - } else if (!strcmp(token, "priority")) { - ret = extend_ctrl_enable(SCHEMA_PRI); - if (ret) - goto out; - } else if (!strcmp(token, "hardlimit")) { - ret = extend_ctrl_enable(SCHEMA_HDL); + } else { + ret = extend_ctrl_enable(token); if (ret) goto out; - } else { - ret = -EINVAL; - goto out; } }