From nobody Mon Jun 8 05:25:29 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.21]) (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 EAE66373BE0 for ; Mon, 1 Jun 2026 19:56:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.21 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780343802; cv=none; b=RjB4PuBV8GXuCkjJG59ciwhcDLrgz+OXnxLyHn6rmPy8jOvbGUxGTsV0kMwUtq9nt0I94Lf4psvwlRXLa0gvIvnXrIsDG5Wx4wGdlQfbbWiNtchADMS5mqnUaAeCIQd1WOIvp2U5QOLOeutXu6BRv4Jk0N9iHN0eodINsCzZMP8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780343802; c=relaxed/simple; bh=zPG4u17CSmDapJsSjj03W/tkwWISS3PaKghXdND+0pI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rDLsv/n3GDJOm20llVe7NPW24Yw1f9vlrhCoC9hKs13v6dI/a8lnXmYMAFXPs+ItHBPkhkxqY3BN8R7IiRDwAwhI6NywZ/r7d3/XQD92DXkfFaLKgQixDv3JuOT/gAFpu4pedbj0bgqS7Vyzm/Djyr41APqrd7sR5x2OB0BZmqY= 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=fWa3YD0U; arc=none smtp.client-ip=198.175.65.21 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="fWa3YD0U" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1780343801; x=1811879801; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=zPG4u17CSmDapJsSjj03W/tkwWISS3PaKghXdND+0pI=; b=fWa3YD0UCuOEKimAOWuXbNcwLF98LzZrH8q5Nl2khVYZ4TMtfkBaAfSO DDjbQnV95vCMffc4xUATYXtebo5BbVLHQHIzrZeTAMcyD8HVu6UnCH8Ww flx2zAgno99N2JWLkTAc+JIxG7bl+55ROrQ3vYudircoALjrgJXe7raL+ 5nNbdmd8l1/BOIDaR/HiP8Ddqxwq2t/42akxJvhXqRp1ArOea5fQzw6sT TLAZztN89UyViveLn/WpXud/GPOrc59QE3QQ0yE/D/dpklLTs2dO99y+l yU7SypDE/KDVVVnyMpLR+hWusPA74OOGdiCdz5JD2AQrqTmp1QO3AhIFX g==; X-CSE-ConnectionGUID: B5vghW84SZK5+GarruEjYA== X-CSE-MsgGUID: 5OlJCcjfSYWH1xiOJg7eFA== X-IronPort-AV: E=McAfee;i="6800,10657,11804"; a="81011558" X-IronPort-AV: E=Sophos;i="6.24,181,1774335600"; d="scan'208";a="81011558" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by orvoesa113.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2026 12:56:40 -0700 X-CSE-ConnectionGUID: fpnQP2SVTrSXGloqeKVDOg== X-CSE-MsgGUID: ysw3RAWaQ1CZupdO/ev81Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.24,181,1774335600"; d="scan'208";a="247946489" Received: from lstrano-mobl6.amr.corp.intel.com (HELO agluck-desk3.home.arpa) ([10.124.221.168]) by orviesa004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2026 12:56:39 -0700 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Maciej Wieczor-Retman , Peter Newman , James Morse , Babu Moger , Drew Fustini , Dave Martin , Chen Yu , David E Box , x86@kernel.org Cc: Christoph Hellwig , linux-kernel@vger.kernel.org, patches@lists.linux.dev, Tony Luck , Ben Horgan Subject: [PATCH v7 01/14] fs/resctrl: Move functions to avoid forward references in subsequent fixes Date: Mon, 1 Jun 2026 12:56:19 -0700 Message-ID: <20260601195632.15876-2-tony.luck@intel.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260601195632.15876-1-tony.luck@intel.com> References: <20260601195632.15876-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: Reinette Chatre Signed-off-by: Tony Luck 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 Mon Jun 8 05:25:29 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.21]) (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 494F236F8E6 for ; Mon, 1 Jun 2026 19:56:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.21 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780343803; cv=none; b=bpmzUxVfkISYcxo6iJELehv2uF9tsnzpXnYpV2T4Bwo74/bJhr51B/nsLdGpJKrQEl1QhfGCIHtwQfD4jyr8qQsd4Qk/HMvf0jzZlKk0lpK8+dUbP3XoUmubBZ2HQaRsdWAT71G6RYjegEJ8DmE1PGU0lQhNtNVsDHrpj//mtfY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780343803; c=relaxed/simple; bh=TKc6gWppFBsDVx6x4J5vR8ORMiG/xUxRFM8fxE7zof4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=D4PTMQU4MN0Ah4Y3K5ckat+34A22VkGBcaqOyt/3CID5cHQBPhZvqgb4saSvMcPz9AFJgxTmEI1ENGR9bPcS5io/t1F8v2JBmKuGwsFI54lKxdbrChNIZ6ycvM81ShFkd3PtkjP/ZSulQqTOC06RqWrhUWwxDD5rEbf2SBnP7c0= 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=lDT9mPTA; arc=none smtp.client-ip=198.175.65.21 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="lDT9mPTA" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1780343803; x=1811879803; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=TKc6gWppFBsDVx6x4J5vR8ORMiG/xUxRFM8fxE7zof4=; b=lDT9mPTAbeziW1w4b/ASZX5tMz3pN8S3QK27MyM61JDEhIfqLeCakRkD XyUHloB05HaBSJIYPRbScRtQhypTwNVZ+YCnIoEy9LoPoFfrneywiOVwo VLiRTRpLyjDnM4NiRdA6rhGfK0JK6zXh/BKiFYQTZphQ0G6PKm1oxoiSY Wp+tM9YNuqJGrr4HnDYtrRQCXboeOQ7iRh2j438shb8zYUgna0HAP56s5 a/HMC/BK2ipa6CytlkVWeujIT4P45yJD3D4BecuzEqmVqOXbfAXNs8MXi lrqHQXEO8X6V451l/7Uu6PR3U0E4bDCXw2ox5gEPlt/kUtoDfpHWmLuce g==; X-CSE-ConnectionGUID: 4HiRB+hoS/OteeHNkEMpXA== X-CSE-MsgGUID: lpwa9FXCR0aGx6ecZAh5yg== X-IronPort-AV: E=McAfee;i="6800,10657,11804"; a="81011567" X-IronPort-AV: E=Sophos;i="6.24,181,1774335600"; d="scan'208";a="81011567" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by orvoesa113.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2026 12:56:41 -0700 X-CSE-ConnectionGUID: zfxHr8X9S4GzqSysE6NxjA== X-CSE-MsgGUID: Y5M5YCjSTsauvDSib0OTPw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.24,181,1774335600"; d="scan'208";a="247946493" Received: from lstrano-mobl6.amr.corp.intel.com (HELO agluck-desk3.home.arpa) ([10.124.221.168]) by orviesa004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2026 12:56:39 -0700 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Maciej Wieczor-Retman , Peter Newman , James Morse , Babu Moger , Drew Fustini , Dave Martin , Chen Yu , David E Box , x86@kernel.org Cc: Christoph Hellwig , linux-kernel@vger.kernel.org, patches@lists.linux.dev, Tony Luck , Ben Horgan Subject: [PATCH v7 02/14] fs/resctrl: Free mon_data structures on rdt_get_tree() failure Date: Mon, 1 Jun 2026 12:56:20 -0700 Message-ID: <20260601195632.15876-3-tony.luck@intel.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260601195632.15876-1-tony.luck@intel.com> References: <20260601195632.15876-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 Signed-off-by: Reinette Chatre Signed-off-by: Tony Luck Reviewed-by: Ben Horgan Reviewed-by: Chen Yu --- 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 Mon Jun 8 05:25:29 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.21]) (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 9060337CD4E for ; Mon, 1 Jun 2026 19:56:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.21 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780343804; cv=none; b=alIHuLAYxZ4qTh/Ys3D3gDBsm3kDahsKWJSYqvURRJ6dJcLs7o8emk+nQQXoEsZIXsso5e+n9jGsYt+waN+f3DB/726XD5SV4+zlgaJYTgUuG4Q0DchJ8rJvfg5ssn9kP7WyCIrg42DduOmZK9pBj6l4iFw3u76k8pQdYIsy4KI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780343804; c=relaxed/simple; bh=KWzZiN4PnLBKT0ZxCr2BGbKILpgQE+52KEovuBGUNfc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=eIGqIgKnCPDVEYT8B/2kDWzvUQQkY4C7sUSrqCfmJ1XZqDQ/lgilk5x/oZBpdDVYyXpMJC1xyxcC3CohdacE/ToL0E+wWmwcj9EfBTu4PvApaPswQxopmgQ1X4eHEHI+x1o9aXASkA+Yd/Dm2nMwe/VLZMtjyJj+AuHGeF5tNFc= 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=gY1KPrFO; arc=none smtp.client-ip=198.175.65.21 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="gY1KPrFO" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1780343803; x=1811879803; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=KWzZiN4PnLBKT0ZxCr2BGbKILpgQE+52KEovuBGUNfc=; b=gY1KPrFO9UitqL4GvMD6DOm1hZW04QBjI2E2NHdmgEyP/hidIrNuD7WL XiQPRuhMuMcYLhjcN12YjCWr0JHteTiaHsM9BkoyUvX0STKrjzoKb9MvJ W2FraiXq6ONbvvXusNft9090UOb5y9W58snDGU1Ggrk9BzvZdexDGXzwd 5yRi4u/x/T5SmBHwg3ii6GBTG44X0EnVqqJk33dXBqBgLrM1k1idH+5VL pkiYpzrVfPVGeB891ysFSluhqSMa+RP3YWVsxC+MzC/QC4deZczqsq6ZY tED5RWRjw19+zMdYRQN2KBOFMs4OcUKmTk77VEbtk02BP3aGsf8fXNaIL A==; X-CSE-ConnectionGUID: MLuDO8lIRbKg/abRsZDhog== X-CSE-MsgGUID: QCPd043aTea/4SQlQWv/JQ== X-IronPort-AV: E=McAfee;i="6800,10657,11804"; a="81011576" X-IronPort-AV: E=Sophos;i="6.24,181,1774335600"; d="scan'208";a="81011576" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by orvoesa113.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2026 12:56:41 -0700 X-CSE-ConnectionGUID: rnaDRR4rTHGNFIuff739MA== X-CSE-MsgGUID: AB3hqHX5S+m7P6b0ZDXrHA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.24,181,1774335600"; d="scan'208";a="247946496" Received: from lstrano-mobl6.amr.corp.intel.com (HELO agluck-desk3.home.arpa) ([10.124.221.168]) by orviesa004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2026 12:56:40 -0700 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Maciej Wieczor-Retman , Peter Newman , James Morse , Babu Moger , Drew Fustini , Dave Martin , Chen Yu , David E Box , x86@kernel.org Cc: Christoph Hellwig , linux-kernel@vger.kernel.org, patches@lists.linux.dev, Tony Luck , Sashiko Subject: [PATCH v7 03/14] fs/resctrl: Fix use-after-free during unmount Date: Mon, 1 Jun 2026 12:56:21 -0700 Message-ID: <20260601195632.15876-4-tony.luck@intel.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260601195632.15876-1-tony.luck@intel.com> References: <20260601195632.15876-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. Set RDT_DELETED for the default group unconditionally since the flag does not lead to free 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: Reinette Chatre Signed-off-by: Tony Luck 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 Mon Jun 8 05:25:29 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.21]) (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 A507337D10A for ; Mon, 1 Jun 2026 19:56:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.21 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780343804; cv=none; b=CuLrBxDfeL2Gw2Us/IXIdt9g6T0mvlvfLDkfT/q3iLoTX6kF7Hvn9zxfEqMhIHZU9fRLCmvakcp/TyfzAKVRFEzvRTSwhaAo3ylE3wzuk1yw5MoWktjo7g5ul8G1SMfVGqhJ55CUhG8+4afxGz9qBnU/jjWQp+HdFN0wDEb4Xio= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780343804; c=relaxed/simple; bh=mwI/yhmgeN5/52KEyoVb6JwFkIjGCcVHBKa4n3GiI4Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lypPFfLFRVNnnnEj2mF2VBzEu7nUlHNSjUkKahMxJjuQnsDIcr3STzHdM23A2o4DDnMHhcMHANnLCW9BUS84WWpAamh/VRL86rcb+8sY79mEiqfEkZ8kUkNLmeIryI9dp/s/hipNTQjnbrboF4LQqNkK8UTxQxcLjqq0Qb/gfHw= 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=Gr5WipBH; arc=none smtp.client-ip=198.175.65.21 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="Gr5WipBH" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1780343803; x=1811879803; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=mwI/yhmgeN5/52KEyoVb6JwFkIjGCcVHBKa4n3GiI4Y=; b=Gr5WipBHaiTDy6d9tZoLC7IMUTp/hcQam9dui3hE0M6Gu+bXkF2g7ATD HWZJs0T6gKkBR2GeyC6jBbVJlIgFnfSLteYjAN9xbSK/NptDxXizt+3oH kGI+scGSwd+3GEQ/4hfDbEZhwqleXIQ2/rhkqQpmbNQcMe+ELGjVsWogL lZl0acSPliNAPUKAB1LKOAH+/3BYLM005cpSnkOXjMRSRizDoHquQpwRl BSAeH7EaVaYz5KgiG/nbRrHmPwOav8ms4cUuxf7YR9wHKgkOtUXbP6WsK IKmSyb4hLOdEv9N9E9J12QMG5/gX8IO+pqWPNrOzZW3E8gz3CNaExp40B A==; X-CSE-ConnectionGUID: iwgmc3UiSLi35YPJZ71msQ== X-CSE-MsgGUID: 4mHIv+AhQH+e6JjP/oSMiA== X-IronPort-AV: E=McAfee;i="6800,10657,11804"; a="81011586" X-IronPort-AV: E=Sophos;i="6.24,181,1774335600"; d="scan'208";a="81011586" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by orvoesa113.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2026 12:56:41 -0700 X-CSE-ConnectionGUID: q0n2xr5jSnGO8/6ZNb5cQw== X-CSE-MsgGUID: a13zFb1PT/O1PAvg970IIA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.24,181,1774335600"; d="scan'208";a="247946499" Received: from lstrano-mobl6.amr.corp.intel.com (HELO agluck-desk3.home.arpa) ([10.124.221.168]) by orviesa004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2026 12:56:40 -0700 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Maciej Wieczor-Retman , Peter Newman , James Morse , Babu Moger , Drew Fustini , Dave Martin , Chen Yu , David E Box , x86@kernel.org Cc: Christoph Hellwig , linux-kernel@vger.kernel.org, patches@lists.linux.dev, Sashiko , Tony Luck , Ben Horgan Subject: [PATCH v7 04/14] fs/resctrl: Fix deadlock for errors during mount Date: Mon, 1 Jun 2026 12:56:22 -0700 Message-ID: <20260601195632.15876-5-tony.luck@intel.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260601195632.15876-1-tony.luck@intel.com> References: <20260601195632.15876-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 on the same thread before the call returns. rdt_kill_sb() unconditionally attempts to acquire rdtgroup_mutex and deadlock occurs. Move the call to 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. Add an extra hold in this error path on rdtgroup_default.kn to defend again= st other races destroying the root which is then dereferenced in kernfs_kill_s= b() Add resctrl_unmount() helper to keep code consistent between the rdt_get_tree() failure path and a normal unmount. 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: Reinette Chatre Signed-off-by: Tony Luck Reviewed-by: Chen Yu Reviewed-by: Ben Horgan --- fs/resctrl/rdtgroup.c | 82 +++++++++++++++++++++++++++++-------------- 1 file changed, 55 insertions(+), 27 deletions(-) diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c index ac3285ba8775..d2a1f88d8782 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,37 @@ static int rdt_get_tree(struct fs_context *fc) RESCTRL_PICK_ANY_CPU); } =20 - goto out; + /* + * Ensure root kn 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. + */ + 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 fr= eed + * 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 o= verwritten + * 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 +3145,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 +3231,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 Mon Jun 8 05:25:29 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.21]) (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 9113F37DAB5 for ; Mon, 1 Jun 2026 19:56:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.21 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780343806; cv=none; b=VZanks+Hp5KLg8KYlwZAUag66KpeSzpngcfyswUqZcCK09wGBKEb1p01RKC5BkPQdfUHoKI9kizX78grqZOuRzmslSmMtl+ZFyRyKD123Ha+LVBstBO/cPL3KMEx1wwOBMytZjsAPjn8RUW9C9SC8cIDO46veSn7++K0E3mWr24= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780343806; c=relaxed/simple; bh=2yRBZq0wNgcv23WH3tFU/B6WYYBVM9uDMjWdCDryFvM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gpKDWMO8pXrbISLP0zwiP3ctGWlbEhlX4djposXmFNcuRUuZX7d4uzxEJdKhgQpniz6Tp8xkpxBgOCo79Wwp2AuMeAAtZzFrCLaYF6nfwZhbgD6aER/h4AZKYWii6QQRLfvzY95valnJOqe5EMT4DjrAz2FSz10jg5wLR8QcNn8= 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=dY7i5mAv; arc=none smtp.client-ip=198.175.65.21 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="dY7i5mAv" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1780343804; x=1811879804; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=2yRBZq0wNgcv23WH3tFU/B6WYYBVM9uDMjWdCDryFvM=; b=dY7i5mAvccK4oo1MCFDOuQA5i92uTc0F/QiBAC8KGEF9JSNZPJmKJgNZ cdX4D9Dvj1JkicSVNIUUz/h/0uRZaIfqZxd+pFXoCcp0XYaabtXJ6JL6+ rMIURXpCb5ZHyknyk/wgv07qXqkpkWJ+kqV2JVMFEX300P4qVESqZwgtT /Wsb0m++zdxbRWPd7Lm7pV0dRjnFG6jiASX1wgahUctb6y4XlBuIEvR83 yK8Xkl7rWpjoQedOSFM+HO9lQEQPONZHw2aUV8UHZ9rIb5Fb3B27oeFJ6 DF8Z1vDzH9YAPIe8tEWv4EgSJxtZuCnPJnD2smaJk0X9EmQ7nAwaOEJgp Q==; X-CSE-ConnectionGUID: OL5w5qyETHSOAMS3eCwgVw== X-CSE-MsgGUID: wEOxbENhR4+MjHdz+PL9lg== X-IronPort-AV: E=McAfee;i="6800,10657,11804"; a="81011595" X-IronPort-AV: E=Sophos;i="6.24,181,1774335600"; d="scan'208";a="81011595" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by orvoesa113.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2026 12:56:42 -0700 X-CSE-ConnectionGUID: HvpD4iFwSDqR6yT5lC/1DA== X-CSE-MsgGUID: nyzngwtaRdeLzvPMBaZmng== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.24,181,1774335600"; d="scan'208";a="247946503" Received: from lstrano-mobl6.amr.corp.intel.com (HELO agluck-desk3.home.arpa) ([10.124.221.168]) by orviesa004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2026 12:56:41 -0700 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Maciej Wieczor-Retman , Peter Newman , James Morse , Babu Moger , Drew Fustini , Dave Martin , Chen Yu , David E Box , x86@kernel.org Cc: Christoph Hellwig , linux-kernel@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [PATCH v7 05/14] x86/resctrl: Stop setting event_group::force_off on RMID shortage Date: Mon, 1 Jun 2026 12:56:23 -0700 Message-ID: <20260601195632.15876-6-tony.luck@intel.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260601195632.15876-1-tony.luck@intel.com> References: <20260601195632.15876-1-tony.luck@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Drop the force_off assignment from all_regions_have_sufficient_rmid(). This preserves current single-enumeration behaviour while preparing for the upcoming per-mount enumeration, where latching force_off would incorrectly suppress re-enumeration on subsequent mounts - even when the user explicitly requested the feature via "rdt=3D{feature}". Signed-off-by: Tony Luck --- arch/x86/kernel/cpu/resctrl/intel_aet.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/intel_aet.c b/arch/x86/kernel/cpu/= resctrl/intel_aet.c index 89b8b619d5d5..e2af700bca04 100644 --- a/arch/x86/kernel/cpu/resctrl/intel_aet.c +++ b/arch/x86/kernel/cpu/resctrl/intel_aet.c @@ -60,8 +60,8 @@ struct pmt_event { * data for all telemetry regions of type @pfname. * Valid if the system supports the event group, * NULL otherwise. - * @force_off: True when "rdt" command line or architecture code disables - * this event group due to insufficient RMIDs. + * @force_off: True when "rdt" command line disables this event group + * to avoid system limitations due to insufficient RMIDs. * @force_on: True when "rdt" command line overrides disable of this * event group. * @guid: Unique number per XML description file. @@ -214,10 +214,8 @@ static bool all_regions_have_sufficient_rmid(struct ev= ent_group *e, struct pmt_f if (!p->regions[i].addr) continue; tr =3D &p->regions[i]; - if (tr->num_rmids < e->num_rmid) { - e->force_off =3D true; + if (tr->num_rmids < e->num_rmid) return false; - } } =20 return true; --=20 2.54.0 From nobody Mon Jun 8 05:25:29 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.21]) (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 11E973BB105 for ; Mon, 1 Jun 2026 19:56:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.21 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780343814; cv=none; b=rrfi42UreIHdDAEcUQiS7eRuOVmPI/VRLffzXynYaD67Kgl7Q/wxTMdUbKE1cOwcF51J0iLp3fANAxN8ah2Ykw1lnW9oqG9jzx/PFqtzZKOwjkl7xG/hzK5n4Zu++iR0ivW7T5uY4cArcCfK5JFApOcM8fsdOsEaMCuYd6e7ySc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780343814; c=relaxed/simple; bh=gn29ksqcgLqQx3BYgdSXJ9a+ZmiZ8zoguD3IHim5rWE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HM5yWhGtBXYe4QWJjDEX3zzTs39CLMTv1i7WdtIUhc8/gLucs305kmhVYejzFEP12cX2zqlGI3E5qUnMU7hA7GQ247tWCQVpvopzJBXcqmkDVOR/+GOST2fpf+I97w7XPJ9ucxOy5PhBjYKNZlZXNn4jbAdtCvOFh+1BIG8OLLc= 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=bicUM6zt; arc=none smtp.client-ip=198.175.65.21 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="bicUM6zt" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1780343805; x=1811879805; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=gn29ksqcgLqQx3BYgdSXJ9a+ZmiZ8zoguD3IHim5rWE=; b=bicUM6ztmh2LVCK/X0FiGKXg1Br65CqwQ5v1W5JlVfxkoC3Y3PBKzIwE xUwZIvHpdmxvquq9NLOQLr2ZaLmTwhJ26YkG5wpnpkZz7WxBo+RhgOwue BAxhTP/sQ9NVGd0RM15B8Ir3oXMkTv3PBpPxrIXLK1C5lzyLmPrQFvQLq DndBanhuQEVGzHJOORFwoeKx4v6n+9zDwRF0RNrcFlljhaf5LJLlSRHl0 Z2FhrMozwGmTZcQDESAccgU5+lZ1FimhnxfIVVlYuxcNDal45msHLRYmC 20mqgxOJt/k7n1qTLIBGqrOQomCt+Hfg/onKKT2cuZFs/0yhlY9THnen4 g==; X-CSE-ConnectionGUID: YZpsiv90Theuk83boPuTHg== X-CSE-MsgGUID: M+nLh2VCQ3KA9QCAbLEX7w== X-IronPort-AV: E=McAfee;i="6800,10657,11804"; a="81011605" X-IronPort-AV: E=Sophos;i="6.24,181,1774335600"; d="scan'208";a="81011605" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by orvoesa113.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2026 12:56:42 -0700 X-CSE-ConnectionGUID: XoVOOPm+QiSh/JsmGuH/RQ== X-CSE-MsgGUID: 0QIUE/lpQ+eFQUWTF6K1Qg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.24,181,1774335600"; d="scan'208";a="247946507" Received: from lstrano-mobl6.amr.corp.intel.com (HELO agluck-desk3.home.arpa) ([10.124.221.168]) by orviesa004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2026 12:56:41 -0700 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Maciej Wieczor-Retman , Peter Newman , James Morse , Babu Moger , Drew Fustini , Dave Martin , Chen Yu , David E Box , x86@kernel.org Cc: Christoph Hellwig , linux-kernel@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [PATCH v7 06/14] fs/resctrl: Add interface to disable a monitor event Date: Mon, 1 Jun 2026 12:56:24 -0700 Message-ID: <20260601195632.15876-7-tony.luck@intel.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260601195632.15876-1-tony.luck@intel.com> References: <20260601195632.15876-1-tony.luck@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" In preparation for re-running AET enumeration on every mount, AET code must= be able to disable events on unmount so the next mount starts from a clean sla= te. Add a file system interface for architecture to clear the enabled flag for a given event. Add kerneldoc comments to describe limitations on when events may be enabled or disabled. Signed-off-by: Tony Luck --- include/linux/resctrl.h | 34 ++++++++++++++++++++++++++++++++++ fs/resctrl/monitor.c | 12 ++++++++++++ 2 files changed, 46 insertions(+) diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index 006e57fd7ca5..a8338656f836 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -414,9 +414,43 @@ u32 resctrl_arch_get_num_closid(struct rdt_resource *r= ); u32 resctrl_arch_system_num_rmid_idx(void); int resctrl_arch_update_domains(struct rdt_resource *r, u32 closid); =20 +/** + * resctrl_enable_mon_event() - Enable monitoring event + * @eventid: ID of the event + * @any_cpu: True if event data can be read from any CPU. + * @binary_bits:Number of binary places of the fixed-point value expected = to + * back a floating point event. Can only be set for floating point + * events. + * @arch_priv: Architecture private data associated with event. Passed ba= ck to + * architecture when reading the event via resctrl_arch_rmid_read(). + * + * The file system must not be mounted when enabling an event. + * + * Events that require per-domain (architectural and/or filesystem) state = must + * be enabled before the domain structures are allocated. For example befo= re + * CPU hotplug callbacks that allocate domain structures are registered. I= f the + * architecture discovers a resource after initialization it should enable + * events needing per-domain state before any domain structure allocation = which + * should be coordinated with the CPU hotplug callbacks. + * + * Return: + * true if event was successfully enabled, false otherwise. + */ bool resctrl_enable_mon_event(enum resctrl_event_id eventid, bool any_cpu, unsigned int binary_bits, void *arch_priv); =20 +/** + * resctrl_disable_mon_event() - Disable monitoring event + * @eventid: ID of the event + * + * The file system must not be mounted when disabling an event. + * + * Events that require per-domain (architectural and/or filesystem) state + * will require additional cleanup which should be coordinated with the CPU + * hotplug callbacks. + */ +void resctrl_disable_mon_event(enum resctrl_event_id eventid); + bool resctrl_is_mon_event_enabled(enum resctrl_event_id eventid); =20 bool resctrl_arch_is_evt_configurable(enum resctrl_event_id evt); diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c index 9fd901c78dc6..327e7a863614 100644 --- a/fs/resctrl/monitor.c +++ b/fs/resctrl/monitor.c @@ -1012,6 +1012,18 @@ bool resctrl_enable_mon_event(enum resctrl_event_id = eventid, bool any_cpu, return true; } =20 +void resctrl_disable_mon_event(enum resctrl_event_id eventid) +{ + if (WARN_ON_ONCE(eventid < QOS_FIRST_EVENT || eventid >=3D QOS_NUM_EVENTS= )) + return; + if (!mon_event_all[eventid].enabled) { + pr_warn("Repeat disable for event %d\n", eventid); + return; + } + + mon_event_all[eventid].enabled =3D false; +} + bool resctrl_is_mon_event_enabled(enum resctrl_event_id eventid) { return eventid >=3D QOS_FIRST_EVENT && eventid < QOS_NUM_EVENTS && --=20 2.54.0 From nobody Mon Jun 8 05:25:29 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.21]) (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 127063BED69 for ; Mon, 1 Jun 2026 19:56:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.21 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780343814; cv=none; b=MHtP7RklR/sY0NQSwCTIbfUuB1JTYibF0/M3992Gb1B7L7TKY29EVyL/sZ73BbpLkMDFPfE2sa1TOiKcFhV8oFT/mkXA32owfPLaE4zUnWNMNmNyLVFhfEeoOUEuUA9WcrFw+vyEbenjqfwhVJDdM8QRIAgO1aFJmsyPqSahGe0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780343814; c=relaxed/simple; bh=5woIoOc43z2dzYZgi/fPqVTgZV6nkyOwMkU2OHyiCx0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KkbimZjDPhqYumMMG2NPrRM5AvFRXtGWWK4a1kyxT0dKbTjgDlZh//4ackrbialeCE9x6pJK1WhjSYvbNABwFQB8ETmgTePmQQ9t6VUknuGT1B3Y8kpVtWtE3EVpeCr/KReS2EbAc6k6zeNzOaxLBx/165cm66vslRzi4sZ1MkU= 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=nrGl9hzz; arc=none smtp.client-ip=198.175.65.21 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="nrGl9hzz" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1780343805; x=1811879805; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=5woIoOc43z2dzYZgi/fPqVTgZV6nkyOwMkU2OHyiCx0=; b=nrGl9hzzeQ3X896jS5WtvYXE9Q/j6A1pPL8oERvt8F7bxt47uHC4hRhH NH6De1joZjwYocbqrjVadRPzFnisrqew5DPBeWFAFr6TD0pqp2xKkiTee 1KBWVI4gL8V29IRbZ8LboDPv2bg7pHFn6GoJonei4mDOD2BAeIqZ2s2Ir uGRhucxX0byZbpML8mF8w56kcutbxYnui1vXkEavxwFsGBUeAs9tFQnDT B5iOg6FJwnYI0hT3nx0gcLhawfmrRv9FxDoAS31Qq+rfTayIs4mZvouNG B/vzKUUS2skbVjFBXw2AXUb/iJsa8Gzbp6ITxlWGnsnVc03Tcn6mN2ekZ A==; X-CSE-ConnectionGUID: T3MmNAi3SI2EJMhsAcAehQ== X-CSE-MsgGUID: 7oQ2QA/3RSeidQXsCruLsg== X-IronPort-AV: E=McAfee;i="6800,10657,11804"; a="81011615" X-IronPort-AV: E=Sophos;i="6.24,181,1774335600"; d="scan'208";a="81011615" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by orvoesa113.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2026 12:56:43 -0700 X-CSE-ConnectionGUID: wXWD48CBS5+gnTBjaV2KlQ== X-CSE-MsgGUID: w5wqfjKYSKi/ShwzlBy54w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.24,181,1774335600"; d="scan'208";a="247946511" Received: from lstrano-mobl6.amr.corp.intel.com (HELO agluck-desk3.home.arpa) ([10.124.221.168]) by orviesa004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2026 12:56:42 -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 v7 07/14] x86/resctrl: Maintain a count of enabled monitor features Date: Mon, 1 Jun 2026 12:56:25 -0700 Message-ID: <20260601195632.15876-8-tony.luck@intel.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260601195632.15876-1-tony.luck@intel.com> References: <20260601195632.15876-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" AET (Application Energy Telemetry) may be enabled/disabled from one mount to the next depending on whether the pmt_telemetry module is loaded. If AET is the only monitoring feature supported on a system and it is enabled in one mount, but disabled in a subsequent mount this will result in empty mon_data directories. Change from a boolean to a count of enabled monitor features inside architecture code. File system code only needs to know if any monitor features are enabled so resctrl_arch_mon_capable() can still return boolean. Signed-off-by: Tony Luck --- arch/x86/include/asm/resctrl.h | 4 ++-- arch/x86/kernel/cpu/resctrl/internal.h | 2 +- arch/x86/kernel/cpu/resctrl/core.c | 24 +++++++++++++----------- arch/x86/kernel/cpu/resctrl/monitor.c | 11 +++-------- 4 files changed, 19 insertions(+), 22 deletions(-) diff --git a/arch/x86/include/asm/resctrl.h b/arch/x86/include/asm/resctrl.h index 575f8408a9e7..1e50c7dc3fe3 100644 --- a/arch/x86/include/asm/resctrl.h +++ b/arch/x86/include/asm/resctrl.h @@ -43,7 +43,7 @@ struct resctrl_pqr_state { DECLARE_PER_CPU(struct resctrl_pqr_state, pqr_state); =20 extern bool rdt_alloc_capable; -extern bool rdt_mon_capable; +extern int rdt_mon_feature_count; =20 DECLARE_STATIC_KEY_FALSE(rdt_enable_key); DECLARE_STATIC_KEY_FALSE(rdt_alloc_enable_key); @@ -68,7 +68,7 @@ static inline void resctrl_arch_disable_alloc(void) =20 static inline bool resctrl_arch_mon_capable(void) { - return rdt_mon_capable; + return !!rdt_mon_feature_count; } =20 static inline void resctrl_arch_enable_mon(void) diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/r= esctrl/internal.h index e3cfa0c10e92..3b09cfe9a046 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -224,7 +224,7 @@ union l3_qos_abmc_cfg { =20 void rdt_ctrl_update(void *arg); =20 -int rdt_get_l3_mon_config(struct rdt_resource *r); +void rdt_get_l3_mon_config(struct rdt_resource *r); =20 bool rdt_cpu_has(int flag); =20 diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resct= rl/core.c index 7667cf7c4e94..1af8f965fdd0 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -779,7 +779,7 @@ void resctrl_arch_pre_mount(void) cpus_read_lock(); mutex_lock(&domain_list_lock); r->mon_capable =3D true; - rdt_mon_capable =3D true; + rdt_mon_feature_count++; for_each_online_cpu(cpu) domain_add_cpu_mon(cpu, r); mutex_unlock(&domain_list_lock); @@ -959,30 +959,32 @@ static __init bool get_rdt_alloc_resources(void) return ret; } =20 -static __init bool get_rdt_mon_resources(void) +static __init int get_rdt_mon_resources(void) { struct rdt_resource *r =3D &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl; - bool ret =3D false; + int ret =3D 0; =20 if (rdt_cpu_has(X86_FEATURE_CQM_OCCUP_LLC)) { resctrl_enable_mon_event(QOS_L3_OCCUP_EVENT_ID, false, 0, NULL); - ret =3D true; + ret++; } if (rdt_cpu_has(X86_FEATURE_CQM_MBM_TOTAL)) { resctrl_enable_mon_event(QOS_L3_MBM_TOTAL_EVENT_ID, false, 0, NULL); - ret =3D true; + ret++; } if (rdt_cpu_has(X86_FEATURE_CQM_MBM_LOCAL)) { resctrl_enable_mon_event(QOS_L3_MBM_LOCAL_EVENT_ID, false, 0, NULL); - ret =3D true; + ret++; } if (rdt_cpu_has(X86_FEATURE_ABMC)) - ret =3D true; + ret++; =20 if (!ret) - return false; + return 0; =20 - return !rdt_get_l3_mon_config(r); + rdt_get_l3_mon_config(r); + + return ret; } =20 static __init void __check_quirks_intel(void) @@ -1013,9 +1015,9 @@ 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(); + rdt_mon_feature_count =3D get_rdt_mon_resources(); =20 - return (rdt_mon_capable || rdt_alloc_capable); + return (rdt_mon_feature_count || 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 9bd87bae4983..497cc57ac135 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -25,11 +25,8 @@ =20 #include "internal.h" =20 -/* - * Global boolean for rdt_monitor which is true if any - * resource monitoring is enabled. - */ -bool rdt_mon_capable; +/* Global count of number of resource monitor functions that are enabled. = */ +int rdt_mon_feature_count; =20 #define CF(cf) ((unsigned long)(1048576 * (cf) + 0.5)) =20 @@ -402,7 +399,7 @@ static __init int snc_get_config(void) return ret; } =20 -int __init rdt_get_l3_mon_config(struct rdt_resource *r) +void __init rdt_get_l3_mon_config(struct rdt_resource *r) { unsigned int mbm_offset =3D boot_cpu_data.x86_cache_mbm_width_offset; struct rdt_hw_resource *hw_res =3D resctrl_to_arch_res(r); @@ -460,8 +457,6 @@ int __init rdt_get_l3_mon_config(struct rdt_resource *r) } =20 r->mon_capable =3D true; - - return 0; } =20 void __init intel_rdt_mbm_apply_quirk(void) --=20 2.54.0 From nobody Mon Jun 8 05:25:29 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.21]) (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 E05AC3B95F9 for ; Mon, 1 Jun 2026 19:56:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.21 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780343815; cv=none; b=r5E59hjsMJtq7VG+UIpvkDkfAWlpR6DzW+SpcJe6MYyYBkXwSN82SDgchPY8UaIhZE6svr3efneoC74W153MVoOoFi4lbEqNUqI9sdp9Oj4w7yhNdcOWVICVIaY6w7InuVlQkDYQG5J7WestP9G2ZMEi1mSj6gf5tNGxC5rAno4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780343815; c=relaxed/simple; bh=nCYc6fH1RLD1MGo78gaYDpKcyUShs28yNo/4DjBwTPs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XnCEbTytG5pwOvroGk5dcjFQKjz2hgvLCpp+VMSTlhYWGPEk9xxy/XIuTX24emTXvTFPLGfZ4S4758D2ea133VN90UhAJqmXk2080miLQuH5DRTTRbaqZ551W9zPMprY1migiW9UxzB0E/Ba6VLWEguuhFn/mcImzyC1cf53aPc= 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=evXrOfQa; arc=none smtp.client-ip=198.175.65.21 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="evXrOfQa" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1780343807; x=1811879807; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=nCYc6fH1RLD1MGo78gaYDpKcyUShs28yNo/4DjBwTPs=; b=evXrOfQaxP4TR6jD8iwEdcKY1zrCGlQiALcqVcEyl3Q8VtGtFhCE61/E ZVsjDHWsIl4lbwGz8p8bCYXyu/U+PM/41EFJb6fWw49cjWBn1bhJ0xIVk nsJyBdqgNctB8zdXos4MxYE/OxyRaaDPOK5nnpdkDL9OP7wf+2z8xQQ5l xPmgf/tBmpR16+ANLvdPOERZde92N6hzfhFzOnPo0hTzVwL+R6uu1cjzI Sx5BtL0kNhUEOt1U/5Y1KQHn90r/dmAPJoZLSuyUrz+HWqrPmTAOF9YJs 8C3GtN1JEpiCn09t/riwVikwSvW2N+/fPd24g/cxWAJi1aDWqAavJt85Z w==; X-CSE-ConnectionGUID: SuYRDu8NRJml3O77HanaHw== X-CSE-MsgGUID: A7cTZVzvQRe1mWH+BwDsPw== X-IronPort-AV: E=McAfee;i="6800,10657,11804"; a="81011624" X-IronPort-AV: E=Sophos;i="6.24,181,1774335600"; d="scan'208";a="81011624" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by orvoesa113.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2026 12:56:43 -0700 X-CSE-ConnectionGUID: cl39qHC2S9CqYDKdcDZGZQ== X-CSE-MsgGUID: d9CStnUQTSqPgGjzZQVPpQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.24,181,1774335600"; d="scan'208";a="247946516" Received: from lstrano-mobl6.amr.corp.intel.com (HELO agluck-desk3.home.arpa) ([10.124.221.168]) by orviesa004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2026 12:56:42 -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 v7 08/14] fs,x86,mpam/resctrl: Handle change in number of RMIDs on each mount Date: Mon, 1 Jun 2026 12:56:26 -0700 Message-ID: <20260601195632.15876-9-tony.luck@intel.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260601195632.15876-1-tony.luck@intel.com> References: <20260601195632.15876-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 of 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. Add resctrl_arch_system_max_rmid_idx() interface to provide the maximum supported number of RMIDs on a system. For x86 this is RDT_RESOURCE_L3 rdt_resource::mon.num_rmid (if L3 monitoring is enabled). Allocate the rmid_ptrs, rdt_l3_mon_domain::rmid_busy_llc, and rdt_l3_mon_domain::mbm_states based on the maximum possible. Initialize rmid_free_lru based on the number of RMIDs available for this mount. Note that some RMIDs may still be marked busy from a previous mount. Don't add these to the free list. Check current RMID limit in limbo_release_entry() and do not add out of range RMIDs to the free list. Signed-off-by: Tony Luck --- include/linux/resctrl.h | 1 + arch/x86/kernel/cpu/resctrl/core.c | 12 ++++++++ drivers/resctrl/mpam_resctrl.c | 5 ++++ fs/resctrl/monitor.c | 47 ++++++++++++++++++++---------- fs/resctrl/rdtgroup.c | 2 +- 5 files changed, 50 insertions(+), 17 deletions(-) diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index a8338656f836..3705f0214fa6 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -412,6 +412,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 1af8f965fdd0..934492c7e643 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -129,6 +129,18 @@ 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. + */ +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 327e7a863614..b374e2f84a75 100644 --- a/fs/resctrl/monitor.c +++ b/fs/resctrl/monitor.c @@ -115,10 +115,17 @@ static inline struct rmid_entry *__rmid_entry(u32 idx) =20 static void limbo_release_entry(struct rmid_entry *entry) { + u32 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) < idx_limit) + 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,7 +140,7 @@ static void limbo_release_entry(struct rmid_entry *entr= y) 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(); + u32 idx_limit =3D resctrl_arch_system_max_rmid_idx(); struct rmid_entry *entry; u32 idx, cur_idx =3D 1; void *arch_mon_ctx; @@ -192,7 +199,7 @@ 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 idx_limit =3D resctrl_arch_system_max_rmid_idx(); =20 return find_first_bit(d->rmid_busy_llc, idx_limit) !=3D idx_limit; } @@ -916,24 +923,32 @@ 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; + if (!rmid_ptrs) { + idx_limit =3D resctrl_arch_system_max_rmid_idx(); + rmid_ptrs =3D kzalloc_objs(struct rmid_entry, idx_limit); + if (!rmid_ptrs) + return -ENOMEM; + + for (i =3D 0; i < idx_limit; i++) { + entry =3D &rmid_ptrs[i]; + INIT_LIST_HEAD(&entry->list); + + resctrl_arch_rmid_idx_decode(i, &entry->closid, &entry->rmid); + } + } =20 + /* Find how many RMIDs are needed for this mount */ idx_limit =3D resctrl_arch_system_num_rmid_idx(); - rmid_ptrs =3D kzalloc_objs(struct rmid_entry, idx_limit); - if (!rmid_ptrs) - return -ENOMEM; =20 + INIT_LIST_HEAD(&rmid_free_lru); for (i =3D 0; i < idx_limit; i++) { entry =3D &rmid_ptrs[i]; - INIT_LIST_HEAD(&entry->list); - - resctrl_arch_rmid_idx_decode(i, &entry->closid, &entry->rmid); + if (i && entry->busy) + continue; list_add_tail(&entry->list, &rmid_free_lru); } =20 @@ -1156,7 +1171,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 idx_limit =3D resctrl_arch_system_max_rmid_idx(); enum resctrl_event_id evt; int idx; =20 diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c index d2a1f88d8782..6d647b71c5db 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -4416,7 +4416,7 @@ 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 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 2.54.0 From nobody Mon Jun 8 05:25:29 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.21]) (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 2120A373BE0 for ; Mon, 1 Jun 2026 19:56:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.21 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780343816; cv=none; b=eNY6/KcQpiZSKwO0nNMc/jCYNxTmqpQhmSeLJbUIIFq7t5x4sjAfUfushnRI3O6f+zrxf8GDJt+uGxg2Y2vY6sq3E9Aj8uFc8VT2aQgcaSiRvEU5fAeHjO5SB1gJkEudFn3Qyyp6+nAOjNcE1Oa0MZ4QCas6wSmYWkX5jzJr/Ho= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780343816; c=relaxed/simple; bh=OSgWP4UuE9mXdfXnJ5+20fMkWBkqKVlxn+C7zA/elbE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HQxt7IH1qfY/3T4zbbnxZVSDL8ZTiWhUBPucHp7bRg0wXk2JZ1UeSGJRicswn2M9tinDItoCLNdiJ9Bn3uKVOZ8ejaLmMKEySl6zXeHzQNfEsxUWOhqwJEv6ueV71NJkWnQgE3YxVCXwOfBuTTn+WTO9XGW7Ji82lJ/SEhHOZA4= 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=UICCwfnO; arc=none smtp.client-ip=198.175.65.21 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="UICCwfnO" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1780343815; x=1811879815; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=OSgWP4UuE9mXdfXnJ5+20fMkWBkqKVlxn+C7zA/elbE=; b=UICCwfnOM0v2k5DGhzWE9ZwFdRDoooLmFpjvbflutUXMbIvwxDDhKczt 6fnpweJVHgxqyuQRa3wzopfJef6FP5FBzc1xYTRZzlma98fsJZrT60VKx qcaiJTb2fsmkAyNvetWJpdrgcfAsMXR2+/NH8Cc/dDxpg8lK9mpBmmjZS NWTmTriBvyAfDOttxPkrea3T/zTaBPwIxbEUu9J6yz0zx731IueiODDYa qT1/5gOkyKxjVRGd3xcNX3EYjMTaPgo6XOUfy3Oh2N0BR2TW0dsSHVax+ IOoLKagAg6AXdReN3pUdg8hlwOP/dAyirOuxaZ54yShn8ZHhpmSAEc7/1 A==; X-CSE-ConnectionGUID: NGg9cHtxRWKD360kYwyvkg== X-CSE-MsgGUID: fEUNqas7RjSyQV2BUwr+3w== X-IronPort-AV: E=McAfee;i="6800,10657,11804"; a="81011633" X-IronPort-AV: E=Sophos;i="6.24,181,1774335600"; d="scan'208";a="81011633" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by orvoesa113.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2026 12:56:44 -0700 X-CSE-ConnectionGUID: i4ZnBhQ+TkioMETWFmVQRA== X-CSE-MsgGUID: qx6SYmdnQoyQDdFazmfhBA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.24,181,1774335600"; d="scan'208";a="247946519" Received: from lstrano-mobl6.amr.corp.intel.com (HELO agluck-desk3.home.arpa) ([10.124.221.168]) by orviesa004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2026 12:56:42 -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 v7 09/14] x86/resctrl: Add PMT registration API for AET enumeration callbacks Date: Mon, 1 Jun 2026 12:56:27 -0700 Message-ID: <20260601195632.15876-10-tony.luck@intel.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260601195632.15876-1-tony.luck@intel.com> References: <20260601195632.15876-1-tony.luck@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" resctrl is always built-in; INTEL_PMT_TELEMETRY may be a module. Add, and export, register/unregister functions so the PMT module can supply/clear enumeration callback functions when loaded/unloaded. Suggested-by: Christoph Hellwig Signed-off-by: Tony Luck --- arch/x86/include/asm/resctrl.h | 22 ++++++++++++++++++ arch/x86/kernel/cpu/resctrl/intel_aet.c | 30 +++++++++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/arch/x86/include/asm/resctrl.h b/arch/x86/include/asm/resctrl.h index 1e50c7dc3fe3..c23d9c56a337 100644 --- a/arch/x86/include/asm/resctrl.h +++ b/arch/x86/include/asm/resctrl.h @@ -4,6 +4,8 @@ =20 #ifdef CONFIG_X86_CPU_RESCTRL =20 +#include +#include #include #include #include @@ -193,11 +195,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 e2af700bca04..db671725acbb 100644 --- a/arch/x86/kernel/cpu/resctrl/intel_aet.c +++ b/arch/x86/kernel/cpu/resctrl/intel_aet.c @@ -12,17 +12,21 @@ #define pr_fmt(fmt) "resctrl: " fmt =20 #include +#include #include #include #include #include #include +#include #include #include #include #include #include #include +#include +#include #include #include #include @@ -289,6 +293,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, @@ -323,6 +331,28 @@ bool intel_aet_get_events(void) return ret; } =20 +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 Mon Jun 8 05:25:29 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.21]) (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 21D9837474E for ; Mon, 1 Jun 2026 19:56:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.21 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780343815; cv=none; b=PKJKnuRuAJzSAlbP3A2+o1FI8iucH0W8jNItSZSGC8vmlmY+l+/tMoLJA8TyW+Wnvzzx2MejqrMJD4Rb6OE8izxsIDIAiv1qLKqOaHjIbbvZ2whUL0LLxmwIbYQWUBNV5d7Rcj+NWhpoJDevaH9rA1sT1XSgHJ/wfhoFHCf47mM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780343815; c=relaxed/simple; bh=+hfZeCBGK1YwjNIsH0I9wSKydbOTanbZiJHodPfMrkc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CaoIK5kmm+y5n1ItZC356Rd2Ky/IRq7ikZu8U34MuykUr8n4+fC/PHyIzEc+0UWZL/++k0Ca5oOPqCR7T5nseAPEjnGtkNvo9gpOu1O5Ab/Q5+lPB96hCp74Llh9td/AWd/8iaiddPOzZ6r63LXATEfyL2qibndFSkwVnTYPxIw= 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=SCaDguZe; arc=none smtp.client-ip=198.175.65.21 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="SCaDguZe" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1780343815; x=1811879815; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=+hfZeCBGK1YwjNIsH0I9wSKydbOTanbZiJHodPfMrkc=; b=SCaDguZe13av519SLKoU2gfQsMkcRL/EBZZ+gJ1vJMuY1SpGJh2KPo6O 0eXyI1FqASzXDxqDnziBEMbbTy3QXdGXYgEtGQw/3bdWaLQSRO2VM83Z+ Q65B56POoMSyfoE3LOfibf3nPhZvFBwitIa12kKb+ztSQDH19R3N4BwcN RmhSgwskqBemjRdHCgf6g4sURVqPfWJSDpDfIacfXjzJLgaQleFhXSiHS hRUimLLIkwNBeOagSj8GovU5ny2xv00CkPUonGP9G+sdOQZNmjRWynbrW UfNx1CHI+eFtCZnmuLpWcFTs4xPOLNxRXWoJp8+/QvY5cR1h+LJJIdle1 g==; X-CSE-ConnectionGUID: Y5q5CIqeQq+6u1IyHHatuA== X-CSE-MsgGUID: tHGXvrKqSTCz9/Acl/2PoA== X-IronPort-AV: E=McAfee;i="6800,10657,11804"; a="81011642" X-IronPort-AV: E=Sophos;i="6.24,181,1774335600"; d="scan'208";a="81011642" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by orvoesa113.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2026 12:56:44 -0700 X-CSE-ConnectionGUID: Q46sFpuZRBeubJKzHKgEuQ== X-CSE-MsgGUID: ztUamcPOT8yXZyIJRSuQ3Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.24,181,1774335600"; d="scan'208";a="247946523" Received: from lstrano-mobl6.amr.corp.intel.com (HELO agluck-desk3.home.arpa) ([10.124.221.168]) by orviesa004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2026 12:56:43 -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 v7 10/14] platform/x86/intel/pmt: Register enumeration functions with resctrl Date: Mon, 1 Jun 2026 12:56:28 -0700 Message-ID: <20260601195632.15876-11-tony.luck@intel.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260601195632.15876-1-tony.luck@intel.com> References: <20260601195632.15876-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 init, and unregister them at module exit. Note that checkpatch complains about the #include of . This is needed rather than to get the function stub definitions when CONFIG_X86_CPU_RESCTRL=3Dn. Suggested-by: Christoph Hellwig Signed-off-by: Tony Luck --- drivers/platform/x86/intel/pmt/telemetry.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/platform/x86/intel/pmt/telemetry.c b/drivers/platform/= x86/intel/pmt/telemetry.c index bdc7c24a3678..33c1f8e7022f 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 @@ -425,12 +427,21 @@ static struct auxiliary_driver pmt_telem_aux_driver = =3D { =20 static int __init pmt_telem_init(void) { - return auxiliary_driver_register(&pmt_telem_aux_driver); + int ret; + + ret =3D auxiliary_driver_register(&pmt_telem_aux_driver); + if (ret) + return ret; + + intel_aet_register_enumeration(THIS_MODULE, intel_pmt_get_regions_by_feat= ure, + intel_pmt_put_feature_group); + return 0; } module_init(pmt_telem_init); =20 static void __exit pmt_telem_exit(void) { + intel_aet_unregister_enumeration(); auxiliary_driver_unregister(&pmt_telem_aux_driver); xa_destroy(&telem_array); } --=20 2.54.0 From nobody Mon Jun 8 05:25:29 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.21]) (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 1DC5339DBFF for ; Mon, 1 Jun 2026 19:56:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.21 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780343817; cv=none; b=NH4ZTFI0kmOQCPhxMLMstiQM1y5dwewcRyDdhFgnU58QanuPrCwtYpk2Kh+JxSFqxzJADLV4/UQqzKlgUXMm/euhkxddgCNNuhCBtZ4TEFsTVEVFFyS+lgzoTa4QyPIv13BaAxzXUoy5JZwxCz/nl8gUkmIg1ADyYhHpVItirtQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780343817; c=relaxed/simple; bh=aEK4q/sy4C3crg0Z5RSKSZ4FT1n1WD1XBObWZJvjRjw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=A/UNpsR+nBd6mxEMaFfBT8M8+YgZzFqnshsK2BTco50PJMMpvIVnlZaRgjae/0RA8UpqqfW3RUZzIDyRICSJ5iIRDBcxz5liICXP3WXdYmrJXDB+a9C+/O91yExUxDE5Dd146LljKuW9bO+8RkKyRqqfZ4xKJGaSGouUWydCH50= 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=IHnKtBwC; arc=none smtp.client-ip=198.175.65.21 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="IHnKtBwC" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1780343816; x=1811879816; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=aEK4q/sy4C3crg0Z5RSKSZ4FT1n1WD1XBObWZJvjRjw=; b=IHnKtBwC+lCmcwUNT58abKCm5+YSfR9ae2pWvkSQvtM6/YXUG7esHCEU IrLaWYdPual+j3ZV/6GK4E5EGM/kaXa3mrAfccZ7hBhj/F8f1AVm5KZvu TGGEzSvrCWO0lxyobKHRG0xRGV87czkJIw6feV+roll/JxYRLsrtUCMhg zVU+VqG82yy1t+aDgs8/GXFMZ4dlAa+/thrND2/e+9CLHFsr/Syfe6f/Y nFmbaK+PhatNTRU4nw6xH2e3rRr03k5glDg0IfoPXpaeeEw+Qrby16PKS ZGSz2Ezr518LwGd2s5FflRRD5NrsoKqOW54jAcVZpcRfFrz8XszcQEXGk Q==; X-CSE-ConnectionGUID: ZojjbyweQW+THJi08lml8Q== X-CSE-MsgGUID: qcybzF7eRdyI1wRJc1uHgA== X-IronPort-AV: E=McAfee;i="6800,10657,11804"; a="81011651" X-IronPort-AV: E=Sophos;i="6.24,181,1774335600"; d="scan'208";a="81011651" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by orvoesa113.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2026 12:56:44 -0700 X-CSE-ConnectionGUID: 9F4AyOoUQE6+vppDgEqG3Q== X-CSE-MsgGUID: BL9XtWbPSUKrOxUSupA4bA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.24,181,1774335600"; d="scan'208";a="247946526" Received: from lstrano-mobl6.amr.corp.intel.com (HELO agluck-desk3.home.arpa) ([10.124.221.168]) by orviesa004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2026 12:56:43 -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 v7 11/14] mpam,x86/resctrl: Resolve INTEL_PMT_TELEMETRY symbols at runtime Date: Mon, 1 Jun 2026 12:56:29 -0700 Message-ID: <20260601195632.15876-12-tony.luck@intel.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260601195632.15876-1-tony.luck@intel.com> References: <20260601195632.15876-1-tony.luck@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" resctrl is always built-in, but INTEL_PMT_TELEMETRY and INTEL_TPMI are logically independent and should be loadable modules. Switch AET to use the function-pointer registration API (introduced in the preceding patch) instead of direct link-time references to PMT symbols. 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. Add locking and state (resctrl_arch_mount_entries) to avoid repeated enumeration on nested mount requests from file system code (which will be failed with -EBUSY status). 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 --- include/linux/resctrl.h | 3 ++ arch/x86/kernel/cpu/resctrl/internal.h | 8 ++-- arch/x86/kernel/cpu/resctrl/core.c | 41 +++++++++++++++++-- arch/x86/kernel/cpu/resctrl/intel_aet.c | 52 ++++++++++++++++++++++--- drivers/resctrl/mpam_resctrl.c | 4 ++ 5 files changed, 95 insertions(+), 13 deletions(-) diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index 3705f0214fa6..9534d42e0c57 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -557,6 +557,9 @@ void resctrl_offline_cpu(unsigned int cpu); */ void resctrl_arch_pre_mount(void); =20 +/* Called to report unmount. */ +void resctrl_arch_unmount(void); + /** * resctrl_arch_rmid_read() - Read the eventid counter corresponding to rm= id * for this resource and domain. diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/r= esctrl/internal.h index 3b09cfe9a046..017a19143ec9 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -234,15 +234,15 @@ void rdt_domain_reconfigure_cdp(struct rdt_resource *= r); void resctrl_arch_mbm_cntr_assign_set_one(struct rdt_resource *r); =20 #ifdef CONFIG_X86_CPU_RESCTRL_INTEL_AET -bool intel_aet_get_events(void); -void __exit intel_aet_exit(void); +bool intel_aet_pre_mount(void); +void intel_aet_unmount(void); int intel_aet_read_event(int domid, u32 rmid, void *arch_priv, u64 *val); void intel_aet_mon_domain_setup(int cpu, int id, struct rdt_resource *r, struct list_head *add_pos); bool intel_handle_aet_option(bool force_off, char *tok); #else -static inline bool intel_aet_get_events(void) { return false; } -static inline void __exit intel_aet_exit(void) { } +static inline bool intel_aet_pre_mount(void) { return false; } +static inline void intel_aet_unmount(void) { } static inline int intel_aet_read_event(int domid, u32 rmid, void *arch_pri= v, u64 *val) { return -EINVAL; diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resct= rl/core.c index 934492c7e643..9336299b9647 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -16,10 +16,12 @@ =20 #define pr_fmt(fmt) "resctrl: " fmt =20 +#include #include #include #include #include +#include =20 #include #include @@ -776,12 +778,20 @@ static int resctrl_arch_offline_cpu(unsigned int cpu) return 0; } =20 +static DEFINE_MUTEX(resctrl_arch_mount_lock); +static int 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()) + guard(mutex)(&resctrl_arch_mount_lock); + + if (++resctrl_arch_mount_entries > 1) + return; + + if (!intel_aet_pre_mount()) return; =20 /* @@ -798,6 +808,33 @@ void resctrl_arch_pre_mount(void) cpus_read_unlock(); } =20 +void resctrl_arch_unmount(void) +{ + struct rdt_resource *r =3D &rdt_resources_all[RDT_RESOURCE_PERF_PKG].r_re= sctrl; + int cpu; + + guard(mutex)(&resctrl_arch_mount_lock); + + if (--resctrl_arch_mount_entries > 0) + return; + + WARN_ON(resctrl_arch_mount_entries < 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; + rdt_mon_feature_count--; + mutex_unlock(&domain_list_lock); + cpus_read_unlock(); +} + enum { RDT_FLAG_CMT, RDT_FLAG_MBM_TOTAL, @@ -1174,8 +1211,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 db671725acbb..74c34593876b 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 @@ -308,7 +308,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; @@ -317,14 +317,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 @@ -353,16 +353,56 @@ void intel_aet_unregister_enumeration(void) } EXPORT_SYMBOL_NS_GPL(intel_aet_unregister_enumeration, "INTEL_PMT"); =20 -void __exit intel_aet_exit(void) +/* + * The pmt_telemetry module may not be loaded when the resctrl file system + * is mounted. Keep track of whether a hold was placed on the module to kn= ow + * whether to release it during unmount. + */ +static bool have_pmt_hold; + +bool intel_aet_pre_mount(void) +{ + bool ret; + + guard(mutex)(&aet_register_lock); + if (!get_feature || !put_feature) + return false; + + if (pmt_module) { + if (!try_module_get(pmt_module)) + return false; + have_pmt_hold =3D true; + } + + ret =3D aet_get_events(); + + if (!ret && pmt_module && have_pmt_hold) { + module_put(pmt_module); + have_pmt_hold =3D false; + } + + return ret; +} + +void intel_aet_unmount(void) { struct event_group **peg; =20 + guard(mutex)(&aet_register_lock); for_each_event_group(peg) { if ((*peg)->pfg) { - intel_pmt_put_feature_group((*peg)->pfg); + struct event_group *e =3D *peg; + + for (int j =3D 0; j < e->num_events; j++) + resctrl_disable_mon_event(e->evts[j].id); + put_feature((*peg)->pfg); (*peg)->pfg =3D NULL; } } + if (have_pmt_hold && pmt_module) { + module_put(pmt_module); + have_pmt_hold =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 Mon Jun 8 05:25:29 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.21]) (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 7AFF43CF973 for ; Mon, 1 Jun 2026 19:56:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.21 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780343818; cv=none; b=q4t8AI8DoPmZVAdL1kkhneg9woPHK85FRxHLBUytgb1hPyArmVGjU+stsJocwOQK+90m+mh+tvwbXtb6ffc23WAEmAs1hdzlq97elAqYy8CAbe2H6A321mGxQcs9/XEOnrDnJ7PTyMgeQKlbrSDsajAv9gitQowHTqad5SL1zpU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780343818; c=relaxed/simple; bh=vhcRn5GflIKPR5TdRF784Mb9z/uJDX2D/dGTqB0zBZM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gP6yGRM/HR6sJfzT6ezzQSVwtp/PPvNZ+sZXFmPfJ9bV37p7QTCuYF6Aw6FFAFOhjc4EWxmIAPitoTeOSFdLApOsRSom3lLLzVdlgDWAhy50ayZEoApoGHWAWTSQPu20s1TVRwLm4oCStQZ1HYA8R7JNgXqJv7fAEa6EDooxHrY= 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=Lm7KFjdM; arc=none smtp.client-ip=198.175.65.21 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="Lm7KFjdM" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1780343816; x=1811879816; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=vhcRn5GflIKPR5TdRF784Mb9z/uJDX2D/dGTqB0zBZM=; b=Lm7KFjdMcDYDbLfm5G/MViHj9im+NMcjwUNbtFQtwsHmvCTtlfuZnP/s xIbjuACiw4oxIW30JRfxfeC9/XTE7xkTeTZQoFcMnLsBaIe37kIBVpT52 b+pW/Gu3T5IvKvDPoIrVA240bw41SZQZjVGZoQSPLaxqPu6oV4qJSSsBu qE0D0NXtAjkLBf4WyKMNANON6pkBdv0nfexQA60vDjMdczcZie3G2Lw+p nZMbDzFAFRx1HUrVUcIBFm+KQqyW+aEw8v8Q7oikPES94LZQaBwMzuwmr rw2iFbVlf5WqOO/HsbxaIEuZwA8awoGAUdVCjcSl0PPC6HFoTo/QqmxzT g==; X-CSE-ConnectionGUID: l/lWcaRcSlawtJsf3J4l2A== X-CSE-MsgGUID: 3Q+Qk/VgQrOeuol9Su+mqw== X-IronPort-AV: E=McAfee;i="6800,10657,11804"; a="81011660" X-IronPort-AV: E=Sophos;i="6.24,181,1774335600"; d="scan'208";a="81011660" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by orvoesa113.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2026 12:56:45 -0700 X-CSE-ConnectionGUID: 9hbvjgPCQAuM1F2KaksV6A== X-CSE-MsgGUID: ISHGNnS5Qt+G+rxgoVQsyQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.24,181,1774335600"; d="scan'208";a="247946529" Received: from lstrano-mobl6.amr.corp.intel.com (HELO agluck-desk3.home.arpa) ([10.124.221.168]) by orviesa004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2026 12:56:44 -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 v7 12/14] fs/resctrl: Call architecture hooks for every mount/unmount Date: Mon, 1 Jun 2026 12:56:30 -0700 Message-ID: <20260601195632.15876-13-tony.luck@intel.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260601195632.15876-1-tony.luck@intel.com> References: <20260601195632.15876-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 --- include/linux/resctrl.h | 7 +++++-- fs/resctrl/rdtgroup.c | 9 +++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index 9534d42e0c57..e8a87c3664db 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -552,12 +552,15 @@ void resctrl_online_cpu(unsigned int cpu); void resctrl_offline_cpu(unsigned int cpu); =20 /* - * Architecture hook called at beginning of first file system mount attemp= t. + * Architecture hook called before attempting to mount the file system. * No locks are held. */ void resctrl_arch_pre_mount(void); =20 -/* Called to report unmount. */ +/* + * Architecture hook called when mount fails, or on unmount. + * No locks are held. + */ void resctrl_arch_unmount(void); =20 /** diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c index 6d647b71c5db..195ebb15c5f0 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); @@ -3147,6 +3148,10 @@ static int rdt_get_tree(struct fs_context *fc) out: mutex_unlock(&rdtgroup_mutex); cpus_read_unlock(); + + if (ret) + resctrl_arch_unmount(); + return ret; } =20 --=20 2.54.0 From nobody Mon Jun 8 05:25:29 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.21]) (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 446F137CD42 for ; Mon, 1 Jun 2026 19:56:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.21 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780343818; cv=none; b=CDt5a8K0sHevfKnDsQEtYImk0Tr8WbUoSMitNCsDhVNOHm6X+O5WWxw8o8chPqWKDE4s+8Y5rSLjDKcrqxl3RkrutnrXGbZRGKm77vvEZXk3TWJCsGuPdlBEZsdzsPVO/1H+k8r0rXrO6pswD+G3nJuL2XTFoK+wB5+Cs2f/HHQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780343818; c=relaxed/simple; bh=HaCy2UcOAtXgMRHDUcRnuReWIZTKPx2CtYe4rvcCsRk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IMppFlxlE3UgpP75o3ea0sSnIkAVYeSBVB90yKd7K7oXaQvCF78yn42wKKJFAOn2LMyytjygSUzQgTDPe7yDqasq0Wc8665CAKIlyT+sGNFHuGvQBHOWkAJsfLWJaqoSjeli1UTRBu+JCCY/opu9hfsRFBwZQeq11gakPg+fsig= 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=OYOyudDz; arc=none smtp.client-ip=198.175.65.21 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="OYOyudDz" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1780343817; x=1811879817; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=HaCy2UcOAtXgMRHDUcRnuReWIZTKPx2CtYe4rvcCsRk=; b=OYOyudDz6ODwMjDpI2cqvNoj28xmUxTvtxxco+znySUYLBjr5qL3kAHS BbX/ZiwCFoKiun0nQ/po8BfZa2uEAkI5JWS85Mlr+poA7XbAfOoAFI+bq P5rX6CgEmQTCI28kyLkblkL1DWLBQBV63inST/AFQy8joLEOo4tFc9I4x ijLLWV4VzvL0ay5NqQ7M5VjQKP1vA1Rx2mIWoqIh57pSkhyC7419BcVoA shWyaMxxoZp1+5pvOsReplce0wX8kHlHshchIGu80nuF8Wm1MZ0E4jgH2 7Dhb7HTJfITQq6dTJAlBs6MNXwzC4Ujom8I/yjG0hESILZA/3NsChlvsQ A==; X-CSE-ConnectionGUID: dBgwTVVySaG1q9Y91XTk9w== X-CSE-MsgGUID: GgfjgV9MQ+qB6PlzHm/qzQ== X-IronPort-AV: E=McAfee;i="6800,10657,11804"; a="81011669" X-IronPort-AV: E=Sophos;i="6.24,181,1774335600"; d="scan'208";a="81011669" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by orvoesa113.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2026 12:56:45 -0700 X-CSE-ConnectionGUID: bSlny4kXTlGSDAGXigF5VA== X-CSE-MsgGUID: j1VPjJdeTpWeF0tZDSuvPw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.24,181,1774335600"; d="scan'208";a="247946532" Received: from lstrano-mobl6.amr.corp.intel.com (HELO agluck-desk3.home.arpa) ([10.124.221.168]) by orviesa004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2026 12:56:44 -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 v7 13/14] x86/resctrl: Simplify Kconfig options for resctrl Date: Mon, 1 Jun 2026 12:56:31 -0700 Message-ID: <20260601195632.15876-14-tony.luck@intel.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260601195632.15876-1-tony.luck@intel.com> References: <20260601195632.15876-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 unnaturally 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 c23d9c56a337..5a61d0b0955d 100644 --- a/arch/x86/include/asm/resctrl.h +++ b/arch/x86/include/asm/resctrl.h @@ -195,17 +195,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 017a19143ec9..4a89f00aaa01 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -233,24 +233,11 @@ 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 #endif /* _ASM_X86_RESCTRL_INTERNAL_H */ 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 Mon Jun 8 05:25:29 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.21]) (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 8B2A23D88F6 for ; Mon, 1 Jun 2026 19:56:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.21 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780343819; cv=none; b=j/1RCWHxzE/B19GcE5X0OqHlApQ4N/6cvW0ezzEwKdG93Aj2an+c6g0i/OJ2A83veDc7d/G6a/TXhFng9zB3BWQ7vspPGiwFfM0e3Mg9Si+GWGa9kljMFSEx5NXQehn0e135PNjnuTAXE1WuyjE2bw+BZzT9GPlLFuueX6fQQH4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780343819; c=relaxed/simple; bh=85p7ItNAhTY8AtSyHL6/wWbocxWYL2NWxuDEDMK36/E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=G1hbCsLgT+gek6Avs6qtab13POI9NGPEKtqIfVGbUdCuxvGaEvmuevr7JkSlGZ5nVL+PJNwChCgVrydqFFF86qXgYBlKFh9k5I1wnb58hg56E9TtpRakWVe41ewyxaDDJcbw3NtH81CMsX4KvQoprxjN6MQsefyqoqytiHotiIc= 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=B1arSZYv; arc=none smtp.client-ip=198.175.65.21 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="B1arSZYv" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1780343818; x=1811879818; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=85p7ItNAhTY8AtSyHL6/wWbocxWYL2NWxuDEDMK36/E=; b=B1arSZYvJk5RSD0erbri0RiqaGuSEYHVR4r/Hq2ldsrBKxRMwn4CV6NG C7UVvh3KyXTGP81qHZOq3aBCZx+k+woyHGa2IwEYgZLoH5c9GOpSbpmer 5rutGRAMUx/5PYGXFaF1FwLP0YzY01qkZoFeXFN8Fuq6otg1/nLzeeXsJ 3DDLUtqRWJfRj/yb5WssrD6lB9prVQgyrK/A64cdOW+P7jfAB55rrCZ23 cHEfDHwlVefjo1lbCV0ejSXT1q3mCYwoXYFI7OVsvVWMeiYQdbNubGF6n mGluAyViACGT6wx7LlQhv7i1x7gf02OVMa0Zj1g0yHsDVwa0YeeaANaJD g==; X-CSE-ConnectionGUID: u06ncHOkRtOz8jcBjzCXHg== X-CSE-MsgGUID: KhlBqLRBTaOniRtAG4rRVg== X-IronPort-AV: E=McAfee;i="6800,10657,11804"; a="81011678" X-IronPort-AV: E=Sophos;i="6.24,181,1774335600"; d="scan'208";a="81011678" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by orvoesa113.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2026 12:56:46 -0700 X-CSE-ConnectionGUID: GfKAONXhTAmKb3HJzJ2L+w== X-CSE-MsgGUID: 1BMn2RaPTvKi7CaRM9536Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.24,181,1774335600"; d="scan'208";a="247946536" Received: from lstrano-mobl6.amr.corp.intel.com (HELO agluck-desk3.home.arpa) ([10.124.221.168]) by orviesa004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2026 12:56:45 -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 v7 14/14] Documentation/filesystems/resctrl: Add footnote for telemetry fstab mount caveat Date: Mon, 1 Jun 2026 12:56:32 -0700 Message-ID: <20260601195632.15876-15-tony.luck@intel.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260601195632.15876-1-tony.luck@intel.com> References: <20260601195632.15876-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 because PMT driver enumerates telemetry features asynchronously, an automatic mount of resctrl from /etc/fstab at boot may occur before those features are available, resulting in them not being enabled. Assisted-by: Claude:Sonnet_4.6 Signed-off-by: Tony Luck --- 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..4e62b8c5e0d6 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. + "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