Skip to content

Commit e198fde

Browse files
James Morsesuryasaimadhu
authored andcommitted
x86/resctrl: Move the schemata names into struct resctrl_schema
resctrl 'info' directories and schema parsing use the schema name. This lives in the struct rdt_resource, and is specified by the architecture code. Once the CDP resources are merged, there will only be one resource (and one name) in use by two schemata. To allow the CDP CODE/DATA property to be the type of configuration the schema uses, the name should also be per-schema. Add a name field to struct resctrl_schema, and use this wherever the schema name is exposed (or read from) user-space. Calculating max_name_width for padding the schemata file also moves as this is visible to user-space. As the names in struct rdt_resource already include the CDP information, schemata_list_create() copies them. schemata_list_create() includes the length of the CDP suffix when calculating max_name_width in preparation for CDP resources being merged. Signed-off-by: James Morse <james.morse@arm.com> Signed-off-by: Borislav Petkov <bp@suse.de> Reviewed-by: Jamie Iles <jamie@nuviainc.com> Reviewed-by: Reinette Chatre <reinette.chatre@intel.com> Tested-by: Babu Moger <babu.moger@amd.com> Link: https://lkml.kernel.org/r/20210728170637.25610-13-james.morse@arm.com
1 parent c091e90 commit e198fde

File tree

4 files changed

+30
-16
lines changed

4 files changed

+30
-16
lines changed

