From nobody Sat Jun 13 10:57:24 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.18]) (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 A802238C416 for ; Fri, 10 Apr 2026 20:05:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775851542; cv=none; b=jAwiNfgYpToTJw0tHM7xUxXeorE48rxCE4KSW/Kwq6FJW/oxtDhGZ9/iV71Igx0mklWvrGtN30oKSnYYuXB5b+eWZVyiaT+mEFdqqx9t4uQ12X99PBgugjx6JXtufsCqqoV+Kg3H4jzDkn+/GUdXicqXJctzBQ320LeUdKPAqEQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775851542; c=relaxed/simple; bh=TpqgBuTQel4V5/BGOHX3wAgyHeUcGtOmEJQ2AKSmzOg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=u3z+LPa09cQH30LJkOGnNo9wGA9aCcBuKkmJgnw3DfsGOpoQrd/91qjb1ewoSWSYeIlh+ljQvKoMtUHsrMH9dSfGCFd8ypTYZ8NAqoLD+jxMlEJMbrhfOvWHm3nLEJTfEJQJgva1VHHL67CFKRoAFCbZA9FPzJsfe7w/vCsHx2s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=AsSpZrCw; arc=none smtp.client-ip=198.175.65.18 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="AsSpZrCw" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1775851541; x=1807387541; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=TpqgBuTQel4V5/BGOHX3wAgyHeUcGtOmEJQ2AKSmzOg=; b=AsSpZrCwsWje5iKA4D1KPQFi4Mip3xtudK6oTW/eP2cRbir0WD/F7xat 4oRKVSXLCIwpPCAQNfpacaqqXjJv1WU67ZrJIIIDPIe4SZohel8kx2rmn Zad/KtMZpBUYrlDTvL0YoL6rcmqsJiZVTZslUqN/E7NOuZVdGKAqAvbG8 6Y5r0vkcy+niSSYqd58z07bbZ1zoTTy/V0l5wI31pcw1kK8j9p3oLqHBk hmOaLbTOFHVqdjnOdpGr5VpOekzwPHfkx0EnTi6EKjYR79iadNSSGkWWL 3aaQPSV25IKjxry+FFK2i9n2mGFSdSUXKdqxegzUaZNKIQz7GsNn4OsWT w==; X-CSE-ConnectionGUID: 6PtlvDbWRH+IkZVifDLoVw== X-CSE-MsgGUID: 9XXStQxXTJ6uQKfcfH3gqQ== X-IronPort-AV: E=McAfee;i="6800,10657,11755"; a="76898060" X-IronPort-AV: E=Sophos;i="6.23,172,1770624000"; d="scan'208";a="76898060" Received: from orviesa006.jf.intel.com ([10.64.159.146]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Apr 2026 13:05:40 -0700 X-CSE-ConnectionGUID: RAow2HSwTw6pLENSIsE6EQ== X-CSE-MsgGUID: n0RpBQcMTnCXaCWFyY2vyg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.23,172,1770624000"; d="scan'208";a="228155001" Received: from khuang2-desk.gar.corp.intel.com (HELO agluck-desk3.intel.com) ([10.124.221.106]) by orviesa006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Apr 2026 13:05:39 -0700 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Maciej Wieczor-Retman , Peter Newman , James Morse , Babu Moger , Drew Fustini , Dave Martin , Chen Yu , David E Box , x86@kernel.org Cc: Christoph Hellwig , linux-kernel@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [RFC PATCH v5 1/7] x86/resctrl: Stop setting event_group::force_off on RMID shortage Date: Fri, 10 Apr 2026 13:05:26 -0700 Message-ID: <20260410200532.58602-2-tony.luck@intel.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260410200532.58602-1-tony.luck@intel.com> References: <20260410200532.58602-1-tony.luck@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Drop the force_off assignment from all_regions_have_sufficient_rmid(). This preserves current single-enumeration behaviour while preparing for the upcoming per-mount enumeration, where latching force_off would incorrectly suppress re-enumeration on subsequent mounts - even when the user explicitly requested the feature via "rdt=3D{feature}". Signed-off-by: Tony Luck --- arch/x86/kernel/cpu/resctrl/intel_aet.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/intel_aet.c b/arch/x86/kernel/cpu/= resctrl/intel_aet.c index 89b8b619d5d5..e2af700bca04 100644 --- a/arch/x86/kernel/cpu/resctrl/intel_aet.c +++ b/arch/x86/kernel/cpu/resctrl/intel_aet.c @@ -60,8 +60,8 @@ struct pmt_event { * data for all telemetry regions of type @pfname. * Valid if the system supports the event group, * NULL otherwise. - * @force_off: True when "rdt" command line or architecture code disables - * this event group due to insufficient RMIDs. + * @force_off: True when "rdt" command line disables this event group + * to avoid system limitations due to insufficient RMIDs. * @force_on: True when "rdt" command line overrides disable of this * event group. * @guid: Unique number per XML description file. @@ -214,10 +214,8 @@ static bool all_regions_have_sufficient_rmid(struct ev= ent_group *e, struct pmt_f if (!p->regions[i].addr) continue; tr =3D &p->regions[i]; - if (tr->num_rmids < e->num_rmid) { - e->force_off =3D true; + if (tr->num_rmids < e->num_rmid) return false; - } } =20 return true; --=20 2.53.0 From nobody Sat Jun 13 10:57:24 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.18]) (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 47AB836C5BB for ; Fri, 10 Apr 2026 20:05:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775851543; cv=none; b=AT51NELRhwuJ/pbZZ6SLct1C6ZRt0mk+1tGu1FiBT6DIX8mOadQix8B+HufdqZyITzO4E0WR1F+CENPRPpQSDz8wC1xJbtSq9tmDZt8fT4JOCwBOvk6NsNFjAaK9o4xj/iP8FvncyRt3XkPXIZz1Tj42AwMnW/PB5v9iCnW1t5Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775851543; c=relaxed/simple; bh=fk2FeTa5sC5C/JCX1a5sNfgQLpavS6OsCw5bkUgeGFg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SYLs5H1JHgCt4/SmUsiw30mRVWDdRninyAluCYw5dtEFQAmo8OHdXqfE0TbfnU1blqyCyqMhxCu4beeZMym5DMAVfy4gYBzVUA+Co7mxb8aPQsvLp+fW/WY/TotCSswHwIM5rePQqIv9gFq3AtJyzr6ghu2LfJpfCPWdmnn1RIM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=oIMRo0uq; arc=none smtp.client-ip=198.175.65.18 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="oIMRo0uq" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1775851541; x=1807387541; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=fk2FeTa5sC5C/JCX1a5sNfgQLpavS6OsCw5bkUgeGFg=; b=oIMRo0uq/NMclgRGMICSSYasEEUigO7B+zLhn2KQAwS6qz7PxyoTB/PS dH3Vlw54pBPF3ssh0kgp87xcVV/A3w+O6GPnyX7HHwPctg0wR0OvnTlvc a8mIYectfZJN2XFTjlgBKh8JNcXFzJVCr7HaN5pxg01L4d5gxl7B5S7Pz FJj7GCqkVWRNPOGxwpFs98StTKvyeLJ5tnFIwwc2AU0aDCge31aqqCNxG aQLYVuCEcYzPAJjmamiETwAg8aq1I38OtI8yP+C8Xhj2OEG5bhiJemELE q/j0XNp/25IrG2P8IzJzd2HVc7xn6WXXyqCQRuD2XqQ3lJ4Rr0pwyy4FQ A==; X-CSE-ConnectionGUID: 2xvDKZ8cTG2yqnpsVp+7Xg== X-CSE-MsgGUID: WIV3Fe5dSEKFuPoOtXWwFA== X-IronPort-AV: E=McAfee;i="6800,10657,11755"; a="76898069" X-IronPort-AV: E=Sophos;i="6.23,172,1770624000"; d="scan'208";a="76898069" Received: from orviesa006.jf.intel.com ([10.64.159.146]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Apr 2026 13:05:40 -0700 X-CSE-ConnectionGUID: SMvz9TcQSoq3RVSDU8qzyg== X-CSE-MsgGUID: kM7dIBIySS6kCOHsD39fdA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.23,172,1770624000"; d="scan'208";a="228155006" Received: from khuang2-desk.gar.corp.intel.com (HELO agluck-desk3.intel.com) ([10.124.221.106]) by orviesa006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Apr 2026 13:05:39 -0700 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Maciej Wieczor-Retman , Peter Newman , James Morse , Babu Moger , Drew Fustini , Dave Martin , Chen Yu , David E Box , x86@kernel.org Cc: Christoph Hellwig , linux-kernel@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [RFC PATCH v5 2/7] fs/resctrl: Add interface to disable a monitor event Date: Fri, 10 Apr 2026 13:05:27 -0700 Message-ID: <20260410200532.58602-3-tony.luck@intel.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260410200532.58602-1-tony.luck@intel.com> References: <20260410200532.58602-1-tony.luck@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" In preparation for re-running AET enumeration on every mount, AET code must be able to disable events on unmount so the next mount starts from a clean slate. Add resctrl_disable_mon_event(eventid) which clears the enabled flag for the given event. Add kerneldoc comments to describe limitations on when events may be enabled or disabled. Signed-off-by: Tony Luck --- include/linux/resctrl.h | 34 ++++++++++++++++++++++++++++++++++ fs/resctrl/monitor.c | 12 ++++++++++++ 2 files changed, 46 insertions(+) diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index 006e57fd7ca5..a8338656f836 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -414,9 +414,43 @@ u32 resctrl_arch_get_num_closid(struct rdt_resource *r= ); u32 resctrl_arch_system_num_rmid_idx(void); int resctrl_arch_update_domains(struct rdt_resource *r, u32 closid); =20 +/** + * resctrl_enable_mon_event() - Enable monitoring event + * @eventid: ID of the event + * @any_cpu: True if event data can be read from any CPU. + * @binary_bits:Number of binary places of the fixed-point value expected = to + * back a floating point event. Can only be set for floating point + * events. + * @arch_priv: Architecture private data associated with event. Passed ba= ck to + * architecture when reading the event via resctrl_arch_rmid_read(). + * + * The file system must not be mounted when enabling an event. + * + * Events that require per-domain (architectural and/or filesystem) state = must + * be enabled before the domain structures are allocated. For example befo= re + * CPU hotplug callbacks that allocate domain structures are registered. I= f the + * architecture discovers a resource after initialization it should enable + * events needing per-domain state before any domain structure allocation = which + * should be coordinated with the CPU hotplug callbacks. + * + * Return: + * true if event was successfully enabled, false otherwise. + */ bool resctrl_enable_mon_event(enum resctrl_event_id eventid, bool any_cpu, unsigned int binary_bits, void *arch_priv); =20 +/** + * resctrl_disable_mon_event() - Disable monitoring event + * @eventid: ID of the event + * + * The file system must not be mounted when disabling an event. + * + * Events that require per-domain (architectural and/or filesystem) state + * will require additional cleanup which should be coordinated with the CPU + * hotplug callbacks. + */ +void resctrl_disable_mon_event(enum resctrl_event_id eventid); + bool resctrl_is_mon_event_enabled(enum resctrl_event_id eventid); =20 bool resctrl_arch_is_evt_configurable(enum resctrl_event_id evt); diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c index 49f3f6b846b2..0def41c26edc 100644 --- a/fs/resctrl/monitor.c +++ b/fs/resctrl/monitor.c @@ -1010,6 +1010,18 @@ bool resctrl_enable_mon_event(enum resctrl_event_id = eventid, bool any_cpu, return true; } =20 +void resctrl_disable_mon_event(enum resctrl_event_id eventid) +{ + if (WARN_ON_ONCE(eventid < QOS_FIRST_EVENT || eventid >=3D QOS_NUM_EVENTS= )) + return; + if (!mon_event_all[eventid].enabled) { + pr_warn("Repeat disable for event %d\n", eventid); + return; + } + + mon_event_all[eventid].enabled =3D false; +} + bool resctrl_is_mon_event_enabled(enum resctrl_event_id eventid) { return eventid >=3D QOS_FIRST_EVENT && eventid < QOS_NUM_EVENTS && --=20 2.53.0 From nobody Sat Jun 13 10:57:24 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.18]) (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 ED77D39021D for ; Fri, 10 Apr 2026 20:05:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775851544; cv=none; b=nfMB3ZguWcawcJJCXc6IcaUzb/X3uuYf3tFESAfVzH+iA08fB/ApwHZk6WnSZYUphFcB7iJ8icyPaeqLi7tHFZ9xsMK0iWU+PEh9gKvjo+C9QcBYNM/m/8+9c6JF4v8lPdomGRQH0M26YIPhN5U+3Ano7eAqLaYfQaje/aK3QN4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775851544; c=relaxed/simple; bh=5Y+Hl8XUznNXOIiGmrYMs3h89O8MnhL1SwAGZMoxg1s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KdOjC7X7AtaJsINvVpRCNYA26mf4VPs7D7CKhERf33A1qqkPTZi3CNTH5hPq8yhT4BVB+xdReZnYNIFBSZJ3NHZGTdBIMIpP4Dv2JDZfv4VSLN3kEHxTLRwSR4Q+/AGU0uAjQglp7A1o2jQugktJoXoUEKQO68he8v4n1aY1OIA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=Edsqseky; arc=none smtp.client-ip=198.175.65.18 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Edsqseky" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1775851542; x=1807387542; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=5Y+Hl8XUznNXOIiGmrYMs3h89O8MnhL1SwAGZMoxg1s=; b=EdsqsekymdPEJj7LFX8aM+e0zDcbeJYDxBSicYJyWZPLXp3wV21TdsbU BI/TmgVXIrv4s8dbmR22QZH3ubEq7H/QxiGr5J1vjeBbpMOl73IdHnR06 k7RAVH1e3ZZ1E2/RcuVArVZKJT1byoXZfBsGlSxcltMtqznptAj6ayosO yIhUIdNee6Lqm02RLq/LYyDwPXN4UMnrptAcPRNWeCDMTgMo5Ln2xjlS+ VsZJtyzD0nBamqzJ8euh6h0jJxXhyXIuR2ystcMFYZT/WKAtzIcLVOhAT Mli+BHbIb3rTTAMmbARp1QlT5S6RWzV0FrX/7Uh27tiXTu3b/RN8vuRSD A==; X-CSE-ConnectionGUID: BDF9onXhQyiSoK8iHF9jlA== X-CSE-MsgGUID: VaWYSsKbQMihK3fFzTh4yw== X-IronPort-AV: E=McAfee;i="6800,10657,11755"; a="76898079" X-IronPort-AV: E=Sophos;i="6.23,172,1770624000"; d="scan'208";a="76898079" Received: from orviesa006.jf.intel.com ([10.64.159.146]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Apr 2026 13:05:40 -0700 X-CSE-ConnectionGUID: RH4q9cwOR7STZ+ICBVlgIQ== X-CSE-MsgGUID: eYyWKV9SRk61n51Fu4KZgA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.23,172,1770624000"; d="scan'208";a="228155012" Received: from khuang2-desk.gar.corp.intel.com (HELO agluck-desk3.intel.com) ([10.124.221.106]) by orviesa006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Apr 2026 13:05:39 -0700 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Maciej Wieczor-Retman , Peter Newman , James Morse , Babu Moger , Drew Fustini , Dave Martin , Chen Yu , David E Box , x86@kernel.org Cc: Christoph Hellwig , linux-kernel@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [RFC PATCH v5 3/7] x86/resctrl: x86/resctrl: Add PMT registration API for AET enumeration callbacks Date: Fri, 10 Apr 2026 13:05:28 -0700 Message-ID: <20260410200532.58602-4-tony.luck@intel.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260410200532.58602-1-tony.luck@intel.com> References: <20260410200532.58602-1-tony.luck@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" resctrl is always built-in; INTEL_PMT_TELEMETRY may be a module. Add, and export, register/unregister functions so the PMT module can supply/clear enumeration callback functions when loaded/unloaded. Suggested-by: Christoph Hellwig Signed-off-by: Tony Luck --- arch/x86/include/asm/resctrl.h | 19 ++++++++++++++ arch/x86/kernel/cpu/resctrl/intel_aet.c | 35 +++++++++++++++++++++++++ 2 files changed, 54 insertions(+) diff --git a/arch/x86/include/asm/resctrl.h b/arch/x86/include/asm/resctrl.h index 575f8408a9e7..b5fa54c4637c 100644 --- a/arch/x86/include/asm/resctrl.h +++ b/arch/x86/include/asm/resctrl.h @@ -4,6 +4,8 @@ =20 #ifdef CONFIG_X86_CPU_RESCTRL =20 +#include +#include #include #include #include @@ -193,11 +195,28 @@ static inline void resctrl_arch_mon_ctx_free(struct r= dt_resource *r, =20 void resctrl_cpu_detect(struct cpuinfo_x86 *c); =20 +#ifdef CONFIG_X86_CPU_RESCTRL_INTEL_AET +void intel_aet_register_enumeration(struct pmt_feature_group *(*get)(enum = pmt_feature_id id), + void (*put)(struct pmt_feature_group *p)); +void intel_aet_unregister_enumeration(void); #else +static inline void intel_aet_register_enumeration(struct pmt_feature_group= *(*get)(enum pmt_feature_id id), + void (*put)(struct pmt_feature_group *p)) { } +static inline void intel_aet_unregister_enumeration(void) { } +#endif /* CONFIG_X86_CPU_RESCTRL_INTEL_AET */ + +#else + +#include +#include =20 static inline void resctrl_arch_sched_in(struct task_struct *tsk) {} static inline void resctrl_cpu_detect(struct cpuinfo_x86 *c) {} =20 +static inline void intel_aet_register_enumeration(struct pmt_feature_group= *(*get)(enum pmt_feature_id id), + void (*put)(struct pmt_feature_group *p)) { } +static inline void intel_aet_unregister_enumeration(void) { } + #endif /* CONFIG_X86_CPU_RESCTRL */ =20 #endif /* _ASM_X86_RESCTRL_H */ diff --git a/arch/x86/kernel/cpu/resctrl/intel_aet.c b/arch/x86/kernel/cpu/= resctrl/intel_aet.c index e2af700bca04..2b3677783427 100644 --- a/arch/x86/kernel/cpu/resctrl/intel_aet.c +++ b/arch/x86/kernel/cpu/resctrl/intel_aet.c @@ -12,17 +12,21 @@ #define pr_fmt(fmt) "resctrl: " fmt =20 #include +#include #include #include #include #include #include +#include #include #include #include #include #include #include +#include +#include #include #include #include @@ -289,6 +293,9 @@ static enum pmt_feature_id lookup_pfid(const char *pfna= me) return FEATURE_INVALID; } =20 +static struct pmt_feature_group *(*get_feature)(enum pmt_feature_id id); +static void (*put_feature)(struct pmt_feature_group *p); + /* * Request a copy of struct pmt_feature_group for each event group. If the= re is * one, the returned structure has an array of telemetry_region structures, @@ -323,6 +330,25 @@ bool intel_aet_get_events(void) return ret; } =20 +static DEFINE_MUTEX(aet_register_lock); + +void intel_aet_register_enumeration(struct pmt_feature_group *(*get)(enum = pmt_feature_id id), + void (*put)(struct pmt_feature_group *p)) +{ + guard(mutex)(&aet_register_lock); + get_feature =3D get; + put_feature =3D put; +} +EXPORT_SYMBOL_GPL(intel_aet_register_enumeration); + +void intel_aet_unregister_enumeration(void) +{ + guard(mutex)(&aet_register_lock); + get_feature =3D NULL; + put_feature =3D NULL; +} +EXPORT_SYMBOL_GPL(intel_aet_unregister_enumeration); + void __exit intel_aet_exit(void) { struct event_group **peg; @@ -405,3 +431,12 @@ void intel_aet_mon_domain_setup(int cpu, int id, struc= t rdt_resource *r, kfree(d); } } + +static int __init intel_aet_init(void) +{ + request_module("pmt_telemetry"); + + return 0; +} + +late_initcall(intel_aet_init); --=20 2.53.0 From nobody Sat Jun 13 10:57:24 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.18]) (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 2C5F833F5B4 for ; Fri, 10 Apr 2026 20:05:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775851543; cv=none; b=eU4NX8/bPluV+uGiS5EL/vrvTmNEw0iIU8z3lxUErdMghMm+lwxqXNYv1esXzEI7mkccGwaGK86UZxCnX8VuTI2jsJUhGBVTx7kH1/NT7xw3wQFhxweKyWhNgUnVmt/3BikymxGRuCM1jrgBy0xxvZz5UxSPIpXd52JvIPJxces= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775851543; c=relaxed/simple; bh=iV4S5j2BrthBeOJkRN+K1btg+O2lMEcy08RQXWT+Hj0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pxNbVTOKoCZ59eXh9SeUisFSugdvsIQHPn7m2z/nPkxn810/4bHlsijNCc6tzaHDCzEOAwsdXx5HxM2KwTF/7dKHmC0pCtVZtVPaFq+XZdJCP7YujskLFVMRKF7F4KV+WyqmhqRw38ywY2plLB8vJl7KNxS2YDZnO+BHT2wIhc8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=nXV/eBDI; arc=none smtp.client-ip=198.175.65.18 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="nXV/eBDI" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1775851542; x=1807387542; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=iV4S5j2BrthBeOJkRN+K1btg+O2lMEcy08RQXWT+Hj0=; b=nXV/eBDIZy1a6i73Z1qQ+mY6J2S58kJ7zn6riwftNzlWNiSwVnWxmy5S AyZHZxWG5+BqnRgFHKDB9RegnbEjY4Mi+DKsXhDSxJPkmfnzXshWIMBCy rwGxfUiaYKzJSuulbbZ6zeHYhXNZBh0SKmfaCi+qGD31FJuNvr4/0XAlP Y4SsA1v4Ki78VeD4OL8WqEm6TAvKcky6KIHgTULRBi2JmFl004aNqfT5V F4wSlfGYAnAAFhsJYRvZZwF2SLRKg4+jk9FqfAzm6Mu4gZ+Xo/kLFEPkS tX4T1IAQHXwHnwXB7QQln9Z2eOaRPavI/i4jZl1EywHiFwRAXgq10yl9R g==; X-CSE-ConnectionGUID: 4lxxSq3BR/q/zoAt0aSMCw== X-CSE-MsgGUID: YteNvb9cR+SD5iGGRKBkWQ== X-IronPort-AV: E=McAfee;i="6800,10657,11755"; a="76898088" X-IronPort-AV: E=Sophos;i="6.23,172,1770624000"; d="scan'208";a="76898088" Received: from orviesa006.jf.intel.com ([10.64.159.146]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Apr 2026 13:05:41 -0700 X-CSE-ConnectionGUID: ibWS4kWOSPiuRpWr1/m+vQ== X-CSE-MsgGUID: z3Dcjo0sRvK8lFRSOni/Aw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.23,172,1770624000"; d="scan'208";a="228155017" Received: from khuang2-desk.gar.corp.intel.com (HELO agluck-desk3.intel.com) ([10.124.221.106]) by orviesa006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Apr 2026 13:05:40 -0700 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Maciej Wieczor-Retman , Peter Newman , James Morse , Babu Moger , Drew Fustini , Dave Martin , Chen Yu , David E Box , x86@kernel.org Cc: Christoph Hellwig , linux-kernel@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [RFC PATCH v5 4/7] platform/x86/intel/pmt: Register enumeration functions with resctrl Date: Fri, 10 Apr 2026 13:05:29 -0700 Message-ID: <20260410200532.58602-5-tony.luck@intel.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260410200532.58602-1-tony.luck@intel.com> References: <20260410200532.58602-1-tony.luck@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" INTEL_PMT_TELEMETRY is a loadable module, but resctrl is built-in and cannot call PMT functions directly. Register the telemetry enumeration function pointers at resctrl module init, and unregister them at module exit. Add module_{get,put} calls to the PMT get/put functions to ensure that INTEL_PMT_TELEMETRY cannot be unloaded while resctrl is mounted and referencing the MMIO register space mapped by INTEL_PMT_TELEMETRY. Note that checkpatch complains about the #include of . This is needed rather than to get the function stub definitions when CONFIG_X86_CPU_RESCTRL=3Dn. Suggested-by: Christoph Hellwig Signed-off-by: Tony Luck --- drivers/platform/x86/intel/pmt/telemetry.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/platform/x86/intel/pmt/telemetry.c b/drivers/platform/= x86/intel/pmt/telemetry.c index a52803bfe124..e76927cabc97 100644 --- a/drivers/platform/x86/intel/pmt/telemetry.c +++ b/drivers/platform/x86/intel/pmt/telemetry.c @@ -25,6 +25,8 @@ #include #include =20 +#include + #include "class.h" =20 #define TELEM_SIZE_OFFSET 0x0 @@ -283,6 +285,9 @@ struct pmt_feature_group *intel_pmt_get_regions_by_feat= ure(enum pmt_feature_id i region++; } =20 + if (!try_module_get(THIS_MODULE)) + return ERR_PTR(-EINVAL); + kref_init(&feature_group->kref); =20 return no_free_ptr(feature_group); @@ -292,6 +297,7 @@ EXPORT_SYMBOL(intel_pmt_get_regions_by_feature); void intel_pmt_put_feature_group(struct pmt_feature_group *feature_group) { kref_put(&feature_group->kref, pmt_feature_group_release); + module_put(THIS_MODULE); } EXPORT_SYMBOL(intel_pmt_put_feature_group); =20 @@ -404,6 +410,9 @@ static int pmt_telem_probe(struct auxiliary_device *aux= dev, const struct auxilia intel_pmt_get_features(entry); } =20 + intel_aet_register_enumeration(intel_pmt_get_regions_by_feature, + intel_pmt_put_feature_group); + return 0; abort_probe: pmt_telem_remove(auxdev); @@ -432,6 +441,7 @@ static void __exit pmt_telem_exit(void) { auxiliary_driver_unregister(&pmt_telem_aux_driver); xa_destroy(&telem_array); + intel_aet_unregister_enumeration(); } module_exit(pmt_telem_exit); =20 --=20 2.53.0 From nobody Sat Jun 13 10:57:24 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.18]) (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 8173C391E4D for ; Fri, 10 Apr 2026 20:05:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775851547; cv=none; b=uF4y6PB1Tx1fNdONECD77NBmBHGZaXkR9XBC3wQB2jN4yMhUlajqR1kqQNVPFcuhtJ0qHhntm4dvARxEX6YEgY9GLhxZbsG1kGW9rhoXOZHIw/D5bK90YI6FwzDEPqCwaJR3jScx8wSeoSKHnWsKhcWOIr+1Rx8rxL7cmS9TBRY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775851547; c=relaxed/simple; bh=M6g8GJVRdCE1i9P5NJ/YxLzsYmvfhI0q9YyUKzFv3EQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PoEWe+MTYFPizaghwAuXl9ee7SjyGyZWi9lOW1OBcm4jEo7a10o8Su7eHFJx9qDRFenwnSYBy2sipe68EmaRX09b5YvhCNoK09q8LKNHFfFguu6l2qkqxgNCIuwOshsVy5t4ZZ9Q5Be0HQpehPJKQ+FfPFLIUtV8TPZpKK9vYmk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=B76EdYcR; arc=none smtp.client-ip=198.175.65.18 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="B76EdYcR" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1775851544; x=1807387544; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=M6g8GJVRdCE1i9P5NJ/YxLzsYmvfhI0q9YyUKzFv3EQ=; b=B76EdYcRc/REWRVwB1/TiaOo5eiCxW0zezPRd1AsTsxpF7R37uSwIILJ bO2+jlEmiwpB6D2HTbnfv2YCWcE5XaxPFqb25CICREcLlDygkEaLau0XO fWvFBj32eAsfdhcgnS65i6cGyhISbaQheXhId2G1Ca7+y0uOeluvgmwSh bhSSjSKKUwJH8VnpbbmyMSlHKtBaZVNvoZwOU+PKFRM8ONhUO2ba2xP9p caatpJY7BCRopJH67KMxHB1OHg0cKaIOAx/zStB08Lb2LUTwnM6o/3cv6 JJqtbmhP5IquKr8Rm0llId3f2dY/4UMtRNTG5dRpPLYcHsP+O2Sw8n/xE Q==; X-CSE-ConnectionGUID: +VMeQs9/T5aLtEO8bohJDw== X-CSE-MsgGUID: C+WPg+xdTkifWUmfUSnCZg== X-IronPort-AV: E=McAfee;i="6800,10657,11755"; a="76898097" X-IronPort-AV: E=Sophos;i="6.23,172,1770624000"; d="scan'208";a="76898097" Received: from orviesa006.jf.intel.com ([10.64.159.146]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Apr 2026 13:05:41 -0700 X-CSE-ConnectionGUID: 7whBBn+PRIaUclIuuJsfYg== X-CSE-MsgGUID: q/nRp+ZyQ3mzDw+P0a3rOw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.23,172,1770624000"; d="scan'208";a="228155023" Received: from khuang2-desk.gar.corp.intel.com (HELO agluck-desk3.intel.com) ([10.124.221.106]) by orviesa006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Apr 2026 13:05:40 -0700 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Maciej Wieczor-Retman , Peter Newman , James Morse , Babu Moger , Drew Fustini , Dave Martin , Chen Yu , David E Box , x86@kernel.org Cc: Christoph Hellwig , linux-kernel@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [RFC PATCH v5 5/7] x86/resctrl: Resolve INTEL_PMT_TELEMETRY symbols at runtime Date: Fri, 10 Apr 2026 13:05:30 -0700 Message-ID: <20260410200532.58602-6-tony.luck@intel.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260410200532.58602-1-tony.luck@intel.com> References: <20260410200532.58602-1-tony.luck@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" resctrl is always built-in, but INTEL_PMT_TELEMETRY and INTEL_TPMI are logically independent and should be loadable modules. Switch AET to use the function-pointer registration API (introduced in the preceding patch) instead of direct link-time references to PMT symbols. Move AET enumeration into resctrl_arch_pre_mount() and cleanup into resctrl_arch_unmount() so the PMT module can be unloaded whenever the filesystem is not mounted. Because all cleanup now happens in the unmount path, intel_aet_exit() is no longer needed and is removed. Signed-off-by: Tony Luck --- include/linux/resctrl.h | 3 +++ arch/x86/kernel/cpu/resctrl/internal.h | 8 ++++---- arch/x86/kernel/cpu/resctrl/core.c | 23 +++++++++++++++++++--- arch/x86/kernel/cpu/resctrl/intel_aet.c | 26 +++++++++++++++++++------ 4 files changed, 47 insertions(+), 13 deletions(-) diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index a8338656f836..f3eb6dfa61d4 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -556,6 +556,9 @@ void resctrl_offline_cpu(unsigned int cpu); */ void resctrl_arch_pre_mount(void); =20 +/* Called to report unmount. */ +void resctrl_arch_unmount(void); + /** * resctrl_arch_rmid_read() - Read the eventid counter corresponding to rm= id * for this resource and domain. diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/r= esctrl/internal.h index e3cfa0c10e92..14b8e7fd66db 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -234,15 +234,15 @@ void rdt_domain_reconfigure_cdp(struct rdt_resource *= r); void resctrl_arch_mbm_cntr_assign_set_one(struct rdt_resource *r); =20 #ifdef CONFIG_X86_CPU_RESCTRL_INTEL_AET -bool intel_aet_get_events(void); -void __exit intel_aet_exit(void); +bool intel_aet_pre_mount(void); +void intel_aet_unmount(void); int intel_aet_read_event(int domid, u32 rmid, void *arch_priv, u64 *val); void intel_aet_mon_domain_setup(int cpu, int id, struct rdt_resource *r, struct list_head *add_pos); bool intel_handle_aet_option(bool force_off, char *tok); #else -static inline bool intel_aet_get_events(void) { return false; } -static inline void __exit intel_aet_exit(void) { } +static inline bool intel_aet_pre_mount(void) { return false; } +static inline void intel_aet_unmount(void) { } static inline int intel_aet_read_event(int domid, u32 rmid, void *arch_pri= v, u64 *val) { return -EINVAL; diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resct= rl/core.c index 7667cf7c4e94..94a055719ea2 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -769,7 +769,7 @@ void resctrl_arch_pre_mount(void) struct rdt_resource *r =3D &rdt_resources_all[RDT_RESOURCE_PERF_PKG].r_re= sctrl; int cpu; =20 - if (!intel_aet_get_events()) + if (!intel_aet_pre_mount()) return; =20 /* @@ -786,6 +786,25 @@ void resctrl_arch_pre_mount(void) cpus_read_unlock(); } =20 +void resctrl_arch_unmount(void) +{ + struct rdt_resource *r =3D &rdt_resources_all[RDT_RESOURCE_PERF_PKG].r_re= sctrl; + int cpu; + + intel_aet_unmount(); + + if (!r->mon_capable) + return; + + cpus_read_lock(); + mutex_lock(&domain_list_lock); + for_each_online_cpu(cpu) + domain_remove_cpu_mon(cpu, r); + r->mon_capable =3D false; + mutex_unlock(&domain_list_lock); + cpus_read_unlock(); +} + enum { RDT_FLAG_CMT, RDT_FLAG_MBM_TOTAL, @@ -1160,8 +1179,6 @@ late_initcall(resctrl_arch_late_init); =20 static void __exit resctrl_arch_exit(void) { - intel_aet_exit(); - cpuhp_remove_state(rdt_online); =20 resctrl_exit(); diff --git a/arch/x86/kernel/cpu/resctrl/intel_aet.c b/arch/x86/kernel/cpu/= resctrl/intel_aet.c index 2b3677783427..6e7458a722f9 100644 --- a/arch/x86/kernel/cpu/resctrl/intel_aet.c +++ b/arch/x86/kernel/cpu/resctrl/intel_aet.c @@ -25,8 +25,8 @@ #include #include #include -#include #include +#include #include #include #include @@ -307,7 +307,7 @@ static void (*put_feature)(struct pmt_feature_group *p); * struct pmt_feature_group to indicate that its events are successfully * enabled. */ -bool intel_aet_get_events(void) +static bool aet_get_events(void) { struct pmt_feature_group *p; enum pmt_feature_id pfid; @@ -316,14 +316,14 @@ bool intel_aet_get_events(void) =20 for_each_event_group(peg) { pfid =3D lookup_pfid((*peg)->pfname); - p =3D intel_pmt_get_regions_by_feature(pfid); + p =3D get_feature(pfid); if (IS_ERR_OR_NULL(p)) continue; if (enable_events(*peg, p)) { (*peg)->pfg =3D p; ret =3D true; } else { - intel_pmt_put_feature_group(p); + put_feature(p); } } =20 @@ -349,13 +349,27 @@ void intel_aet_unregister_enumeration(void) } EXPORT_SYMBOL_GPL(intel_aet_unregister_enumeration); =20 -void __exit intel_aet_exit(void) +bool intel_aet_pre_mount(void) +{ + guard(mutex)(&aet_register_lock); + if (!get_feature || !put_feature) + return false; + + return aet_get_events(); +} + +void intel_aet_unmount(void) { struct event_group **peg; =20 + guard(mutex)(&aet_register_lock); for_each_event_group(peg) { if ((*peg)->pfg) { - intel_pmt_put_feature_group((*peg)->pfg); + struct event_group *e =3D *peg; + + for (int j =3D 0; j < e->num_events; j++) + resctrl_disable_mon_event(e->evts[j].id); + put_feature((*peg)->pfg); (*peg)->pfg =3D NULL; } } --=20 2.53.0 From nobody Sat Jun 13 10:57:25 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.18]) (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 A085639524B for ; Fri, 10 Apr 2026 20:05:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775851547; cv=none; b=nYlLbYdnxBKOeKMZtarE+nwCp0mIHIpWxXe8FXOi7fh7r0tMxjad3b/rhyc6smrHaDFWxuE9DPwxleUYwYdz3e4bS7ZzwDnUpsoKvkAVYNFS0cHPogGdsRBhjjpQ3mYfLQQERi3KwQcFvZJCuI+6AxY24/kp/lu3Q0/LzppGhDw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775851547; c=relaxed/simple; bh=8+xCiqAx7z0gGvhV6GHtmnlfV71IyVd56yR7wAWwwTU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PTK9jWgJrAc7yEfGCjs3cDVEP8eMlI4bMvYwQH2vUiIp/imVq95BW/pifFdEMeUSw+YOO4TQx/7rGeXbSS5hM5L6lgGUNo8qvDXlowxznDzIb10Y61Uuf0/yXHgpYbN/ulyx+SturIJaoslsBI70ZXBaca8X7lnGSbeAjIzm/dk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=bRPlE7ae; arc=none smtp.client-ip=198.175.65.18 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="bRPlE7ae" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1775851544; x=1807387544; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=8+xCiqAx7z0gGvhV6GHtmnlfV71IyVd56yR7wAWwwTU=; b=bRPlE7aekIADI0pu6MGI0LiF/vVbZ2CDHHD/6CqgnK0qtQBt1HV5d8Nf qK22Jsmpi0xI/N9HX9DqRMbxfIw+a05Manl3KnG1Szoh0jgJ3aH4S2Rv0 jpMdQ0tsjIAV6CPryhXHXh+lOuiEfyHcsPWiF0H9QppQ0biHkJI7PAyOk PMi7FHtaE6K21/ogBpAWQ8bL7DkyJGopam6hRKuI1IIg50aGJbETCpYQU 0biX/5QKrumg5/0lOv5D1++Wb+VfHMlJ2PJxpKXU34GXNmzeYQ+FgHSQC yrzvjvWsO+MrICH0fuMuvJqAer4Ik8i0hIGCZs6lMc92nBDB0KjSxa+lX A==; X-CSE-ConnectionGUID: BjR6rffiQbmgvSEoFXH4JA== X-CSE-MsgGUID: Z1DemkoOSMi5aDSZsf/GvQ== X-IronPort-AV: E=McAfee;i="6800,10657,11755"; a="76898106" X-IronPort-AV: E=Sophos;i="6.23,172,1770624000"; d="scan'208";a="76898106" Received: from orviesa006.jf.intel.com ([10.64.159.146]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Apr 2026 13:05:42 -0700 X-CSE-ConnectionGUID: Qf75QDRhQHCJLvKXJkN5BA== X-CSE-MsgGUID: Yw7VLsxaTuiHmyMwK/u8Gw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.23,172,1770624000"; d="scan'208";a="228155028" Received: from khuang2-desk.gar.corp.intel.com (HELO agluck-desk3.intel.com) ([10.124.221.106]) by orviesa006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Apr 2026 13:05:41 -0700 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Maciej Wieczor-Retman , Peter Newman , James Morse , Babu Moger , Drew Fustini , Dave Martin , Chen Yu , David E Box , x86@kernel.org Cc: Christoph Hellwig , linux-kernel@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [RFC PATCH v5 6/7] fs/resctrl: Call architecture hooks for every mount/unmount Date: Fri, 10 Apr 2026 13:05:31 -0700 Message-ID: <20260410200532.58602-7-tony.luck@intel.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260410200532.58602-1-tony.luck@intel.com> References: <20260410200532.58602-1-tony.luck@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Architecture code for AET needs to acquire INTEL_PMT_TELEMETRY module references on mount and release them on unmount. Add hooks for every mount/unmount of the resctrl file system so that architecture code can allocate on mount and free on unmount. Add resctrl_mount_lock to protect mount/unmount operations and write access to "resctrl_mounted". This simplifies the code flow around the repeat mount with -EBUSY return to avoid calling resctrl_arch_pre_mount() when the file system is mounted. Signed-off-by: Tony Luck --- include/linux/resctrl.h | 9 ++++++--- fs/resctrl/rdtgroup.c | 35 ++++++++++++++++++++++++++++------- 2 files changed, 34 insertions(+), 10 deletions(-) diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index f3eb6dfa61d4..f3da533e182c 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -551,12 +551,15 @@ void resctrl_online_cpu(unsigned int cpu); void resctrl_offline_cpu(unsigned int cpu); =20 /* - * Architecture hook called at beginning of first file system mount attemp= t. - * No locks are held. + * Architecture hook called before attempting to mount the file system. + * Called with just resctrl_mount_lock held. */ void resctrl_arch_pre_mount(void); =20 -/* Called to report unmount. */ +/* + * Architecture hook called when mount fails, or on unmount. + * Called with just resctrl_mount_lock held. + */ void resctrl_arch_unmount(void); =20 /** diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c index 5da305bd36c9..444bc359e4a7 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -18,7 +18,6 @@ #include #include #include -#include #include #include #include @@ -48,7 +47,14 @@ LIST_HEAD(resctrl_schema_all); */ static LIST_HEAD(mon_data_kn_priv_list); =20 -/* The filesystem can only be mounted once. */ +/* Mutex protecting mount/unmount operations */ +static DEFINE_MUTEX(resctrl_mount_lock); + +/* + * The filesystem can only be mounted once. + * Updated with both rdtgroup_mutex and resctrl_mount_lock held. + * Safe to read while holding either rdtgroup_mutex or resctrl_mount_lock. + */ bool resctrl_mounted; =20 /* Kernel fs node for "info" directory under root */ @@ -2788,18 +2794,21 @@ static int rdt_get_tree(struct fs_context *fc) struct rdt_resource *r; int ret; =20 - DO_ONCE_SLEEPABLE(resctrl_arch_pre_mount); + mutex_lock(&resctrl_mount_lock); =20 - cpus_read_lock(); - mutex_lock(&rdtgroup_mutex); /* * resctrl file system can only be mounted once. */ if (resctrl_mounted) { - ret =3D -EBUSY; - goto out; + mutex_unlock(&resctrl_mount_lock); + return -EBUSY; } =20 + resctrl_arch_pre_mount(); + + cpus_read_lock(); + mutex_lock(&rdtgroup_mutex); + ret =3D setup_rmid_lru_list(); if (ret) goto out; @@ -2897,6 +2906,12 @@ static int rdt_get_tree(struct fs_context *fc) rdt_last_cmd_clear(); mutex_unlock(&rdtgroup_mutex); cpus_read_unlock(); + + if (ret) + resctrl_arch_unmount(); + + mutex_unlock(&resctrl_mount_lock); + return ret; } =20 @@ -3169,6 +3184,8 @@ static void rdt_kill_sb(struct super_block *sb) { struct rdt_resource *r; =20 + mutex_lock(&resctrl_mount_lock); + cpus_read_lock(); mutex_lock(&rdtgroup_mutex); =20 @@ -3187,6 +3204,10 @@ static void rdt_kill_sb(struct super_block *sb) kernfs_kill_sb(sb); mutex_unlock(&rdtgroup_mutex); cpus_read_unlock(); + + resctrl_arch_unmount(); + + mutex_unlock(&resctrl_mount_lock); } =20 static struct file_system_type rdt_fs_type =3D { --=20 2.53.0 From nobody Sat Jun 13 10:57:25 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.18]) (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 45844396562 for ; Fri, 10 Apr 2026 20:05:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775851550; cv=none; b=ZWi96ZLf3/TLJCDF6fjxFkgfCHQ84LwkydfJxIutE0CvfHw1vHg8w9+7ZdOJysLAycGjEHZ1HjlLS4neABV5WQdRHxPkrWEyviswbC/oNLW1V1GhlTYcKY7RGv2fbixPe5NibYBMmFFO0hK1eu+2rSFAvAIQqYxLHzzYF+BmCNw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775851550; c=relaxed/simple; bh=7BKmVp4Jak6CUpTsD40UwX1nrKrmQl1rsGLW3/TW0C0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=K4Eefbe63apSUr0HDQ2UuUGtTaBo/4DRQQPuw9FMlFN++LoxfCAnX/3xMqwijCoI/Wjc18SfG4HTb4DROFZr/udmoQ7sPZLjhSI76FVBWKlL0nlsaA/9zvj+Iakb0c66/kQc9gddDsF4JDAMFtvln/iAQ+E4q0ow8qwGC3bj9Dk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=bQkesZvY; arc=none smtp.client-ip=198.175.65.18 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="bQkesZvY" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1775851544; x=1807387544; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=7BKmVp4Jak6CUpTsD40UwX1nrKrmQl1rsGLW3/TW0C0=; b=bQkesZvYAi30+ZmNKX+PbPyG8Hma35VxLUZx+JimxaJ+jZK/YjmnG+/u csWgaAHwihzTc4790pqIZE5aAZby/7zlwIeJWMOrKpvDX30z7PeplAnCQ XT5eeB0TH4JLI8b6WAYcSKNvMjtZYEmiZ9JG1HDKCuQOMiG5fnL0L8Zw9 S1GcArjB2sNmXmmqd0dANn0Od+mpIrxzOBJhuH8V1P+JdsrL55gf+rojD e5vM5nhzjZaXPqBC4Z5gJePgzSS+xMsyKBsuqp6pluV7G71ywyHVtctoy IdLrtDmM1g7IDZM6XgQubLYG6B1VnJc4PLDun3GORXzl9mbwNRfK+74+6 w==; X-CSE-ConnectionGUID: QE6auRnhTWGyS1DsqZ93pw== X-CSE-MsgGUID: R1p8taqFQUyYPKCi5g25Lg== X-IronPort-AV: E=McAfee;i="6800,10657,11755"; a="76898117" X-IronPort-AV: E=Sophos;i="6.23,172,1770624000"; d="scan'208";a="76898117" Received: from orviesa006.jf.intel.com ([10.64.159.146]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Apr 2026 13:05:42 -0700 X-CSE-ConnectionGUID: 71undcw1QP2KzOdcCojFXw== X-CSE-MsgGUID: jEN7YwvcSd+y+I9aAejhDg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.23,172,1770624000"; d="scan'208";a="228155035" Received: from khuang2-desk.gar.corp.intel.com (HELO agluck-desk3.intel.com) ([10.124.221.106]) by orviesa006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Apr 2026 13:05:41 -0700 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Maciej Wieczor-Retman , Peter Newman , James Morse , Babu Moger , Drew Fustini , Dave Martin , Chen Yu , David E Box , x86@kernel.org Cc: Christoph Hellwig , linux-kernel@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [RFC PATCH v5 7/7] x86/resctrl: Relax Kconfig dependency on INTEL_PMT_TELEMETRY Date: Fri, 10 Apr 2026 13:05:32 -0700 Message-ID: <20260410200532.58602-8-tony.luck@intel.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260410200532.58602-1-tony.luck@intel.com> References: <20260410200532.58602-1-tony.luck@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Now that AET resolves PMT symbols at runtime via the registration API, INTEL_PMT_TELEMETRY no longer needs to be built-in. Relax the Kconfig dependency so that INTEL_PMT_TELEMETRY can be configured as a loadable modu= le. Signed-off-by: Tony Luck --- arch/x86/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index e2df1b147184..1a60da62da33 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -542,7 +542,7 @@ config X86_CPU_RESCTRL =20 config X86_CPU_RESCTRL_INTEL_AET bool "Intel Application Energy Telemetry" - depends on X86_64 && X86_CPU_RESCTRL && CPU_SUP_INTEL && INTEL_PMT_TELEME= TRY=3Dy && INTEL_TPMI=3Dy + depends on X86_64 && X86_CPU_RESCTRL && CPU_SUP_INTEL && INTEL_PMT_TELEME= TRY !=3D n && INTEL_TPMI !=3D n help Enable per-RMID telemetry events in resctrl. =20 --=20 2.53.0