From nobody Tue Oct 7 08:58:03 2025 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.20]) (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 1123D23817C for ; Fri, 11 Jul 2025 23:54:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.20 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752278044; cv=none; b=HzQMiGmmWGPz/NcU0e0Qk3DtHMQQCW0bMyDBTHrcXPRRU+9p6UTbWSbCyHjMOImrZ3TZYF+WrR2Fy0Gpxgm1xALA1xbnpwUlEyEueh95o2jB7gCbLeJRJlzUA5pYFHWJgwriyZUugl8QDjciFih2tNT9U3NtQ/V61FKHI1TnkWs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752278044; c=relaxed/simple; bh=RuDPAVv20v1ihSOXLdGfI0iErN0OH8Y3gkYvUvOoUGY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ClkAumP7ZMUiyuT1LUbfyqhrAulxYWMEGKWqE1LJM5jgFD1J9AEh4ukMJnaH516J6dATpfznQx9V8fOuNXpQ5Yv3AdAxEqXLUOVKdojBbc61E59a7RtH14pAvfUx1qRUsXEF9VS0PUWLebpbb6AxV0SPL2TXw6chmx6xpkXbZhU= 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=lnWW3p9s; arc=none smtp.client-ip=198.175.65.20 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="lnWW3p9s" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1752278042; x=1783814042; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=RuDPAVv20v1ihSOXLdGfI0iErN0OH8Y3gkYvUvOoUGY=; b=lnWW3p9soRFdoV/qu3VbqoUvt1BwyGkYjsfE3in8JJ7/yRsui3dWt3VG WZjLvWW0uxgRMOZKiS64W8v/mPx1wZkvwCN5XFVurQGltzIM4BjvnhzCx PA7jAYAMILSPfzE0kSst0ArjiVZGFMuJxhCaOSeDzTf8IVkGb9SBNLCv0 X2vQtUrNlN+yIYqZDtCk6hHL9WuPQwpqWnVs6PvIEuJQyJGBwk2/Pz928 8TbQzjonmExPtQiYJi06xv4jNykbv96bQ1RuJXEKNJdUXVh2lIdsVJLBa RZbzwPMVdIgY9QVy4vYJ932a7mR4CvRH2j0V6K5HQVRegTnP6W6DtlJZt A==; X-CSE-ConnectionGUID: 6cFwzYqlTtaG/RRQIX3vRQ== X-CSE-MsgGUID: mIgp3OslRnyUcLNr+bsqDw== X-IronPort-AV: E=McAfee;i="6800,10657,11491"; a="54292691" X-IronPort-AV: E=Sophos;i="6.16,305,1744095600"; d="scan'208";a="54292691" Received: from orviesa006.jf.intel.com ([10.64.159.146]) by orvoesa112.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Jul 2025 16:53:59 -0700 X-CSE-ConnectionGUID: IlvRsKYeQnWA4N+ugy4zSw== X-CSE-MsgGUID: jaq1vAD9R36Ke+vuppiI2g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.16,305,1744095600"; d="scan'208";a="155902131" Received: from agluck-desk3.sc.intel.com ([172.25.103.51]) by orviesa006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Jul 2025 16:53:59 -0700 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Maciej Wieczor-Retman , Peter Newman , James Morse , Babu Moger , Drew Fustini , Dave Martin , Anil Keshavamurthy , Chen Yu Cc: x86@kernel.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [PATCH v7 15/31] x86,fs/resctrl: Add an architectural hook called for each mount Date: Fri, 11 Jul 2025 16:53:22 -0700 Message-ID: <20250711235341.113933-16-tony.luck@intel.com> X-Mailer: git-send-email 2.50.0 In-Reply-To: <20250711235341.113933-1-tony.luck@intel.com> References: <20250711235341.113933-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 not complete when the resctrl "late_init" code is executed. 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. The hook is called on every attempted mount. But expectations are that most actions (like enumeration) will only need to be performed on the first call. The call is made 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 e9a1cabfc724..d2fc0fcd0226 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -460,6 +460,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 for each attempted file system mount. + * 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 0286d3cf6754..22ff91b666d0 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 6df06bf0e694..627243a1175c 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; =20 + resctrl_arch_pre_mount(); + cpus_read_lock(); mutex_lock(&rdtgroup_mutex); /* --=20 2.50.0