arch/x86/kernel/cpu/resctrl/core.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -782,13 +782,8 @@ static int resctrl_offline_cpu(unsigned int cpu)
782782
static __init void rdt_init_padding(void)
783783
{
784784
struct rdt_resource *r;
785-
int cl;
786785

787786
for_each_alloc_capable_rdt_resource(r) {
788-
cl = strlen(r->name);
789-
if (cl > max_name_width)
790-
max_name_width = cl;
791-
792787
if (r->data_width > max_data_width)
793788
max_data_width = r->data_width;
794789
}

arch/x86/kernel/cpu/resctrl/ctrlmondata.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -290,11 +290,9 @@ static int rdtgroup_parse_resource(char *resname, char *tok,
290290
struct rdtgroup *rdtgrp)
291291
{
292292
struct resctrl_schema *s;
293-
struct rdt_resource *r;
294293

295294
list_for_each_entry(s, &resctrl_schema_all, list) {
296-
r = s->res;
297-
if (!strcmp(resname, r->name) && rdtgrp->closid < s->num_closid)
295+
if (!strcmp(resname, s->name) && rdtgrp->closid < s->num_closid)
298296
return parse_line(tok, s, rdtgrp);
299297
}
300298
rdt_last_cmd_printf("Unknown or unsupported resource name '%s'\n", resname);
@@ -388,7 +386,7 @@ static void show_doms(struct seq_file *s, struct resctrl_schema *schema, int clo
388386
bool sep = false;
389387
u32 ctrl_val;
390388

391-
seq_printf(s, "%*s:", max_name_width, r->name);
389+
seq_printf(s, "%*s:", max_name_width, schema->name);
392390
list_for_each_entry(dom, &r->domains, list) {
393391
hw_dom = resctrl_to_arch_dom(dom);
394392
if (sep)
@@ -408,16 +406,14 @@ int rdtgroup_schemata_show(struct kernfs_open_file *of,
408406
{
409407
struct resctrl_schema *schema;
410408
struct rdtgroup *rdtgrp;
411-
struct rdt_resource *r;
412409
int ret = 0;
413410
u32 closid;
414411

415412
rdtgrp = rdtgroup_kn_lock_live(of->kn);
416413
if (rdtgrp) {
417414
if (rdtgrp->mode == RDT_MODE_PSEUDO_LOCKSETUP) {
418415
list_for_each_entry(schema, &resctrl_schema_all, list) {
419-
r = schema->res;
420-
seq_printf(s, "%s:uninitialized\n", r->name);
416+
seq_printf(s, "%s:uninitialized\n", schema->name);
421417
}
422418
} else if (rdtgrp->mode == RDT_MODE_PSEUDO_LOCKED) {
423419
if (!rdtgrp->plr->d) {

arch/x86/kernel/cpu/resctrl/rdtgroup.c

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1439,7 +1439,7 @@ static int rdtgroup_size_show(struct kernfs_open_file *of,
14391439
ret = -ENODEV;
14401440
} else {
14411441
seq_printf(s, "%*s:", max_name_width,
1442-
rdtgrp->plr->s->res->name);
1442+
rdtgrp->plr->s->name);
14431443
size = rdtgroup_cbm_to_size(rdtgrp->plr->s->res,
14441444
rdtgrp->plr->d,
14451445
rdtgrp->plr->cbm);
@@ -1451,7 +1451,7 @@ static int rdtgroup_size_show(struct kernfs_open_file *of,
14511451
list_for_each_entry(schema, &resctrl_schema_all, list) {
14521452
r = schema->res;
14531453
sep = false;
1454-
seq_printf(s, "%*s:", max_name_width, r->name);
1454+
seq_printf(s, "%*s:", max_name_width, schema->name);
14551455
list_for_each_entry(d, &r->domains, list) {
14561456
hw_dom = resctrl_to_arch_dom(d);
14571457
if (sep)
@@ -1823,7 +1823,7 @@ static int rdtgroup_create_info_dir(struct kernfs_node *parent_kn)
18231823
list_for_each_entry(s, &resctrl_schema_all, list) {
18241824
r = s->res;
18251825
fflags = r->fflags | RF_CTRL_INFO;
1826-
ret = rdtgroup_mkdir_info_resdir(s, r->name, fflags);
1826+
ret = rdtgroup_mkdir_info_resdir(s, s->name, fflags);
18271827
if (ret)
18281828
goto out_destroy;
18291829
}
@@ -2141,6 +2141,7 @@ static int schemata_list_create(void)
21412141
{
21422142
struct resctrl_schema *s;
21432143
struct rdt_resource *r;
2144+
int ret, cl;
21442145

21452146
for_each_alloc_enabled_rdt_resource(r) {
21462147
s = kzalloc(sizeof(*s), GFP_KERNEL);
@@ -2151,6 +2152,26 @@ static int schemata_list_create(void)
21512152
s->conf_type = resctrl_to_arch_res(r)->conf_type;
21522153
s->num_closid = resctrl_arch_get_num_closid(r);
21532154

2155+
ret = snprintf(s->name, sizeof(s->name), r->name);
2156+
if (ret >= sizeof(s->name)) {
2157+
kfree(s);
2158+
return -EINVAL;
2159+
}
2160+
2161+
cl = strlen(s->name);
2162+
2163+
/*
2164+
* If CDP is supported by this resource, but not enabled,
2165+
* include the suffix. This ensures the tabular format of the
2166+
* schemata file does not change between mounts of the
2167+
* filesystem.
2168+
*/
2169+
if (r->cdp_capable && !resctrl_arch_get_cdp_enabled(r->rid))
2170+
cl += 4;
2171+
2172+
if (cl > max_name_width)
2173+
max_name_width = cl;
2174+
21542175
INIT_LIST_HEAD(&s->list);
21552176
list_add(&s->list, &resctrl_schema_all);
21562177
}
@@ -2784,7 +2805,7 @@ static int __init_one_rdt_domain(struct rdt_domain *d, struct resctrl_schema *s,
27842805
*/
27852806
tmp_cbm = d->new_ctrl;
27862807
if (bitmap_weight(&tmp_cbm, r->cache.cbm_len) < r->cache.min_cbm_bits) {
2787-
rdt_last_cmd_printf("No space on %s:%d\n", r->name, d->id);
2808+
rdt_last_cmd_printf("No space on %s:%d\n", s->name, d->id);
27882809
return -ENOSPC;
27892810
}
27902811
d->have_new_ctrl = true;

include/linux/resctrl.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ struct rdt_resource {
171171
* struct resctrl_schema - configuration abilities of a resource presented to
172172
* user-space
173173
* @list: Member of resctrl_schema_all.
174+
* @name: The name to use in the "schemata" file.
174175
* @conf_type: Whether this schema is specific to code/data.
175176
* @res: The resource structure exported by the architecture to describe
176177
* the hardware that is configured by this schema.
@@ -180,6 +181,7 @@ struct rdt_resource {
180181
*/
181182
struct resctrl_schema {
182183
struct list_head list;
184+
char name[8];
183185
enum resctrl_conf_type conf_type;
184186
struct rdt_resource *res;
185187
u32 num_closid;

0 commit comments

Comments
 (0)