From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.14]) (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 4E85B25783B for ; Fri, 29 Aug 2025 19:34:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.14 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756496045; cv=none; b=SFmn8XQriu+v+kPPu5X62aPD9WSXVsyaZ59xac0HFrWSCkDHrnUqrhje3YL/CCtvb8TUP5scVDFosaieYtieK9944p+ycb9MkOvYBojRG1tqTGWffWfXEa46BECz2ifjtQ3gGB6vT7Gv4Vbg4Nrq3MGJX7rdHySi+9Exgv61fhM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756496045; c=relaxed/simple; bh=8Iu0QPtvruTdWjl0MWMNxRM+tyqkNM4NG++5QMDhrPs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AlxZWN4N18XAj2fL/a2QnKtZtEP8JX+H9wAC0UcJQfYACZaXL9pH0N8Us6+rqq8T6oUuVdgIgx9HP1BO2OeiXEqQOzwJI5OjKR4T0+gSbyP+shS7KS8CmMwAb0pdBWReBgYdCiTfQ0srUqbFfYM6EO7TbkA1DzHGjHkX+XHQp2I= 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=LYNG0/NG; arc=none smtp.client-ip=198.175.65.14 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="LYNG0/NG" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1756496043; x=1788032043; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=8Iu0QPtvruTdWjl0MWMNxRM+tyqkNM4NG++5QMDhrPs=; b=LYNG0/NG6apFEFHLTtZsWq4GBSARIS7SSjJG8/hU4qfIM1OMYMXaY0q9 54b5iSvze0DZNsYhR+C2OpayJqJZa1+Sy3CCRrXNUZTL+/vGcIstz2m5K 8NR3aOeCFJFp3AwCVcFLuHFuVYvfT6EP9SXpICqgLlzP7dWZfXHiYpphi syGlK1TwTo/+qyAlxptTNQCv4I/BrrdwDjxr74zYPh9E+DfxsmKVdke4h gwc0EoKlWEj7E1Ks+j+/oKMvQcVmyPdqdwvoQyBd/MxpFq7j/iPrXkfC5 6ozOAmKOkvOzOOBHQ7XtAUmPjCeSlU/Pma/S59/A2J2AdEWwi8kkg7N5D g==; X-CSE-ConnectionGUID: H5cq4ENBSge5sU8gVFMjFQ== X-CSE-MsgGUID: b7Xfph6TRa+s0maWD+PXcQ== X-IronPort-AV: E=McAfee;i="6800,10657,11531"; a="62625257" X-IronPort-AV: E=Sophos;i="6.17,312,1747724400"; d="scan'208";a="62625257" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by orvoesa106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Aug 2025 12:33:55 -0700 X-CSE-ConnectionGUID: PMcvsBPUQV+motC7+i5v/w== X-CSE-MsgGUID: SjW52UWATl+0MYhDUR9vYA== X-ExtLoop1: 1 Received: from ldmartin-desk2.corp.intel.com (HELO agluck-desk3.intel.com) ([10.124.220.202]) by fmviesa003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Aug 2025 12:33:55 -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 v9 15/31] x86,fs/resctrl: Add an architectural hook called for each mount Date: Fri, 29 Aug 2025 12:33:27 -0700 Message-ID: <20250829193346.31565-16-tony.luck@intel.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20250829193346.31565-1-tony.luck@intel.com> References: <20250829193346.31565-1-tony.luck@intel.com> Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 --- 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 fe39bdbcd46f..f29a602d1b71 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -459,6 +459,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); +/* + * 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 rmid * for this resource and domain. diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resctrl/core.c index 8bc533ae896b..5ff0db08e132 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -718,6 +718,15 @@ static int resctrl_arch_offline_cpu(unsigned int cpu) return 0; } +void resctrl_arch_pre_mount(void) +{ + static atomic_t only_once = ATOMIC_INIT(0); + int old = 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 f98f34e75f35..abefdda245dd 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -2585,6 +2585,8 @@ static int rdt_get_tree(struct fs_context *fc) struct rdt_resource *r; int ret; + resctrl_arch_pre_mount(); + cpus_read_lock(); mutex_lock(&rdtgroup_mutex); /* -- 2.50.1