From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.11]) (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 E5FF23C378D for ; Wed, 1 Jul 2026 21:36:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.11 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782941768; cv=none; b=pElSS+Rva97r2HjcajikvRP03YCLkrGrXAwNVtiSWulG4yLXbzSiyfvF8iQpaqYw0wN8IADb4gl5yBz+pXc0sPI2G/aQWVuOvGPsclQJPNU+AI8Z6bU6Aej+JpoBrWMDO4tF/ngwB40X0eoJLQpqlXV6H33k0ZEsGGFUZLvfVNc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782941768; c=relaxed/simple; bh=Pa2itfRaZ8FrGBGS7z0awLifmkGGXaNoCaGOcBsX5HY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rw9ona5nUTuSN2unylxyKeF5DNdTd4L3pWLea4sd/lPejBd++d3S5sHI690pB0dkkYP6rK1Kff5skPM+H6ZAvTubWFfiC8dpH50PA1C0WpcK8pm/2arlbnnqXS5fQQ9zDajYF1cg5jO685owxnsMoEMzqEEKmeCegNlHUSiwxt4= 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=Awn1wuXc; arc=none smtp.client-ip=192.198.163.11 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="Awn1wuXc" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1782941767; x=1814477767; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Pa2itfRaZ8FrGBGS7z0awLifmkGGXaNoCaGOcBsX5HY=; b=Awn1wuXcRMANp1dBZ24cwvr0TI1bQ5hJesbeMzD/e6lKwlyhF0JmLqtS cS/VBSAWUecrJN4TxizTU4EXb5hXGJEVba2FhaMzntKTH1NbciWZJuL2C 7Yksh9c1LhUY6KHpEBXVT8ShIpR5Ubrm5AMdTdl1H1N7RINqn5VXAJtze TEMucCDleZlTFq73aLWhSo/11ZKXT6LAj2entYIYojSMeR1vWqWN/mwOk a7B7Ar+LvLvfhEKy+Z5r13pWleJhylCKS9DwCUPk8hJ0qgYmQ0UygTS4x Pk7hAd2DooO1Zk453pViptuP+Yq/tR4ef43S+AAzhdSOETOMbk9/Qm33V w==; X-CSE-ConnectionGUID: ZfohfG3USdCjZMJCBOMAvA== X-CSE-MsgGUID: tNUXR88PTDK84Lp89ulfgQ== X-IronPort-AV: E=McAfee;i="6800,10657,11834"; a="94285808" X-IronPort-AV: E=Sophos;i="6.25,142,1779174000"; d="scan'208";a="94285808" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jul 2026 14:36:04 -0700 X-CSE-ConnectionGUID: JRREuX1+RSSlZWVsYRdByQ== X-CSE-MsgGUID: Gl0ra/IrS6iMdUCUarkhIw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.25,142,1779174000"; d="scan'208";a="252242539" Received: from mdroper-mobl2.amr.corp.intel.com (HELO agluck-desk3.intel.com) ([10.124.221.120]) by orviesa008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jul 2026 14:36:03 -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 v9 07/12] x86/resctrl: Add PMT registration API for AET enumeration callbacks Date: Wed, 1 Jul 2026 14:35:48 -0700 Message-ID: <20260701213553.15222-8-tony.luck@intel.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260701213553.15222-1-tony.luck@intel.com> References: <20260701213553.15222-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: 8bit 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 | 34 +++++++++++++++++++++++++ 2 files changed, 56 insertions(+) diff --git a/arch/x86/include/asm/resctrl.h b/arch/x86/include/asm/resctrl.h index a9f481b7a8ed..48ad55bcda66 100644 --- a/arch/x86/include/asm/resctrl.h +++ b/arch/x86/include/asm/resctrl.h @@ -4,6 +4,8 @@ #ifdef CONFIG_X86_CPU_RESCTRL +#include +#include #include #include #include @@ -189,11 +191,31 @@ static inline void resctrl_arch_mon_ctx_free(struct rdt_resource *r, void resctrl_cpu_detect(struct cpuinfo_x86 *c); +#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 static inline void resctrl_arch_sched_in(struct task_struct *tsk) {} static inline void resctrl_cpu_detect(struct cpuinfo_x86 *c) {} +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 */ #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 cd8257c58f84..c26bd813e057 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 #include +#include #include #include #include #include #include +#include #include #include #include #include #include #include +#include +#include #include #include #include @@ -291,6 +295,10 @@ static enum pmt_feature_id lookup_pfid(const char *pfname) return FEATURE_INVALID; } +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 there is * one, the returned structure has an array of telemetry_region structures, @@ -325,6 +333,32 @@ bool intel_aet_get_events(void) return ret; } +/* + * Defend against races between pmt_telemetry register/unregister and + * resctrl file system mount/unmount. + */ +static DEFINE_MUTEX(aet_register_lock); + +void intel_aet_register_enumeration(struct module *module, + struct pmt_feature_group *(*get)(enum pmt_feature_id id), + void (*put)(struct pmt_feature_group *p)) +{ + guard(mutex)(&aet_register_lock); + get_feature = get; + put_feature = put; + pmt_module = module; +} +EXPORT_SYMBOL_NS_GPL(intel_aet_register_enumeration, "INTEL_PMT"); + +void intel_aet_unregister_enumeration(void) +{ + guard(mutex)(&aet_register_lock); + pmt_module = NULL; + get_feature = NULL; + put_feature = NULL; +} +EXPORT_SYMBOL_NS_GPL(intel_aet_unregister_enumeration, "INTEL_PMT"); + void __exit intel_aet_exit(void) { struct event_group **peg; -- 2.54.0