Skip to content

Commit 77b6623

Browse files
babumogerbp3tk0v
authored andcommitted
fs/resctrl: Introduce interface to display io_alloc CBMs
Introduce the "io_alloc_cbm" resctrl file to display the capacity bitmasks (CBMs) that represent the portions of each cache instance allocated for I/O traffic on a cache resource that supports the "io_alloc" feature. io_alloc_cbm resides in the info directory of a cache resource, for example, /sys/fs/resctrl/info/L3/. Since the resource name is part of the path, it is not necessary to display the resource name as done in the schemata file. When CDP is enabled, io_alloc routes traffic using the highest CLOSID associated with the CDP_CODE resource and that CLOSID becomes unusable for the CDP_DATA resource. The highest CLOSID of CDP_CODE and CDP_DATA resources will be kept in sync to ensure consistent user interface. In preparation for this, access the CBMs for I/O traffic through highest CLOSID of either CDP_CODE or CDP_DATA resource. Signed-off-by: Babu Moger <babu.moger@amd.com> Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de> Reviewed-by: Reinette Chatre <reinette.chatre@intel.com> Link: https://patch.msgid.link/55a3ff66a70e7ce8239f022e62b334e9d64af604.1762995456.git.babu.moger@amd.com
1 parent 9445c70 commit 77b6623

4 files changed

Lines changed: 73 additions & 4 deletions

File tree

Documentation/filesystems/resctrl.rst

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,25 @@ related to allocation:
182182
available for general (CPU) cache allocation for both the CDP_CODE
183183
and CDP_DATA resources.
184184

185+
"io_alloc_cbm":
186+
Capacity bitmasks that describe the portions of cache instances to
187+
which I/O traffic from supported I/O devices are routed when "io_alloc"
188+
is enabled.
189+
190+
CBMs are displayed in the following format:
191+
192+
<cache_id0>=<cbm>;<cache_id1>=<cbm>;...
193+
194+
Example::
195+
196+
# cat /sys/fs/resctrl/info/L3/io_alloc_cbm
197+
0=ffff;1=ffff
198+
199+
When CDP is enabled "io_alloc_cbm" associated with the CDP_DATA and CDP_CODE
200+
resources may reflect the same values. For example, values read from and
201+
written to /sys/fs/resctrl/info/L3DATA/io_alloc_cbm may be reflected by
202+
/sys/fs/resctrl/info/L3CODE/io_alloc_cbm and vice versa.
203+
185204
Memory bandwidth(MB) subdirectory contains the following files
186205
with respect to allocation:
187206

fs/resctrl/ctrlmondata.c

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,8 @@ ssize_t rdtgroup_schemata_write(struct kernfs_open_file *of,
381381
return ret ?: nbytes;
382382
}
383383

384-
static void show_doms(struct seq_file *s, struct resctrl_schema *schema, int closid)
384+
static void show_doms(struct seq_file *s, struct resctrl_schema *schema,
385+
char *resource_name, int closid)
385386
{
386387
struct rdt_resource *r = schema->res;
387388
struct rdt_ctrl_domain *dom;
@@ -391,7 +392,8 @@ static void show_doms(struct seq_file *s, struct resctrl_schema *schema, int clo
391392
/* Walking r->domains, ensure it can't race with cpuhp */
392393
lockdep_assert_cpus_held();
393394

394-
seq_printf(s, "%*s:", max_name_width, schema->name);
395+
if (resource_name)
396+
seq_printf(s, "%*s:", max_name_width, resource_name);
395397
list_for_each_entry(dom, &r->ctrl_domains, hdr.list) {
396398
if (sep)
397399
seq_puts(s, ";");
@@ -437,7 +439,7 @@ int rdtgroup_schemata_show(struct kernfs_open_file *of,
437439
closid = rdtgrp->closid;
438440
list_for_each_entry(schema, &resctrl_schema_all, list) {
439441
if (closid < schema->num_closid)
440-
show_doms(s, schema, closid);
442+
show_doms(s, schema, schema->name, closid);
441443
}
442444
}
443445
} else {
@@ -823,3 +825,40 @@ ssize_t resctrl_io_alloc_write(struct kernfs_open_file *of, char *buf,
823825

824826
return ret ?: nbytes;
825827
}
828+
829+
int resctrl_io_alloc_cbm_show(struct kernfs_open_file *of, struct seq_file *seq, void *v)
830+
{
831+
struct resctrl_schema *s = rdt_kn_parent_priv(of->kn);
832+
struct rdt_resource *r = s->res;
833+
int ret = 0;
834+
835+
cpus_read_lock();
836+
mutex_lock(&rdtgroup_mutex);
837+
838+
rdt_last_cmd_clear();
839+
840+
if (!r->cache.io_alloc_capable) {
841+
rdt_last_cmd_printf("io_alloc is not supported on %s\n", s->name);
842+
ret = -ENODEV;
843+
goto out_unlock;
844+
}
845+
846+
if (!resctrl_arch_get_io_alloc_enabled(r)) {
847+
rdt_last_cmd_printf("io_alloc is not enabled on %s\n", s->name);
848+
ret = -EINVAL;
849+
goto out_unlock;
850+
}
851+
852+
/*
853+
* When CDP is enabled, the CBMs of the highest CLOSID of CDP_CODE and
854+
* CDP_DATA are kept in sync. As a result, the io_alloc CBMs shown for
855+
* either CDP resource are identical and accurately represent the CBMs
856+
* used for I/O.
857+
*/
858+
show_doms(seq, s, NULL, resctrl_io_alloc_closid(r));
859+
860+
out_unlock:
861+
mutex_unlock(&rdtgroup_mutex);
862+
cpus_read_unlock();
863+
return ret;
864+
}

fs/resctrl/internal.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,8 @@ ssize_t resctrl_io_alloc_write(struct kernfs_open_file *of, char *buf,
438438
size_t nbytes, loff_t off);
439439

440440
const char *rdtgroup_name_by_closid(u32 closid);
441+
int resctrl_io_alloc_cbm_show(struct kernfs_open_file *of, struct seq_file *seq,
442+
void *v);
441443

442444
#ifdef CONFIG_RESCTRL_FS_PSEUDO_LOCK
443445
int rdtgroup_locksetup_enter(struct rdtgroup *rdtgrp);

fs/resctrl/rdtgroup.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1971,6 +1971,12 @@ static struct rftype res_common_files[] = {
19711971
.seq_show = resctrl_io_alloc_show,
19721972
.write = resctrl_io_alloc_write,
19731973
},
1974+
{
1975+
.name = "io_alloc_cbm",
1976+
.mode = 0444,
1977+
.kf_ops = &rdtgroup_kf_single_ops,
1978+
.seq_show = resctrl_io_alloc_cbm_show,
1979+
},
19741980
{
19751981
.name = "max_threshold_occupancy",
19761982
.mode = 0644,
@@ -2171,9 +2177,12 @@ static void io_alloc_init(void)
21712177
{
21722178
struct rdt_resource *r = resctrl_arch_get_resource(RDT_RESOURCE_L3);
21732179

2174-
if (r->cache.io_alloc_capable)
2180+
if (r->cache.io_alloc_capable) {
21752181
resctrl_file_fflags_init("io_alloc", RFTYPE_CTRL_INFO |
21762182
RFTYPE_RES_CACHE);
2183+
resctrl_file_fflags_init("io_alloc_cbm",
2184+
RFTYPE_CTRL_INFO | RFTYPE_RES_CACHE);
2185+
}
21772186
}
21782187

21792188
void resctrl_file_fflags_init(const char *config, unsigned long fflags)

0 commit comments

Comments
 (0)