[PATCH v2 3/6] fs/resctrl: Make 'event_filter' files read only if they're not configurable
From: Ben Horgan
Date: Fri Mar 13 2026 - 13:48:22 EST
When the counter assignment mode is mbm_event resctrl assumes the mbm
events are configurable and exposes the 'event_filter' files. These files
live at info/L3_MON/event_configs/<event>/event_filter and are used to
display and set the event configuration. The MPAM driver has no support for
changing event configuration and so mbm_event mode can't be used.
In order to support mbm_event event with MPAM make the 'event_filter' files
read only if the event configuration can't be changed. A user can still
chmod the file and so also return an error from event_filter_write().
Signed-off-by: Ben Horgan <ben.horgan@xxxxxxx>
---
fs/resctrl/monitor.c | 6 ++++++
fs/resctrl/rdtgroup.c | 16 ++++++++++++++++
2 files changed, 22 insertions(+)
diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c
index d25622ee22c5..a2da771d82df 100644
--- a/fs/resctrl/monitor.c
+++ b/fs/resctrl/monitor.c
@@ -1414,6 +1414,12 @@ ssize_t event_filter_write(struct kernfs_open_file *of, char *buf, size_t nbytes
rdt_last_cmd_clear();
+ if (!resctrl_arch_is_evt_configurable(mevt->evtid, true)) {
+ rdt_last_cmd_printf("event_filter is not configurable for %s\n", mevt->name);
+ ret = -EPERM;
+ goto out_unlock;
+ }
+
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");
diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c
index 4753841c2ca3..2f0a509b313a 100644
--- a/fs/resctrl/rdtgroup.c
+++ b/fs/resctrl/rdtgroup.c
@@ -2341,6 +2341,22 @@ static int resctrl_mkdir_event_configs(struct rdt_resource *r, struct kernfs_nod
ret = rdtgroup_add_files(kn_subdir2, RFTYPE_ASSIGN_CONFIG);
if (ret)
return ret;
+
+ if (!resctrl_arch_is_evt_configurable(mevt->evtid, true)) {
+ struct iattr iattr = {.ia_valid = ATTR_MODE,};
+ struct kernfs_node *kn;
+
+ kn = kernfs_find_and_get_ns(kn_subdir2, "event_filter", NULL);
+ if (!kn)
+ return -ENOENT;
+
+ iattr.ia_mode = S_IFREG | 0444;
+
+ ret = kernfs_setattr(kn, &iattr);
+ kernfs_put(kn);
+ if (ret)
+ return ret;
+ }
}
return 0;
--
2.43.0