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: Introduce mbm_assign_on_mkdir to enable assignments on mkdir
The "mbm_event" counter assignment mode allows users to assign a hardware counter to an RMID, event pair and monitor the bandwidth as long as it is assigned. Introduce a user-configurable option that determines if a counter will automatically be assigned to an RMID, event pair when its associated monitor group is created via mkdir. Accessible when "mbm_event" counter assignment mode is enabled. Suggested-by: Peter Newman <peternewman@google.com> 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
f9ae5913d4
commit
ac1df9bb0b
@ -355,6 +355,26 @@ with the following files:
|
||||
# cat /sys/fs/resctrl/info/L3_MON/event_configs/mbm_total_bytes/event_filter
|
||||
local_reads,local_non_temporal_writes
|
||||
|
||||
"mbm_assign_on_mkdir":
|
||||
Exists when "mbm_event" counter assignment mode is supported. Accessible
|
||||
only when "mbm_event" counter assignment mode is enabled.
|
||||
|
||||
Determines if a counter will automatically be assigned to an RMID, MBM event
|
||||
pair when its associated monitor group is created via mkdir. Enabled by default
|
||||
on boot, also when switched from "default" mode to "mbm_event" counter assignment
|
||||
mode. Users can disable this capability by writing to the interface.
|
||||
|
||||
"0":
|
||||
Auto assignment is disabled.
|
||||
"1":
|
||||
Auto assignment is enabled.
|
||||
|
||||
Example::
|
||||
|
||||
# echo 0 > /sys/fs/resctrl/info/L3_MON/mbm_assign_on_mkdir
|
||||
# cat /sys/fs/resctrl/info/L3_MON/mbm_assign_on_mkdir
|
||||
0
|
||||
|
||||
"max_threshold_occupancy":
|
||||
Read/write file provides the largest value (in
|
||||
bytes) at which a previously used LLC_occupancy
|
||||
|
||||
@ -410,6 +410,12 @@ 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);
|
||||
|
||||
int resctrl_mbm_assign_on_mkdir_show(struct kernfs_open_file *of,
|
||||
struct seq_file *s, void *v);
|
||||
|
||||
ssize_t resctrl_mbm_assign_on_mkdir_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);
|
||||
|
||||
|
||||
@ -1027,6 +1027,57 @@ out_unlock:
|
||||
return ret;
|
||||
}
|
||||
|
||||
int resctrl_mbm_assign_on_mkdir_show(struct kernfs_open_file *of, struct seq_file *s,
|
||||
void *v)
|
||||
{
|
||||
struct rdt_resource *r = rdt_kn_parent_priv(of->kn);
|
||||
int ret = 0;
|
||||
|
||||
mutex_lock(&rdtgroup_mutex);
|
||||
rdt_last_cmd_clear();
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
seq_printf(s, "%u\n", r->mon.mbm_assign_on_mkdir);
|
||||
|
||||
out_unlock:
|
||||
mutex_unlock(&rdtgroup_mutex);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
ssize_t resctrl_mbm_assign_on_mkdir_write(struct kernfs_open_file *of, char *buf,
|
||||
size_t nbytes, loff_t off)
|
||||
{
|
||||
struct rdt_resource *r = rdt_kn_parent_priv(of->kn);
|
||||
bool value;
|
||||
int ret;
|
||||
|
||||
ret = kstrtobool(buf, &value);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
mutex_lock(&rdtgroup_mutex);
|
||||
rdt_last_cmd_clear();
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
r->mon.mbm_assign_on_mkdir = value;
|
||||
|
||||
out_unlock:
|
||||
mutex_unlock(&rdtgroup_mutex);
|
||||
|
||||
return ret ?: nbytes;
|
||||
}
|
||||
|
||||
/*
|
||||
* rdtgroup_assign_cntr() - Assign/unassign the counter ID for the event, RMID
|
||||
* pair in the domain.
|
||||
@ -1457,6 +1508,8 @@ int resctrl_mon_resource_init(void)
|
||||
resctrl_file_fflags_init("available_mbm_cntrs",
|
||||
RFTYPE_MON_INFO | RFTYPE_RES_CACHE);
|
||||
resctrl_file_fflags_init("event_filter", RFTYPE_ASSIGN_CONFIG);
|
||||
resctrl_file_fflags_init("mbm_assign_on_mkdir", RFTYPE_MON_INFO |
|
||||
RFTYPE_RES_CACHE);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
@ -1808,6 +1808,13 @@ static struct rftype res_common_files[] = {
|
||||
.seq_show = rdt_last_cmd_status_show,
|
||||
.fflags = RFTYPE_TOP_INFO,
|
||||
},
|
||||
{
|
||||
.name = "mbm_assign_on_mkdir",
|
||||
.mode = 0644,
|
||||
.kf_ops = &rdtgroup_kf_single_ops,
|
||||
.seq_show = resctrl_mbm_assign_on_mkdir_show,
|
||||
.write = resctrl_mbm_assign_on_mkdir_write,
|
||||
},
|
||||
{
|
||||
.name = "num_closids",
|
||||
.mode = 0444,
|
||||
|
||||
@ -277,12 +277,15 @@ enum resctrl_schema_fmt {
|
||||
* monitoring events can be configured.
|
||||
* @num_mbm_cntrs: Number of assignable counters.
|
||||
* @mbm_cntr_assignable:Is system capable of supporting counter assignment?
|
||||
* @mbm_assign_on_mkdir:True if counters should automatically be assigned to MBM
|
||||
* events of monitor groups created via mkdir.
|
||||
*/
|
||||
struct resctrl_mon {
|
||||
int num_rmid;
|
||||
unsigned int mbm_cfg_mask;
|
||||
int num_mbm_cntrs;
|
||||
bool mbm_cntr_assignable;
|
||||
bool mbm_assign_on_mkdir;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user