Re: [PATCH v2 3/6] fs/resctrl: Make 'event_filter' files read only if they're not configurable

From: Luck, Tony

Date: Fri Mar 13 2026 - 14:34:50 EST


On Fri, Mar 13, 2026 at 05:45:21PM +0000, Ben Horgan wrote:
> 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().
> +++ 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;
> + }


Instead of making the file writable, and then fixing the mode. Maybe
patch the mode in res_common_files[] before calling rdtgroup_add_files():


if (!resctrl_arch_is_evt_configurable(mevt->evtid, true)) {
struct rftype *rft;

rft = rdtgroup_get_rftype_by_name("event_filter");
if (rft)
rft->mode = 0444;
}

-Tony