mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ben Horgan <ben.horgan@arm.com>
To: "Luck, Tony" <tony.luck@intel.com>
Cc: linux-kernel@vger.kernel.org, reinette.chatre@intel.com,
	Dave.Martin@arm.com, james.morse@arm.com, babu.moger@amd.com,
	tglx@kernel.org, mingo@redhat.com, bp@alien8.de,
	dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com,
	fenghuay@nvidia.com, tan.shaopeng@fujitsu.com
Subject: Re: [PATCH v2 3/6] fs/resctrl: Make 'event_filter' files read only if they're not configurable
Date: Mon, 16 Mar 2026 09:51:22 +0000	[thread overview]
Message-ID: <f0be6eaa-6712-4ac9-ba72-4324eb179189@arm.com> (raw)
In-Reply-To: <abRYfLePHinIywuh@agluck-desk3>

Hi Tony,

On 3/13/26 18:33, Luck, Tony wrote:
> 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():


I initially rejected this idea because res_common_files[] is global and the
read/write choice is per event type but we can safely save restore the mode as
we're holding the rdtgroup mutex. How about this?

 static int resctrl_mkdir_event_configs(struct rdt_resource *r, struct kernfs_node *l3_mon_kn)
 {
+       struct rftype *rft = rdtgroup_get_rftype_by_name("event_filter");
        struct kernfs_node *kn_subdir, *kn_subdir2;
        struct mon_evt *mevt;
        int ret;

+       if (!rft)
+               return -ENOENT;
+
        kn_subdir = kernfs_create_dir(l3_mon_kn, "event_configs", l3_mon_kn->mode, NULL);
        if (IS_ERR(kn_subdir))
                return PTR_ERR(kn_subdir);
@@ -2325,6 +2329,8 @@ static int resctrl_mkdir_event_configs(struct rdt_resource *r, struct kernfs_nod
                return ret;

        for_each_mon_event(mevt) {
+               umode_t saved_mode;
+
                if (mevt->rid != r->rid || !mevt->enabled || !resctrl_is_mbm_event(mevt->evtid))
                        continue;

@@ -2338,25 +2344,14 @@ static int resctrl_mkdir_event_configs(struct rdt_resource *r, struct kernfs_nod
                if (ret)
                        return ret;

+               saved_mode = rft->mode;
+               if (!resctrl_arch_is_evt_configurable(mevt->evtid, true))
+                       rft->mode = 0444;
+
                ret = rdtgroup_add_files(kn_subdir2, RFTYPE_ASSIGN_CONFIG);
+               rft->mode = saved_mode;
                if (ret)
                        return ret;

Thanks,

Ben


> 
> 
> 	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


  reply	other threads:[~2026-03-16  9:51 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-13 17:45 [PATCH v2 0/6] x86,fs/resctrl: Pave the way for MPAM counter assignment Ben Horgan
2026-03-13 17:45 ` [PATCH v2 1/6] x86,fs/resctrl: Make resctrl_arch_is_evt_configurable() aware of mbm_assign_mode Ben Horgan
2026-03-13 17:45 ` [PATCH v2 2/6] fs/resctrl: Tidy up the error path in resctrl_mkdir_event_configs() Ben Horgan
2026-03-13 17:45 ` [PATCH v2 3/6] fs/resctrl: Make 'event_filter' files read only if they're not configurable Ben Horgan
2026-03-13 18:33   ` Luck, Tony
2026-03-16  9:51     ` Ben Horgan [this message]
2026-03-16 16:27       ` Luck, Tony
2026-03-16 17:02         ` Ben Horgan
2026-03-16 17:29           ` Reinette Chatre
2026-03-17 12:05             ` Ben Horgan
2026-03-13 17:45 ` [PATCH v2 4/6] fs/resctrl: Disallow the software controller when mbm counters are assignable Ben Horgan
2026-03-16 21:35   ` Reinette Chatre
2026-03-17 11:13     ` Ben Horgan
2026-03-17 17:17       ` Reinette Chatre
2026-03-18 15:44         ` Ben Horgan
2026-03-18 15:55           ` Ben Horgan
2026-03-18 22:17           ` Reinette Chatre
2026-03-13 17:45 ` [PATCH v2 5/6] x86,fs/resctrl: Add resctrl_arch_mbm_cntr_assign_fixed() Ben Horgan
2026-03-13 17:45 ` [PATCH v2 6/6] arm_mpam: resctrl: Adapt to new or changed resctrl arch functions Ben Horgan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f0be6eaa-6712-4ac9-ba72-4324eb179189@arm.com \
    --to=ben.horgan@arm.com \
    --cc=Dave.Martin@arm.com \
    --cc=babu.moger@amd.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=fenghuay@nvidia.com \
    --cc=hpa@zytor.com \
    --cc=james.morse@arm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=reinette.chatre@intel.com \
    --cc=tan.shaopeng@fujitsu.com \
    --cc=tglx@kernel.org \
    --cc=tony.luck@intel.com \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®