From nobody Sat Sep 27 21:20:23 2025 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 314AB321422 for ; Thu, 25 Sep 2025 20:04:13 +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=1758830655; cv=none; b=i0YnGVVoPRwR3Xtxn0EJy1Rw36sVYL5Z7iF0gmT2GRN1rBjGgfyV3nSEAppAiU0OBkcIQwsnLJRRDiMoFjgLSxuTlqZn/R7Zx4btRxFZ/9r6WoviYCd3JdkOAnFd9ETaxjns4dhoOVksZ76Kpniai/Xo4z1HsOSMB7GhVdbCwCk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758830655; c=relaxed/simple; bh=AkDDdTR9vj1/vTSw7b2/MkEuHeAyPOmzsSwe02gqWMU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=r/Q8yV2KT9V7p3+sO6wWJzyQbWwxwi9JitKSc00XF+QjfIZhr6hfWI5jPnxMGS10vbizw3TTXePBfmqXRiis1ZzZU7/kqTAH8iWYRUIreejgXSrkrjSbkoqJ0x0/zSFvtNC89tDOv4TY341U1aTGkvRy7qn0VRn3rKljA5yuPq0= 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=ViG7v1BQ; 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="ViG7v1BQ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1758830654; x=1790366654; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=AkDDdTR9vj1/vTSw7b2/MkEuHeAyPOmzsSwe02gqWMU=; b=ViG7v1BQgUXIAUOGefI+nEJdIKfXCQ2Uqp9/XS11TLHefCN2jzC2tU7Q /szvXZVsbVs+TKQ51FdzBT/a6GdSICM/bKTJ2tjmLefF7D1gD6VFvsYy0 k7S4qq+iko3kRHe4w3wyTPRa3Wcf1i8dkcorVnsQ9cPVuXZHMJXbpSH3a Ct5Oi/Rkl6z81b/QYgtZxXE7mgm5rNh/QtaQ0EUheCQRkLgP/ZL8tIJCg HkFSlNJttTGgY6d4zx8+CJn4Rd5/KaxdavTgGbuReB/4j5uDPYuxzu7He 5dP1jFGmpJWN7HHuiU9vRoo/8vdjQxqg189ojb3fMz4E33UMnBkVFhpys g==; X-CSE-ConnectionGUID: y1PzFIrRSdWi43r+lvt7Tg== X-CSE-MsgGUID: 2KA0B3RJRsiHIr24hGf6Rg== X-IronPort-AV: E=McAfee;i="6800,10657,11531"; a="61074229" X-IronPort-AV: E=Sophos;i="6.17,312,1747724400"; d="scan'208";a="61074229" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by orvoesa113.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Sep 2025 13:04:09 -0700 X-CSE-ConnectionGUID: pO/ZfK+2S7GIisluk+GECQ== X-CSE-MsgGUID: PqIXRIbOTTu75LM++VP/PQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.18,293,1751266800"; d="scan'208";a="177003639" Received: from inaky-mobl1.amr.corp.intel.com (HELO agluck-desk3.intel.com) ([10.124.220.206]) by orviesa009-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Sep 2025 13:04:08 -0700 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Maciej Wieczor-Retman , Peter Newman , James Morse , Babu Moger , Drew Fustini , Dave Martin , Chen Yu Cc: x86@kernel.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [PATCH v11 12/31] x86,fs/resctrl: Add an architectural hook called for each mount Date: Thu, 25 Sep 2025 13:03:06 -0700 Message-ID: <20250925200328.64155-13-tony.luck@intel.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250925200328.64155-1-tony.luck@intel.com> References: <20250925200328.64155-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" Enumeration of Intel telemetry events is an asynchronous process involving several mutually dependent drivers added as auxiliary devices during the device_initcall() phase of Linux boot. The process finishes after the probe functions of these drivers completes. But this happens after resctrl_arch_late_init() is executed. Tracing the enumeration process shows that it does complete a full seven seconds before the earliest possible mount of the resctrl file system (when included in /etc/fstab for automatic mount by systemd). Add a hook at the beginning of the mount code that will be used to check for telemetry events and initialize if any are found. Call the hook on every attempted mount. Expectations are that most actions (like enumeration) will only need to be performed on the first call. resctrl filesystem calls the hook with no locks held. Architecture code is responsible for any required locking. Signed-off-by: Tony Luck Reviewed-by: Reinette Chatre --- include/linux/resctrl.h | 6 ++++++ arch/x86/kernel/cpu/resctrl/core.c | 9 +++++++++ fs/resctrl/rdtgroup.c | 2 ++ 3 files changed, 17 insertions(+) diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index de66928e9430..6350064ac8be 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -511,6 +511,12 @@ void resctrl_offline_mon_domain(struct rdt_resource *r= , struct rdt_domain_hdr *h void resctrl_online_cpu(unsigned int cpu); void resctrl_offline_cpu(unsigned int cpu); =20 +/* + * Architecture hook called at beginning of each file system mount attempt. + * No locks are held. + */ +void resctrl_arch_pre_mount(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/core.c b/arch/x86/kernel/cpu/resct= rl/core.c index ccba27df3ea6..ee6d53aae455 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -717,6 +717,15 @@ static int resctrl_arch_offline_cpu(unsigned int cpu) return 0; } =20 +void resctrl_arch_pre_mount(void) +{ + static atomic_t only_once =3D ATOMIC_INIT(0); + int old =3D 0; + + if (!atomic_try_cmpxchg(&only_once, &old, 1)) + return; +} + enum { RDT_FLAG_CMT, RDT_FLAG_MBM_TOTAL, diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c index dc289b03c3d1..72ae7224a2da 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -2720,6 +2720,8 @@ static int rdt_get_tree(struct fs_context *fc) struct rdt_resource *r; int ret; =20 + resctrl_arch_pre_mount(); + cpus_read_lock(); mutex_lock(&rdtgroup_mutex); /* --=20 2.51.0