提交 7e440b59 编写于 作者: W Wang ShaoBo 提交者: Zheng Zengkai

arm64/mpam: make mbw_max/min not less than min_bw

hulk inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I61CPK
CVE: NA

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

Do not allow min_bw below the granularity with adjusting mbw_max/min,
and with setting mbw_max/min less than min_bw, return 'Invalid argument'
directly.
Signed-off-by: NWang ShaoBo <bobo.shaobowang@huawei.com>
Signed-off-by: NJialin Zhang <zhangjialin11@huawei.com>
Reviewed-by: NXie XiuQi <xiexiuqi@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 f2d665f1
...@@ -338,15 +338,11 @@ parse_bw(char *buf, struct resctrl_resource *r, ...@@ -338,15 +338,11 @@ parse_bw(char *buf, struct resctrl_resource *r,
switch (rr->ctrl_features[type].evt) { switch (rr->ctrl_features[type].evt) {
case QOS_MBA_MAX_EVENT_ID: case QOS_MBA_MAX_EVENT_ID:
case QOS_MBA_PBM_EVENT_ID: case QOS_MBA_PBM_EVENT_ID:
if (kstrtoul(buf, rr->ctrl_features[type].base, &data))
return -EINVAL;
data = (data < r->mbw.min_bw) ? r->mbw.min_bw : data;
data = roundup(data, r->mbw.bw_gran);
break;
case QOS_MBA_MIN_EVENT_ID: case QOS_MBA_MIN_EVENT_ID:
if (kstrtoul(buf, rr->ctrl_features[type].base, &data)) if (kstrtoul(buf, rr->ctrl_features[type].base, &data))
return -EINVAL; return -EINVAL;
/* for mbw min feature, 0 of setting is allowed */ if (data < r->mbw.min_bw)
return -EINVAL;
data = roundup(data, r->mbw.bw_gran); data = roundup(data, r->mbw.bw_gran);
break; break;
default: default:
......
...@@ -419,6 +419,9 @@ static int mpam_resctrl_resource_init(struct mpam_resctrl_res *res) ...@@ -419,6 +419,9 @@ static int mpam_resctrl_resource_init(struct mpam_resctrl_res *res)
* of 1 would appear too fine to make percentage conversions. * of 1 would appear too fine to make percentage conversions.
*/ */
r->mbw.bw_gran = GRAN_MBA_BW; r->mbw.bw_gran = GRAN_MBA_BW;
/* do not allow mbw_max/min below mbw.bw_gran */
if (r->mbw.min_bw < r->mbw.bw_gran)
r->mbw.min_bw = r->mbw.bw_gran;
/* We will only pick a class that can monitor and control */ /* We will only pick a class that can monitor and control */
r->alloc_capable = true; r->alloc_capable = true;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册