From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0E29C1E1DF0 for ; Mon, 16 Mar 2026 09:51:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773654693; cv=none; b=a0OZaFFZcyuSdwn/Xn+rQFCIJGvuki/AxWoN7rzVc0ychHyKf1aMXSTX4BLF/jpxxHurjLqtbGu58wpEHBxiwyqV5QMU5Yy/mn9VaSIuS8Vsv/zuBhcEUym6DczZ1aj9bskIwqbIo3/c+onRXT2uS+SrEk86hil2I/6fcByxjpg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773654693; c=relaxed/simple; bh=t/C6UgSTB6TflHKpEBjELl8bZGh8p/4Ie0fLJguNUe0=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=bMUmua3/yGs4RTRzylZkEAFGnRx7wQYS5O3+fGjXN26qzJmjFcREUfPfWlUnKFiFrs++Nf3R9REqi9uDPFt+5dxsgC3Thuo0vPbSF5yX0io5PxfLcV0jmSPX3aFjcPoOC8VrhqEJUeGWz/qlc8Uh3kOFKEs9hRsYJ6+Czydwk4E= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 696CF1477; Mon, 16 Mar 2026 02:51:25 -0700 (PDT) Received: from [10.1.196.46] (e134344.arm.com [10.1.196.46]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id F17CF3F778; Mon, 16 Mar 2026 02:51:29 -0700 (PDT) Message-ID: Date: Mon, 16 Mar 2026 09:51:22 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Thunderbird Daily Subject: Re: [PATCH v2 3/6] fs/resctrl: Make 'event_filter' files read only if they're not configurable To: "Luck, Tony" 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 References: <20260313174524.3482767-1-ben.horgan@arm.com> <20260313174524.3482767-4-ben.horgan@arm.com> Content-Language: en-US From: Ben Horgan In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit 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_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