From nobody Tue Jun 16 19:33:08 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.12]) (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 AC807313E31 for ; Mon, 15 Jun 2026 18:25:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781547910; cv=none; b=KCmJbFWdr750FXLtqbWry0cuNz3LfILIT5MFX79dlAehAKFoCA9qR4+JR8uQ9SUJDzi7/+c9QOTwGWvXAr2+gQ/SiDwd8zBv7mCmwPPGf+WXB93cDg3UdDjLUIhf2hKFRyoPaLaU574yc8GxSYeIe/ptUdNkW0udSh6CakdM+cs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781547910; c=relaxed/simple; bh=O5uisUIU0S7xYoADy958jPSZY+kSfiqxIs0NzJ2DqfM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NBaGtyScJT2bcPOXKU+ax7ErPkeb3bYm21LaX/hopUEiemI/ZrbyrEddmVs/6hneYrK0oQc2cyVFNEACGw7toSgBfjhro7I/b3gupzJxMndNHxsSzU9pI1ZYDrkckJnbTwW/HlA+PLEB+tuKd7rlCHLi8RZrlgn+mu1yej3Bh58= 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=SdcpAksX; arc=none smtp.client-ip=198.175.65.12 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="SdcpAksX" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1781547907; x=1813083907; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=O5uisUIU0S7xYoADy958jPSZY+kSfiqxIs0NzJ2DqfM=; b=SdcpAksXNsL+QXT2iMXh4oDQyw/yg6kY7D/XS56WVe0avdZKzAF8WRdO JyTw5D1X4l+sXgbQ9kaGc2bk7MwlPZ6Zhy/zvqjzZqvCMRO6Hot86xlAK qHjmzWzl6bJGN6ylSZq+ZUejICZOtrjPQu1Rby/qebYpVsNvgus5bxE5K 4blXPnLrKaVDO8ZoeN0AUG0hXLiI23L34poOjLWnDQmUceqTJ0g5uGS8h 10+djf87+5laD0GqgviY86BEToLKjbmoyu/iIEzoAa13fNIinOHaGBe5S yS8PNidNG4WP6jXN/OwYX51exlS8RNKJmZ1Tu9QG+2KejSEbkdHAdMUj2 g==; X-CSE-ConnectionGUID: KM6JUaonSCuELYHLXpd3gQ== X-CSE-MsgGUID: A5t6A+OiQjeSLZdCDk3iug== X-IronPort-AV: E=McAfee;i="6800,10657,11818"; a="93789918" X-IronPort-AV: E=Sophos;i="6.24,206,1774335600"; d="scan'208";a="93789918" Received: from orviesa007.jf.intel.com ([10.64.159.147]) by orvoesa104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jun 2026 11:25:06 -0700 X-CSE-ConnectionGUID: 9LIU0lkNRhGvg/3aKuAT6Q== X-CSE-MsgGUID: eBAGd1vORO2KX5rWjyEFww== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.24,206,1774335600"; d="scan'208";a="247620581" Received: from spandruv-desk1.amr.corp.intel.com (HELO agluck-desk3.intel.com) ([10.124.221.121]) by orviesa007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jun 2026 11:25:05 -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 , Ben Horgan Subject: [PATCH v8 01/16] fs/resctrl: Move functions to avoid forward references in subsequent fixes Date: Mon, 15 Jun 2026 11:24:42 -0700 Message-ID: <20260615182457.14725-2-tony.luck@intel.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260615182457.14725-1-tony.luck@intel.com> References: <20260615182457.14725-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" rdt_get_tree() manages resctrl fs mount and rdt_kill_sb() manages resctrl fs unmount. There is significant overlap between error cleanup during resctrl mount failure and cleanup on resctrl unmount yet the cleanup is not done consistently in these two flows. Pull some cleanup functions before rdt_get_tree() in preparation for a new helper that can be shared between mount and unmount. Signed-off-by: Tony Luck Signed-off-by: Reinette Chatre Reviewed-by: Ben Horgan --- fs/resctrl/rdtgroup.c | 376 +++++++++++++++++++++--------------------- 1 file changed, 188 insertions(+), 188 deletions(-) diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c index 5dfdaa6f9d8f..a6376a3fc4c3 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -2782,6 +2782,194 @@ static void schemata_list_destroy(void) } } =20 +/* + * Move tasks from one to the other group. If @from is NULL, then all tasks + * in the systems are moved unconditionally (used for teardown). + * + * If @mask is not NULL the cpus on which moved tasks are running are set + * in that mask so the update smp function call is restricted to affected + * cpus. + */ +static void rdt_move_group_tasks(struct rdtgroup *from, struct rdtgroup *t= o, + struct cpumask *mask) +{ + struct task_struct *p, *t; + + read_lock(&tasklist_lock); + for_each_process_thread(p, t) { + if (!from || is_closid_match(t, from) || + is_rmid_match(t, from)) { + resctrl_arch_set_closid_rmid(t, to->closid, + to->mon.rmid); + + /* + * Order the closid/rmid stores above before the loads + * in task_curr(). This pairs with the full barrier + * between the rq->curr update and + * resctrl_arch_sched_in() during context switch. + */ + smp_mb(); + + /* + * If the task is on a CPU, set the CPU in the mask. + * The detection is inaccurate as tasks might move or + * schedule before the smp function call takes place. + * In such a case the function call is pointless, but + * there is no other side effect. + */ + if (IS_ENABLED(CONFIG_SMP) && mask && task_curr(t)) + cpumask_set_cpu(task_cpu(t), mask); + } + } + read_unlock(&tasklist_lock); +} + +static void free_all_child_rdtgrp(struct rdtgroup *rdtgrp) +{ + struct rdtgroup *sentry, *stmp; + struct list_head *head; + + head =3D &rdtgrp->mon.crdtgrp_list; + list_for_each_entry_safe(sentry, stmp, head, mon.crdtgrp_list) { + rdtgroup_unassign_cntrs(sentry); + free_rmid(sentry->closid, sentry->mon.rmid); + list_del(&sentry->mon.crdtgrp_list); + + if (atomic_read(&sentry->waitcount) !=3D 0) + sentry->flags =3D RDT_DELETED; + else + rdtgroup_remove(sentry); + } +} + +/* + * Forcibly remove all of subdirectories under root. + */ +static void rmdir_all_sub(void) +{ + struct rdtgroup *rdtgrp, *tmp; + + /* Move all tasks to the default resource group */ + rdt_move_group_tasks(NULL, &rdtgroup_default, NULL); + + list_for_each_entry_safe(rdtgrp, tmp, &rdt_all_groups, rdtgroup_list) { + /* Free any child rmids */ + free_all_child_rdtgrp(rdtgrp); + + /* Remove each rdtgroup other than root */ + if (rdtgrp =3D=3D &rdtgroup_default) + continue; + + if (rdtgrp->mode =3D=3D RDT_MODE_PSEUDO_LOCKSETUP || + rdtgrp->mode =3D=3D RDT_MODE_PSEUDO_LOCKED) + rdtgroup_pseudo_lock_remove(rdtgrp); + + /* + * Give any CPUs back to the default group. We cannot copy + * cpu_online_mask because a CPU might have executed the + * offline callback already, but is still marked online. + */ + cpumask_or(&rdtgroup_default.cpu_mask, + &rdtgroup_default.cpu_mask, &rdtgrp->cpu_mask); + + rdtgroup_unassign_cntrs(rdtgrp); + + free_rmid(rdtgrp->closid, rdtgrp->mon.rmid); + + kernfs_remove(rdtgrp->kn); + list_del(&rdtgrp->rdtgroup_list); + + if (atomic_read(&rdtgrp->waitcount) !=3D 0) + rdtgrp->flags =3D RDT_DELETED; + else + rdtgroup_remove(rdtgrp); + } + /* Notify online CPUs to update per cpu storage and PQR_ASSOC MSR */ + update_closid_rmid(cpu_online_mask, &rdtgroup_default); + + kernfs_remove(kn_info); + kernfs_remove(kn_mongrp); + kernfs_remove(kn_mondata); +} + +/** + * mon_get_kn_priv() - Get the mon_data priv data for this event. + * + * The same values are used across the mon_data directories of all control= and + * monitor groups for the same event in the same domain. Keep a list of + * allocated structures and re-use an existing one with the same values for + * @rid, @domid, etc. + * + * @rid: The resource id for the event file being created. + * @domid: The domain id for the event file being created. + * @mevt: The type of event file being created. + * @do_sum: Whether SNC summing monitors are being created. Only set + * when @rid =3D=3D RDT_RESOURCE_L3. + * + * Return: Pointer to mon_data private data of the event, NULL on failure. + */ +static struct mon_data *mon_get_kn_priv(enum resctrl_res_level rid, int do= mid, + struct mon_evt *mevt, + bool do_sum) +{ + struct mon_data *priv; + + lockdep_assert_held(&rdtgroup_mutex); + + list_for_each_entry(priv, &mon_data_kn_priv_list, list) { + if (priv->rid =3D=3D rid && priv->domid =3D=3D domid && + priv->sum =3D=3D do_sum && priv->evt =3D=3D mevt) + return priv; + } + + priv =3D kzalloc_obj(*priv); + if (!priv) + return NULL; + + priv->rid =3D rid; + priv->domid =3D domid; + priv->sum =3D do_sum; + priv->evt =3D mevt; + list_add_tail(&priv->list, &mon_data_kn_priv_list); + + return priv; +} + +/** + * mon_put_kn_priv() - Free all allocated mon_data structures. + * + * Called when resctrl file system is unmounted. + */ +static void mon_put_kn_priv(void) +{ + struct mon_data *priv, *tmp; + + lockdep_assert_held(&rdtgroup_mutex); + + list_for_each_entry_safe(priv, tmp, &mon_data_kn_priv_list, list) { + list_del(&priv->list); + kfree(priv); + } +} + +static void resctrl_fs_teardown(void) +{ + lockdep_assert_held(&rdtgroup_mutex); + + /* Cleared by rdtgroup_destroy_root() */ + if (!rdtgroup_default.kn) + return; + + rmdir_all_sub(); + rdtgroup_unassign_cntrs(&rdtgroup_default); + mon_put_kn_priv(); + rdt_pseudo_lock_release(); + rdtgroup_default.mode =3D RDT_MODE_SHAREABLE; + closid_exit(); + schemata_list_destroy(); + rdtgroup_destroy_root(); +} + static int rdt_get_tree(struct fs_context *fc) { struct rdt_fs_context *ctx =3D rdt_fc2context(fc); @@ -2981,194 +3169,6 @@ static int rdt_init_fs_context(struct fs_context *f= c) return 0; } =20 -/* - * Move tasks from one to the other group. If @from is NULL, then all tasks - * in the systems are moved unconditionally (used for teardown). - * - * If @mask is not NULL the cpus on which moved tasks are running are set - * in that mask so the update smp function call is restricted to affected - * cpus. - */ -static void rdt_move_group_tasks(struct rdtgroup *from, struct rdtgroup *t= o, - struct cpumask *mask) -{ - struct task_struct *p, *t; - - read_lock(&tasklist_lock); - for_each_process_thread(p, t) { - if (!from || is_closid_match(t, from) || - is_rmid_match(t, from)) { - resctrl_arch_set_closid_rmid(t, to->closid, - to->mon.rmid); - - /* - * Order the closid/rmid stores above before the loads - * in task_curr(). This pairs with the full barrier - * between the rq->curr update and - * resctrl_arch_sched_in() during context switch. - */ - smp_mb(); - - /* - * If the task is on a CPU, set the CPU in the mask. - * The detection is inaccurate as tasks might move or - * schedule before the smp function call takes place. - * In such a case the function call is pointless, but - * there is no other side effect. - */ - if (IS_ENABLED(CONFIG_SMP) && mask && task_curr(t)) - cpumask_set_cpu(task_cpu(t), mask); - } - } - read_unlock(&tasklist_lock); -} - -static void free_all_child_rdtgrp(struct rdtgroup *rdtgrp) -{ - struct rdtgroup *sentry, *stmp; - struct list_head *head; - - head =3D &rdtgrp->mon.crdtgrp_list; - list_for_each_entry_safe(sentry, stmp, head, mon.crdtgrp_list) { - rdtgroup_unassign_cntrs(sentry); - free_rmid(sentry->closid, sentry->mon.rmid); - list_del(&sentry->mon.crdtgrp_list); - - if (atomic_read(&sentry->waitcount) !=3D 0) - sentry->flags =3D RDT_DELETED; - else - rdtgroup_remove(sentry); - } -} - -/* - * Forcibly remove all of subdirectories under root. - */ -static void rmdir_all_sub(void) -{ - struct rdtgroup *rdtgrp, *tmp; - - /* Move all tasks to the default resource group */ - rdt_move_group_tasks(NULL, &rdtgroup_default, NULL); - - list_for_each_entry_safe(rdtgrp, tmp, &rdt_all_groups, rdtgroup_list) { - /* Free any child rmids */ - free_all_child_rdtgrp(rdtgrp); - - /* Remove each rdtgroup other than root */ - if (rdtgrp =3D=3D &rdtgroup_default) - continue; - - if (rdtgrp->mode =3D=3D RDT_MODE_PSEUDO_LOCKSETUP || - rdtgrp->mode =3D=3D RDT_MODE_PSEUDO_LOCKED) - rdtgroup_pseudo_lock_remove(rdtgrp); - - /* - * Give any CPUs back to the default group. We cannot copy - * cpu_online_mask because a CPU might have executed the - * offline callback already, but is still marked online. - */ - cpumask_or(&rdtgroup_default.cpu_mask, - &rdtgroup_default.cpu_mask, &rdtgrp->cpu_mask); - - rdtgroup_unassign_cntrs(rdtgrp); - - free_rmid(rdtgrp->closid, rdtgrp->mon.rmid); - - kernfs_remove(rdtgrp->kn); - list_del(&rdtgrp->rdtgroup_list); - - if (atomic_read(&rdtgrp->waitcount) !=3D 0) - rdtgrp->flags =3D RDT_DELETED; - else - rdtgroup_remove(rdtgrp); - } - /* Notify online CPUs to update per cpu storage and PQR_ASSOC MSR */ - update_closid_rmid(cpu_online_mask, &rdtgroup_default); - - kernfs_remove(kn_info); - kernfs_remove(kn_mongrp); - kernfs_remove(kn_mondata); -} - -/** - * mon_get_kn_priv() - Get the mon_data priv data for this event. - * - * The same values are used across the mon_data directories of all control= and - * monitor groups for the same event in the same domain. Keep a list of - * allocated structures and re-use an existing one with the same values for - * @rid, @domid, etc. - * - * @rid: The resource id for the event file being created. - * @domid: The domain id for the event file being created. - * @mevt: The type of event file being created. - * @do_sum: Whether SNC summing monitors are being created. Only set - * when @rid =3D=3D RDT_RESOURCE_L3. - * - * Return: Pointer to mon_data private data of the event, NULL on failure. - */ -static struct mon_data *mon_get_kn_priv(enum resctrl_res_level rid, int do= mid, - struct mon_evt *mevt, - bool do_sum) -{ - struct mon_data *priv; - - lockdep_assert_held(&rdtgroup_mutex); - - list_for_each_entry(priv, &mon_data_kn_priv_list, list) { - if (priv->rid =3D=3D rid && priv->domid =3D=3D domid && - priv->sum =3D=3D do_sum && priv->evt =3D=3D mevt) - return priv; - } - - priv =3D kzalloc_obj(*priv); - if (!priv) - return NULL; - - priv->rid =3D rid; - priv->domid =3D domid; - priv->sum =3D do_sum; - priv->evt =3D mevt; - list_add_tail(&priv->list, &mon_data_kn_priv_list); - - return priv; -} - -/** - * mon_put_kn_priv() - Free all allocated mon_data structures. - * - * Called when resctrl file system is unmounted. - */ -static void mon_put_kn_priv(void) -{ - struct mon_data *priv, *tmp; - - lockdep_assert_held(&rdtgroup_mutex); - - list_for_each_entry_safe(priv, tmp, &mon_data_kn_priv_list, list) { - list_del(&priv->list); - kfree(priv); - } -} - -static void resctrl_fs_teardown(void) -{ - lockdep_assert_held(&rdtgroup_mutex); - - /* Cleared by rdtgroup_destroy_root() */ - if (!rdtgroup_default.kn) - return; - - rmdir_all_sub(); - rdtgroup_unassign_cntrs(&rdtgroup_default); - mon_put_kn_priv(); - rdt_pseudo_lock_release(); - rdtgroup_default.mode =3D RDT_MODE_SHAREABLE; - closid_exit(); - schemata_list_destroy(); - rdtgroup_destroy_root(); -} - static void rdt_kill_sb(struct super_block *sb) { struct rdt_resource *r; --=20 2.54.0 From nobody Tue Jun 16 19:33:08 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.12]) (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 883DE314D18 for ; Mon, 15 Jun 2026 18:25:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781547910; cv=none; b=crELcDj05KkEMmrgbti8YLUfFuTQ4jwoGyR0Z3lczbgPmlR7RwxLRTUVMUAjzNFD0YeQ/4+DAHnhKpFsab7V/U0qAnJ/Hcp53NqUxqkfEKiAznqSuVEfjE0gAxktUJ7jBK/H6Fm/SgAFN2oi/1CRBluVlyz1u4g9ltkeygYagPs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781547910; c=relaxed/simple; bh=rrS+ShOnTIe+Z2HmkEebbrrhPJuER4oUO425uK51bII=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DoCYbTKnBpV4YEZSsXS/eOriSfWbM+GubC4h1JxBjBaYBVbl0BdKr2T2lRBea8pc2VG8IuowOSxn7Xce8eaukGjNxgeytMpZ/97ruHofqwTpqearfro2AbSyb1vdu8NRI7txGhuKzWWTLp3kUSXluvIi8NeDeUz0ykC9YHnWkjk= 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=jdcucTE7; arc=none smtp.client-ip=198.175.65.12 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="jdcucTE7" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1781547908; x=1813083908; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=rrS+ShOnTIe+Z2HmkEebbrrhPJuER4oUO425uK51bII=; b=jdcucTE7l20Lgk1kzyCkOaZCdVaKB450cNq5jaHh8hUc70oDzVRwHy7i r7q+Nl91zZhVs9IEI7GoldIFhmDFuu9WO+igaAdUjyp99u1Dfb85/NiP0 QHbI04bkB8vEcLasniLY+GQn5me46W1e2Z9upEXbskxL03NAfjlXBouZ7 BXb+Aht2AXyBlM5wRQgJAIEcKZQFz1wjJrRzeaZnNA29nPNpqvs1KwP3T 64dHvKkRxBN+NBZcFE24M3upICpHJVm4P/9n/uobZaFigx+lfERBjZ0x5 Eil7zspKnKVAzKAZnbCiQgJRHeQHj2P/WLgP6kXU8ipWHtCQft65cM1Im w==; X-CSE-ConnectionGUID: dhtCoEmwS8+cuDxOt+ib0g== X-CSE-MsgGUID: MN5LJ00CRmSgw0FKIU1HNQ== X-IronPort-AV: E=McAfee;i="6800,10657,11818"; a="93789928" X-IronPort-AV: E=Sophos;i="6.24,206,1774335600"; d="scan'208";a="93789928" Received: from orviesa007.jf.intel.com ([10.64.159.147]) by orvoesa104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jun 2026 11:25:06 -0700 X-CSE-ConnectionGUID: Hiw8gGhmTdSRUJDF0M5Pjw== X-CSE-MsgGUID: YWU09aL2SBSc7ZRCMbp/dQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.24,206,1774335600"; d="scan'208";a="247620593" Received: from spandruv-desk1.amr.corp.intel.com (HELO agluck-desk3.intel.com) ([10.124.221.121]) by orviesa007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jun 2026 11:25:06 -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 , Ben Horgan Subject: [PATCH v8 02/16] fs/resctrl: Free mon_data structures on rdt_get_tree() failure Date: Mon, 15 Jun 2026 11:24:43 -0700 Message-ID: <20260615182457.14725-3-tony.luck@intel.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260615182457.14725-1-tony.luck@intel.com> References: <20260615182457.14725-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" If mkdir_mondata_all() or a subsequent call in rdt_get_tree() fails, the mon_data structures allocated by mon_get_kn_priv() are leaked. Add mon_put_kn_priv() to the out_mongrp error path to free the mon_data structures. Fixes: 2a6566038544 ("x86/resctrl: Expand the width of domid by replacing m= on_data_bits") Reported-by: Reinette Chatre Closes: https://lore.kernel.org/lkml/5d38c1fb-8f91-472b-8897-24b2f50c772b@i= ntel.com/ Signed-off-by: Tony Luck Signed-off-by: Reinette Chatre Reviewed-by: Chen Yu Reviewed-by: Ben Horgan --- fs/resctrl/rdtgroup.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c index a6376a3fc4c3..506b40dc9430 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -3071,6 +3071,7 @@ static int rdt_get_tree(struct fs_context *fc) kernfs_remove(kn_mondata); out_mongrp: if (resctrl_arch_mon_capable()) { + mon_put_kn_priv(); rdtgroup_unassign_cntrs(&rdtgroup_default); kernfs_remove(kn_mongrp); } --=20 2.54.0 From nobody Tue Jun 16 19:33:08 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.12]) (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 9540B315793 for ; Mon, 15 Jun 2026 18:25:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781547910; cv=none; b=lDwVEAz+GV8wNl4e+G9wOQAl17v4h1X40OGTnlMfjHDaovg2N/fPZUOJUapziMpPdtA0j+jNufeQIUuZ3NCp5jw6oI2Dd18nz3MAo23jVLblwQbmXNUDB3Mdqk4oGWldXHlNt64qgm1VDUtm2/1Yfomfgkh2Hmmh8m/nsuK2CjA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781547910; c=relaxed/simple; bh=khZC/cb/YriYJ5rCY3qYgNgFYHgvXsuwbdEZkvXw7UU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=defLtGTPxD6BnMVElcqIHBjiGRP/mvXGr3Z6oaYXvE82KRBdoVkvMIihZY2D+B+32Nk32ILWhBIJ7wMblJEALoB6ueZuF88jY4cNzEucqDFqfmF+AU/ZEj/ChsgVd8PNsXeDVKsl66UWW+EGqentz61lasDQO2cE4T1pT3auPgM= 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=YgJ8Hd2J; arc=none smtp.client-ip=198.175.65.12 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="YgJ8Hd2J" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1781547908; x=1813083908; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=khZC/cb/YriYJ5rCY3qYgNgFYHgvXsuwbdEZkvXw7UU=; b=YgJ8Hd2J9hBU1RMWCSjPbJf7gzRzVeCp4P/o/ZVFbmJetBMQ+3QE82it xUVWbCQNxCIPUgCoUpc9JAaxw7H0BKtYUiyek5PLS4qugDmgDxnVnI/uI s9U89FCDZN26UpcOul1gcizQVVIBEsu0dvdO83cot+x3mw1Uw7GDg1hth 6QMWZ4UotxdV3uvnoWi5C2uvawHgj2u+h4OSJtNYhiPedLW4qhlo4Ej4E 7E90UiKDjXw/QW8rzupHSh1zevD12vqTPuanjGCyOyyRvbiDKu+iQ2LHR 5OAnA6Lw9Tlv9SDSOBI2E0vJaTpavrqkxoxWWeQoy7w05f8sqBpiV7eDl A==; X-CSE-ConnectionGUID: LhvGGHhqTk2bn5Uqd/+aBA== X-CSE-MsgGUID: 4h0kyCtMT/+BmnVy7VKwgg== X-IronPort-AV: E=McAfee;i="6800,10657,11818"; a="93789938" X-IronPort-AV: E=Sophos;i="6.24,206,1774335600"; d="scan'208";a="93789938" Received: from orviesa007.jf.intel.com ([10.64.159.147]) by orvoesa104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jun 2026 11:25:07 -0700 X-CSE-ConnectionGUID: IJryhtrTTxakmndUQUWxkw== X-CSE-MsgGUID: 4zwEXoQoSQ6pYeBDz08UDw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.24,206,1774335600"; d="scan'208";a="247620604" Received: from spandruv-desk1.amr.corp.intel.com (HELO agluck-desk3.intel.com) ([10.124.221.121]) by orviesa007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jun 2026 11:25:06 -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 , Sashiko Subject: [PATCH v8 03/16] fs/resctrl: Fix use-after-free during unmount Date: Mon, 15 Jun 2026 11:24:44 -0700 Message-ID: <20260615182457.14725-4-tony.luck@intel.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260615182457.14725-1-tony.luck@intel.com> References: <20260615182457.14725-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" During unmount or failure teardown all mon_data structures that contain monitoring event file private data are freed after which kernfs nodes are removed. However, the RDT_DELETED flag is never set for the statically allocated default resource group. A concurrent reader of an event file associated with the default resource group may, after dropping kernfs active protection, block on rdtgroup_mutex while unmount proceeds to free the file private data and destroy the kernfs node without waiting for the reader. When the mutex is released, the reader wakes up, observes that RDT_DELETED is not set for the default group, and dereferences the already-freed file private data. The scenario can be depicted as follows: CPU0 CPU1 /* * Default resource group's * monitoring data accessible via * kernfs file with kernfs_node::priv * pointing to a struct mon_data. * User opens the file for reading. */ rdtgroup_mondata_show() /* arch encounters fatal error */ rdtgroup_kn_lock_live() resctrl_exit() atomic_inc(&rdtgroup_default.waitcount) cpus_read_lock() kernfs_break_active_protection(kn) mutex_lock(&rdtgroup_mutex) cpus_read_lock() resctrl_fs_teardown() mutex_lock(&rdtgroup_mutex) rmdir_all_sub() mon_put_kn_priv() /* Delete all mon_data struc= tures */ rdtgroup_destroy_root() kernfs_destroy_root() rdtgroup_default.kn =3D NULL mutex_unlock(&rdtgroup_mutex) /* * rdtgroup_default.flags is empty so * rdtgroup_kn_lock_live() returns * &rdtgroup_default */ md =3D of->kn->priv; /* md points to freed mon_data */ Set RDT_DELETED for the default group unconditionally since the flag does not lead to the freeing of this statically allocated group. Do not allow a new resctrl mount if there are any waiters on default group of previous mount. A new mount will re-initialize the default group that would appear to waiters from previous mount as though the default group is accessible causing them to access the mon_data structures from the previous mount that have been removed. Fixes: 2a6566038544 ("x86/resctrl: Expand the width of domid by replacing m= on_data_bits") Reported-by: Sashiko Closes: https://sashiko.dev/#/patchset/20260508182143.14592-1-tony.luck%40i= ntel.com?part=3D2 [1] Signed-off-by: Tony Luck Signed-off-by: Reinette Chatre Reviewed-by: Chen Yu --- fs/resctrl/rdtgroup.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c index 506b40dc9430..ac3285ba8775 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -585,14 +585,20 @@ static ssize_t rdtgroup_cpus_write(struct kernfs_open= _file *of, * * On resource group creation via a mkdir, an extra kernfs_node reference = is * taken to ensure that the rdtgroup structure remains accessible for the - * rdtgroup_kn_unlock() calls where it is removed. + * rdtgroup_kn_unlock() calls where it is removed. The default group is + * statically allocated: it does not have an extra reference but will have + * RDT_DELETED set on unmount to support safe access to its associated fil= es + * via rdtgroup_kn_lock_live/rdtgroup_kn_unlock(). * - * Drop the extra reference here, then free the rdtgroup structure. + * For all but the default group: drop the extra reference, then free the + * rdtgroup structure. * * Return: void */ static void rdtgroup_remove(struct rdtgroup *rdtgrp) { + if (rdtgrp =3D=3D &rdtgroup_default) + return; kernfs_put(rdtgrp->kn); kfree(rdtgrp); } @@ -2965,6 +2971,7 @@ static void resctrl_fs_teardown(void) mon_put_kn_priv(); rdt_pseudo_lock_release(); rdtgroup_default.mode =3D RDT_MODE_SHAREABLE; + rdtgroup_default.flags =3D RDT_DELETED; closid_exit(); schemata_list_destroy(); rdtgroup_destroy_root(); @@ -2990,6 +2997,12 @@ static int rdt_get_tree(struct fs_context *fc) goto out; } =20 + /* Avoid races from pending operations from a previous mount */ + if (atomic_read(&rdtgroup_default.waitcount) !=3D 0) { + ret =3D -EBUSY; + goto out; + } + ret =3D setup_rmid_lru_list(); if (ret) goto out; @@ -4265,6 +4278,7 @@ static int rdtgroup_setup_root(struct rdt_fs_context = *ctx) =20 ctx->kfc.root =3D rdt_root; rdtgroup_default.kn =3D kernfs_root_to_node(rdt_root); + rdtgroup_default.flags =3D 0; =20 return 0; } --=20 2.54.0 From nobody Tue Jun 16 19:33:08 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.12]) (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 307B2313E2C for ; Mon, 15 Jun 2026 18:25:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781547912; cv=none; b=BOvMI61gBuwCIiqc+hLNbbZJDff1V9MC3Lbl3JWIyOD/luxP57QCsaZ8BglbuJEKoD0iCqpKUvGjkG7D3yz8eSPFu/RAjPZbsReFrDAubsTTGfmzcIEQ8UN3a8w80yNLU1hmDAKl/xBATRkwW09/lgoWcdvmUZP9PCyXGkiS4U8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781547912; c=relaxed/simple; bh=KxLowYXEe81y+BszRgYh51N7JWArxU6FgCVNOrdu17w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=W8pWW8EyB51DKSYShfdEfTIeoWNuM0cYEbULujkezlpduXpQxZWJoIaOt9gJLljHLgrgX6x0jSL90uPy88MFuI0sepRk/F+4R5abVhKBEP4rxxiclDP2dbkBU9qtngXgekIG9LTWpbTSiNpW6GZ8Cl4b//Rv52iQxigL3waMuTY= 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=Pah+t+ty; arc=none smtp.client-ip=198.175.65.12 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="Pah+t+ty" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1781547910; x=1813083910; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=KxLowYXEe81y+BszRgYh51N7JWArxU6FgCVNOrdu17w=; b=Pah+t+tyYdiZ4sBRSZpjw6DVmbpiuaArF9myCL303p+vwaGU9LMULv60 +oD2LKsLc5q4IyUwvY0vGNFW6N0v4sDzES2LSBoLl/Ow9l6R2+9J3Tcmu y8aP9HojWLfWAcC7gr8HV29n1Cmg8e5KZmTR/F6xVBytCOclVBmfFpVnq 1SaKHN5KVRtV8L6h0p98860tr1AuVA0eGgKBQzw5193g9+B8r1WbIE9Wk 5caznoJFO5FvLjRHZQVI4zzm+1S7ZaqZwBMIGCNerVgLcLQdIkzHJqZt7 YGzEPSCE2s9g+8BUzr8VPvK75wlpHkAvoE451OdCrAjePyfWZ/LaHKs3W A==; X-CSE-ConnectionGUID: ucBlBPuKQn6jxWC/kLvgxA== X-CSE-MsgGUID: vDEO4lqLR0WAYpB5OU7x4Q== X-IronPort-AV: E=McAfee;i="6800,10657,11818"; a="93789947" X-IronPort-AV: E=Sophos;i="6.24,206,1774335600"; d="scan'208";a="93789947" Received: from orviesa007.jf.intel.com ([10.64.159.147]) by orvoesa104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jun 2026 11:25:08 -0700 X-CSE-ConnectionGUID: 5NdOs2nxQ62DH8dFdu7H+w== X-CSE-MsgGUID: G3zOsiMeR06CY0ZflQnqOw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.24,206,1774335600"; d="scan'208";a="247620613" Received: from spandruv-desk1.amr.corp.intel.com (HELO agluck-desk3.intel.com) ([10.124.221.121]) by orviesa007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jun 2026 11:25:07 -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, Sashiko , Tony Luck , Ben Horgan Subject: [PATCH v8 04/16] fs/resctrl: Fix deadlock on errors during mount Date: Mon, 15 Jun 2026 11:24:45 -0700 Message-ID: <20260615182457.14725-5-tony.luck@intel.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260615182457.14725-1-tony.luck@intel.com> References: <20260615182457.14725-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" From: Reinette Chatre rdt_get_tree() acquires rdtgroup_mutex before calling kernfs_get_tree(). If superblock setup fails inside kernfs_get_tree(), the VFS calls .kill_sb() (rdt_kill_sb()) on the same thread before kernfs_get_tree() returns. rdt_kill_sb() unconditionally attempts to acquire rdtgroup_mutex and deadlock occurs. Since mount failure resulting from kernfs_get_tree() already calls the resctrl fs unmount handler (rdt_kill_sb()) let both call the same helper to make it clear both paths perform the same cleanup. Call kernfs_get_tree() outside of locks. If kernfs_get_tree() fails and ctx->kfc.new_sb_created is set, then rdt_kill_sb() has already been called and no further cleanup is needed. kernfs_get_tree() may set ctx->kfc.new_sb_created and then fail to obtain an inode for the new kn, causing the rdt_kill_sb() path to run with one few= er reference than required for the root to remain accessible in kernfs_kill_sb= (). Add an extra hold on rdtgroup_default.kn to defend against this scenario and ensure the root can be dereferenced safely from kernfs_kill_sb(). Dropping locks before kernfs_get_tree() creates a window where CPU hotplug callbacks can race with the mount operation. Specifically, an online event observing resctrl_mounted =3D=3D true could concurrently append directories= to the unactivated kernfs tree, allocate mon_data structures, and arm backgrou= nd workers. This concurrency is safe because the mount has not yet returned to the VFS, meaning userspace cannot interact with these transient files. If kernfs_get_tree() subsequently fails, the standard resctrl_unmount() teardo= wn safely manages the concurrent modifications: any dynamically generated kern= fs nodes are removed, and the associated memory is freed. Any background workers spawned by the hotplug event will naturally exit without re-arming when they acquire rdtgroup_mutex and observe resctrl_mounted =3D=3D false. Fixes: 5ff193fbde20 ("x86/intel_rdt: Add basic resctrl filesystem support") Reported-by: Sashiko Closes: https://sashiko.dev/#/patchset/20260429184858.36423-1-tony.luck%40i= ntel.com [1] Co-developed-by: Tony Luck Signed-off-by: Tony Luck Signed-off-by: Reinette Chatre Reviewed-by: Ben Horgan Reviewed-by: Chen Yu --- fs/resctrl/rdtgroup.c | 83 +++++++++++++++++++++++++++++-------------- 1 file changed, 56 insertions(+), 27 deletions(-) diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c index ac3285ba8775..a8f84b653607 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -2977,10 +2977,34 @@ static void resctrl_fs_teardown(void) rdtgroup_destroy_root(); } =20 +static void resctrl_unmount(void) +{ + struct rdt_resource *r; + + cpus_read_lock(); + mutex_lock(&rdtgroup_mutex); + + rdt_disable_ctx(); + + /* Put everything back to default values. */ + for_each_alloc_capable_rdt_resource(r) + resctrl_arch_reset_all_ctrls(r); + + resctrl_fs_teardown(); + if (resctrl_arch_alloc_capable()) + resctrl_arch_disable_alloc(); + if (resctrl_arch_mon_capable()) + resctrl_arch_disable_mon(); + resctrl_mounted =3D false; + mutex_unlock(&rdtgroup_mutex); + cpus_read_unlock(); +} + static int rdt_get_tree(struct fs_context *fc) { struct rdt_fs_context *ctx =3D rdt_fc2context(fc); unsigned long flags =3D RFTYPE_CTRL_BASE; + struct kernfs_node *rdt_root_kn; struct rdt_l3_mon_domain *dom; struct rdt_resource *r; int ret; @@ -3056,10 +3080,6 @@ static int rdt_get_tree(struct fs_context *fc) if (ret) goto out_mondata; =20 - ret =3D kernfs_get_tree(fc); - if (ret < 0) - goto out_psl; - if (resctrl_arch_alloc_capable()) resctrl_arch_enable_alloc(); if (resctrl_arch_mon_capable()) @@ -3075,10 +3095,38 @@ static int rdt_get_tree(struct fs_context *fc) RESCTRL_PICK_ANY_CPU); } =20 - goto out; + /* + * Ensure root remains accessible after mutex is unlocked so that + * kernfs_kill_sb() can run safely if called by kernfs_get_tree()'s + * failure path after creating a superblock but before taking reference + * on root kn (for example, if unable to get inode for root kn). + */ + kernfs_get(rdtgroup_default.kn); + + /* + * Make backup of the current root kn being created to be used in + * kernfs_put(). The additional reference taken above will prevent the + * kn from being freed before kernfs_kill_sb() can run but + * rdtgroup_default.kn may be set to NULL via rdtgroup_destroy_root() + * and its backing root (rdt_root) could be overwritten before + * kernfs_put() can run. + */ + rdt_root_kn =3D rdtgroup_default.kn; + + rdt_last_cmd_clear(); + mutex_unlock(&rdtgroup_mutex); + cpus_read_unlock(); + + ret =3D kernfs_get_tree(fc); + /* + * resctrl can only be mounted once, new superblock only expected + * to be created once. + */ + if (!ctx->kfc.new_sb_created) + resctrl_unmount(); + kernfs_put(rdt_root_kn); + return ret; =20 -out_psl: - rdt_pseudo_lock_release(); out_mondata: if (resctrl_arch_mon_capable()) kernfs_remove(kn_mondata); @@ -3098,7 +3146,6 @@ static int rdt_get_tree(struct fs_context *fc) out_root: rdtgroup_destroy_root(); out: - rdt_last_cmd_clear(); mutex_unlock(&rdtgroup_mutex); cpus_read_unlock(); return ret; @@ -3185,26 +3232,8 @@ static int rdt_init_fs_context(struct fs_context *fc) =20 static void rdt_kill_sb(struct super_block *sb) { - struct rdt_resource *r; - - cpus_read_lock(); - mutex_lock(&rdtgroup_mutex); - - rdt_disable_ctx(); - - /* Put everything back to default values. */ - for_each_alloc_capable_rdt_resource(r) - resctrl_arch_reset_all_ctrls(r); - - resctrl_fs_teardown(); - if (resctrl_arch_alloc_capable()) - resctrl_arch_disable_alloc(); - if (resctrl_arch_mon_capable()) - resctrl_arch_disable_mon(); - resctrl_mounted =3D false; + resctrl_unmount(); kernfs_kill_sb(sb); - mutex_unlock(&rdtgroup_mutex); - cpus_read_unlock(); } =20 static struct file_system_type rdt_fs_type =3D { --=20 2.54.0 From nobody Tue Jun 16 19:33:08 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.12]) (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 CDFF431619D for ; Mon, 15 Jun 2026 18:25:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781547912; cv=none; b=Nh1d4BCiTgYQ/TGpHZw3ohRqpQdFe4m3SwxGlYA4Hm+3aV3TL4yKVRADUvCvNJ8X82zmdCuIMUbxfocz8/gvvdNfvonM6Yn9Qg4QUyNsPhLMhDFr9/JL4uIBZ5oDVvcCsBs24QHGXYfom9KqxFypLRKQTz+yygcwi56ZXGkjSOY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781547912; c=relaxed/simple; bh=0iKcIZsqX45bD5N+at4BI0K+0YFsdRGRBhddBITR9bM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VkadkQgzhve1TfsiSaLa7kNHYA/njAGbptcLJ62YmfH0eNpqAiejMAeOoC/bXzDbXM4YQCHdA0WqiSwXGNV3nqA2Noho2SQNbq+Zr2fLmbttCuHl+RJxScSizh6ceCCnY8D9JI0G3HZCAhfEtjreyP4Jg6hRL+hzIJaeZqDLssE= 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=YZ/KOCnw; arc=none smtp.client-ip=198.175.65.12 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="YZ/KOCnw" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1781547911; x=1813083911; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=0iKcIZsqX45bD5N+at4BI0K+0YFsdRGRBhddBITR9bM=; b=YZ/KOCnwgWM13ave5+fB/IXo1ODUZVZ9UwpPtg/z4l7vWzss1yICg8TG f0QgTHiJVwf/Qfb33IJoMnS3/z8LM1skuu00DeEvJ/GRD1JyEn8x1wITB S5Hai/pisv5irctHl5XDbRkvPe79bARWg/VIyYkHc8KhmK+CLibEXqyEK 6LolzCeBQsydgrrRCpA+UFZi5L+u6vHagLyMZ84WAPXRciFzMbqrskpVZ lIoMkUzBByRAK2/uZhA+4ybUs0bHXflyllEnkpau0pY9FHfwrAP8Zg4Uc s8ypEXLA5BcPQz8v2iShN+0B0PGhwPeUWwoho74zNWE+lmSCVvJ7tyvch g==; X-CSE-ConnectionGUID: FcRa6wm4SBSTCl+nyelsjQ== X-CSE-MsgGUID: HxvQrEHDTZumWH188pny0g== X-IronPort-AV: E=McAfee;i="6800,10657,11818"; a="93789957" X-IronPort-AV: E=Sophos;i="6.24,206,1774335600"; d="scan'208";a="93789957" Received: from orviesa007.jf.intel.com ([10.64.159.147]) by orvoesa104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jun 2026 11:25:08 -0700 X-CSE-ConnectionGUID: PJAP5uxIRBCBVnijK3BMRw== X-CSE-MsgGUID: ehw1ztdFRZeM5dMTtITsiQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.24,206,1774335600"; d="scan'208";a="247620619" Received: from spandruv-desk1.amr.corp.intel.com (HELO agluck-desk3.intel.com) ([10.124.221.121]) by orviesa007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jun 2026 11:25:07 -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: [PATCH v8 05/16] platform/x86/intel/pmt: Prevent unbind of PMT telemetry driver Date: Mon, 15 Jun 2026 11:24:46 -0700 Message-ID: <20260615182457.14725-6-tony.luck@intel.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260615182457.14725-1-tony.luck@intel.com> References: <20260615182457.14725-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" The resctrl AET code uses intel_pmt_get_regions_by_feature() (exported by the pmt_telemetry module) to obtain pmt_feature_group instances that are populated using data from the pmt_discovery module. The returned telemetry_region::addr values are MMIO mappings created in the telemetry driver's probe path, and resctrl reads from them while a mount is active. However, a user can unbind the auxiliary driver from its device via the sysfs "unbind" attribute. Unbinding the telemetry driver would tear down the MMIO mappings, leaving resctrl with stale pointers and causing a fault on the next access. It is safe for the discovery driver to be unbound. It does all its work at initial probe time and saves a copy of the features and RMID count. Set device_driver::suppress_bind_attrs in the telemetry driver so that the "bind" and "unbind" sysfs attributes are not exposed and the user cannot detach the driver from its devices while resctrl (or any other in-kernel consumer) may be using the resources. Fixes: 1fb2daa60de6 ("x86/resctrl: Discover hardware telemetry events") Assisted-by: Claude:Opus-4.7 Signed-off-by: Tony Luck -- v8: New patch --- drivers/platform/x86/intel/pmt/telemetry.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/platform/x86/intel/pmt/telemetry.c b/drivers/platform/= x86/intel/pmt/telemetry.c index bdc7c24a3678..daa6da9bad2a 100644 --- a/drivers/platform/x86/intel/pmt/telemetry.c +++ b/drivers/platform/x86/intel/pmt/telemetry.c @@ -421,6 +421,9 @@ static struct auxiliary_driver pmt_telem_aux_driver =3D= { .id_table =3D pmt_telem_id_table, .remove =3D pmt_telem_remove, .probe =3D pmt_telem_probe, + .driver =3D { + .suppress_bind_attrs =3D true, + }, }; =20 static int __init pmt_telem_init(void) --=20 2.54.0 From nobody Tue Jun 16 19:33:08 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.12]) (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 1CBA6313E07 for ; Mon, 15 Jun 2026 18:25:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781547912; cv=none; b=CYXi/Jw5OlA9zwBg9tfcCk/+sazfcE5/iDOgQ1Ox2zJQQIeqwsGd/rE1PMCm7apEEZpOkiO2hGmVjV5g36RpAFPYyMxav7uNeRqu8Oo04/mApYTttg/Jr1btrpxSwZgiSW/fS1CSBLd/YDkElamTRTIbq6r0TDBjjaLxdaVgvIk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781547912; c=relaxed/simple; bh=lLBCWvlZ8cRVEaDn3jj+Op8c5L4RsOuuqU3grwlC7Es=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cW2ECG4zlmiWXdsirjzIRyPrGjPKXYJGVwt7cPHic/I6xTTmuE8XGzOZ1fsJZb9DNbzUb37j/AIuMqWjmsej4o2fiiwpsqt4m2/4JPrjA9+OC9nVDBN600Kx0dyxeosHFyP7Dy609H3b8LKYd3Eagva042rzCXTIyGetqLcFI0g= 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=ecSbW2Cm; arc=none smtp.client-ip=198.175.65.12 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="ecSbW2Cm" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1781547911; x=1813083911; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=lLBCWvlZ8cRVEaDn3jj+Op8c5L4RsOuuqU3grwlC7Es=; b=ecSbW2Cm/8NEegwBb4XPKyClWZWOTvOZmq653Vi3Tq/jYSVdurwe5lIB zoF7fCR9GWCaGGv5E8ozKvoC2ceU2cxI+scsHE8v+8F7NHqeumu1ffNTw rwvFDKkzF0mNzUzxOlz9jVTAzSCJtQq/g77maB9GFzF1sQ67vWbVGohlo nkPQaY4a9XBj1dYcueu0cbne4Wttv9JvfzD0wUBz1vLGd2oNtjwtix1fd jljel3XGQxos+CYmtn7P/2HJCZmxVUmtCofbEO5OB5ZhlY9M/ddpmzPMW MCTNybE8DbDoe0Sg+npWSJPCHumrDhEjv/EMY01wsvHopRqnv1yQF9Vgt w==; X-CSE-ConnectionGUID: hFzjQr31QPikezZ3TWCO7w== X-CSE-MsgGUID: EZxMEbbZSouNWFdko+3kdQ== X-IronPort-AV: E=McAfee;i="6800,10657,11818"; a="93789967" X-IronPort-AV: E=Sophos;i="6.24,206,1774335600"; d="scan'208";a="93789967" Received: from orviesa007.jf.intel.com ([10.64.159.147]) by orvoesa104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jun 2026 11:25:08 -0700 X-CSE-ConnectionGUID: zdkDylV3REKoxsGAobN91g== X-CSE-MsgGUID: YZCwwsLGTQSiqHyWQesV1w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.24,206,1774335600"; d="scan'208";a="247620623" Received: from spandruv-desk1.amr.corp.intel.com (HELO agluck-desk3.intel.com) ([10.124.221.121]) by orviesa007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jun 2026 11:25:08 -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: [PATCH v8 06/16] fs/resctrl: Remove redundant calls to resctrl_arch_mon_capable() Date: Mon, 15 Jun 2026 11:24:47 -0700 Message-ID: <20260615182457.14725-7-tony.luck@intel.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260615182457.14725-1-tony.luck@intel.com> References: <20260615182457.14725-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 provides resctrl_arch_mon_capable() so that file system code knows whether any monitor features are supported. This is used to decide whether to create "mon_data" directories etc. Initially resctrl_arch_mon_capable() was an inline function providing the value of the x86 architecture variable "rdt_mon_capable". I.e. extremely low overhead and so it was used liberally as a sanity check. The ARM implementation of resctrl_arch_mon_capable() is not inline and chases a couple of pointers. Future changes to x86 implementation will also make resctrl_arch_mon_capable() more expensive. Redundant calls to resctrl_arch_mon_capable() in hot code paths should be eliminated. 1) mbm_handle_overflow() This function is called once per second from worker threads running on each L3 domain. The call is clearly redundant because worker threads are only created if the MBM monitoring feature is enabled. 2) is_rmid_match() This function is called when a user reads a "tasks" file of a MON_GROUP. The call is redundant because the function also checks "r->type =3D=3D RDTMON_GROUP" and this type of group can only be created on systems that support monitoring. Remove the call to resctrl_arch_mon_capable() from both of these functions. Signed-off-by: Tony Luck --- v8: New patch fs/resctrl/monitor.c | 2 +- fs/resctrl/rdtgroup.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c index 9fd901c78dc6..3df188bee433 100644 --- a/fs/resctrl/monitor.c +++ b/fs/resctrl/monitor.c @@ -848,7 +848,7 @@ void mbm_handle_overflow(struct work_struct *work) * If the filesystem has been unmounted this work no longer needs to * run. */ - if (!resctrl_mounted || !resctrl_arch_mon_capable()) + if (!resctrl_mounted) goto out_unlock; =20 r =3D resctrl_arch_get_resource(RDT_RESOURCE_L3); diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c index a8f84b653607..c671644f1e12 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -691,7 +691,7 @@ static bool is_closid_match(struct task_struct *t, stru= ct rdtgroup *r) =20 static bool is_rmid_match(struct task_struct *t, struct rdtgroup *r) { - return (resctrl_arch_mon_capable() && (r->type =3D=3D RDTMON_GROUP) && + return ((r->type =3D=3D RDTMON_GROUP) && resctrl_arch_match_rmid(t, r->mon.parent->closid, r->mon.rmid)); } --=20 2.54.0 From nobody Tue Jun 16 19:33:08 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.12]) (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 76915319860 for ; Mon, 15 Jun 2026 18:25:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781547914; cv=none; b=BYAreqLpdeAWbkZcFXHstq+aCeQmH6gKkc0Tgx6W5rPAdkM2uNqw+2E4OZmUKf1g/kFpZrpZ1dXtYMlxsrN+8J5Mx0qNZbvbHYsLl3KDT555o/yAUM16GKtxrT4k3wiqaFU7ZO9N5tRA5NYQltnWBDMNiI1Q0L5IE4ItZsZeMXw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781547914; c=relaxed/simple; bh=ucjESAd9trJMZWbtlPk+6IV2WpT9Oqade/fpZgVuRZA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CPkE2HWbeHMY7eYwxDj6KmaWhwB2FEEZCXz2tuEg/RKZsJfCaoVJ7ktJ+l2nif4fPKAVT4LlIA0gvWWuFKlx2jpPcuzAoVSuR5meHpNRXKuXYCwOqGoHSE6EiIiLa18gKVXFg4bLDSVrrn7q8a0BE9SYakBbz6yOrPNwHUkJJw8= 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=ZWcuWy8X; arc=none smtp.client-ip=198.175.65.12 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="ZWcuWy8X" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1781547912; x=1813083912; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ucjESAd9trJMZWbtlPk+6IV2WpT9Oqade/fpZgVuRZA=; b=ZWcuWy8Xwhh/KjB3ZoOf4gkw63zMD/cPs3LhzRU/u4rKVZG007IWns1e 0BY3BoSReYwfHLWPv9D4MoPLl3rgM0onNXKLW5fB5xbxMT5+jQr9h4I5f q5KihpgHAMfAVlts+7anNPEiqNVCIusw9bpm7PcT/arYqabW35/keAhgn OSeEW9ILkVd2TxY5PebGPIaWzGLwp0cntTSUvZkPGX4UJnHEifiPCSP5j PBMUAUpnZD6QjKioGTZ3C8DFwcZ4Qitmy1qV1va4e1PbjQGtKuy3sT1/Q 96oabDzNXLQ6c1vmDT5D+5rjgIwxDgnJfv1/TyVpLJZXRfh4S1QSkyadu A==; X-CSE-ConnectionGUID: DplxKRg7TGiIUTlonEMvuA== X-CSE-MsgGUID: 14iTtt0gTN61gCPVIQnt/g== X-IronPort-AV: E=McAfee;i="6800,10657,11818"; a="93789977" X-IronPort-AV: E=Sophos;i="6.24,206,1774335600"; d="scan'208";a="93789977" Received: from orviesa007.jf.intel.com ([10.64.159.147]) by orvoesa104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jun 2026 11:25:10 -0700 X-CSE-ConnectionGUID: YZjXIaJgRnSScE8bH2VPIg== X-CSE-MsgGUID: d2CDrl4aRpqOxqH+Jyh2uA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.24,206,1774335600"; d="scan'208";a="247620631" Received: from spandruv-desk1.amr.corp.intel.com (HELO agluck-desk3.intel.com) ([10.124.221.121]) by orviesa007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jun 2026 11:25:08 -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: [PATCH v8 07/16] x86/resctrl: Honor rdt=perf option to force enable AET perf events Date: Mon, 15 Jun 2026 11:24:48 -0700 Message-ID: <20260615182457.14725-8-tony.luck@intel.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260615182457.14725-1-tony.luck@intel.com> References: <20260615182457.14725-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" The kernel command line option "rdt=3D" is used to force enable or disable individual resctrl features. Linux only enumerates AET (Application Energy Telemetry) once on first mount. But that is going to change to enumerate on each mount to allow the pmt_telemetry driver to be configured as a module, and allow unloading when not in use. The following scenario will be a problem: 1) User mounts the resctrl file system. all_regions_have_sufficient_rmid() notes that a perf telemetry region supports fewer RMIDs than expected for the event_group and sets e->force_off =3D true. But the user had specified "rdt=3Dperf" on the kernel command line so perf events are enabled for this first mount. 2) Resctrl file system is unmounted and later remounted. 3) During this new mount cycle enable_events() sees that e->force_off is set and stops enumeration for this event group. So on this second, and all subsequent, mounts perf events are not enabled. Fix by checking the state of e->force_on at the start of enable_events(). Signed-off-by: Tony Luck --- v8: New subject and commit comment Fix by changing test at start of enable_events() instead of changing all_regions_have_sufficient_rmid() arch/x86/kernel/cpu/resctrl/intel_aet.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/intel_aet.c b/arch/x86/kernel/cpu/= resctrl/intel_aet.c index 89b8b619d5d5..07e9d6d4959e 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. @@ -228,7 +228,7 @@ static bool enable_events(struct event_group *e, struct= pmt_feature_group *p) struct rdt_resource *r =3D &rdt_resources_all[RDT_RESOURCE_PERF_PKG].r_re= sctrl; int skipped_events =3D 0; =20 - if (e->force_off) + if (e->force_off && !e->force_on) return false; =20 if (!group_has_usable_regions(e, p)) --=20 2.54.0 From nobody Tue Jun 16 19:33:08 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.12]) (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 A0B7E31A062 for ; Mon, 15 Jun 2026 18:25:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781547915; cv=none; b=GsYJwxDNYiXBZAuacGv7YVCjaUCqxviKYTsAHGFW0cqZ6zGga16hoWLRCCqNML8sqm5lSx2Q8PiMht9c6CYnutSdkJIdO5qH32fFf1PrqdDoqkUQ5OOYyjm+2HEHyqof3/zEF53+qfbVVntDtw8XaZ73IX32U1Xp0jH7dMYuEOA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781547915; c=relaxed/simple; bh=Phroedg9xgFNldBgvX+72+A5/sONrbvincUmkJpw8XU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=d2jaWyLvzQdEfDFUawes+v3ObXrleQgyMbSFawwn4Bvzxf5vA7gndnCYMtTUErlLsIGLXt6pur4CnYMAPsoksldAMK6kIRwBBvvptnaxO8hPKrDGIDLLYMcq3TTIisKK7rw3VK2dWVjBWNbDLyBLb3ZTDXSWzBgXosoTfahO56c= 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=d5iZNvdh; arc=none smtp.client-ip=198.175.65.12 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="d5iZNvdh" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1781547912; x=1813083912; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Phroedg9xgFNldBgvX+72+A5/sONrbvincUmkJpw8XU=; b=d5iZNvdhvw3BPQYOC+R4FC8YGyH+ChfwtM886sBAWZDgE7skvJf4MJPO 9svakywTU9bQobWoXmlKyq9fuPKxabku4gpR8dTaf9NkAHzazqv8rldxR CNSVKPGCsBV2ySMg6xtjdA0BD+fIpUnoeI1VodyCJZaubiB3JLKK2Rh89 Lc1yIBOkDk6pgrkFZA0+d2gjjLsrimbBpRibkQf/pZUDGmkKJFKvzTAHf dW1+xO8bJqFCQkJZn9cgyK+SkRUXkZ27iggliLvikqHIFSyE37eWm6zvh hlRxUDJDoJ7Re89Ysy+jKiaWbixQfyU/B590tWMhiHXlQTD2d3P7SYLM1 w==; X-CSE-ConnectionGUID: him+GDKET62v1fmxQmKhsA== X-CSE-MsgGUID: aOJBIDf+QomyeLJMGPRU7Q== X-IronPort-AV: E=McAfee;i="6800,10657,11818"; a="93789992" X-IronPort-AV: E=Sophos;i="6.24,206,1774335600"; d="scan'208";a="93789992" Received: from orviesa007.jf.intel.com ([10.64.159.147]) by orvoesa104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jun 2026 11:25:10 -0700 X-CSE-ConnectionGUID: FGKnyo4xQwynXnR07FUgEA== X-CSE-MsgGUID: Ix5WBpwmQR6PB7vSGDT6GQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.24,206,1774335600"; d="scan'208";a="247620635" Received: from spandruv-desk1.amr.corp.intel.com (HELO agluck-desk3.intel.com) ([10.124.221.121]) by orviesa007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jun 2026 11:25:09 -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: [PATCH v8 08/16] fs/resctrl: Add interface to disable a monitor event Date: Mon, 15 Jun 2026 11:24:49 -0700 Message-ID: <20260615182457.14725-9-tony.luck@intel.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260615182457.14725-1-tony.luck@intel.com> References: <20260615182457.14725-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 currently assumes all monitor events are enabled before any domain is created, because per-domain state is allocated by the architecture's CPU hotplug callbacks. There is no way to disable an event once registered. AET events are enumerated by the INTEL_PMT_TELEMETRY driver. To allow that driver to be a loadable module, resctrl must tolerate AET events appearing and disappearing, which requires the ability to disable an event when the driver is unloaded. Add resctrl_disable_mon_event(). The architecture owns domain lifetime and knows mount state, so it is responsible for calling this only while resctrl is unmounted and for cleaning up any per-domain state. Document those requirements in the kerneldoc since they are not enforced in code. Signed-off-by: Tony Luck --- v8: Updated commit message Clear all architecture controlled mon_event::* fields. include/linux/resctrl.h | 34 ++++++++++++++++++++++++++++++++++ fs/resctrl/monitor.c | 15 +++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index 006e57fd7ca5..138810ada049 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 3df188bee433..8178fc65318e 100644 --- a/fs/resctrl/monitor.c +++ b/fs/resctrl/monitor.c @@ -1012,6 +1012,21 @@ 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].any_cpu =3D false; + mon_event_all[eventid].binary_bits =3D 0; + mon_event_all[eventid].arch_priv =3D NULL; + 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.54.0 From nobody Tue Jun 16 19:33:08 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.12]) (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 DF83C31BCAE for ; Mon, 15 Jun 2026 18:25:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781547915; cv=none; b=asuWPCj0oQ0llB9jFh3lqV+u1A43GZfq7gm+yzeGCKVt6PEAC5NCXpL/QPbDl51cSy3m7vmtaBQqueeSoz9ub1v0ZFhQHuNWOrdJtgosgofJuMITn+MYwtRZNZ8i/x18RopYNR/q/mv3f7WeErVQoYAdK2M4DbXZyGgwPpVdwJI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781547915; c=relaxed/simple; bh=8s+4l5dBFT8j0RbC0XLevFKHwJIItgN5f7cvG24Wo00=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KjhRYB6NAm6j0zNwKU37usZCqdh0E5dBxU52ZWbrdrKMJaZzuKmnWchcwXNgNOhE60jymO2YWEyOSYIkKR9vILz/Aqs8wUmDU5lhbNZjg/oKcjmdZvJAhLLyU7qPHEuxBOQ8amL1Hhk0xbvJu5YOAOWBVWvFlLVQsHR+c2cczd0= 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=Yg777ojW; arc=none smtp.client-ip=198.175.65.12 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="Yg777ojW" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1781547913; x=1813083913; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=8s+4l5dBFT8j0RbC0XLevFKHwJIItgN5f7cvG24Wo00=; b=Yg777ojWifvnkpAJK7qbpelEz329PrUxb1EBKE7xubepTjFRYre79Y7k xnNd0oOFQU+6EDX0HOde3Sz+64UUfAPvJt1DH6j5AhclYy231b+cwNw2C M/7PFrgtKR2BtaEv4XExRBFXXCQCaggkRu0mZBpW8MtbZ4e0PKZhNSzS9 GXE5ODUUyIowF6dtLtJgulqNnqOXRfdZDdrxtxTIJlW+BKQdMiEe7gLic ls9r+oeU6Q8e5lxxQ9jLymccUPPYhm0lKsTXORIN3bVY5TdguDbULTbqP R8Qc80qswJWFKAdaZ8srOeAW9Zk5PcTsCvvpNq74QPuJc9zGsPulvOKR7 Q==; X-CSE-ConnectionGUID: Gf2HxOKzT56z7HqZyc6Kug== X-CSE-MsgGUID: fgKvitYkRimeV0VcdkZNOQ== X-IronPort-AV: E=McAfee;i="6800,10657,11818"; a="93789996" X-IronPort-AV: E=Sophos;i="6.24,206,1774335600"; d="scan'208";a="93789996" Received: from orviesa007.jf.intel.com ([10.64.159.147]) by orvoesa104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jun 2026 11:25:10 -0700 X-CSE-ConnectionGUID: XClgXzk2SYyjjKjvSLE7wA== X-CSE-MsgGUID: dO6kUSfjR6Cy2fqolPdk4Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.24,206,1774335600"; d="scan'208";a="247620639" Received: from spandruv-desk1.amr.corp.intel.com (HELO agluck-desk3.intel.com) ([10.124.221.121]) by orviesa007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jun 2026 11:25:09 -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: [PATCH v8 09/16] x86/resctrl: Drop global 'rdt_mon_capable' flag Date: Mon, 15 Jun 2026 11:24:50 -0700 Message-ID: <20260615182457.14725-10-tony.luck@intel.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260615182457.14725-1-tony.luck@intel.com> References: <20260615182457.14725-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" File system code calls resctrl_arch_mon_capable() to determine if the system supports any monitoring features. x86 architecture code sets a global flag to support implementation of resctrl_arch_mon_capable() but the upcoming change to enumerate AET (Application Energy Telemetry) features on each mount introduces a new corner case. Specifically when AET is the only monitoring feature, loading and unloading the pmt_telemetry module between resctrl mounts may result in monitoring support enabled on some mounts, but not on others. Replace the global flag with a scan of resources to check if any are marked mon_capable. Signed-off-by: Tony Luck --- v8: Change from a count of monitor features to a scan of the rdt_resources checking for any that are mon_capable. arch/x86/include/asm/resctrl.h | 6 +----- arch/x86/kernel/cpu/resctrl/core.c | 18 +++++++++++++++--- arch/x86/kernel/cpu/resctrl/monitor.c | 6 ------ 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/arch/x86/include/asm/resctrl.h b/arch/x86/include/asm/resctrl.h index 575f8408a9e7..a9f481b7a8ed 100644 --- a/arch/x86/include/asm/resctrl.h +++ b/arch/x86/include/asm/resctrl.h @@ -43,7 +43,6 @@ struct resctrl_pqr_state { DECLARE_PER_CPU(struct resctrl_pqr_state, pqr_state); =20 extern bool rdt_alloc_capable; -extern bool rdt_mon_capable; =20 DECLARE_STATIC_KEY_FALSE(rdt_enable_key); DECLARE_STATIC_KEY_FALSE(rdt_alloc_enable_key); @@ -66,10 +65,7 @@ static inline void resctrl_arch_disable_alloc(void) static_branch_dec_cpuslocked(&rdt_enable_key); } =20 -static inline bool resctrl_arch_mon_capable(void) -{ - return rdt_mon_capable; -} +bool resctrl_arch_mon_capable(void); =20 static inline void resctrl_arch_enable_mon(void) { diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resct= rl/core.c index 7667cf7c4e94..fb6d52ea3406 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -50,6 +50,20 @@ DEFINE_PER_CPU(struct resctrl_pqr_state, pqr_state); */ bool rdt_alloc_capable; =20 +/* + * Need to re-evaluate on each mount whether any mon_capable resources + * are enabled. + */ +bool resctrl_arch_mon_capable(void) +{ + struct rdt_resource *r; + + for_each_mon_capable_rdt_resource(r) + return true; + + return false; +} + static void mba_wrmsr_intel(struct msr_param *m); static void cat_wrmsr(struct msr_param *m); static void mba_wrmsr_amd(struct msr_param *m); @@ -779,7 +793,6 @@ void resctrl_arch_pre_mount(void) cpus_read_lock(); mutex_lock(&domain_list_lock); r->mon_capable =3D true; - rdt_mon_capable =3D true; for_each_online_cpu(cpu) domain_add_cpu_mon(cpu, r); mutex_unlock(&domain_list_lock); @@ -1013,9 +1026,8 @@ static __init void check_quirks(void) static __init bool get_rdt_resources(void) { rdt_alloc_capable =3D get_rdt_alloc_resources(); - rdt_mon_capable =3D get_rdt_mon_resources(); =20 - return (rdt_mon_capable || rdt_alloc_capable); + return get_rdt_mon_resources() || rdt_alloc_capable; } =20 static __init void rdt_init_res_defs_intel(void) diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/re= sctrl/monitor.c index 59215fef3924..682585fffe46 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -25,12 +25,6 @@ =20 #include "internal.h" =20 -/* - * Global boolean for rdt_monitor which is true if any - * resource monitoring is enabled. - */ -bool rdt_mon_capable; - #define CF(cf) ((unsigned long)(1048576 * (cf) + 0.5)) =20 static int snc_nodes_per_l3_cache =3D 1; --=20 2.54.0 From nobody Tue Jun 16 19:33:08 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.12]) (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 38FE9344031 for ; Mon, 15 Jun 2026 18:25:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781547917; cv=none; b=q9m88cYzbNuZoGGRTGNnsnEmOv1pBCOHN9/2bnQsoSVbgWVT6oTbTod9iUQMg1FXHn5ORZDtqLlWyU3LdEGfKBgK2HsDaf3CbiWLW6GsK/OlpbRe2zaBmIFDj4tIriv7yaDisGUiCxpG2caLElAiyWPCX4s88O2sy9oFZBqFwj0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781547917; c=relaxed/simple; bh=/7aA8QlF0XwldwOMloEcg+E9c38a6zMUX+zdAt5H90A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tI9WiTWubIGTlQsMq2FiY8uupCqYcojK8VO+poTrOdPlXAnFvKlgEt0JBVfRhKcv/MLKT/OAZs7FWo31EeiriAUvb8qrbBkHX/eumWzMMOMgGKgbSdH41bdkxU3luDThyR5QJAUXRcx6RW/gyk4W32Et/KyNJFukL0tHTb/a59w= 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=BIayo5O5; arc=none smtp.client-ip=198.175.65.12 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="BIayo5O5" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1781547915; x=1813083915; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=/7aA8QlF0XwldwOMloEcg+E9c38a6zMUX+zdAt5H90A=; b=BIayo5O5EuQWGin01wo5M5QWXCpsFiOApqqJUaR4pyIXabKBiyD8uEOw gdOzQly1flcZUwq561p6Z6fG9VhBhYkmjTEO8Wmeo1DfuRbIKsYOrGYmb A1OLF7XopppgzVpdckaRNvcLg52kfAPVyu/29wzTj7HeRx/WD2IQxCHd5 q+K7Sh+gRB7asQF6op70wLC/yWZ4eU41riQYc+Ra7JmiPRWw6gF6sPwvl c/Bz55ufPUc/CTOR+1DlpH+uGVX6g7GGwBnA5CCW3xF8WPv8/5GiiYhJh 3+f/Np/0A/gOJv123IHNzQNRzq/ZccFEFYypWJaYGwli72lFrSCzm/j/t w==; X-CSE-ConnectionGUID: 8LZfbtfHQ/eT/EO3+XWOgA== X-CSE-MsgGUID: V9ycVwE6QiCxXgwkLzL+8w== X-IronPort-AV: E=McAfee;i="6800,10657,11818"; a="93790006" X-IronPort-AV: E=Sophos;i="6.24,206,1774335600"; d="scan'208";a="93790006" Received: from orviesa007.jf.intel.com ([10.64.159.147]) by orvoesa104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jun 2026 11:25:11 -0700 X-CSE-ConnectionGUID: n+1ZWMTTQQm3z+Qs1+OQyg== X-CSE-MsgGUID: 5XMWle5TRV+Z3xwtpT0lXQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.24,206,1774335600"; d="scan'208";a="247620646" Received: from spandruv-desk1.amr.corp.intel.com (HELO agluck-desk3.intel.com) ([10.124.221.121]) by orviesa007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jun 2026 11:25:10 -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: [PATCH v8 10/16] arm,x86,fs/resctrl: Handle change in number of RMIDs on each mount Date: Mon, 15 Jun 2026 11:24:51 -0700 Message-ID: <20260615182457.14725-11-tony.luck@intel.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260615182457.14725-1-tony.luck@intel.com> References: <20260615182457.14725-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" Application Energy Telemetry (AET) event enumeration takes place asynchronously. Linux builds the pmt_telemetry module into the kernel to kick off enumeration early enough that it completes before first mount of the resctrl file system. Allowing pmt_telemetry to be a loadable module means that it is possible for different numbers of RMIDs to be supported on each mount, depending on whether pmt_telemetry module is loaded. For simplicity, calculate the maximum possible number of RMIDs and use that value to allocate the rmid_ptrs[] array just once. Also use this maximum RMID value when allocating rdt_l3_mon_domain::rmid_busy_llc bitmap and rdt_l3_mon_domain::mbm_states. The limbo code must deal with changes in the number of RMIDs from one mount to the next because some RMIDs may still be "busy" when the file system is unmounted, but be above resctrl_arch_system_num_rmid_idx() for the remount. In this case RMIDs that can be released are not put onto the rmid_free_lru list. Signed-off-by: Tony Luck --- v8: Pick arm,x86,fs/resctrl as standard tag syntax Update kerneldoc for rdt_l3_mon_domain::rmid_busy_llc and rdt_l3_mon_domain::mbm_states to say they are sized for max RMID. Rename local variable idx_limit. Use max_idx_limit when dealing with the maximum possible RMID value and min_idx_limit when dealing with the minimum value across resources for the current mount. Compute index of reserved RMID instead of assuming "0" in setup_rmid_lru_list() Update commit comment to provide overview of the change instead of details of the code change. include/linux/resctrl.h | 5 +- arch/x86/kernel/cpu/resctrl/core.c | 14 ++++++ drivers/resctrl/mpam_resctrl.c | 5 ++ fs/resctrl/monitor.c | 76 +++++++++++++++++++----------- fs/resctrl/rdtgroup.c | 6 +-- 5 files changed, 75 insertions(+), 31 deletions(-) diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index 138810ada049..8740dc52b0f7 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -182,10 +182,12 @@ struct mbm_cntr_cfg { * struct rdt_l3_mon_domain - group of CPUs sharing RDT_RESOURCE_L3 monito= ring * @hdr: common header for different domain types * @ci_id: cache info id for this domain - * @rmid_busy_llc: bitmap of which limbo RMIDs are above threshold + * @rmid_busy_llc: bitmap of which limbo RMIDs are above threshold. Sized = for + * resctrl_arch_system_max_rmid_idx() RMIDs * @mbm_states: Per-event pointer to the MBM event's saved state. * An MBM event's state is an array of struct mbm_state * indexed by RMID on x86 or combined CLOSID, RMID on Arm. + * Also sized for resctrl_arch_system_max_rmid_idx() RMIDs * @mbm_over: worker to periodically read MBM h/w counters * @cqm_limbo: worker to periodically read CQM h/w counters * @mbm_work_cpu: worker CPU for MBM h/w counters @@ -412,6 +414,7 @@ static inline u32 resctrl_get_default_ctrl(struct rdt_r= esource *r) /* The number of closid supported by this resource regardless of CDP */ u32 resctrl_arch_get_num_closid(struct rdt_resource *r); u32 resctrl_arch_system_num_rmid_idx(void); +u32 resctrl_arch_system_max_rmid_idx(void); int resctrl_arch_update_domains(struct rdt_resource *r, u32 closid); =20 /** diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resct= rl/core.c index fb6d52ea3406..08a229e25883 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -143,6 +143,20 @@ u32 resctrl_arch_system_num_rmid_idx(void) return num_rmids =3D=3D U32_MAX ? 0 : num_rmids; } =20 +/** + * resctrl_arch_system_max_rmid_idx - Largest possible number of RMIDs + * + * Return: If L3 monitoring is supported, largest possible comes from L3 b= ased + * on CPUID(0xf,0x0).EBX (scaled down on Sub-NUMA Cluster systems). Otherw= ise + * maximum from any other mon_capable resources. + */ +u32 resctrl_arch_system_max_rmid_idx(void) +{ + struct rdt_resource *r =3D &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl; + + return r->mon_capable ? r->mon.num_rmid : resctrl_arch_system_num_rmid_id= x(); +} + struct rdt_resource *resctrl_arch_get_resource(enum resctrl_res_level l) { if (l >=3D RDT_NUM_RESOURCES) diff --git a/drivers/resctrl/mpam_resctrl.c b/drivers/resctrl/mpam_resctrl.c index 226ff6f532fa..7079870ca894 100644 --- a/drivers/resctrl/mpam_resctrl.c +++ b/drivers/resctrl/mpam_resctrl.c @@ -272,6 +272,11 @@ u32 resctrl_arch_system_num_rmid_idx(void) return (mpam_pmg_max + 1) * (mpam_partid_max + 1); } =20 +u32 resctrl_arch_system_max_rmid_idx(void) +{ + return resctrl_arch_system_num_rmid_idx(); +} + u32 resctrl_arch_rmid_idx_encode(u32 closid, u32 rmid) { return closid * (mpam_pmg_max + 1) + rmid; diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c index 8178fc65318e..67cc99a9b582 100644 --- a/fs/resctrl/monitor.c +++ b/fs/resctrl/monitor.c @@ -115,10 +115,18 @@ static inline struct rmid_entry *__rmid_entry(u32 idx) =20 static void limbo_release_entry(struct rmid_entry *entry) { + u32 min_idx_limit =3D resctrl_arch_system_num_rmid_idx(); + lockdep_assert_held(&rdtgroup_mutex); =20 rmid_limbo_count--; - list_add_tail(&entry->list, &rmid_free_lru); + + /* + * Limbo may be freeing an RMID from a previous mount where there + * were more RMIDs available. + */ + if (resctrl_arch_rmid_idx_encode(entry->closid, entry->rmid) < min_idx_li= mit) + list_add_tail(&entry->list, &rmid_free_lru); =20 if (IS_ENABLED(CONFIG_RESCTRL_RMID_DEPENDS_ON_CLOSID)) closid_num_dirty_rmid[entry->closid]--; @@ -133,14 +141,20 @@ static void limbo_release_entry(struct rmid_entry *en= try) void __check_limbo(struct rdt_l3_mon_domain *d, bool force_free) { struct rdt_resource *r =3D resctrl_arch_get_resource(RDT_RESOURCE_L3); - u32 idx_limit =3D resctrl_arch_system_num_rmid_idx(); struct rmid_entry *entry; u32 idx, cur_idx =3D 1; void *arch_mon_ctx; + u32 max_idx_limit; void *arch_priv; bool rmid_dirty; u64 val =3D 0; =20 + /* + * Need to check all possible RMIDs, not just the range available + * in this mount cycle. + */ + max_idx_limit =3D resctrl_arch_system_max_rmid_idx(); + arch_priv =3D mon_event_all[QOS_L3_OCCUP_EVENT_ID].arch_priv; arch_mon_ctx =3D resctrl_arch_mon_ctx_alloc(r, QOS_L3_OCCUP_EVENT_ID); if (IS_ERR(arch_mon_ctx)) { @@ -156,8 +170,8 @@ void __check_limbo(struct rdt_l3_mon_domain *d, bool fo= rce_free) * RMID and move it to the free list when the counter reaches 0. */ for (;;) { - idx =3D find_next_bit(d->rmid_busy_llc, idx_limit, cur_idx); - if (idx >=3D idx_limit) + idx =3D find_next_bit(d->rmid_busy_llc, max_idx_limit, cur_idx); + if (idx >=3D max_idx_limit) break; =20 entry =3D __rmid_entry(idx); @@ -192,9 +206,9 @@ void __check_limbo(struct rdt_l3_mon_domain *d, bool fo= rce_free) =20 bool has_busy_rmid(struct rdt_l3_mon_domain *d) { - u32 idx_limit =3D resctrl_arch_system_num_rmid_idx(); + u32 max_idx_limit =3D resctrl_arch_system_max_rmid_idx(); =20 - return find_first_bit(d->rmid_busy_llc, idx_limit) !=3D idx_limit; + return find_first_bit(d->rmid_busy_llc, max_idx_limit) !=3D max_idx_limit; } =20 static struct rmid_entry *resctrl_find_free_rmid(u32 closid) @@ -907,8 +921,8 @@ void mbm_setup_overflow_handler(struct rdt_l3_mon_domai= n *dom, unsigned long del =20 int setup_rmid_lru_list(void) { + u32 max_idx_limit, min_idx_limit; struct rmid_entry *entry =3D NULL; - u32 idx_limit; u32 idx; int i; =20 @@ -916,27 +930,29 @@ int setup_rmid_lru_list(void) return 0; =20 /* - * Called on every mount, but the number of RMIDs cannot change - * after the first mount, so keep using the same set of rmid_ptrs[] - * until resctrl_exit(). Note that the limbo handler continues to - * access rmid_ptrs[] after resctrl is unmounted. + * Allocate the largest number of RMIDs that this system will ever + * need. These cannot be freed until resctrl_exit() because the limbo + * handler continues to access rmid_ptrs[] after resctrl is unmounted. */ - if (rmid_ptrs) - return 0; - - idx_limit =3D resctrl_arch_system_num_rmid_idx(); - rmid_ptrs =3D kzalloc_objs(struct rmid_entry, idx_limit); - if (!rmid_ptrs) - return -ENOMEM; + if (!rmid_ptrs) { + max_idx_limit =3D resctrl_arch_system_max_rmid_idx(); + rmid_ptrs =3D kzalloc_objs(struct rmid_entry, max_idx_limit); + if (!rmid_ptrs) + return -ENOMEM; =20 - for (i =3D 0; i < idx_limit; i++) { - entry =3D &rmid_ptrs[i]; - INIT_LIST_HEAD(&entry->list); + for (i =3D 0; i < max_idx_limit; i++) { + entry =3D &rmid_ptrs[i]; + INIT_LIST_HEAD(&entry->list); =20 - resctrl_arch_rmid_idx_decode(i, &entry->closid, &entry->rmid); - list_add_tail(&entry->list, &rmid_free_lru); + resctrl_arch_rmid_idx_decode(i, &entry->closid, &entry->rmid); + } } =20 + /* Find how many RMIDs are needed for this mount */ + min_idx_limit =3D resctrl_arch_system_num_rmid_idx(); + + INIT_LIST_HEAD(&rmid_free_lru); + /* * RESCTRL_RESERVED_CLOSID and RESCTRL_RESERVED_RMID are special and * are always allocated. These are used for the rdtgroup_default @@ -944,8 +960,14 @@ int setup_rmid_lru_list(void) */ idx =3D resctrl_arch_rmid_idx_encode(RESCTRL_RESERVED_CLOSID, RESCTRL_RESERVED_RMID); - entry =3D __rmid_entry(idx); - list_del(&entry->list); + + for (i =3D 0; i < min_idx_limit; i++) { + entry =3D &rmid_ptrs[i]; + /* Don't add reserved or busy entries to free list */ + if (i =3D=3D idx || entry->busy) + continue; + list_add_tail(&entry->list, &rmid_free_lru); + } =20 return 0; } @@ -1159,7 +1181,7 @@ static void mbm_cntr_free_all(struct rdt_resource *r,= struct rdt_l3_mon_domain * */ static void resctrl_reset_rmid_all(struct rdt_resource *r, struct rdt_l3_m= on_domain *d) { - u32 idx_limit =3D resctrl_arch_system_num_rmid_idx(); + u32 max_idx_limit =3D resctrl_arch_system_max_rmid_idx(); enum resctrl_event_id evt; int idx; =20 @@ -1167,7 +1189,7 @@ static void resctrl_reset_rmid_all(struct rdt_resourc= e *r, struct rdt_l3_mon_dom if (!resctrl_is_mon_event_enabled(evt)) continue; idx =3D MBM_STATE_IDX(evt); - memset(d->mbm_states[idx], 0, sizeof(*d->mbm_states[0]) * idx_limit); + memset(d->mbm_states[idx], 0, sizeof(*d->mbm_states[0]) * max_idx_limit); } } =20 diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c index c671644f1e12..ee948787f9db 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -4417,13 +4417,13 @@ void resctrl_offline_mon_domain(struct rdt_resource= *r, struct rdt_domain_hdr *h */ static int domain_setup_l3_mon_state(struct rdt_resource *r, struct rdt_l3= _mon_domain *d) { - u32 idx_limit =3D resctrl_arch_system_num_rmid_idx(); + u32 max_idx_limit =3D resctrl_arch_system_max_rmid_idx(); size_t tsize =3D sizeof(*d->mbm_states[0]); enum resctrl_event_id eventid; int idx; =20 if (resctrl_is_mon_event_enabled(QOS_L3_OCCUP_EVENT_ID)) { - d->rmid_busy_llc =3D bitmap_zalloc(idx_limit, GFP_KERNEL); + d->rmid_busy_llc =3D bitmap_zalloc(max_idx_limit, GFP_KERNEL); if (!d->rmid_busy_llc) return -ENOMEM; } @@ -4432,7 +4432,7 @@ static int domain_setup_l3_mon_state(struct rdt_resou= rce *r, struct rdt_l3_mon_d if (!resctrl_is_mon_event_enabled(eventid)) continue; idx =3D MBM_STATE_IDX(eventid); - d->mbm_states[idx] =3D kcalloc(idx_limit, tsize, GFP_KERNEL); + d->mbm_states[idx] =3D kcalloc(max_idx_limit, tsize, GFP_KERNEL); if (!d->mbm_states[idx]) goto cleanup; } --=20 2.54.0 From nobody Tue Jun 16 19:33:08 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.12]) (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 ADEBC33F583 for ; Mon, 15 Jun 2026 18:25:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781547916; cv=none; b=vAL0QpZxCEc3AS9nr1ngtV4NrvfNLAD9bdINfxA80ws602qJED93NaZVYx9S5SShA8acL17IBf8gFHempWpUy0Zsf6IE0AM97eSQvjT65kjgWQXL84q4ERfVgIyHGmLjI68Ao1guC98qTdrOqsCWhBf7NCGlj6aGARF62MmNMDk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781547916; c=relaxed/simple; bh=CTdMZ9ztIS52XlqYUMlXC+yz0GzvZLZHgwZikZ4Mj4A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UIEZZ2rZB8t4QAMJGnQuMrpFUzFIvwq7N8qSIO4yrE7wJSCsLG+bkwcbc/4QGpwqhJN2qOK4o28NcQm0gW5cVp9xbC/x8TJIURFAuKUGOjAye4Fkbwfj6C8CpEwqo2NtvmpFNSGOoFcKkZ2t2wJZmYJ1yQos0fZeibnSvRqqm9Y= 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=jcKG23LZ; arc=none smtp.client-ip=198.175.65.12 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="jcKG23LZ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1781547914; x=1813083914; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=CTdMZ9ztIS52XlqYUMlXC+yz0GzvZLZHgwZikZ4Mj4A=; b=jcKG23LZ9YSFfEuZM9XhLW1znO4TKT6yx1fxjZWEjZKozAhRpZuJZrxO SxIOIutu2bjlwbaFhnD1DTNR45LDle0b5ccM+iesE9IonxmhT7SH5Q5zY RUcYgpxvtbLEWXpPJMuJFC06/qj/PrwI/EJN/B6UKF3irttH49Ka3hiQP qtNClEgqPN1jAYahRiBASOpgBTtvdcnLRf89Vi7roXYTOfEjMYy0sEcur WQuJrmasgTORot2n7WxVW6VU3dxQEV65VqbPiUsEiIFt/1zpwbl5qCu7z S5b5qlemAvhK6u2wObJZpLlpODeF6XMMo9x9kz3D2yp4qdSogbza+qb8V g==; X-CSE-ConnectionGUID: qdzg+B8uS0Su03k5aM7x8g== X-CSE-MsgGUID: 7ohF8Ep5RvymRImwRPXq5w== X-IronPort-AV: E=McAfee;i="6800,10657,11818"; a="93790016" X-IronPort-AV: E=Sophos;i="6.24,206,1774335600"; d="scan'208";a="93790016" Received: from orviesa007.jf.intel.com ([10.64.159.147]) by orvoesa104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jun 2026 11:25:11 -0700 X-CSE-ConnectionGUID: itkrOfPPRYeDMu4QnPUEQA== X-CSE-MsgGUID: MKkxin7qSAaZKlpY16dwTQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.24,206,1774335600"; d="scan'208";a="247620649" Received: from spandruv-desk1.amr.corp.intel.com (HELO agluck-desk3.intel.com) ([10.124.221.121]) by orviesa007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jun 2026 11:25:10 -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: [PATCH v8 11/16] x86/resctrl: Add PMT registration API for AET enumeration callbacks Date: Mon, 15 Jun 2026 11:24:52 -0700 Message-ID: <20260615182457.14725-12-tony.luck@intel.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260615182457.14725-1-tony.luck@intel.com> References: <20260615182457.14725-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 --- v8: Add comment for what aet_register_lock will protect arch/x86/include/asm/resctrl.h | 22 ++++++++++++++++ arch/x86/kernel/cpu/resctrl/intel_aet.c | 34 +++++++++++++++++++++++++ 2 files changed, 56 insertions(+) diff --git a/arch/x86/include/asm/resctrl.h b/arch/x86/include/asm/resctrl.h index a9f481b7a8ed..48ad55bcda66 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 @@ -189,11 +191,31 @@ 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 module *module, + 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 module *module, + 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 module *module, + 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 07e9d6d4959e..bc15cf37a7d0 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 @@ -291,6 +295,10 @@ static enum pmt_feature_id lookup_pfid(const char *pfn= ame) return FEATURE_INVALID; } =20 +static struct module *pmt_module; +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, @@ -325,6 +333,32 @@ bool intel_aet_get_events(void) return ret; } =20 +/* + * Defend against races between pmt_telemetry register/unregister and + * resctrl file system mount/unmount. + */ +static DEFINE_MUTEX(aet_register_lock); + +void intel_aet_register_enumeration(struct module *module, + 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; + pmt_module =3D module; +} +EXPORT_SYMBOL_NS_GPL(intel_aet_register_enumeration, "INTEL_PMT"); + +void intel_aet_unregister_enumeration(void) +{ + guard(mutex)(&aet_register_lock); + pmt_module =3D NULL; + get_feature =3D NULL; + put_feature =3D NULL; +} +EXPORT_SYMBOL_NS_GPL(intel_aet_unregister_enumeration, "INTEL_PMT"); + void __exit intel_aet_exit(void) { struct event_group **peg; --=20 2.54.0 From nobody Tue Jun 16 19:33:08 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.12]) (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 3BBAC3446CB for ; Mon, 15 Jun 2026 18:25:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781547917; cv=none; b=N9QX5bARuseA1poaLG1R/wjOjHi5nvdIRn4i3tNnE8D79SIup463dyvyJ/2Nw3LWSxUYIezDrkZzCoN2YqU2p1DuaFhOAEt3rSwVzTyWqwRBRPWfUyIxw2U/2wplzqvQbhcHE2OByqQ1RRJoS04YwwJ0vqEk/jEoTXrc9TASuo8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781547917; c=relaxed/simple; bh=MrhqPa7j2JGoW5KXGgtohMR/jOgI/vkqvszj5jCodoM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gwAAC1GUu7bq8TypyePNxyEjAubFSEDzRnBhb/sOT+LwVftXHwgugJXYwEidVMEyfPZkMDd9Yn8U2v/r0qPlfViDVJIii8SiQh5ahV8ROkdmTCowACfDMGrr4uFx5vqsR/gHMjoftGYFBvAGfF1AIBHSphq6oS4LXf8MOuM+C+g= 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=htW/dHZH; arc=none smtp.client-ip=198.175.65.12 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="htW/dHZH" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1781547915; x=1813083915; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=MrhqPa7j2JGoW5KXGgtohMR/jOgI/vkqvszj5jCodoM=; b=htW/dHZH8ojl86h2Td8uzfCy7ZYHZra4ARe1ooX6lPdknfC2Y1wDo3AA pTRMent4/UgqxpmXw8Ct5VR6SPM99B9MM08rCfb+9jo1OiiyTI0iXLQrX AmiZW+DESAHbMG9wVJ/2pyNaZcub4RQOrgefhF1+NlR5b6OyVjxufvHgp pj+6XtrYmWLfZI/5sY0xXORZdAFp+M2q9s8b5f4zGWQn85GvNwhGjjUaL x+F3e7+cvjGdhZhuukdl5wBwZIr3gItguM+6KatFbLgZlQ6MxCKg5ztOZ EjZSwCRF1mfKG1lQ9tAWtck1WYCv4CC9EixUGXaqQVpFIlz/QLOxen9Yw A==; X-CSE-ConnectionGUID: eI90hYV9RSSRUfKQ2/St0Q== X-CSE-MsgGUID: g4V+TMmLSiGaEDpOInlbUw== X-IronPort-AV: E=McAfee;i="6800,10657,11818"; a="93790028" X-IronPort-AV: E=Sophos;i="6.24,206,1774335600"; d="scan'208";a="93790028" Received: from orviesa007.jf.intel.com ([10.64.159.147]) by orvoesa104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jun 2026 11:25:11 -0700 X-CSE-ConnectionGUID: dxyYtQtPTuyOlPZ6USejjA== X-CSE-MsgGUID: 0uKHzxPJQqGZmRRq/+KssQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.24,206,1774335600"; d="scan'208";a="247620653" Received: from spandruv-desk1.amr.corp.intel.com (HELO agluck-desk3.intel.com) ([10.124.221.121]) by orviesa007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jun 2026 11:25:11 -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: [PATCH v8 12/16] platform/x86/intel/pmt: Register enumeration functions with resctrl Date: Mon, 15 Jun 2026 11:24:53 -0700 Message-ID: <20260615182457.14725-13-tony.luck@intel.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260615182457.14725-1-tony.luck@intel.com> References: <20260615182457.14725-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 pmt_telemetry module .probe(), and unregister them at module .remove(). 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 --- v8: Move register/unregister calls to .probe()/.remove() drivers/platform/x86/intel/pmt/telemetry.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/platform/x86/intel/pmt/telemetry.c b/drivers/platform/= x86/intel/pmt/telemetry.c index daa6da9bad2a..fa4033f94d2f 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 @@ -365,6 +367,8 @@ static void pmt_telem_remove(struct auxiliary_device *a= uxdev) struct pmt_telem_priv *priv =3D auxiliary_get_drvdata(auxdev); int i; =20 + intel_aet_unregister_enumeration(); + mutex_lock(&ep_lock); for (i =3D 0; i < priv->num_entries; i++) { struct intel_pmt_entry *entry =3D &priv->entry[i]; @@ -405,6 +409,8 @@ static int pmt_telem_probe(struct auxiliary_device *aux= dev, const struct auxilia intel_pmt_get_features(entry); } =20 + intel_aet_register_enumeration(THIS_MODULE, intel_pmt_get_regions_by_feat= ure, + intel_pmt_put_feature_group); return 0; abort_probe: pmt_telem_remove(auxdev); --=20 2.54.0 From nobody Tue Jun 16 19:33:08 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.12]) (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 BB46B34D394 for ; Mon, 15 Jun 2026 18:25:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781547918; cv=none; b=GuoxnaoOkkBiQGammUZiNN9QYJ08jP1TlvW/17/hrdqqE/NbdI29pMRZPArPP/8Z753uM3TjoJsWuSnfbp5bLkz7Ibif4y6dRBedE/qtyiaLZ3YkdcbQMUpBcXfeyabUZdPTBKB1/lb6BC+sL35R1m+Ui99ObFj5J38rnhdnaKw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781547918; c=relaxed/simple; bh=MQWbJOZCaoBJeZRGiNL6pLEmGrFCHZ2YMuR3myGYkB8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FN0nIiqFc8JCn4ZA40nqWJLjwiJHgOaJmqa4/QxZiqLWk+QL1zshyyiiOOH1z5MhcGKtZIMSd63BVT4gi+r7stDvV1zbD0ZueMXnQSbkGkn7HWhLdv4sqbZxndKqb5mF7jRD02wAyWUIp6mpRqGHCZK3RhaBEHLP3HJ7LGcteG0= 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=nKd9jJ08; arc=none smtp.client-ip=198.175.65.12 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="nKd9jJ08" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1781547917; x=1813083917; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=MQWbJOZCaoBJeZRGiNL6pLEmGrFCHZ2YMuR3myGYkB8=; b=nKd9jJ08lIgk1MpICjru7udxr4eWcjQ6IMcWl8kTE6JEgs7qLgUnaZJc H9NeCeVtC69uZzi7SlrNsl/oyh99fzuCDy5h8NP5kyAWp6mSRTj4osqxa jBeH0YqC3RHydVZAP8mFgFu/305MXdDpD0AxvPD+/AuerUm4lpJADDria y7FjtajRZCD9NOKOhbU1q4ZiZhU+HfVovqXAC70j0nEmzK9oZRVhVajc6 v+Nqy481dvKr1zvxGN3W1RcuyCesK2rdzsibfFfgxHnSRjtjGhXn/bBCI uELrAfTcAlZEpSbA8CZRhKe7GdMxmSpxQNTtgMYmwZBNtt43rGe6ueGzz A==; X-CSE-ConnectionGUID: LnIbsuk6ReOiGH0BEM/3TA== X-CSE-MsgGUID: qHQgFt/TTGC+gCnyvOsRsw== X-IronPort-AV: E=McAfee;i="6800,10657,11818"; a="93790037" X-IronPort-AV: E=Sophos;i="6.24,206,1774335600"; d="scan'208";a="93790037" Received: from orviesa007.jf.intel.com ([10.64.159.147]) by orvoesa104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jun 2026 11:25:12 -0700 X-CSE-ConnectionGUID: rKSB93vYTjmjeE66I2ke4A== X-CSE-MsgGUID: tEtw8Q+uRhGcu9HNu38IVg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.24,206,1774335600"; d="scan'208";a="247620657" Received: from spandruv-desk1.amr.corp.intel.com (HELO agluck-desk3.intel.com) ([10.124.221.121]) by orviesa007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jun 2026 11:25:11 -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: [PATCH v8 13/16] arm,x86/resctrl: Resolve INTEL_PMT_TELEMETRY symbols at runtime Date: Mon, 15 Jun 2026 11:24:54 -0700 Message-ID: <20260615182457.14725-14-tony.luck@intel.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260615182457.14725-1-tony.luck@intel.com> References: <20260615182457.14725-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 instead of direct link-time references to PMT symbols. Prepare for the file system to call resctrl_arch_pre_mount() on every mount by moving AET enumeration into resctrl_arch_pre_mount() and cleanup into resctrl_arch_unmount(). This allows the PMT module to be unloaded whenever the filesystem is not mounted. Remove intel_aet_exit because all cleanup now happens in the unmount path. Note that the Linux file system code does not serialize calls to fs_context_operations::get_tree(), so there may be arbitrarily many parallel calls if users invoke mount(2) multiple times. Use an atomic counter to detect and ignore nested mount attempts. AET doesn= 't need to do anything for these. File system will fail them with an -EBUSY error code. event_group::num_rmid may be reset (reduced) during enumeration. This is not worth resetting on unmount because the same reduction would occur on each subsequent mount. Signed-off-by: Tony Luck --- v8: Drop reference to preceding patch in commit Drop resctrl_arch_mount_lock and replace with atomic ops Fix comment about "have_pmt_hold" in intel_aet_pre_mount() Rename have_pmt_hold to pmt_in_use and simplify mount/unmount Add intel_aet_try_module_get() and intel_aet_module_put() helpers with stubs for the CONFIG_INTEL_PMT_TELEMETRY=3Dy case. include/linux/resctrl.h | 6 +++ arch/x86/kernel/cpu/resctrl/internal.h | 23 +++++++++-- arch/x86/kernel/cpu/resctrl/core.c | 37 +++++++++++++++-- arch/x86/kernel/cpu/resctrl/intel_aet.c | 53 +++++++++++++++++++++---- drivers/resctrl/mpam_resctrl.c | 4 ++ 5 files changed, 108 insertions(+), 15 deletions(-) diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index 8740dc52b0f7..ace41847da46 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -559,6 +559,12 @@ void resctrl_offline_cpu(unsigned int cpu); */ void resctrl_arch_pre_mount(void); =20 +/* + * Architecture hook called when mount fails, or on unmount. + * No locks are held. + */ +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..a891017f69ec 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; @@ -253,4 +253,19 @@ static inline void intel_aet_mon_domain_setup(int cpu,= int id, struct rdt_resour static inline bool intel_handle_aet_option(bool force_off, char *tok) { re= turn false; } #endif =20 +#ifdef CONFIG_INTEL_PMT_TELEMETRY_MODULE +static inline bool intel_aet_try_module_get(struct module *mod) +{ + return try_module_get(mod); +} + +static inline void intel_aet_module_put(struct module *mod) +{ + module_put(mod); +} +#else +static inline bool intel_aet_try_module_get(struct module *mod) { return t= rue; } +static inline void intel_aet_module_put(struct module *mod) { } +#endif + #endif /* _ASM_X86_RESCTRL_INTERNAL_H */ diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resct= rl/core.c index 08a229e25883..371d3dfcb506 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -16,10 +16,13 @@ =20 #define pr_fmt(fmt) "resctrl: " fmt =20 +#include +#include #include #include #include #include +#include =20 #include #include @@ -792,12 +795,17 @@ static int resctrl_arch_offline_cpu(unsigned int cpu) return 0; } =20 +static atomic_t resctrl_arch_mount_entries; + 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 (atomic_inc_return(&resctrl_arch_mount_entries) > 1) + return; + + if (!intel_aet_pre_mount()) return; =20 /* @@ -813,6 +821,31 @@ 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 n =3D atomic_dec_return(&resctrl_arch_mount_entries); + int cpu; + + if (n > 0) + return; + + WARN_ON_ONCE(n < 0); + + 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, @@ -1186,8 +1219,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 bc15cf37a7d0..57b19cf8920c 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 @@ -310,7 +310,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; @@ -319,14 +319,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 @@ -359,16 +359,53 @@ void intel_aet_unregister_enumeration(void) } EXPORT_SYMBOL_NS_GPL(intel_aet_unregister_enumeration, "INTEL_PMT"); =20 -void __exit intel_aet_exit(void) +/* + * Track whether pmt_telemetry enumeration succeeded during mount for use + * during unmount. + */ +static bool pmt_in_use; + +bool intel_aet_pre_mount(void) +{ + bool ret; + + guard(mutex)(&aet_register_lock); + if (!get_feature || !put_feature) + return false; + + if (!intel_aet_try_module_get(pmt_module)) + return false; + + ret =3D aet_get_events(); + + if (!ret) + intel_aet_module_put(pmt_module); + else + pmt_in_use =3D true; + + return ret; +} + +void intel_aet_unmount(void) { struct event_group **peg; =20 + guard(mutex)(&aet_register_lock); + if (!pmt_in_use) + return; + for_each_event_group(peg) { - if ((*peg)->pfg) { - intel_pmt_put_feature_group((*peg)->pfg); - (*peg)->pfg =3D NULL; + struct event_group *e =3D *peg; + + if (e->pfg) { + for (int j =3D 0; j < e->num_events; j++) + resctrl_disable_mon_event(e->evts[j].id); + put_feature(e->pfg); + e->pfg =3D NULL; } } + intel_aet_module_put(pmt_module); + pmt_in_use =3D false; } =20 #define DATA_VALID BIT_ULL(63) diff --git a/drivers/resctrl/mpam_resctrl.c b/drivers/resctrl/mpam_resctrl.c index 7079870ca894..5859cc0f5e37 100644 --- a/drivers/resctrl/mpam_resctrl.c +++ b/drivers/resctrl/mpam_resctrl.c @@ -162,6 +162,10 @@ void resctrl_arch_pre_mount(void) { } =20 +void resctrl_arch_unmount(void) +{ +} + bool resctrl_arch_get_cdp_enabled(enum resctrl_res_level rid) { return mpam_resctrl_controls[rid].cdp_enabled; --=20 2.54.0 From nobody Tue Jun 16 19:33:08 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.12]) (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 2F2CF3546E8 for ; Mon, 15 Jun 2026 18:25:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781547919; cv=none; b=fmPbTc740K7J/KWk5uW/d/HEfLTUBa9gkBaQnTYS9KK23vu6pUE1PmupUTnOWzWYsZ37JAbu+QXdVx+lwQ+Ks35A+lxubCywy5cCBJYlJo4UuSbU97+/O5yuT+AU1CQwUxxvmjIVpjad9jQB55WF0deUuk3JVS4Y3bE5GYWK1ds= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781547919; c=relaxed/simple; bh=W0q/LR+GtRRWTrCUuqYhoRcxdKm7RXJuhll57sFPUTk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VmBS8LLefU1R3PiYYxi9QnJaJqEW08EVXxJvxJX6c2zhfTMmR31aqTptgkUIwbSoyAcJSO0kT76YdDsGe+7w72oS1vV0xAfYUS1LW1dhB41Cdfzsd3sbzdGH7mXcJcZ3Y+Dz/GRFZxZWI/IL1MLd6fuUL9S853N8Nrr8OSP3gXk= 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=ioL2Cw9B; arc=none smtp.client-ip=198.175.65.12 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="ioL2Cw9B" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1781547917; x=1813083917; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=W0q/LR+GtRRWTrCUuqYhoRcxdKm7RXJuhll57sFPUTk=; b=ioL2Cw9BroUnDMBe4+NaF32ehxrkf35YPbfy6mBB4T/V5cwGIkU9N60x bbCxG5OIB4njy8xRowPe6AraY6uQwqLimRb1AZ0TPAx5si+2pqcr3TGTA JUdGe68fR/aqT7FjlKnpNFjrKtwB2w4e21d+lHYQdGSTahSirsPVIq8rT RMcFuyNbtisWEl+esdr5NB/AaP4YV42qbTpRF9PQzqWNn2NpZgvNkxEtf M+uKj92xe06vmlzyOMFrUs/YZJiRa+Se9DYzb3Lh3AbX/FswWzOlNXtKw V0rkoecF5SKcpOm50ykXV7UF+kI9d8WDYJid1DnjiU5YyvNOheYdZo6L0 w==; X-CSE-ConnectionGUID: p48AzHNPQq2nItQOGV6ulQ== X-CSE-MsgGUID: yOnS6FGUREesPUG9JzEy8g== X-IronPort-AV: E=McAfee;i="6800,10657,11818"; a="93790046" X-IronPort-AV: E=Sophos;i="6.24,206,1774335600"; d="scan'208";a="93790046" Received: from orviesa007.jf.intel.com ([10.64.159.147]) by orvoesa104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jun 2026 11:25:12 -0700 X-CSE-ConnectionGUID: Qtyql3TrQeCf4FLtOe5S4A== X-CSE-MsgGUID: 5KIqEC6eTweLjoRFzwIC7A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.24,206,1774335600"; d="scan'208";a="247620660" Received: from spandruv-desk1.amr.corp.intel.com (HELO agluck-desk3.intel.com) ([10.124.221.121]) by orviesa007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jun 2026 11:25:12 -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: [PATCH v8 14/16] fs/resctrl: Call architecture hooks for every mount/unmount Date: Mon, 15 Jun 2026 11:24:55 -0700 Message-ID: <20260615182457.14725-15-tony.luck@intel.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260615182457.14725-1-tony.luck@intel.com> References: <20260615182457.14725-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" The intel_pmt module should only be pinned while the resctrl file system is mounted. Add hooks for every mount/unmount of the resctrl file system so that architecture code can increment the intel_pmt module reference count on mount and decrement on unmount. Signed-off-by: Tony Luck --- v8: Remove check for "ret" in rdt_get_tree() error path include/linux/resctrl.h | 2 +- fs/resctrl/rdtgroup.c | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index ace41847da46..e23458bb6e4c 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -554,7 +554,7 @@ 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. + * Architecture hook called before attempting to mount the file system. * No locks are held. */ void resctrl_arch_pre_mount(void); diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c index ee948787f9db..ecb638088896 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -18,7 +18,6 @@ #include #include #include -#include #include #include #include @@ -2998,6 +2997,8 @@ static void resctrl_unmount(void) resctrl_mounted =3D false; mutex_unlock(&rdtgroup_mutex); cpus_read_unlock(); + + resctrl_arch_unmount(); } =20 static int rdt_get_tree(struct fs_context *fc) @@ -3009,7 +3010,7 @@ static int rdt_get_tree(struct fs_context *fc) struct rdt_resource *r; int ret; =20 - DO_ONCE_SLEEPABLE(resctrl_arch_pre_mount); + resctrl_arch_pre_mount(); =20 cpus_read_lock(); mutex_lock(&rdtgroup_mutex); @@ -3148,6 +3149,9 @@ static int rdt_get_tree(struct fs_context *fc) out: mutex_unlock(&rdtgroup_mutex); cpus_read_unlock(); + + resctrl_arch_unmount(); + return ret; } =20 --=20 2.54.0 From nobody Tue Jun 16 19:33:08 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.12]) (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 792B5357CE8 for ; Mon, 15 Jun 2026 18:25:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781547919; cv=none; b=GkHlrY7UFib6p5iHlDKPopnjwrlJknCOBVQWL5r78ZqqsFBxP3/EMa9eQAKFNtFXi6cRTdX1PVgFbmY+8CwN3ngmY4JdcQeGQWCCaFfqpm0bTNBnRHC4lFMqZ9Ccd+JhcrLYz1LNebnFwJAjM6YpO5E6f0A8bj3oT+vDLvwQfv4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781547919; c=relaxed/simple; bh=pAWWzaipgrPxB0ZOrNRgiTDc9Pva08qS32lA3iAp3IQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nFFubjPBFzGlWq0POHpd2b03GfFPWaX/agELCO/aTYQZgcDKP/ziDFLZDmPWFjBD1zhdf/IMyLHm0jHR/uvr76czlMlAcKiilgvsM2EL/8Gu4Ulh4xSMoIsySWM0NdRQWgmWusYwc5nkqOKN+PvrZTRbliGHIyudiWqAQQYiVrc= 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=I/vhFXmc; arc=none smtp.client-ip=198.175.65.12 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="I/vhFXmc" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1781547917; x=1813083917; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=pAWWzaipgrPxB0ZOrNRgiTDc9Pva08qS32lA3iAp3IQ=; b=I/vhFXmcMO0tN9QglgbdjX/G6UmNGbeJh/iLDRUi+5ssh8eXzFWxHiFZ Q3KwFVZZe69wc9ocvfLz63WjG/D12U1TXGjQeJ3zUEe7nDIvwitaSJZmv kotlIZScr7pU2GRvVyezzOJ0rtIHcbveM6UOGtHt5N/tfyS5rBX4+R/WA d29Dflxaxbkmb6w13phPZ26m10A0WJb+RcCK1uso1can6wu2bJ9utHfRy COhIrBwmCDuUcImvaPCKg8GlMqr5DBZOKGI7TMaj21MS5p+RWNr81DEds 1um+7LXDx0Bxvk5vVJeMjmpoTSlxPKCz7QNelCyafbQacr2u2K24uXZ4l w==; X-CSE-ConnectionGUID: AcZeVEeBR1qmdeieVCauww== X-CSE-MsgGUID: HCobORrfTlaowEnm/9P6fw== X-IronPort-AV: E=McAfee;i="6800,10657,11818"; a="93790056" X-IronPort-AV: E=Sophos;i="6.24,206,1774335600"; d="scan'208";a="93790056" Received: from orviesa007.jf.intel.com ([10.64.159.147]) by orvoesa104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jun 2026 11:25:13 -0700 X-CSE-ConnectionGUID: 49apt+lpSNOkDI7zVa+ddQ== X-CSE-MsgGUID: EbOF2gP5RMK+j/EobIcamA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.24,206,1774335600"; d="scan'208";a="247620664" Received: from spandruv-desk1.amr.corp.intel.com (HELO agluck-desk3.intel.com) ([10.124.221.121]) by orviesa007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jun 2026 11:25:12 -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: [PATCH v8 15/16] x86/resctrl: Simplify Kconfig options for resctrl Date: Mon, 15 Jun 2026 11:24:56 -0700 Message-ID: <20260615182457.14725-16-tony.luck@intel.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260615182457.14725-1-tony.luck@intel.com> References: <20260615182457.14725-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" Linus Torvalds complained[1] about Kconfig complexity making it too hard for "random people to build their own kernels". CONFIG_X86_CPU_RESCTRL_INTEL_AET has been causing problems since it was first added as it required other config options to be set to "built-in". AET now resolves PMT symbols at runtime via the registration API, so INTEL_PMT_TELEMETRY no longer needs to be built-in. This means that AET can be included unconditionally as part of X86_CPU_RESCTRL. CONFIG_X86_CPU_RESCTRL now depends on X86_64 because reading telemetry data needs readq(). Signed-off-by: Tony Luck Link: https://lore.kernel.org/all/CAHk-=3Dwhigg3hvOy7c1j1MXFy6o6CHp0g4Tc3Y-= MAk+XDssHU0A@mail.gmail.com # 1 --- arch/x86/include/asm/resctrl.h | 7 ------- arch/x86/kernel/cpu/resctrl/internal.h | 13 ------------- arch/x86/Kconfig | 15 +-------------- arch/x86/kernel/cpu/resctrl/Makefile | 2 +- 4 files changed, 2 insertions(+), 35 deletions(-) diff --git a/arch/x86/include/asm/resctrl.h b/arch/x86/include/asm/resctrl.h index 48ad55bcda66..abb0790e4a4e 100644 --- a/arch/x86/include/asm/resctrl.h +++ b/arch/x86/include/asm/resctrl.h @@ -191,17 +191,10 @@ 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 module *module, 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 module *module, - 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 */ =20 #else =20 diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/r= esctrl/internal.h index a891017f69ec..b50faedede47 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -233,25 +233,12 @@ void __init intel_rdt_mbm_apply_quirk(void); 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_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_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; -} - -static inline void intel_aet_mon_domain_setup(int cpu, int id, struct rdt_= resource *r, - struct list_head *add_pos) { } -static inline bool intel_handle_aet_option(bool force_off, char *tok) { re= turn false; } -#endif =20 #ifdef CONFIG_INTEL_PMT_TELEMETRY_MODULE static inline bool intel_aet_try_module_get(struct module *mod) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index f3f7cb01d69d..77fd5529542a 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -515,7 +515,7 @@ config X86_MPPARSE =20 config X86_CPU_RESCTRL bool "x86 CPU resource control support" - depends on X86 && (CPU_SUP_INTEL || CPU_SUP_AMD) + depends on X86_64 && (CPU_SUP_INTEL || CPU_SUP_AMD) depends on MISC_FILESYSTEMS select ARCH_HAS_CPU_RESCTRL select RESCTRL_FS @@ -536,19 +536,6 @@ config X86_CPU_RESCTRL =20 Say N if unsure. =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 - help - Enable per-RMID telemetry events in resctrl. - - Intel feature that collects per-RMID execution data - about energy consumption, measure of frequency independent - activity and other performance metrics. Data is aggregated - per package. - - Say N if unsure. - config X86_FRED bool "Flexible Return and Event Delivery" depends on X86_64 diff --git a/arch/x86/kernel/cpu/resctrl/Makefile b/arch/x86/kernel/cpu/res= ctrl/Makefile index 273ddfa30836..97ceb4e44dfa 100644 --- a/arch/x86/kernel/cpu/resctrl/Makefile +++ b/arch/x86/kernel/cpu/resctrl/Makefile @@ -1,7 +1,7 @@ # SPDX-License-Identifier: GPL-2.0 obj-$(CONFIG_X86_CPU_RESCTRL) +=3D core.o rdtgroup.o monitor.o obj-$(CONFIG_X86_CPU_RESCTRL) +=3D ctrlmondata.o -obj-$(CONFIG_X86_CPU_RESCTRL_INTEL_AET) +=3D intel_aet.o +obj-$(CONFIG_X86_CPU_RESCTRL) +=3D intel_aet.o obj-$(CONFIG_RESCTRL_FS_PSEUDO_LOCK) +=3D pseudo_lock.o =20 # To allow define_trace.h's recursive include: --=20 2.54.0 From nobody Tue Jun 16 19:33:08 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.12]) (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 D607B372057 for ; Mon, 15 Jun 2026 18:25:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781547920; cv=none; b=aeYiEmGDOg+MHIZJjKQCrZIPm9TJPGS6JhuWg8BLvlWOMHi4giAn0YnLpXaAPNKkiBHMbz9fLfixpMKeFTRePAMlOPSxQDuW3WynwajyKO/fsAic4EmTN2NOSv5DJZw2wVoEFFi02A0SZ4uxkuqU0HAvzeMs+0wiX2YzRLc3XiA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781547920; c=relaxed/simple; bh=lxsJCR217OWgpTb9kVFpj4zf+6hJpTyAdiR9fIcpXPU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=iHIu+6tiOzq1FiJ4P6wJ1ZsdH448YLEb5sd/exBV0PlHj0GfYvPmJA6Xpf0G85/MDlq3W+PsH5OfDsDgvb5O8kvBOBWBhetReilXt3F0bRflpQXnLpEJRF76RFno+WvxsWVhSO61D8YqrPzXfZVu0yLKykCuFubSVSuMSOVeGpo= 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=H5LWY/ip; arc=none smtp.client-ip=198.175.65.12 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="H5LWY/ip" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1781547919; x=1813083919; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=lxsJCR217OWgpTb9kVFpj4zf+6hJpTyAdiR9fIcpXPU=; b=H5LWY/ipsDCJg3piVIu0DtDgyezqnwE0HWwq8UI8ioeVdRldtUl65Q44 4XbEsmmGH96uLOjOZsJwfBKwbJnDynqdvfjYwGv4sUD2vhqgmI1Vw1OR7 d5h050Zmh09sQm7TFEEn0RDpqdqJxMXvqVO90cTpMbreFehObzmSmEUIQ Jvq4HjnZJuQUL1kUpnEXOVoE+CnEOF7xD7u2b2/jgU4rOADLcbsSQlWOd Ihxgx4d5ncmo6D2eSqKngKEy8X70YiRDbPN14o6IYT63KH1yiNeKs2/Pl +9H/Ywhg8rPNeswcTGiKq4Uoty9aZV6t495DPRDgsPZEeIuupRLD/UKdH g==; X-CSE-ConnectionGUID: QFN4gNJgTdiwbdWjmjRlpw== X-CSE-MsgGUID: Wf9BRZoARKWaxI2CU2XpDg== X-IronPort-AV: E=McAfee;i="6800,10657,11818"; a="93790065" X-IronPort-AV: E=Sophos;i="6.24,206,1774335600"; d="scan'208";a="93790065" Received: from orviesa007.jf.intel.com ([10.64.159.147]) by orvoesa104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jun 2026 11:25:13 -0700 X-CSE-ConnectionGUID: UusTBMzJSx6RN6k8E3muKA== X-CSE-MsgGUID: 2DP7jZJGTA6t4ix/TPiR5g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.24,206,1774335600"; d="scan'208";a="247620670" Received: from spandruv-desk1.amr.corp.intel.com (HELO agluck-desk3.intel.com) ([10.124.221.121]) by orviesa007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jun 2026 11:25:13 -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: [PATCH v8 16/16] Documentation/filesystems/resctrl: Add footnote for telemetry fstab mount caveat Date: Mon, 15 Jun 2026 11:24:57 -0700 Message-ID: <20260615182457.14725-17-tony.luck@intel.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260615182457.14725-1-tony.luck@intel.com> References: <20260615182457.14725-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" Add a footnote to the 'If telemetry monitoring is enabled' sentence noting that the PMT driver enumerates telemetry features asynchronously, so an automatic mount of resctrl from /etc/fstab at boot may occur before those features are available, resulting in them not being enabled. The time for enumeration is only a few seconds, so retrying the remount should work. Assisted-by: Claude:Sonnet_4.6 Signed-off-by: Tony Luck --- v8: Added to footnote that a remount should fix Documentation/filesystems/resctrl.rst | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Documentation/filesystems/resctrl.rst b/Documentation/filesyst= ems/resctrl.rst index b003bed339fd..942194beebc8 100644 --- a/Documentation/filesystems/resctrl.rst +++ b/Documentation/filesystems/resctrl.rst @@ -620,7 +620,7 @@ When monitoring is enabled all MON groups will also con= tain: each instance of an L3 cache. Each directory contains files for the enabl= ed L3 events (e.g. "llc_occupancy", "mbm_total_bytes", and "mbm_local_bytes"= ). =20 - If telemetry monitoring is enabled, there will be a "mon_PERF_PKG_YY" + If telemetry monitoring is enabled [#]_, there will be a "mon_PERF_PKG_YY" directory for each physical processor package. Each directory contains files for the enabled telemetry events (e.g. "core_energy". "activity", "uops_retired", etc.) @@ -659,6 +659,11 @@ When monitoring is enabled all MON groups will also co= ntain: returned if the MBM event does not have an assigned counter in the CTRL_MON group nor in any of its associated MON groups. =20 +.. [#] Telemetry features are enumerated asynchronously by the PMT driver.= If + resctrl is automatically mounted from ``/etc/fstab`` at boot, the telem= etry + features may not yet be available at mount time and will therefore not = be + enabled. Remounting a few seconds later should fix this. + "mon_hw_id": Available only with debug option. The identifier used by hardware for the monitor group. On x86 this is the RMID. --=20 2.54.0