mirror of
https://github.com/torvalds/linux.git
synced 2026-05-28 09:04:39 +02:00
fs/resctrl: Introduce the interface to modify assignments in a group
Enable the mbm_l3_assignments resctrl file to be used to modify counter
assignments of CTRL_MON and MON groups when the "mbm_event" counter
assignment mode is enabled.
Process the assignment modifications in the following format:
<Event>:<Domain id>=<Assignment state>;<Domain id>=<Assignment state>
Event: A valid MBM event in the
/sys/fs/resctrl/info/L3_MON/event_configs directory.
Domain ID: A valid domain ID. When writing, '*' applies the changes
to all domains.
Assignment states:
_ : Unassign a counter.
e : Assign a counter exclusively.
Examples:
$ cd /sys/fs/resctrl
$ cat /sys/fs/resctrl/mbm_L3_assignments
mbm_total_bytes:0=e;1=e
mbm_local_bytes:0=e;1=e
To unassign the counter associated with the mbm_total_bytes event on
domain 0:
$ echo "mbm_total_bytes:0=_" > mbm_L3_assignments
$ cat /sys/fs/resctrl/mbm_L3_assignments
mbm_total_bytes:0=_;1=e
mbm_local_bytes:0=e;1=e
To unassign the counter associated with the mbm_total_bytes event on
all the domains:
$ echo "mbm_total_bytes:*=_" > mbm_L3_assignments
$ cat /sys/fs/resctrl/mbm_L3_assignments
mbm_total_bytes:0=_;1=_
mbm_local_bytes:0=e;1=e
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://lore.kernel.org/cover.1757108044.git.babu.moger@amd.com
This commit is contained in:
parent
cba8222880
commit
88bee79640
|
|
@ -522,7 +522,8 @@ When monitoring is enabled all MON groups may also contain:
|
|||
Event: A valid MBM event in the
|
||||
/sys/fs/resctrl/info/L3_MON/event_configs directory.
|
||||
|
||||
Domain ID: A valid domain ID.
|
||||
Domain ID: A valid domain ID. When writing, '*' applies the changes
|
||||
to all the domains.
|
||||
|
||||
Assignment states:
|
||||
|
||||
|
|
@ -540,6 +541,35 @@ When monitoring is enabled all MON groups may also contain:
|
|||
mbm_total_bytes:0=e;1=e
|
||||
mbm_local_bytes:0=e;1=e
|
||||
|
||||
Assignments can be modified by writing to the interface.
|
||||
|
||||
Examples:
|
||||
|
||||
To unassign the counter associated with the mbm_total_bytes event on domain 0:
|
||||
::
|
||||
|
||||
# echo "mbm_total_bytes:0=_" > /sys/fs/resctrl/mbm_L3_assignments
|
||||
# cat /sys/fs/resctrl/mbm_L3_assignments
|
||||
mbm_total_bytes:0=_;1=e
|
||||
mbm_local_bytes:0=e;1=e
|
||||
|
||||
To unassign the counter associated with the mbm_total_bytes event on all the domains:
|
||||
::
|
||||
|
||||
# echo "mbm_total_bytes:*=_" > /sys/fs/resctrl/mbm_L3_assignments
|
||||
# cat /sys/fs/resctrl/mbm_L3_assignments
|
||||
mbm_total_bytes:0=_;1=_
|
||||
mbm_local_bytes:0=e;1=e
|
||||
|
||||
To assign a counter associated with the mbm_total_bytes event on all domains in
|
||||
exclusive mode:
|
||||
::
|
||||
|
||||
# echo "mbm_total_bytes:*=e" > /sys/fs/resctrl/mbm_L3_assignments
|
||||
# cat /sys/fs/resctrl/mbm_L3_assignments
|
||||
mbm_total_bytes:0=e;1=e
|
||||
mbm_local_bytes:0=e;1=e
|
||||
|
||||
When the "mba_MBps" mount option is used all CTRL_MON groups will also contain:
|
||||
|
||||
"mba_MBps_event":
|
||||
|
|
@ -1585,6 +1615,125 @@ View the llc occupancy snapshot::
|
|||
# cat /sys/fs/resctrl/p1/mon_data/mon_L3_00/llc_occupancy
|
||||
11234000
|
||||
|
||||
|
||||
Examples on working with mbm_assign_mode
|
||||
========================================
|
||||
|
||||
a. Check if MBM counter assignment mode is supported.
|
||||
::
|
||||
|
||||
# mount -t resctrl resctrl /sys/fs/resctrl/
|
||||
|
||||
# cat /sys/fs/resctrl/info/L3_MON/mbm_assign_mode
|
||||
[mbm_event]
|
||||
default
|
||||
|
||||
The "mbm_event" mode is detected and enabled.
|
||||
|
||||
b. Check how many assignable counters are supported.
|
||||
::
|
||||
|
||||
# cat /sys/fs/resctrl/info/L3_MON/num_mbm_cntrs
|
||||
0=32;1=32
|
||||
|
||||
c. Check how many assignable counters are available for assignment in each domain.
|
||||
::
|
||||
|
||||
# cat /sys/fs/resctrl/info/L3_MON/available_mbm_cntrs
|
||||
0=30;1=30
|
||||
|
||||
d. To list the default group's assign states.
|
||||
::
|
||||
|
||||
# cat /sys/fs/resctrl/mbm_L3_assignments
|
||||
mbm_total_bytes:0=e;1=e
|
||||
mbm_local_bytes:0=e;1=e
|
||||
|
||||
e. To unassign the counter associated with the mbm_total_bytes event on domain 0.
|
||||
::
|
||||
|
||||
# echo "mbm_total_bytes:0=_" > /sys/fs/resctrl/mbm_L3_assignments
|
||||
# cat /sys/fs/resctrl/mbm_L3_assignments
|
||||
mbm_total_bytes:0=_;1=e
|
||||
mbm_local_bytes:0=e;1=e
|
||||
|
||||
f. To unassign the counter associated with the mbm_total_bytes event on all domains.
|
||||
::
|
||||
|
||||
# echo "mbm_total_bytes:*=_" > /sys/fs/resctrl/mbm_L3_assignments
|
||||
# cat /sys/fs/resctrl/mbm_L3_assignment
|
||||
mbm_total_bytes:0=_;1=_
|
||||
mbm_local_bytes:0=e;1=e
|
||||
|
||||
g. To assign a counter associated with the mbm_total_bytes event on all domains in
|
||||
exclusive mode.
|
||||
::
|
||||
|
||||
# echo "mbm_total_bytes:*=e" > /sys/fs/resctrl/mbm_L3_assignments
|
||||
# cat /sys/fs/resctrl/mbm_L3_assignments
|
||||
mbm_total_bytes:0=e;1=e
|
||||
mbm_local_bytes:0=e;1=e
|
||||
|
||||
h. Read the events mbm_total_bytes and mbm_local_bytes of the default group. There is
|
||||
no change in reading the events with the assignment.
|
||||
::
|
||||
|
||||
# cat /sys/fs/resctrl/mon_data/mon_L3_00/mbm_total_bytes
|
||||
779247936
|
||||
# cat /sys/fs/resctrl/mon_data/mon_L3_01/mbm_total_bytes
|
||||
562324232
|
||||
# cat /sys/fs/resctrl/mon_data/mon_L3_00/mbm_local_bytes
|
||||
212122123
|
||||
# cat /sys/fs/resctrl/mon_data/mon_L3_01/mbm_local_bytes
|
||||
121212144
|
||||
|
||||
i. Check the event configurations.
|
||||
::
|
||||
|
||||
# cat /sys/fs/resctrl/info/L3_MON/event_configs/mbm_total_bytes/event_filter
|
||||
local_reads,remote_reads,local_non_temporal_writes,remote_non_temporal_writes,
|
||||
local_reads_slow_memory,remote_reads_slow_memory,dirty_victim_writes_all
|
||||
|
||||
# cat /sys/fs/resctrl/info/L3_MON/event_configs/mbm_local_bytes/event_filter
|
||||
local_reads,local_non_temporal_writes,local_reads_slow_memory
|
||||
|
||||
j. Change the event configuration for mbm_local_bytes.
|
||||
::
|
||||
|
||||
# echo "local_reads, local_non_temporal_writes, local_reads_slow_memory, remote_reads" >
|
||||
/sys/fs/resctrl/info/L3_MON/event_configs/mbm_local_bytes/event_filter
|
||||
|
||||
# cat /sys/fs/resctrl/info/L3_MON/event_configs/mbm_local_bytes/event_filter
|
||||
local_reads,local_non_temporal_writes,local_reads_slow_memory,remote_reads
|
||||
|
||||
k. Now read the local events again. The first read may come back with "Unavailable"
|
||||
status. The subsequent read of mbm_local_bytes will display the current value.
|
||||
::
|
||||
|
||||
# cat /sys/fs/resctrl/mon_data/mon_L3_00/mbm_local_bytes
|
||||
Unavailable
|
||||
# cat /sys/fs/resctrl/mon_data/mon_L3_00/mbm_local_bytes
|
||||
2252323
|
||||
# cat /sys/fs/resctrl/mon_data/mon_L3_01/mbm_local_bytes
|
||||
Unavailable
|
||||
# cat /sys/fs/resctrl/mon_data/mon_L3_01/mbm_local_bytes
|
||||
1566565
|
||||
|
||||
l. Users have the option to go back to 'default' mbm_assign_mode if required. This can be
|
||||
done using the following command. Note that switching the mbm_assign_mode may reset all
|
||||
the MBM counters (and thus all MBM events) of all the resctrl groups.
|
||||
::
|
||||
|
||||
# echo "default" > /sys/fs/resctrl/info/L3_MON/mbm_assign_mode
|
||||
# cat /sys/fs/resctrl/info/L3_MON/mbm_assign_mode
|
||||
mbm_event
|
||||
[default]
|
||||
|
||||
m. Unmount the resctrl filesystem.
|
||||
::
|
||||
|
||||
# umount /sys/fs/resctrl/
|
||||
|
||||
Intel RDT Errata
|
||||
================
|
||||
|
||||
|
|
|
|||
|
|
@ -418,6 +418,9 @@ ssize_t resctrl_mbm_assign_on_mkdir_write(struct kernfs_open_file *of, char *buf
|
|||
|
||||
int mbm_L3_assignments_show(struct kernfs_open_file *of, struct seq_file *s, void *v);
|
||||
|
||||
ssize_t mbm_L3_assignments_write(struct kernfs_open_file *of, char *buf, size_t nbytes,
|
||||
loff_t off);
|
||||
|
||||
#ifdef CONFIG_RESCTRL_FS_PSEUDO_LOCK
|
||||
int rdtgroup_locksetup_enter(struct rdtgroup *rdtgrp);
|
||||
|
||||
|
|
|
|||
|
|
@ -1502,6 +1502,145 @@ int mbm_L3_assignments_show(struct kernfs_open_file *of, struct seq_file *s, voi
|
|||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* mbm_get_mon_event_by_name() - Return the mon_evt entry for the matching
|
||||
* event name.
|
||||
*/
|
||||
static struct mon_evt *mbm_get_mon_event_by_name(struct rdt_resource *r, char *name)
|
||||
{
|
||||
struct mon_evt *mevt;
|
||||
|
||||
for_each_mon_event(mevt) {
|
||||
if (mevt->rid == r->rid && mevt->enabled &&
|
||||
resctrl_is_mbm_event(mevt->evtid) &&
|
||||
!strcmp(mevt->name, name))
|
||||
return mevt;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int rdtgroup_modify_assign_state(char *assign, struct rdt_mon_domain *d,
|
||||
struct rdtgroup *rdtgrp, struct mon_evt *mevt)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
if (!assign || strlen(assign) != 1)
|
||||
return -EINVAL;
|
||||
|
||||
switch (*assign) {
|
||||
case 'e':
|
||||
ret = rdtgroup_assign_cntr_event(d, rdtgrp, mevt);
|
||||
break;
|
||||
case '_':
|
||||
rdtgroup_unassign_cntr_event(d, rdtgrp, mevt);
|
||||
break;
|
||||
default:
|
||||
ret = -EINVAL;
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int resctrl_parse_mbm_assignment(struct rdt_resource *r, struct rdtgroup *rdtgrp,
|
||||
char *event, char *tok)
|
||||
{
|
||||
struct rdt_mon_domain *d;
|
||||
unsigned long dom_id = 0;
|
||||
char *dom_str, *id_str;
|
||||
struct mon_evt *mevt;
|
||||
int ret;
|
||||
|
||||
mevt = mbm_get_mon_event_by_name(r, event);
|
||||
if (!mevt) {
|
||||
rdt_last_cmd_printf("Invalid event %s\n", event);
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
next:
|
||||
if (!tok || tok[0] == '\0')
|
||||
return 0;
|
||||
|
||||
/* Start processing the strings for each domain */
|
||||
dom_str = strim(strsep(&tok, ";"));
|
||||
|
||||
id_str = strsep(&dom_str, "=");
|
||||
|
||||
/* Check for domain id '*' which means all domains */
|
||||
if (id_str && *id_str == '*') {
|
||||
ret = rdtgroup_modify_assign_state(dom_str, NULL, rdtgrp, mevt);
|
||||
if (ret)
|
||||
rdt_last_cmd_printf("Assign operation '%s:*=%s' failed\n",
|
||||
event, dom_str);
|
||||
return ret;
|
||||
} else if (!id_str || kstrtoul(id_str, 10, &dom_id)) {
|
||||
rdt_last_cmd_puts("Missing domain id\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* Verify if the dom_id is valid */
|
||||
list_for_each_entry(d, &r->mon_domains, hdr.list) {
|
||||
if (d->hdr.id == dom_id) {
|
||||
ret = rdtgroup_modify_assign_state(dom_str, d, rdtgrp, mevt);
|
||||
if (ret) {
|
||||
rdt_last_cmd_printf("Assign operation '%s:%ld=%s' failed\n",
|
||||
event, dom_id, dom_str);
|
||||
return ret;
|
||||
}
|
||||
goto next;
|
||||
}
|
||||
}
|
||||
|
||||
rdt_last_cmd_printf("Invalid domain id %ld\n", dom_id);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
ssize_t mbm_L3_assignments_write(struct kernfs_open_file *of, char *buf,
|
||||
size_t nbytes, loff_t off)
|
||||
{
|
||||
struct rdt_resource *r = resctrl_arch_get_resource(RDT_RESOURCE_L3);
|
||||
struct rdtgroup *rdtgrp;
|
||||
char *token, *event;
|
||||
int ret = 0;
|
||||
|
||||
/* Valid input requires a trailing newline */
|
||||
if (nbytes == 0 || buf[nbytes - 1] != '\n')
|
||||
return -EINVAL;
|
||||
|
||||
buf[nbytes - 1] = '\0';
|
||||
|
||||
rdtgrp = rdtgroup_kn_lock_live(of->kn);
|
||||
if (!rdtgrp) {
|
||||
rdtgroup_kn_unlock(of->kn);
|
||||
return -ENOENT;
|
||||
}
|
||||
rdt_last_cmd_clear();
|
||||
|
||||
if (!resctrl_arch_mbm_cntr_assign_enabled(r)) {
|
||||
rdt_last_cmd_puts("mbm_event mode is not enabled\n");
|
||||
rdtgroup_kn_unlock(of->kn);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
while ((token = strsep(&buf, "\n")) != NULL) {
|
||||
/*
|
||||
* The write command follows the following format:
|
||||
* "<Event>:<Domain ID>=<Assignment state>"
|
||||
* Extract the event name first.
|
||||
*/
|
||||
event = strsep(&token, ":");
|
||||
|
||||
ret = resctrl_parse_mbm_assignment(r, rdtgrp, event, token);
|
||||
if (ret)
|
||||
break;
|
||||
}
|
||||
|
||||
rdtgroup_kn_unlock(of->kn);
|
||||
|
||||
return ret ?: nbytes;
|
||||
}
|
||||
|
||||
/**
|
||||
* resctrl_mon_resource_init() - Initialise global monitoring structures.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1939,9 +1939,10 @@ static struct rftype res_common_files[] = {
|
|||
},
|
||||
{
|
||||
.name = "mbm_L3_assignments",
|
||||
.mode = 0444,
|
||||
.mode = 0644,
|
||||
.kf_ops = &rdtgroup_kf_single_ops,
|
||||
.seq_show = mbm_L3_assignments_show,
|
||||
.write = mbm_L3_assignments_write,
|
||||
},
|
||||
{
|
||||
.name = "mbm_assign_mode",
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user