Skip to content

Commit 4fe61bf

Browse files
babumogerbp3tk0v
authored andcommitted
x86/resctrl: Add interface to write mbm_local_bytes_config
The event configuration for mbm_local_bytes can be changed by the user by writing to the configuration file /sys/fs/resctrl/info/L3_MON/mbm_local_bytes_config. The event configuration settings are domain specific and will affect all the CPUs in the domain. Following are the types of events supported: ==== =========================================================== Bits Description ==== =========================================================== 6 Dirty Victims from the QOS domain to all types of memory 5 Reads to slow memory in the non-local NUMA domain 4 Reads to slow memory in the local NUMA domain 3 Non-temporal writes to non-local NUMA domain 2 Non-temporal writes to local NUMA domain 1 Reads to memory in the non-local NUMA domain 0 Reads to memory in the local NUMA domain ==== =========================================================== For example, to change the mbm_local_bytes_config to count all the non-temporal writes on domain 0, the bits 2 and 3 needs to be set which is 1100b (in hex 0xc). Run the command: $echo 0=0xc > /sys/fs/resctrl/info/L3_MON/mbm_local_bytes_config To change the mbm_local_bytes to count only reads to local NUMA domain 1, the bit 0 needs to be set which 1b (in hex 0x1). Run the command: $echo 1=0x1 > /sys/fs/resctrl/info/L3_MON/mbm_local_bytes_config Signed-off-by: Babu Moger <[email protected]> Signed-off-by: Borislav Petkov (AMD) <[email protected]> Reviewed-by: Reinette Chatre <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 92bd5a1 commit 4fe61bf

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

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

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1638,6 +1638,30 @@ static ssize_t mbm_total_bytes_config_write(struct kernfs_open_file *of,
16381638
return ret ?: nbytes;
16391639
}
16401640

1641+
static ssize_t mbm_local_bytes_config_write(struct kernfs_open_file *of,
1642+
char *buf, size_t nbytes,
1643+
loff_t off)
1644+
{
1645+
struct rdt_resource *r = of->kn->parent->priv;
1646+
int ret;
1647+
1648+
/* Valid input requires a trailing newline */
1649+
if (nbytes == 0 || buf[nbytes - 1] != '\n')
1650+
return -EINVAL;
1651+
1652+
mutex_lock(&rdtgroup_mutex);
1653+
1654+
rdt_last_cmd_clear();
1655+
1656+
buf[nbytes - 1] = '\0';
1657+
1658+
ret = mon_config_write(r, buf, QOS_L3_MBM_LOCAL_EVENT_ID);
1659+
1660+
mutex_unlock(&rdtgroup_mutex);
1661+
1662+
return ret ?: nbytes;
1663+
}
1664+
16411665
/* rdtgroup information files for one cache resource. */
16421666
static struct rftype res_common_files[] = {
16431667
{
@@ -1745,9 +1769,10 @@ static struct rftype res_common_files[] = {
17451769
},
17461770
{
17471771
.name = "mbm_local_bytes_config",
1748-
.mode = 0444,
1772+
.mode = 0644,
17491773
.kf_ops = &rdtgroup_kf_single_ops,
17501774
.seq_show = mbm_local_bytes_config_show,
1775+
.write = mbm_local_bytes_config_write,
17511776
},
17521777
{
17531778
.name = "cpus",

0 commit comments

Comments
 (0)