From nobody Sat Jun 13 08:46:45 2026 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 75C423603FB; Fri, 8 May 2026 10:56:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778237803; cv=none; b=XN5s+5rnlUvi4FwixubUKChDPBNtOsXeGWPkIrCARSW04mqLFGlw1cpgSWekRwEPR6EoFdDX/mO1EW/fCgh44wArTyBtOfpdFcEmjAGbAXJ8xSAPaKCHTQNY5iQKA2jTIaqRibrZqRGyP3zC6nQH+2iqKnxH3HxyBnW982FEjdw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778237803; c=relaxed/simple; bh=yAG9c58XNAPP+O36BeSR6BjqVCBrz4kJibH9Z8uH9xc=; h=Date:From:To:Subject:Cc:MIME-Version:Message-ID:Content-Type; b=QEhz8sr2rfppIKI6QJvueCAwi1n1KxnrHxI/TKoX4tjnowJCOO0OLjdMQIKreBAZo+kKzypTNv8Fx8s8rUR8X2QfpXVGmvu36g8WLGTMlPFkJoqcGST7rJYsn8aWSQ+6hb+wAZ4ORP/EA1Gz+41entCfsbDrUsIfFSZXAD4/58M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=Pz2L1pXY; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=qd24Pqzs; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="Pz2L1pXY"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="qd24Pqzs" Date: Fri, 08 May 2026 10:56:38 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1778237799; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=jqFO6Z5LOTHmuESC3bF2xSfmkKZip3GJ5xQJT4fK10c=; b=Pz2L1pXYzB5jp8Q3ptIRiSpBdeBhaQYsc+o/+1EJz+FSCQFq/NymCONCLZ8CZjgSPPW+99 Barj0DDhOfEs+RIsNutj2L977zovUOCl5/9RuAnedFiQIZ6hkEv5VDCH20e0B2myq+wOOq KjG9xFjNWEoxNp0vr3NUepeo5EZJD5NcKIavTbXbviFfiVxnv121ZxSd5vk3NRJNio2Qig u7yiI1vifnIag4DuZKPs9kRB1Hdezlx60sLGp2igHpYhMxocM9CQNBd9PxRGMYvPROy9x9 wF91lk2jb4tuJoFv7xcjZhxX3RJgCNsatWCylVDU+B5sYJsWaxLI7kIEtTJDaw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1778237799; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=jqFO6Z5LOTHmuESC3bF2xSfmkKZip3GJ5xQJT4fK10c=; b=qd24Pqzs/8fhw4hDZaghgm0IixpoALpxocrCeowgryLUPbu/4355OMtYqCKG0fEjUmmZYq p3xR2Aysw1vIHlCg== From: "tip-bot2 for Ben Horgan" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/cache] x86,fs/resctrl: Create 'event_filter' files read only if they're not configurable Cc: Ben Horgan , "Borislav Petkov (AMD)" , Reinette Chatre , Babu Moger , x86@kernel.org, linux-kernel@vger.kernel.org Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <177823779823.864.7567891053032554977.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The following commit has been merged into the x86/cache branch of tip: Commit-ID: 94a1206522d11302ae7e7c28d3d494c8f0c9c58e Gitweb: https://git.kernel.org/tip/94a1206522d11302ae7e7c28d3d494c8f= 0c9c58e Author: Ben Horgan AuthorDate: Wed, 06 May 2026 09:28:50 +01:00 Committer: Borislav Petkov (AMD) CommitterDate: Wed, 06 May 2026 19:06:57 +02:00 x86,fs/resctrl: Create 'event_filter' files read only if they're not config= urable 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 architecture has support for configuring the memory bandwidth utilization (MBWU) counters to only count reads or only count writes. However, in MPAM, this event filtering support is optional in the hardware (and not yet implemented in the MPAM driver) but MBM counter assignment is always possible for MPAM MBWU counters. In order to support mbm_event mode with MPAM, create 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 early with an error from event_filter_write(). Introduce a new monitor property, mbm_cntr_configurable, to indicate whether or not assignable MBM counters are configurable. On x86, set this to true whenever mbm_cntr_assignable is true to keep existing behaviour. Signed-off-by: Ben Horgan Signed-off-by: Borislav Petkov (AMD) Reviewed-by: Reinette Chatre Reviewed-by: Babu Moger Tested-by: Babu Moger Link: https://lore.kernel.org/20260506082855.3694761-1-ben.horgan@arm.com --- Documentation/filesystems/resctrl.rst | 11 +++++------ arch/x86/kernel/cpu/resctrl/monitor.c | 1 + fs/resctrl/internal.h | 2 ++ fs/resctrl/monitor.c | 7 +++++++ fs/resctrl/rdtgroup.c | 11 ++++++++++- include/linux/resctrl.h | 16 +++++++++------- 6 files changed, 34 insertions(+), 14 deletions(-) diff --git a/Documentation/filesystems/resctrl.rst b/Documentation/filesyst= ems/resctrl.rst index b003bed..2898a51 100644 --- a/Documentation/filesystems/resctrl.rst +++ b/Documentation/filesystems/resctrl.rst @@ -427,9 +427,9 @@ with the following files: =20 Two MBM events are supported by default: mbm_local_bytes and mbm_total_by= tes. Each MBM event's sub-directory contains a file named "event_filter" that = is - used to view and modify which memory transactions the MBM event is config= ured - with. The file is accessible only when "mbm_event" counter assignment mod= e is - enabled. + used to view and (if writable) modify which memory transactions the MBM e= vent + is configured with. The file is accessible only when "mbm_event" counter + assignment mode is enabled. =20 List of memory transaction types supported: =20 @@ -454,9 +454,8 @@ with the following files: # cat /sys/fs/resctrl/info/L3_MON/event_configs/mbm_local_bytes/event_f= ilter local_reads,local_non_temporal_writes,local_reads_slow_memory =20 - Modify the event configuration by writing to the "event_filter" file with= in - the "event_configs" directory. The read/write "event_filter" file contain= s the - configuration of the event that reflects which memory transactions are co= unted by it. + The memory transactions the MBM event is configured with can be changed + if "event_filter" is writable. =20 For example:: =20 diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/re= sctrl/monitor.c index 9bd87ba..794a6fb 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -454,6 +454,7 @@ int __init rdt_get_l3_mon_config(struct rdt_resource *r) (rdt_cpu_has(X86_FEATURE_CQM_MBM_TOTAL) || rdt_cpu_has(X86_FEATURE_CQM_MBM_LOCAL))) { r->mon.mbm_cntr_assignable =3D true; + r->mon.mbm_cntr_configurable =3D true; cpuid_count(0x80000020, 5, &eax, &ebx, &ecx, &edx); r->mon.num_mbm_cntrs =3D (ebx & GENMASK(15, 0)) + 1; hw_res->mbm_cntr_assign_enabled =3D true; diff --git a/fs/resctrl/internal.h b/fs/resctrl/internal.h index 1a9b291..48af75b 100644 --- a/fs/resctrl/internal.h +++ b/fs/resctrl/internal.h @@ -408,6 +408,8 @@ void __check_limbo(struct rdt_l3_mon_domain *d, bool fo= rce_free); =20 void resctrl_file_fflags_init(const char *config, unsigned long fflags); =20 +void resctrl_file_mode_init(const char *config, umode_t mode); + void rdt_staged_configs_clear(void); =20 bool closid_allocated(unsigned int closid); diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c index 9fd901c..916f7a9 100644 --- a/fs/resctrl/monitor.c +++ b/fs/resctrl/monitor.c @@ -1422,6 +1422,11 @@ ssize_t event_filter_write(struct kernfs_open_file *= of, char *buf, size_t nbytes ret =3D -EINVAL; goto out_unlock; } + if (!r->mon.mbm_cntr_configurable) { + rdt_last_cmd_puts("event_filter is not configurable\n"); + ret =3D -EPERM; + goto out_unlock; + } =20 ret =3D resctrl_parse_mem_transactions(buf, &evt_cfg); if (!ret && mevt->evt_cfg !=3D evt_cfg) { @@ -1886,6 +1891,8 @@ int resctrl_l3_mon_resource_init(void) resctrl_file_fflags_init("available_mbm_cntrs", RFTYPE_MON_INFO | RFTYPE_RES_CACHE); resctrl_file_fflags_init("event_filter", RFTYPE_ASSIGN_CONFIG); + if (r->mon.mbm_cntr_configurable) + resctrl_file_mode_init("event_filter", 0644); resctrl_file_fflags_init("mbm_assign_on_mkdir", RFTYPE_MON_INFO | RFTYPE_RES_CACHE); resctrl_file_fflags_init("mbm_L3_assignments", RFTYPE_MON_BASE); diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c index eca3bb6..7d800b3 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -2022,7 +2022,7 @@ static struct rftype res_common_files[] =3D { }, { .name =3D "event_filter", - .mode =3D 0644, + .mode =3D 0444, .kf_ops =3D &rdtgroup_kf_single_ops, .seq_show =3D event_filter_show, .write =3D event_filter_write, @@ -2215,6 +2215,15 @@ void resctrl_file_fflags_init(const char *config, un= signed long fflags) rft->fflags =3D fflags; } =20 +void resctrl_file_mode_init(const char *config, umode_t mode) +{ + struct rftype *rft; + + rft =3D rdtgroup_get_rftype_by_name(config); + if (rft) + rft->mode =3D mode; +} + /** * rdtgroup_kn_mode_restrict - Restrict user access to named resctrl file * @r: The resource group with which the file is associated. diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index 006e57f..06e8c72 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -286,13 +286,14 @@ enum resctrl_schema_fmt { =20 /** * struct resctrl_mon - Monitoring related data of a resctrl resource. - * @num_rmid: Number of RMIDs available. - * @mbm_cfg_mask: Memory transactions that can be tracked when bandwidth - * monitoring events can be configured. - * @num_mbm_cntrs: Number of assignable counters. - * @mbm_cntr_assignable:Is system capable of supporting counter assignment? - * @mbm_assign_on_mkdir:True if counters should automatically be assigned = to MBM - * events of monitor groups created via mkdir. + * @num_rmid: Number of RMIDs available. + * @mbm_cfg_mask: Memory transactions that can be tracked when + * bandwidth monitoring events can be configured. + * @num_mbm_cntrs: Number of assignable counters. + * @mbm_cntr_assignable: Is system capable of supporting counter assignmen= t? + * @mbm_assign_on_mkdir: True if counters should automatically be assigned= to MBM + * events of monitor groups created via mkdir. + * @mbm_cntr_configurable: True if assignable counters are configurable. */ struct resctrl_mon { u32 num_rmid; @@ -300,6 +301,7 @@ struct resctrl_mon { int num_mbm_cntrs; bool mbm_cntr_assignable; bool mbm_assign_on_mkdir; + bool mbm_cntr_configurable; }; =20 /**