提交 be2167d2 编写于 作者: X Xie XiuQi

arm64/mpam: support resctrl_group_schemata_show

hulk inclusion
category: feature
bugzilla: 5510
CVE: NA
Signed-off-by: NXie XiuQi <xiexiuqi@huawei.com>
Reviewed-by: NHanjun Guo <guohanjun@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 0fcdc966
......@@ -159,6 +159,8 @@ struct rdtgroup {
struct mongroup mon;
};
extern int max_name_width, max_data_width;
/* rdtgroup.flags */
#define RDT_DELETED 1
......
......@@ -281,6 +281,29 @@ static int mpam_offline_cpu(unsigned int cpu)
return 0;
}
/*
* Choose a width for the resource name and resource data based on the
* resource that has widest name and cbm.
*/
static __init void mpam_init_padding(void)
{
struct resctrl_resource *r;
struct raw_resctrl_resource *rr;
int cl;
for_each_resctrl_resource(r) {
if (r->alloc_enabled) {
rr = (struct raw_resctrl_resource *)r->res;
cl = strlen(r->name);
if (cl > max_name_width)
max_name_width = cl;
if (rr->data_width > max_data_width)
max_data_width = rr->data_width;
}
}
}
static __init bool get_rdt_alloc_resources(void)
{
bool ret = true;
......@@ -883,6 +906,8 @@ static int __init mpam_late_init(void)
if (!get_resctrl_resources())
return -ENODEV;
mpam_init_padding();
ret = mpam_nodes_init();
if (ret) {
pr_err("internal error: bad cpu list\n");
......
......@@ -206,9 +206,45 @@ ssize_t resctrl_group_schemata_write(struct kernfs_open_file *of,
return ret ?: nbytes;
}
static void show_doms(struct seq_file *s, struct resctrl_resource *r, int partid)
{
struct raw_resctrl_resource *rr = (struct raw_resctrl_resource *)r->res;
struct rdt_domain *dom;
bool sep = false;
seq_printf(s, "%*s:", max_name_width, r->name);
list_for_each_entry(dom, &r->domains, list) {
if (sep)
seq_puts(s, ";");
seq_printf(s, rr->format_str, dom->id, max_data_width,
dom->ctrl_val[partid]);
sep = true;
}
seq_puts(s, "\n");
}
int resctrl_group_schemata_show(struct kernfs_open_file *of,
struct seq_file *s, void *v)
{
seq_printf(s, "resctrl_group_schemata_show\n");
return 0;
struct rdtgroup *rdtgrp;
struct resctrl_resource *r;
struct raw_resctrl_resource *rr;
int ret = 0;
u32 partid;
rdtgrp = resctrl_group_kn_lock_live(of->kn);
if (rdtgrp) {
partid = rdtgrp->closid;
for_each_resctrl_resource(r) {
if (r->alloc_enabled) {
rr = (struct raw_resctrl_resource *)r->res;
if (partid < rr->num_partid)
show_doms(s, r, partid);
}
}
} else {
ret = -ENOENT;
}
resctrl_group_kn_unlock(of->kn);
return ret;
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册