提交 238f08fe 编写于 作者: W Wang ShaoBo 提交者: Yang Yingliang

arm64/mpam: Sort domains when cpu online

hulk inclusion
category: bugfix
bugzilla: 34278
CVE: NA

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

When cpu online, domains inserted into resctrl_resource structure's
domains list may be out of order, so sort them with domain id.

Fixes: 88371f8b ("arm64/mpam: resctrl: Handle cpuhp and resctrl_dom allocation")
Signed-off-by: NWang ShaoBo <bobo.shaobowang@huawei.com>
Reviewed-by: NJian Cheng <cj.chengjian@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
Signed-off-by: NCheng Jian <cj.chengjian@huawei.com>
上级 e6ec459f
......@@ -59,12 +59,14 @@ mpam_get_domain_from_cpu(int cpu, struct mpam_resctrl_res *res)
static int mpam_resctrl_setup_domain(unsigned int cpu,
struct mpam_resctrl_res *res)
{
struct rdt_domain *d;
struct mpam_resctrl_dom *dom;
struct mpam_class *class = res->class;
struct mpam_component *comp_iter, *comp;
u32 num_partid;
u32 **ctrlval_ptr;
enum resctrl_ctrl_type type;
struct list_head *tmp;
num_partid = mpam_sysprops_num_partid();
......@@ -99,8 +101,17 @@ static int mpam_resctrl_setup_domain(unsigned int cpu,
}
}
/* TODO: this list should be sorted */
list_add_tail(&dom->resctrl_dom.list, &res->resctrl_res.domains);
tmp = &res->resctrl_res.domains;
/* insert domains in id ascending order */
list_for_each_entry(d, &res->resctrl_res.domains, list) {
/* find the last domain with id greater than this domain */
if (dom->resctrl_dom.id > d->id)
tmp = &d->list;
if (dom->resctrl_dom.id < d->id)
break;
}
list_add(&dom->resctrl_dom.list, tmp);
res->resctrl_res.dom_num++;
return 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册