mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-01-12 01:20:14 +00:00
fs/resctrl: Provide interface to update the event configurations
When "mbm_event" counter assignment mode is enabled, users can modify the
event configuration by writing to the 'event_filter' resctrl file. The event
configurations for mbm_event mode are located in
/sys/fs/resctrl/info/L3_MON/event_configs/.
Update the assignments of all CTRL_MON and MON resource groups when the event
configuration is modified.
Example:
$ mount -t resctrl resctrl /sys/fs/resctrl
$ cd /sys/fs/resctrl/
$ cat info/L3_MON/event_configs/mbm_local_bytes/event_filter
local_reads,local_non_temporal_writes,local_reads_slow_memory
$ echo "local_reads,local_non_temporal_writes" >
info/L3_MON/event_configs/mbm_total_bytes/event_filter
$ cat info/L3_MON/event_configs/mbm_total_bytes/event_filter
local_reads,local_non_temporal_writes
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
ea274cbeaf
commit
f9ae5913d4
@ -343,6 +343,18 @@ with the following files:
|
||||
# cat /sys/fs/resctrl/info/L3_MON/event_configs/mbm_local_bytes/event_filter
|
||||
local_reads,local_non_temporal_writes,local_reads_slow_memory
|
||||
|
||||
Modify the event configuration by writing to the "event_filter" file within
|
||||
the "event_configs" directory. The read/write "event_filter" file contains the
|
||||
configuration of the event that reflects which memory transactions are counted by it.
|
||||
|
||||
For example::
|
||||
|
||||
# echo "local_reads, local_non_temporal_writes" >
|
||||
/sys/fs/resctrl/info/L3_MON/event_configs/mbm_total_bytes/event_filter
|
||||
|
||||
# cat /sys/fs/resctrl/info/L3_MON/event_configs/mbm_total_bytes/event_filter
|
||||
local_reads,local_non_temporal_writes
|
||||
|
||||
"max_threshold_occupancy":
|
||||
Read/write file provides the largest value (in
|
||||
bytes) at which a previously used LLC_occupancy
|
||||
|
||||
@ -407,6 +407,9 @@ void rdtgroup_unassign_cntrs(struct rdtgroup *rdtgrp);
|
||||
|
||||
int event_filter_show(struct kernfs_open_file *of, struct seq_file *seq, void *v);
|
||||
|
||||
ssize_t event_filter_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);
|
||||
|
||||
|
||||
@ -1192,6 +1192,120 @@ void rdtgroup_unassign_cntrs(struct rdtgroup *rdtgrp)
|
||||
&mon_event_all[QOS_L3_MBM_LOCAL_EVENT_ID]);
|
||||
}
|
||||
|
||||
static int resctrl_parse_mem_transactions(char *tok, u32 *val)
|
||||
{
|
||||
u32 temp_val = 0;
|
||||
char *evt_str;
|
||||
bool found;
|
||||
int i;
|
||||
|
||||
next_config:
|
||||
if (!tok || tok[0] == '\0') {
|
||||
*val = temp_val;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Start processing the strings for each memory transaction type */
|
||||
evt_str = strim(strsep(&tok, ","));
|
||||
found = false;
|
||||
for (i = 0; i < NUM_MBM_TRANSACTIONS; i++) {
|
||||
if (!strcmp(mbm_transactions[i].name, evt_str)) {
|
||||
temp_val |= mbm_transactions[i].val;
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
rdt_last_cmd_printf("Invalid memory transaction type %s\n", evt_str);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
goto next_config;
|
||||
}
|
||||
|
||||
/*
|
||||
* rdtgroup_update_cntr_event - Update the counter assignments for the event
|
||||
* in a group.
|
||||
* @r: Resource to which update needs to be done.
|
||||
* @rdtgrp: Resctrl group.
|
||||
* @evtid: MBM monitor event.
|
||||
*/
|
||||
static void rdtgroup_update_cntr_event(struct rdt_resource *r, struct rdtgroup *rdtgrp,
|
||||
enum resctrl_event_id evtid)
|
||||
{
|
||||
struct rdt_mon_domain *d;
|
||||
int cntr_id;
|
||||
|
||||
list_for_each_entry(d, &r->mon_domains, hdr.list) {
|
||||
cntr_id = mbm_cntr_get(r, d, rdtgrp, evtid);
|
||||
if (cntr_id >= 0)
|
||||
rdtgroup_assign_cntr(r, d, evtid, rdtgrp->mon.rmid,
|
||||
rdtgrp->closid, cntr_id, true);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* resctrl_update_cntr_allrdtgrp - Update the counter assignments for the event
|
||||
* for all the groups.
|
||||
* @mevt MBM Monitor event.
|
||||
*/
|
||||
static void resctrl_update_cntr_allrdtgrp(struct mon_evt *mevt)
|
||||
{
|
||||
struct rdt_resource *r = resctrl_arch_get_resource(mevt->rid);
|
||||
struct rdtgroup *prgrp, *crgrp;
|
||||
|
||||
/*
|
||||
* Find all the groups where the event is assigned and update the
|
||||
* configuration of existing assignments.
|
||||
*/
|
||||
list_for_each_entry(prgrp, &rdt_all_groups, rdtgroup_list) {
|
||||
rdtgroup_update_cntr_event(r, prgrp, mevt->evtid);
|
||||
|
||||
list_for_each_entry(crgrp, &prgrp->mon.crdtgrp_list, mon.crdtgrp_list)
|
||||
rdtgroup_update_cntr_event(r, crgrp, mevt->evtid);
|
||||
}
|
||||
}
|
||||
|
||||
ssize_t event_filter_write(struct kernfs_open_file *of, char *buf, size_t nbytes,
|
||||
loff_t off)
|
||||
{
|
||||
struct mon_evt *mevt = rdt_kn_parent_priv(of->kn);
|
||||
struct rdt_resource *r;
|
||||
u32 evt_cfg = 0;
|
||||
int ret = 0;
|
||||
|
||||
/* Valid input requires a trailing newline */
|
||||
if (nbytes == 0 || buf[nbytes - 1] != '\n')
|
||||
return -EINVAL;
|
||||
|
||||
buf[nbytes - 1] = '\0';
|
||||
|
||||
cpus_read_lock();
|
||||
mutex_lock(&rdtgroup_mutex);
|
||||
|
||||
rdt_last_cmd_clear();
|
||||
|
||||
r = resctrl_arch_get_resource(mevt->rid);
|
||||
if (!resctrl_arch_mbm_cntr_assign_enabled(r)) {
|
||||
rdt_last_cmd_puts("mbm_event counter assignment mode is not enabled\n");
|
||||
ret = -EINVAL;
|
||||
goto out_unlock;
|
||||
}
|
||||
|
||||
ret = resctrl_parse_mem_transactions(buf, &evt_cfg);
|
||||
if (!ret && mevt->evt_cfg != evt_cfg) {
|
||||
mevt->evt_cfg = evt_cfg;
|
||||
resctrl_update_cntr_allrdtgrp(mevt);
|
||||
}
|
||||
|
||||
out_unlock:
|
||||
mutex_unlock(&rdtgroup_mutex);
|
||||
cpus_read_unlock();
|
||||
|
||||
return ret ?: nbytes;
|
||||
}
|
||||
|
||||
int resctrl_mbm_assign_mode_show(struct kernfs_open_file *of,
|
||||
struct seq_file *s, void *v)
|
||||
{
|
||||
|
||||
@ -1925,9 +1925,10 @@ static struct rftype res_common_files[] = {
|
||||
},
|
||||
{
|
||||
.name = "event_filter",
|
||||
.mode = 0444,
|
||||
.mode = 0644,
|
||||
.kf_ops = &rdtgroup_kf_single_ops,
|
||||
.seq_show = event_filter_show,
|
||||
.write = event_filter_write,
|
||||
},
|
||||
{
|
||||
.name = "mbm_assign_mode",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user