提交 5ac157bf 编写于 作者: W Wang ShaoBo 提交者: Yang Yingliang

arm64/mpam: Filter schema control type with ctrl features

hulk inclusion
category: feature
bugzilla: 34278
CVE: NA

-------------------------------------------------

ctrl_features array, introduced by 61fa56e1dd8a ("arm64/mpam: Add
resctrl_ctrl_feature structure to manage ctrl features"), which lives
in raw_resctrl_resource structure for listing ctrl features's type do
we support in total for this resource, this filters illegal parameters
outside from mount options and provides useful info for add_schema()
for registering a new control type node in schema list.

This action helps us to add new ctrl feature easier later.
Signed-off-by: NWang ShaoBo <bobo.shaobowang@huawei.com>
Reviewed-by: NXiongfeng Wang <wangxiongfeng2@huawei.com>
Reviewed-by: NCheng Jian <cj.chengjian@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
Signed-off-by: NCheng Jian <cj.chengjian@huawei.com>
上级 e0aed913
......@@ -195,6 +195,8 @@ struct resctrl_ctrl_feature {
int default_ctrl;
bool capable;
bool enabled;
const char *ctrl_suffix;
};
struct msr_param {
......
......@@ -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);
}
......
......@@ -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;
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册