From nobody Fri Sep 25 04:07:27 2026 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 526864CA29A for ; Wed, 16 Sep 2026 23:13:31 +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=1789600412; cv=none; b=fyDZN/kHDRvj/VimzcWg4U1/xMmNd6aG7989aZzlAjtfybROl+8WHK4Lr7SrxAZ/pREtnzvlQ7qy0zos74iMmTRP/t5MFuypDJg0pPDs65y1n64DFOx91Fn35uir5IrhF36aZikTYQ4BpWAiQvvvtTDMmjdD9pOW63zkBH2MFqo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789600412; c=relaxed/simple; bh=XCX+SCuVuGGp2hSn0gORTZORy11446xuO1qh/nEZE9U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=S2nuvNQzVDqQjIWxXYgOCraCNVhnHlkoRfX1elhJx8C9RLQBQek2J63D+CMD+CM85OAHMBtQ19AiqGgszge6R2hgV1JSezMwLirAL7AqNKTMTvqtyWnir9ezV2ntViHlIdRzozpDf0N68Vs3gMxSd6fVCAJcz+XbmKkuraIa7KY= 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=d28sS7u6; 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="d28sS7u6" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1789600412; x=1821136412; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=XCX+SCuVuGGp2hSn0gORTZORy11446xuO1qh/nEZE9U=; b=d28sS7u6Pk1iavkKzJr3gTemDLdhy/l4ORUSDZrNxiDSHOrgcAxeGp1b /aGqv+oJEkG1uSa3c4it94xa7ZsrtUutknySPK+q0Mjk7tc8oEtHZffBx /nd6L4pDuOmVL3y5V8VlHxtgi9MRMMSbk0ZNiL2J9CPpzXJpj+ddacfCc ybtJtUDdTZeDE1cLbsDltRJqQo7F3xwyIKpgkQ0g6uf6UM9o3/67R2x8U lW80nkLHEQcNeEqylsi/wX4pCn9ff9aPE8ilzFYxDALoMSYM0V/Az13f7 BbBB9i927EsjBcC+Ygy0fW5SEyDRU7qhXqY6mzRlsx9iyBSu6K5j4IFdL g==; X-CSE-ConnectionGUID: 4ZVRN7mhTYKyacaCTOrgIQ== X-CSE-MsgGUID: wlir2tCJSW61XIgpxpsfXQ== X-IronPort-AV: E=McAfee;i="6800,10657,11905"; a="93861316" X-IronPort-AV: E=Sophos;i="6.27,103,1787036400"; d="scan'208";a="93861316" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by orvoesa106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Sep 2026 16:13:30 -0700 X-CSE-ConnectionGUID: hQxGxMWMRne8pqCNZzK7mQ== X-CSE-MsgGUID: +ni1n5YoRyyxBmVVEGwSYg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,103,1787036400"; d="scan'208";a="277231420" Received: from khuang2-desk.gar.corp.intel.com (HELO agluck-desk3.home.arpa) ([10.124.223.219]) by orviesa004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Sep 2026 16:13:30 -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 v12 01/25] x86/cpufeatures: Add missing CQM feature dependency Date: Wed, 16 Sep 2026 16:12:56 -0700 Message-ID: <20260916231320.14502-2-tony.luck@intel.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260916231320.14502-1-tony.luck@intel.com> References: <20260916231320.14502-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 Software Developer's Manual says that software must check that CPUID(0x7,0x0).EBX[12] (Linux X86_FEATURE_CQM) is set before checking for monitoring features in CPUID leaf 0xF. Add the missing dependency of X86_FEATURE_CQM_LLC on X86_FEATURE_CQM. Signed-off-by: Tony Luck Reviewed-by: Reinette Chatre --- v12: Drop the X86_FEATURE renames. Just add the missing dependency. --- arch/x86/kernel/cpu/cpuid-deps.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/x86/kernel/cpu/cpuid-deps.c b/arch/x86/kernel/cpu/cpuid-d= eps.c index 99801e844b30..93d45b688f6c 100644 --- a/arch/x86/kernel/cpu/cpuid-deps.c +++ b/arch/x86/kernel/cpu/cpuid-deps.c @@ -67,6 +67,7 @@ static const struct cpuid_dep cpuid_deps[] =3D { { X86_FEATURE_AVX512_4FMAPS, X86_FEATURE_AVX512F }, { X86_FEATURE_AVX512_VPOPCNTDQ, X86_FEATURE_AVX512F }, { X86_FEATURE_AVX512_VP2INTERSECT, X86_FEATURE_AVX512VL }, + { X86_FEATURE_CQM_LLC, X86_FEATURE_CQM }, { X86_FEATURE_CQM_OCCUP_LLC, X86_FEATURE_CQM_LLC }, { X86_FEATURE_CQM_MBM_TOTAL, X86_FEATURE_CQM_LLC }, { X86_FEATURE_CQM_MBM_LOCAL, X86_FEATURE_CQM_LLC }, --=20 2.55.0 From nobody Fri Sep 25 04:07:27 2026 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 22E484B3364 for ; Wed, 16 Sep 2026 23:13:32 +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=1789600414; cv=none; b=ppj+XtBU7Esq+ueDjCF4KPKL78tKlWBtKY6wL7+UzLKL9sVqzW/m3FAmWG3eIdf3axM4lv1/yu4MlZ1lCeX38hvje7/Xclr3tq0NtGoIy1QFFp/W1NYiq93M8aURvmg4VBAqGUDYIxsb0h93zClMBSXPKiaKoGXN+32GwWd/4Gg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789600414; c=relaxed/simple; bh=SJWp1RNmkTVmRTX4ajftJQ6TmgZ+7cQho1eSP7VnGvs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BUbDIY7hLIeCKK0Uhkbg3Iz5LVi1ghDJmvAzEJ+1NKTlmoSFxCDz4z4SazdKJ7oUJFh8ZAk8cPVEhYWVBfTYraf6oz+rKHi0SHtlB4tq5YLGiJmGmuiVFmbNRK6pO3qS/K3PaIRfgjsZ2/pZqz6w3YZ7Ej9OHqFF8dMhBnS8iRo= 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=kJ7BXs0O; 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="kJ7BXs0O" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1789600412; x=1821136412; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=SJWp1RNmkTVmRTX4ajftJQ6TmgZ+7cQho1eSP7VnGvs=; b=kJ7BXs0Oz76C7ttxMqpaXjY0oY5CkqFCuZ/LQpOOZXnFtqkxg95wKP8a AK/eTHh2kYz39swCbWK+8n+ek/gyZheqCIsdWHPWItLzB40DKrCYVIRDZ NnoNFOpPnXzv2IvmyXB3ZdOSY3K692qWYFJLkG8/y0UsUXwKmZyd3nIbs EQPrEjL1Fat0iGjIPwfWgeALGIaVmF6UhlcJqMj+wpz9f7D8lkx61iqhC LX4XZ0r0gPkCWtnXVt+CaBkayVbCrm67fsML8diCEqrduwjZZl7jk6sCh 77AJxPs6kyKYaPhZnEIXhRktUpsoqs6uchf0TXqFLtykCdw9L9wKqIdQX A==; X-CSE-ConnectionGUID: J4QFiiavSkS9rXenQVqdMg== X-CSE-MsgGUID: YG0EommPQLWkvGDB08XKVA== X-IronPort-AV: E=McAfee;i="6800,10657,11905"; a="93861325" X-IronPort-AV: E=Sophos;i="6.27,103,1787036400"; d="scan'208";a="93861325" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by orvoesa106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Sep 2026 16:13:31 -0700 X-CSE-ConnectionGUID: 594Vl3cFQtyRZbDeFnEcHw== X-CSE-MsgGUID: lusfiszMQZCUjSAD4fsGZw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,103,1787036400"; d="scan'208";a="277231425" Received: from khuang2-desk.gar.corp.intel.com (HELO agluck-desk3.home.arpa) ([10.124.223.219]) by orviesa004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Sep 2026 16:13:31 -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 v12 02/25] x86/resctrl: Check if monitoring features are supported Date: Wed, 16 Sep 2026 16:12:57 -0700 Message-ID: <20260916231320.14502-3-tony.luck@intel.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260916231320.14502-1-tony.luck@intel.com> References: <20260916231320.14502-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" Both Intel and AMD manuals say that software must first check CPUID(0x7,0x0).EBX[12] (Linux: X86_FEATURE_CQM) to see if any monitoring features are supported before checking for specific features supported in subleaves. Each of the L3-based monitoring features is further gated by CPUID(0xF,0x0).EDX[1] (Linux: X86_FEATURE_CQM_LLC). Add checks for these feature bits. Fixes: cbc82b172638 ("x86: Add support for Intel Cache QoS Monitoring (CQM)= detection") Signed-off-by: Tony Luck --- v12: Revert X86_FEATURE name changes. Invert the test for X86_FEATURE_CQM_LLC to avoid adding extra indentation churn and keep call to rdt_get_l3_mon_config in the X86_FEATURE_CQM_LLC code path. --- arch/x86/kernel/cpu/resctrl/core.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resct= rl/core.c index 55214d6fdc49..34ca3c7cc046 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -968,6 +968,14 @@ static __init bool get_rdt_mon_resources(void) struct rdt_resource *r =3D &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl; bool ret =3D false; =20 + /* Any monitoring at all? */ + if (!cpu_feature_enabled(X86_FEATURE_CQM)) + return false; + + /* Any of the L3 monitoring features? */ + if (!cpu_feature_enabled(X86_FEATURE_CQM_LLC)) + return false; + if (rdt_cpu_has(X86_FEATURE_CQM_OCCUP_LLC)) { resctrl_enable_mon_event(QOS_L3_OCCUP_EVENT_ID, false, 0, NULL); ret =3D true; --=20 2.55.0 From nobody Fri Sep 25 04:07:27 2026 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 BB6054D9908 for ; Wed, 16 Sep 2026 23:13:32 +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=1789600414; cv=none; b=Qt/+8YDws0ncpvxiJpYd/L1BGu4s5vWzsHk/avNYog/aDYtyc0G/7nz5DoP82L20m6cyFunKwcgXInsRze88KUjUgf7uEsQDxEsTIzicXrRsz/gqfA9eC+LNoK6izL+STE6JxhKQ75t9gxPl5h9PrIWN3CK1nMoTW/axLL2ArlE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789600414; c=relaxed/simple; bh=vMkHeDQIC1JCCg3KkGmer0kIWP3pCj5wuRSLO20edJ4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=W6y7VoLctYPUQi0ufQvEB1/nXVnqovq9KmPHqTh3yKe4atLDv7xpdn5D0MYqQLln/h0JwCtrf9iEh6+ehWGXGcMTTPbgAlfBc74WtiGOKo3IzO6qLzY2qxZRxlaz1NtP0rG7CZMcp1tLhifybN2NcKgaeFYYVCA6PyyiTsC5y0Y= 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=FYVQwxh2; 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="FYVQwxh2" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1789600413; x=1821136413; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=vMkHeDQIC1JCCg3KkGmer0kIWP3pCj5wuRSLO20edJ4=; b=FYVQwxh27Cp2AShBurZeLEyrnC0pdMT3gCmQmRKNCXLQ9r+sX3xmVeA5 vCTP60xAOHQKSsub6DOOFOYcQgq9wQxUeXu76galEeao7yzoxBoJbQ+bv Y6XIVVK/wMvTyUWkugvtbH2JJhf9LBvmxVJCezfmu+Ozf959wRLqfx5yt cDAktG4HciJRMRcFEI0Ogg1U1EUI4D5nFL2oCvwrvQdmOLPvDKnoDBXIB B9f6enEda1t4YDdoJ79n8Hwmxs5X74LQ/kV/7P8SPwAwUKC2x3H9pgL8M iaDL17rairUEIeCwSiD7Yo97p0qLlOtu7baMdX5xyi9dP5WDRJdEV/TaZ Q==; X-CSE-ConnectionGUID: RnsyzssCSc+5aRjOYwpH4w== X-CSE-MsgGUID: 1vINy99oSDaEso/IKuaS5A== X-IronPort-AV: E=McAfee;i="6800,10657,11905"; a="93861334" X-IronPort-AV: E=Sophos;i="6.27,103,1787036400"; d="scan'208";a="93861334" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by orvoesa106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Sep 2026 16:13:31 -0700 X-CSE-ConnectionGUID: 7w1MFBkXRbWH3HsfnE/dnQ== X-CSE-MsgGUID: xrsazRYZRVW38TrbM/KBKg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,103,1787036400"; d="scan'208";a="277231430" Received: from khuang2-desk.gar.corp.intel.com (HELO agluck-desk3.home.arpa) ([10.124.223.219]) by orviesa004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Sep 2026 16:13:31 -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 v12 03/25] x86/resctrl: Enumerate monitor features in rdt_get_l3_mon_config() Date: Wed, 16 Sep 2026 16:12:58 -0700 Message-ID: <20260916231320.14502-4-tony.luck@intel.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260916231320.14502-1-tony.luck@intel.com> References: <20260916231320.14502-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 original implementation of Intel Cache QoS Monitoring (CQM) planned to integrate with the "perf" and "cgroup" subsystems. With that plan it made sense for parameters from CPUID to be stored in fields of the cpuinfo_x86 structure. But that plan was abandoned and the resctrl file system user interface replaced it. Change rdt_get_l3_mon_config() to make an explicit cpuid_count() call to enumerate L3 monitoring features in preparation for the removal of resctrl fields from cpuinfo_x86. Signed-off-by: Tony Luck --- v12: Better comment for the cpuid_count() call. s/0xff/GENMASK(7, 0)/ Update commit comment to say that this is in preparation to remove the resctrl elements from boot_cpu_data. --- arch/x86/include/asm/resctrl.h | 9 ++++---- arch/x86/kernel/cpu/resctrl/monitor.c | 32 ++++++++++++++++++++++++--- 2 files changed, 33 insertions(+), 8 deletions(-) diff --git a/arch/x86/include/asm/resctrl.h b/arch/x86/include/asm/resctrl.h index 8f6edcdcfd87..9bfa9b14002b 100644 --- a/arch/x86/include/asm/resctrl.h +++ b/arch/x86/include/asm/resctrl.h @@ -44,6 +44,7 @@ DECLARE_PER_CPU(struct resctrl_pqr_state, pqr_state); =20 extern bool rdt_alloc_capable; extern bool rdt_mon_capable; +extern unsigned int __ro_after_init rdt_l3_mon_scale; =20 DECLARE_STATIC_KEY_FALSE(rdt_enable_key); DECLARE_STATIC_KEY_FALSE(rdt_alloc_enable_key); @@ -132,11 +133,9 @@ static inline void __resctrl_sched_in(struct task_stru= ct *tsk) =20 static inline unsigned int resctrl_arch_round_mon_val(unsigned int val) { - unsigned int scale =3D boot_cpu_data.x86_cache_occ_scale; - - /* h/w works in units of "boot_cpu_data.x86_cache_occ_scale" */ - val /=3D scale; - return val * scale; + /* Round down to nearest h/w monitoring unit */ + val /=3D rdt_l3_mon_scale; + return val * rdt_l3_mon_scale; } =20 static inline void resctrl_arch_set_cpu_default_closid_rmid(int cpu, u32 c= losid, diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/re= sctrl/monitor.c index 3838e0a13d36..89b83cc7e800 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -32,6 +32,11 @@ */ bool rdt_mon_capable; =20 +/* + * Scale factor to convert L3 monitor events to bytes. + */ +unsigned int __ro_after_init rdt_l3_mon_scale; + #define CF(cf) ((unsigned long)(1048576 * (cf) + 0.5)) =20 static int snc_nodes_per_l3_cache =3D 1; @@ -418,16 +423,37 @@ static __init int snc_get_config(void) =20 int __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); + unsigned int mbm_offset; unsigned int threshold; u32 eax, ebx, ecx, edx; + u32 num_rmid; + + /* Resource monitoring leaf is 0xf. L3 monitoring details in subleaf 1 */ + cpuid_count(0xf, 1, &eax, &ebx, &ecx, &edx); + mbm_offset =3D eax & GENMASK(7, 0); + rdt_l3_mon_scale =3D ebx; + num_rmid =3D ecx + 1; + + if (!mbm_offset) { + switch (boot_cpu_data.x86_vendor) { + case X86_VENDOR_AMD: + mbm_offset =3D MBM_CNTR_WIDTH_OFFSET_AMD; + break; + case X86_VENDOR_HYGON: + mbm_offset =3D MBM_CNTR_WIDTH_OFFSET_HYGON; + break; + default: + /* Leave mbm_offset as 0 */ + break; + } + } =20 snc_nodes_per_l3_cache =3D snc_get_config(); =20 resctrl_rmid_realloc_limit =3D boot_cpu_data.x86_cache_size * 1024; - hw_res->mon_scale =3D boot_cpu_data.x86_cache_occ_scale / snc_nodes_per_l= 3_cache; - r->mon.num_rmid =3D (boot_cpu_data.x86_cache_max_rmid + 1) / snc_nodes_pe= r_l3_cache; + hw_res->mon_scale =3D rdt_l3_mon_scale / snc_nodes_per_l3_cache; + r->mon.num_rmid =3D num_rmid / snc_nodes_per_l3_cache; hw_res->mbm_width =3D MBM_CNTR_WIDTH_BASE; =20 if (mbm_offset > 0 && mbm_offset <=3D MBM_CNTR_WIDTH_OFFSET_MAX) --=20 2.55.0 From nobody Fri Sep 25 04:07:27 2026 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 258C94E06DE for ; Wed, 16 Sep 2026 23:13:33 +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=1789600416; cv=none; b=b5Wu++4bXF7ciW7C9hr71pyBxoTrNK2Hs59r/fN6DGfiz3JdVfKT+LVofFsyo3ugSFE6ompoNF4l8+fKYAPTUBUEfqswNgefwyvWq2RvPBsH2uar+UJR7Zv2ELcM1or2E7FMD2BOCyQN3gj8a1D5fy5Q/bjR6JpTe1b9X3StjBw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789600416; c=relaxed/simple; bh=b78w4Q5/oAk8AxLWTFSPezUXUZOigprtMDZLpaZuLKo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gF1TAzT57sG9EWwoO81q6I6CSfvZJ17AieJkZ3cot53LpkLt9fn+KGWvtpoKJacYAObapV33m6T5r5QhMjBJ82VS2ilydKgicUdbC86AzAB2pr83K0Ooxz0I75+LM7meD70AO/pEVkXSonciPG44xe+ssgnKZTbmuKQM4pHNwdA= 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=PgLxNs/T; 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="PgLxNs/T" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1789600413; x=1821136413; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=b78w4Q5/oAk8AxLWTFSPezUXUZOigprtMDZLpaZuLKo=; b=PgLxNs/Tw+7Bw2LrSg/KfwTHa+RFLNW/fPQzwUG35aJeB50QKS8Zgeb8 wXkJOyFej4XD3rVDG93DRqB4V8gjGqVVVVQWaHJ1Bn5UUguN6vNH3kUQJ hXizTJPn5QoFJ8OLXEEItnzs30QbxxkvGHLQdUPgTYE7tf2qkk3vYUhBd e2k2l4vaSGINPGf8Hem3CX2xqXgLjI2YNLdT7dhuWLKc7+QENUG3lFCW9 xlTIgcj3Vh/ajvkaV4i/+O0o5PqgUwd2gNOyLAlSh0d3fNLpvjrE5FjDK cD7gF8dUNciGfMB8zv6wZbsGxEha6s9JTlqxDYwVIRNKZNyL1UPL6HzWj g==; X-CSE-ConnectionGUID: wmE4xdQ5RiS0QiwmyVBHZA== X-CSE-MsgGUID: 2G3qjH3FSjCVNUPyh5TNpg== X-IronPort-AV: E=McAfee;i="6800,10657,11905"; a="93861344" X-IronPort-AV: E=Sophos;i="6.27,103,1787036400"; d="scan'208";a="93861344" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by orvoesa106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Sep 2026 16:13:32 -0700 X-CSE-ConnectionGUID: ouEkTmpaRaWMS2x+lbtJag== X-CSE-MsgGUID: Y43W89fRTeeC8jFitK4zyA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,103,1787036400"; d="scan'208";a="277231433" Received: from khuang2-desk.gar.corp.intel.com (HELO agluck-desk3.home.arpa) ([10.124.223.219]) by orviesa004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Sep 2026 16:13:32 -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 v12 04/25] x86/resctrl: Apply Intel MBM quirk from rdt_get_l3_mon_config() Date: Wed, 16 Sep 2026 16:12:59 -0700 Message-ID: <20260916231320.14502-5-tony.luck@intel.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260916231320.14502-1-tony.luck@intel.com> References: <20260916231320.14502-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 quirk to adjust Memory Bandwidth Monitoring (MBM) values on certain CPUs is applied early, before discovering if MBM is supported. Move the call into rdt_get_l3_mon_config(), but keep the decision on whether it is needed in __check_quirks_intel() with all the other model specific tests. Signed-off-by: Tony Luck --- v12: Change type of cf_index to unsigned in intel_rdt_mbm_apply_quirk() --- arch/x86/kernel/cpu/resctrl/internal.h | 4 +-- arch/x86/kernel/cpu/resctrl/core.c | 2 +- arch/x86/kernel/cpu/resctrl/monitor.c | 35 +++++++++++++++----------- 3 files changed, 23 insertions(+), 18 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/r= esctrl/internal.h index e3cfa0c10e92..e46eb9a4c725 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -151,6 +151,8 @@ static inline struct rdt_hw_resource *resctrl_to_arch_r= es(struct rdt_resource *r =20 extern struct rdt_hw_resource rdt_resources_all[]; =20 +extern bool __initdata intel_rdt_mbm_need_quirk; + void arch_mon_domain_online(struct rdt_resource *r, struct rdt_l3_mon_doma= in *d); =20 /* CPUID.(EAX=3D10H, ECX=3DResID=3D1).EAX */ @@ -228,8 +230,6 @@ int rdt_get_l3_mon_config(struct rdt_resource *r); =20 bool rdt_cpu_has(int flag); =20 -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 diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resct= rl/core.c index 34ca3c7cc046..82b27a0157ae 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -1011,7 +1011,7 @@ static __init void __check_quirks_intel(void) set_rdt_options("!l3cat"); fallthrough; case INTEL_BROADWELL_X: - intel_rdt_mbm_apply_quirk(); + intel_rdt_mbm_need_quirk =3D true; break; } } diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/re= sctrl/monitor.c index 89b83cc7e800..ab9cb34145c5 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -37,6 +37,8 @@ bool rdt_mon_capable; */ unsigned int __ro_after_init rdt_l3_mon_scale; =20 +bool __initdata intel_rdt_mbm_need_quirk; + #define CF(cf) ((unsigned long)(1048576 * (cf) + 0.5)) =20 static int snc_nodes_per_l3_cache =3D 1; @@ -51,7 +53,7 @@ static int snc_nodes_per_l3_cache =3D 1; * 1. The threshold 0 is changed to rmid count - 1 so don't do correction * for the case. * 2. MBM total and local correction table indexed by core counter which is - * equal to (x86_cache_max_rmid + 1) / 8 - 1 and is from 0 up to 27. + * equal to r->mon.num_rmid / 8 - 1 and is from 0 up to 27. * 3. The correction factor is normalized to 2^20 (1048576) so it's faster * to calculate corrected value by shifting: * corrected_value =3D (original_value * correction_factor) >> 20 @@ -421,6 +423,20 @@ static __init int snc_get_config(void) return ret; } =20 +static void __init intel_rdt_mbm_apply_quirk(u32 num_rmid) +{ + unsigned int cf_index; + + cf_index =3D num_rmid / 8 - 1; + if (cf_index >=3D ARRAY_SIZE(mbm_cf_table)) { + pr_info("No MBM correction factor available\n"); + return; + } + + mbm_cf_rmidthreshold =3D mbm_cf_table[cf_index].rmidthreshold; + mbm_cf =3D mbm_cf_table[cf_index].cf; +} + int __init rdt_get_l3_mon_config(struct rdt_resource *r) { struct rdt_hw_resource *hw_res =3D resctrl_to_arch_res(r); @@ -500,25 +516,14 @@ int __init rdt_get_l3_mon_config(struct rdt_resource = *r) hw_res->mbm_cntr_assign_enabled =3D true; } =20 + if (intel_rdt_mbm_need_quirk) + intel_rdt_mbm_apply_quirk(r->mon.num_rmid); + r->mon_capable =3D true; =20 return 0; } =20 -void __init intel_rdt_mbm_apply_quirk(void) -{ - int cf_index; - - cf_index =3D (boot_cpu_data.x86_cache_max_rmid + 1) / 8 - 1; - if (cf_index >=3D ARRAY_SIZE(mbm_cf_table)) { - pr_info("No MBM correction factor available\n"); - return; - } - - mbm_cf_rmidthreshold =3D mbm_cf_table[cf_index].rmidthreshold; - mbm_cf =3D mbm_cf_table[cf_index].cf; -} - static void resctrl_abmc_set_one_amd(void *arg) { bool *enable =3D arg; --=20 2.55.0 From nobody Fri Sep 25 04:07:27 2026 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 BDE2F4E4302 for ; Wed, 16 Sep 2026 23:13:34 +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=1789600418; cv=none; b=IVyUBIHgEYFZaH0hgU7uMWu4c/a8OBhVRriwmzbxyas21n3VDfedS2Vdgad4k0rvpSlGIQwHDp2WERV1f8VFEgDBm0pecYUexaAL71AgL2ESLIZaUVsd9UAJiMNp3SFaU8qgiXdtS6loJdPZTrqAcdY6W3FTTuTNIYKfw+7Ha74= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789600418; c=relaxed/simple; bh=4B8Mhqv72RZOMhlRglNO3ieNTu5l4iDurKmAOs7y3bY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=p8yfX1prYY+h2FDQHm4pJYXAxDO6CjXxGq1BE90HOw/1Pq7LTTo0rqjc9WWxuf7Z2x0Tk3V7yobiwSnyPpjUOT+MuRDyRzO8rWKGZKbXlSJ0p4zHtLoi84CaZO+zHUkbIBZVHyjJPZsMur5Qa2V/EB+7M2yABdRStZfbie71ND4= 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=DPoLW5dc; 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="DPoLW5dc" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1789600415; x=1821136415; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=4B8Mhqv72RZOMhlRglNO3ieNTu5l4iDurKmAOs7y3bY=; b=DPoLW5dcop6XZApYMbzYoIOiqyi6UI3lOv2VsNpQxuGdwMm/YUzJpNZq ZX9vR6LUnOl7SC+iZCxPII3HjdOO7ix2nDDF6jldohFt78tJ1b2mgCBZq gpkvYiAzI9Y3ChpWVZaOouAceH8kcy9QLJX9id+HdrsQIYN0FMa6sMgHa WeQ8N8L8xQXnUuByLj7HRtdXGqrn21uGjDoc67MLkpVFgKSi+ZHMpj8Vj kRLogEkwuLibP1E3bTDYItqYg1rzDIU2igTd6OukbWY7cb148Fz1Na9W6 A7TCr/uRzX5FbVZjZVpobG82U0Z9Y85NNpA1Ro/OWeJAcrHJ/KbV6J7c7 Q==; X-CSE-ConnectionGUID: liQ3a1ykSJm3eVc0l66Zbw== X-CSE-MsgGUID: gSPj9u2uRC+fLkv0FNclWg== X-IronPort-AV: E=McAfee;i="6800,10657,11905"; a="93861353" X-IronPort-AV: E=Sophos;i="6.27,103,1787036400"; d="scan'208";a="93861353" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by orvoesa106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Sep 2026 16:13:32 -0700 X-CSE-ConnectionGUID: CexuQpH5QwG+Cxsxmtjewg== X-CSE-MsgGUID: 5DCXY7VPQOy2hryg1id0vA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,103,1787036400"; d="scan'208";a="277231440" Received: from khuang2-desk.gar.corp.intel.com (HELO agluck-desk3.home.arpa) ([10.124.223.219]) by orviesa004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Sep 2026 16:13:32 -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 , "Borislav Petkov (AMD)" Subject: [PATCH v12 05/25] x86/resctrl: Delete resctrl_cpu_detect() Date: Wed, 16 Sep 2026 16:13:00 -0700 Message-ID: <20260916231320.14502-6-tony.luck@intel.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260916231320.14502-1-tony.luck@intel.com> References: <20260916231320.14502-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" cpuinfo_x86::x86_cache_{max_rmid,occ_scale,mbm_width_offset} are no longer used. Delete resctrl_cpu_detect() and the fields from struct cpuinfo_x86. Signed-off-by: Tony Luck Acked-by: Borislav Petkov (AMD) --- v12: No change --- arch/x86/include/asm/processor.h | 4 --- arch/x86/include/asm/resctrl.h | 3 --- arch/x86/kernel/cpu/amd.c | 3 --- arch/x86/kernel/cpu/hygon.c | 3 --- arch/x86/kernel/cpu/intel.c | 7 ----- arch/x86/kernel/cpu/resctrl/core.c | 42 ------------------------------ 6 files changed, 62 deletions(-) diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/proces= sor.h index ec9db0dfa0df..4deb88c61c94 100644 --- a/arch/x86/include/asm/processor.h +++ b/arch/x86/include/asm/processor.h @@ -185,10 +185,6 @@ struct cpuinfo_x86 { /* in KB - valid for CPUS which support this call: */ unsigned int x86_cache_size; int x86_cache_alignment; /* In bytes */ - /* Cache QoS architectural values, valid only on the BSP: */ - int x86_cache_max_rmid; /* max index */ - int x86_cache_occ_scale; /* scale to bytes */ - int x86_cache_mbm_width_offset; int x86_power; unsigned long loops_per_jiffy; /* protected processor identification number */ diff --git a/arch/x86/include/asm/resctrl.h b/arch/x86/include/asm/resctrl.h index 9bfa9b14002b..ab7f6ccd149e 100644 --- a/arch/x86/include/asm/resctrl.h +++ b/arch/x86/include/asm/resctrl.h @@ -193,12 +193,9 @@ static inline void resctrl_arch_mon_ctx_free(struct rd= t_resource *r, enum resctrl_event_id evtid, void *ctx) { } =20 -void resctrl_cpu_detect(struct cpuinfo_x86 *c); - #else =20 static inline void resctrl_arch_sched_in(struct task_struct *tsk) {} -static inline void resctrl_cpu_detect(struct cpuinfo_x86 *c) {} =20 #endif /* CONFIG_X86_CPU_RESCTRL */ =20 diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c index 54e14ed276b5..dd82a11084f4 100644 --- a/arch/x86/kernel/cpu/amd.c +++ b/arch/x86/kernel/cpu/amd.c @@ -23,7 +23,6 @@ #include #include #include -#include #include #include =20 @@ -475,8 +474,6 @@ static void bsp_init_amd(struct cpuinfo_x86 *c) } } =20 - resctrl_cpu_detect(c); - /* Figure out Zen generations: */ switch (c->x86) { case 0x17: diff --git a/arch/x86/kernel/cpu/hygon.c b/arch/x86/kernel/cpu/hygon.c index ec51c2b9a257..0f226335dd9a 100644 --- a/arch/x86/kernel/cpu/hygon.c +++ b/arch/x86/kernel/cpu/hygon.c @@ -17,7 +17,6 @@ #include #include #include -#include =20 #include "cpu.h" =20 @@ -119,8 +118,6 @@ static void bsp_init_hygon(struct cpuinfo_x86 *c) x86_amd_ls_cfg_ssbd_mask =3D 1ULL << 10; } } - - resctrl_cpu_detect(c); } =20 static void early_init_hygon(struct cpuinfo_x86 *c) diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c index 4297ceb2cb24..2f09710e863c 100644 --- a/arch/x86/kernel/cpu/intel.c +++ b/arch/x86/kernel/cpu/intel.c @@ -22,7 +22,6 @@ #include #include #include -#include #include #include =20 @@ -371,11 +370,6 @@ static void early_init_intel(struct cpuinfo_x86 *c) detect_tme_early(c); } =20 -static void bsp_init_intel(struct cpuinfo_x86 *c) -{ - resctrl_cpu_detect(c); -} - #ifdef CONFIG_X86_32 /* * Early probe support logic for ppro memory erratum #50 @@ -804,7 +798,6 @@ static const struct cpu_dev intel_cpu_dev =3D { #endif .c_detect_tlb =3D intel_detect_tlb, .c_early_init =3D early_init_intel, - .c_bsp_init =3D bsp_init_intel, .c_init =3D init_intel, .c_x86_vendor =3D X86_VENDOR_INTEL, }; diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resct= rl/core.c index 82b27a0157ae..f0cfb37482d3 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -1083,48 +1083,6 @@ static __init void rdt_init_res_defs(void) =20 static enum cpuhp_state rdt_online; =20 -/* Runs once on the BSP during boot. */ -void resctrl_cpu_detect(struct cpuinfo_x86 *c) -{ - if (!cpu_has(c, X86_FEATURE_CQM_LLC) && !cpu_has(c, X86_FEATURE_ABMC)) { - c->x86_cache_max_rmid =3D -1; - c->x86_cache_occ_scale =3D -1; - c->x86_cache_mbm_width_offset =3D -1; - return; - } - - /* will be overridden if occupancy monitoring exists */ - c->x86_cache_max_rmid =3D cpuid_ebx(0xf); - - if (cpu_has(c, X86_FEATURE_CQM_OCCUP_LLC) || - cpu_has(c, X86_FEATURE_CQM_MBM_TOTAL) || - cpu_has(c, X86_FEATURE_CQM_MBM_LOCAL) || - cpu_has(c, X86_FEATURE_ABMC)) { - u32 eax, ebx, ecx, edx; - - /* QoS sub-leaf, EAX=3D0Fh, ECX=3D1 */ - cpuid_count(0xf, 1, &eax, &ebx, &ecx, &edx); - - c->x86_cache_max_rmid =3D ecx; - c->x86_cache_occ_scale =3D ebx; - c->x86_cache_mbm_width_offset =3D eax & 0xff; - - if (!c->x86_cache_mbm_width_offset) { - switch (c->x86_vendor) { - case X86_VENDOR_AMD: - c->x86_cache_mbm_width_offset =3D MBM_CNTR_WIDTH_OFFSET_AMD; - break; - case X86_VENDOR_HYGON: - c->x86_cache_mbm_width_offset =3D MBM_CNTR_WIDTH_OFFSET_HYGON; - break; - default: - /* Leave c->x86_cache_mbm_width_offset as 0 */ - break; - } - } - } -} - static int __init resctrl_arch_late_init(void) { struct rdt_resource *r; --=20 2.55.0 From nobody Fri Sep 25 04:07:27 2026 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 BC36E4E3EFB for ; Wed, 16 Sep 2026 23:13:34 +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=1789600418; cv=none; b=GIJdnhfmdoFA/8z2Wx1dVdsk6xnW8bXyGL8H7PJpmY7IFuB29JAkn8knCAPp0Xkz/jH9lowAet8qS4NbaI+V5BUTV317cDDCqomTHRvyyK9hr7p6tjgHM62cadZRZxic46zwj17pQqZnP4bqos1hGi/b2HVCgYmzf7Mz+CPGYOM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789600418; c=relaxed/simple; bh=qDlEJEGlP/OlBALubimGeO2TbFoCqhbq2JGqKI4msQM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GzwySejeQxTxOMvJHMvqKfVitZTCVtq+7DjCVWGqgbWWR5sDbE1arJAd10VlGEG3vZHsLtr3wCPW+JS3WueMHhE7mxkhiDk6R2I9GAQH4wikHFPbji87nuJ6sPPfB7W5895XdvtuRdRM4CBfwfSxD6nQFkViTXj26PFaz/tQrh4= 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=KbM6VGZe; 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="KbM6VGZe" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1789600415; x=1821136415; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=qDlEJEGlP/OlBALubimGeO2TbFoCqhbq2JGqKI4msQM=; b=KbM6VGZet4sJeYDFFf5tB93Qx5g1E3aP/RkC68PP99s4f4JzrXkyz489 Tgm1Wcp2gM+K2AT7HEqcnKRO0mOczWFf475woq/tkUWuDbRHlXU9Uzivu wCjeA+jqs/vk9NkBmnwOTFE0WRu5ORusSJwahXIVfuCbaO3G6XeV+dyTz DXQpgsd01pnlt/gNhBuxumMQfZalpe77++AFlRzBgnmpwYt5Oio1yplX0 5j4JsJGOIyNK0LL9Cf3OO1pBAfB/9/tahKlMZVCtkY7BitPoDw2wsXPv9 rYSx/U7LQ4kfTP6LZ+kqeO9svRH1dAfpRIZx8xOpRO8KzvzriBumEtGXk Q==; X-CSE-ConnectionGUID: lvHd7fL4QNqbJ3XaDwIM0A== X-CSE-MsgGUID: t4AK9mPDQNugPOQJPFzmRQ== X-IronPort-AV: E=McAfee;i="6800,10657,11905"; a="93861363" X-IronPort-AV: E=Sophos;i="6.27,103,1787036400"; d="scan'208";a="93861363" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by orvoesa106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Sep 2026 16:13:33 -0700 X-CSE-ConnectionGUID: tpe6RBUwTC21cEsbJoIBaA== X-CSE-MsgGUID: dh4ogFmxRP6rn13MPAPnVA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,103,1787036400"; d="scan'208";a="277231443" Received: from khuang2-desk.gar.corp.intel.com (HELO agluck-desk3.home.arpa) ([10.124.223.219]) by orviesa004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Sep 2026 16:13:32 -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 v12 06/25] arm,x86,fs/resctrl: Replace architecture resctrl_arch_{alloc,mon}_capable() Date: Wed, 16 Sep 2026 16:13:01 -0700 Message-ID: <20260916231320.14502-7-tony.luck@intel.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260916231320.14502-1-tony.luck@intel.com> References: <20260916231320.14502-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" All the information to determine whether a system is alloc, or mon, capable is available to the file system. Architecture helpers are not needed. Define generic resctrl_alloc_capable() and resctrl_mon_capable() and replace all architecture versions. Suggested-by: Reinette Chatre Signed-off-by: Tony Luck --- v12: In each of resctrl_alloc_capable() and resctrl_mon_capable() - Header comment is a question, end with "?" instead of period. - Add { } around multi-line for-loop. - s/(r)/r/ - Add blank line before final return. --- include/linux/arm_mpam.h | 3 --- include/linux/resctrl.h | 30 +++++++++++++++++++++++++++ arch/x86/include/asm/resctrl.h | 10 --------- drivers/resctrl/mpam_resctrl.c | 26 ++--------------------- fs/resctrl/monitor.c | 10 ++++----- fs/resctrl/pseudo_lock.c | 6 +++--- fs/resctrl/rdtgroup.c | 38 +++++++++++++++++----------------- 7 files changed, 59 insertions(+), 64 deletions(-) diff --git a/include/linux/arm_mpam.h b/include/linux/arm_mpam.h index f92a36187a52..ba4131048260 100644 --- a/include/linux/arm_mpam.h +++ b/include/linux/arm_mpam.h @@ -50,9 +50,6 @@ static inline int mpam_ris_create(struct mpam_msc *msc, u= 8 ris_idx, } #endif =20 -bool resctrl_arch_alloc_capable(void); -bool resctrl_arch_mon_capable(void); - void resctrl_arch_set_cpu_default_closid(int cpu, u32 closid); void resctrl_arch_set_closid_rmid(struct task_struct *tsk, u32 closid, u32= rmid); void resctrl_arch_set_cpu_default_closid_rmid(int cpu, u32 closid, u32 rmi= d); diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index dd09c2ce9a0f..6b07ac2c8675 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -346,6 +346,36 @@ struct rdt_resource { */ struct rdt_resource *resctrl_arch_get_resource(enum resctrl_res_level l); =20 +/* + * resctrl_alloc_capable - Are any allocation resources enabled? + */ +static inline bool resctrl_alloc_capable(void) +{ + struct rdt_resource *r; + + for_each_rdt_resource(r) { + if (r->alloc_capable) + return true; + } + + return false; +} + +/* + * resctrl_mon_capable - Are any monitor resources enabled? + */ +static inline bool resctrl_mon_capable(void) +{ + struct rdt_resource *r; + + for_each_rdt_resource(r) { + if (r->mon_capable) + return true; + } + + return false; +} + /** * struct resctrl_schema - configuration abilities of a resource presented= to * user-space diff --git a/arch/x86/include/asm/resctrl.h b/arch/x86/include/asm/resctrl.h index ab7f6ccd149e..fb6cfff82e2f 100644 --- a/arch/x86/include/asm/resctrl.h +++ b/arch/x86/include/asm/resctrl.h @@ -50,11 +50,6 @@ DECLARE_STATIC_KEY_FALSE(rdt_enable_key); DECLARE_STATIC_KEY_FALSE(rdt_alloc_enable_key); DECLARE_STATIC_KEY_FALSE(rdt_mon_enable_key); =20 -static inline bool resctrl_arch_alloc_capable(void) -{ - return rdt_alloc_capable; -} - static inline void resctrl_arch_enable_alloc(void) { static_branch_enable_cpuslocked(&rdt_alloc_enable_key); @@ -67,11 +62,6 @@ static inline void resctrl_arch_disable_alloc(void) static_branch_dec_cpuslocked(&rdt_enable_key); } =20 -static inline bool resctrl_arch_mon_capable(void) -{ - return rdt_mon_capable; -} - static inline void resctrl_arch_enable_mon(void) { static_branch_enable_cpuslocked(&rdt_mon_enable_key); diff --git a/drivers/resctrl/mpam_resctrl.c b/drivers/resctrl/mpam_resctrl.c index 9d223057953a..0db62dd2a71c 100644 --- a/drivers/resctrl/mpam_resctrl.c +++ b/drivers/resctrl/mpam_resctrl.c @@ -75,28 +75,6 @@ static DECLARE_WAIT_QUEUE_HEAD(wait_cacheinfo_ready); */ static bool resctrl_enabled; =20 -bool resctrl_arch_alloc_capable(void) -{ - struct mpam_resctrl_res *res; - enum resctrl_res_level rid; - - for_each_mpam_resctrl_control(res, rid) { - if (res->resctrl_res.alloc_capable) - return true; - } - - return false; -} - -bool resctrl_arch_mon_capable(void) -{ - struct mpam_resctrl_res *res =3D &mpam_resctrl_controls[RDT_RESOURCE_L3]; - struct rdt_resource *l3 =3D &res->resctrl_res; - - /* All monitors are presented as being on the L3 cache */ - return l3->mon_capable; -} - bool resctrl_arch_is_evt_configurable(enum resctrl_event_id evt) { return false; @@ -1897,9 +1875,9 @@ int mpam_resctrl_setup(void) =20 cpus_read_unlock(); =20 - if (!resctrl_arch_alloc_capable() && !resctrl_arch_mon_capable()) { + if (!resctrl_alloc_capable() && !resctrl_mon_capable()) { pr_debug("No alloc(%u) or monitor(%u) found - resctrl not supported\n", - resctrl_arch_alloc_capable(), resctrl_arch_mon_capable()); + resctrl_alloc_capable(), resctrl_mon_capable()); return -EOPNOTSUPP; } =20 diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c index 73413cb128ea..362737e13cd3 100644 --- a/fs/resctrl/monitor.c +++ b/fs/resctrl/monitor.c @@ -338,7 +338,7 @@ void free_rmid(u32 closid, u32 rmid) * allows architectures that ignore the closid parameter to avoid an * unnecessary check. */ - if (!resctrl_arch_mon_capable() || + if (!resctrl_mon_capable() || idx =3D=3D resctrl_arch_rmid_idx_encode(RESCTRL_RESERVED_CLOSID, RESCTRL_RESERVED_RMID)) return; @@ -888,7 +888,7 @@ void mbm_handle_overflow(struct work_struct *work) * If the filesystem has been unmounted this work no longer needs to * run. */ - if (!resctrl_mounted || !resctrl_arch_mon_capable()) + if (!resctrl_mounted || !resctrl_mon_capable()) goto out_unlock; =20 /* @@ -950,7 +950,7 @@ void mbm_setup_overflow_handler(struct rdt_l3_mon_domai= n *dom, unsigned long del * When a domain comes online there is no guarantee the filesystem is * mounted. If not, there is no need to catch counter overflow. */ - if (!resctrl_mounted || !resctrl_arch_mon_capable()) + if (!resctrl_mounted || !resctrl_mon_capable()) return; cpu =3D cpumask_any_housekeeping(&dom->hdr.cpu_mask, exclude_cpu); dom->mbm_work_cpu =3D cpu; @@ -966,7 +966,7 @@ int setup_rmid_lru_list(void) u32 idx; int i; =20 - if (!resctrl_arch_mon_capable()) + if (!resctrl_mon_capable()) return 0; =20 /* @@ -1006,7 +1006,7 @@ int setup_rmid_lru_list(void) =20 void free_rmid_lru_list(void) { - if (!resctrl_arch_mon_capable()) + if (!resctrl_mon_capable()) return; =20 mutex_lock(&rdtgroup_mutex); diff --git a/fs/resctrl/pseudo_lock.c b/fs/resctrl/pseudo_lock.c index dea2b4bf966f..04b69c0e37f2 100644 --- a/fs/resctrl/pseudo_lock.c +++ b/fs/resctrl/pseudo_lock.c @@ -383,7 +383,7 @@ static int rdtgroup_locksetup_user_restrict(struct rdtg= roup *rdtgrp) if (ret) goto err_cpus; =20 - if (resctrl_arch_mon_capable()) { + if (resctrl_mon_capable()) { ret =3D rdtgroup_kn_mode_restrict(rdtgrp, "mon_groups"); if (ret) goto err_cpus_list; @@ -430,7 +430,7 @@ static int rdtgroup_locksetup_user_restore(struct rdtgr= oup *rdtgrp) if (ret) goto err_cpus; =20 - if (resctrl_arch_mon_capable()) { + if (resctrl_mon_capable()) { ret =3D rdtgroup_kn_mode_restore(rdtgrp, "mon_groups", 0777); if (ret) goto err_cpus_list; @@ -577,7 +577,7 @@ int rdtgroup_locksetup_exit(struct rdtgroup *rdtgrp) { int ret; =20 - if (resctrl_arch_mon_capable()) { + if (resctrl_mon_capable()) { ret =3D alloc_rmid(rdtgrp->closid); if (ret < 0) { rdt_last_cmd_puts("Out of RMIDs\n"); diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c index 5dcbb0a964e8..79977200b1a0 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -685,13 +685,13 @@ static int __rdtgroup_move_task(struct task_struct *t= sk, =20 static bool is_closid_match(struct task_struct *t, struct rdtgroup *r) { - return (resctrl_arch_alloc_capable() && (r->type =3D=3D RDTCTRL_GROUP) && + return (resctrl_alloc_capable() && (r->type =3D=3D RDTCTRL_GROUP) && resctrl_arch_match_closid(t, r->closid)); } =20 static bool is_rmid_match(struct task_struct *t, struct rdtgroup *r) { - return (resctrl_arch_mon_capable() && (r->type =3D=3D RDTMON_GROUP) && + return (resctrl_mon_capable() && (r->type =3D=3D RDTMON_GROUP) && resctrl_arch_match_rmid(t, r->mon.parent->closid, r->mon.rmid)); } @@ -3159,9 +3159,9 @@ static void resctrl_unmount(void) resctrl_arch_reset_all_ctrls(r); =20 resctrl_fs_teardown(); - if (resctrl_arch_alloc_capable()) + if (resctrl_alloc_capable()) resctrl_arch_disable_alloc(); - if (resctrl_arch_mon_capable()) + if (resctrl_mon_capable()) resctrl_arch_disable_mon(); resctrl_mounted =3D false; mutex_unlock(&rdtgroup_mutex); @@ -3215,7 +3215,7 @@ static int rdt_get_tree(struct fs_context *fc) if (ret) goto out_schemata_free; =20 - if (resctrl_arch_mon_capable()) + if (resctrl_mon_capable()) flags |=3D RFTYPE_MON; =20 ret =3D rdtgroup_add_files(rdtgroup_default.kn, flags); @@ -3228,7 +3228,7 @@ static int rdt_get_tree(struct fs_context *fc) if (ret < 0) goto out_closid_exit; =20 - if (resctrl_arch_mon_capable()) { + if (resctrl_mon_capable()) { ret =3D mongroup_create_dir(rdtgroup_default.kn, &rdtgroup_default, "mon_groups", &kn_mongrp); @@ -3248,12 +3248,12 @@ static int rdt_get_tree(struct fs_context *fc) if (ret) goto out_mondata; =20 - if (resctrl_arch_alloc_capable()) + if (resctrl_alloc_capable()) resctrl_arch_enable_alloc(); - if (resctrl_arch_mon_capable()) + if (resctrl_mon_capable()) resctrl_arch_enable_mon(); =20 - if (resctrl_arch_alloc_capable() || resctrl_arch_mon_capable()) + if (resctrl_alloc_capable() || resctrl_mon_capable()) resctrl_mounted =3D true; =20 if (resctrl_is_mbm_enabled()) { @@ -3296,10 +3296,10 @@ static int rdt_get_tree(struct fs_context *fc) return ret; =20 out_mondata: - if (resctrl_arch_mon_capable()) + if (resctrl_mon_capable()) kernfs_remove(kn_mondata); out_mongrp: - if (resctrl_arch_mon_capable()) { + if (resctrl_mon_capable()) { mon_put_kn_priv(); rdtgroup_unassign_cntrs(&rdtgroup_default); kernfs_remove(kn_mongrp); @@ -3888,7 +3888,7 @@ static int mkdir_rdt_prepare_rmid_alloc(struct rdtgro= up *rdtgrp) { int ret; =20 - if (!resctrl_arch_mon_capable()) + if (!resctrl_mon_capable()) return 0; =20 ret =3D alloc_rmid(rdtgrp->closid); @@ -3913,7 +3913,7 @@ static int mkdir_rdt_prepare_rmid_alloc(struct rdtgro= up *rdtgrp) =20 static void mkdir_rdt_prepare_rmid_free(struct rdtgroup *rgrp) { - if (resctrl_arch_mon_capable()) { + if (resctrl_mon_capable()) { rdtgroup_unassign_cntrs(rgrp); free_rmid(rgrp->closid, rgrp->mon.rmid); } @@ -4004,7 +4004,7 @@ static int mkdir_rdt_prepare(struct kernfs_node *pare= nt_kn, =20 if (rtype =3D=3D RDTCTRL_GROUP) { files =3D RFTYPE_BASE | RFTYPE_CTRL; - if (resctrl_arch_mon_capable()) + if (resctrl_mon_capable()) files |=3D RFTYPE_MON; } else { files =3D RFTYPE_BASE | RFTYPE_MON; @@ -4113,7 +4113,7 @@ static int rdtgroup_mkdir_ctrl_mon(struct kernfs_node= *parent_kn, =20 list_add(&rdtgrp->rdtgroup_list, &rdt_all_groups); =20 - if (resctrl_arch_mon_capable()) { + if (resctrl_mon_capable()) { /* * Create an empty mon_groups directory to hold the subset * of tasks and cpus to monitor. @@ -4154,11 +4154,11 @@ static int rdtgroup_mkdir(struct kernfs_node *paren= t_kn, const char *name, * allocation is supported, add a control and monitoring * subdirectory */ - if (resctrl_arch_alloc_capable() && parent_kn =3D=3D rdtgroup_default.kn) + if (resctrl_alloc_capable() && parent_kn =3D=3D rdtgroup_default.kn) return rdtgroup_mkdir_ctrl_mon(parent_kn, name, mode); =20 /* Else, attempt to add a monitoring subdirectory. */ - if (resctrl_arch_mon_capable()) + if (resctrl_mon_capable()) return rdtgroup_mkdir_mon(parent_kn, name, mode); =20 return -EPERM; @@ -4573,7 +4573,7 @@ void resctrl_offline_mon_domain(struct rdt_resource *= r, struct rdt_domain_hdr *h * If resctrl is mounted, remove all the * per domain monitor data directories. */ - if (resctrl_mounted && resctrl_arch_mon_capable()) + if (resctrl_mounted && resctrl_mon_capable()) rmdir_mondata_subdir_allrdtgrp(r, hdr); =20 if (r->rid !=3D RDT_RESOURCE_L3) @@ -4710,7 +4710,7 @@ int resctrl_online_mon_domain(struct rdt_resource *r,= struct rdt_domain_hdr *hdr * by rdt_get_tree() calling mkdir_mondata_all(). * If resctrl is mounted, add per domain monitor data directories. */ - if (resctrl_mounted && resctrl_arch_mon_capable()) + if (resctrl_mounted && resctrl_mon_capable()) mkdir_mondata_subdir_allrdtgrp(r, hdr); =20 out_unlock: --=20 2.55.0 From nobody Fri Sep 25 04:07:27 2026 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 334484E06FF for ; Wed, 16 Sep 2026 23:13:36 +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=1789600419; cv=none; b=KPkmUVxZ8rkUxOLDvLfCUF43kRbZ/gZwkD2/JLIF0WIg/WC/3qKRqMwtY2K9lpEDY9w4X9i3QNoEvQ+4XwUoNxsxvOoz3t8Pnbg8VbkPHhpZREtCV7LX/Ed/KJizTuh0aY5j/eUZCl4nfw0Rj1Uztv2f2VpmLLHMMGt2wjjpek8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789600419; c=relaxed/simple; bh=mQ1zUO7cuhKE1nxW6bs53CfGHgz37yQzw7l8uP4F3Q8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=equa2HC9w3TuUI2+dg5/TaUAy8OoBEAR39QrUkqMQDjIi69tFMyq3ZP0YcR3S2yKMxZrFwtcL9zQeLtDt6XK+9xd5YeYTxoqqbpIBh1AqwA8pvp0dXHIzlV87/Lq0d1IbTiladJVhFyTLfHGQfQV3zrM3sT2CP3ig6/PYPhJzSA= 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=CH+i4/DB; 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="CH+i4/DB" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1789600417; x=1821136417; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=mQ1zUO7cuhKE1nxW6bs53CfGHgz37yQzw7l8uP4F3Q8=; b=CH+i4/DBHYiYFyo99SCJ/jCoyrjNXjLHQSwEVJntR9kYoMjX16iVr+d5 0K5Knf5cBpiqD9yXB9ZRTjZPWE7X/gI114C0YCTVt5PoiaEVAX2FA21YH q8airQ1vct4qAtAqspNljPM3zfRNulRZGuHumhDzOfn8ZcH4jSKj2znwV lEdbD+lOoGrd1cygDpEUNp5rmfFrWkzWYBJ7yAUFuTGc3twSsVHAsrSw7 WabUUU1gsmfcaeigY+Ue90qHlW+xQsIF6FUsoae9UkhUDGEPhNQTHrytz Xv8wqqUK8FsZ+IU8tpMaIoIkGjYG7GhCBMUJa025iHO3TIQ38Gg4Jk/pa w==; X-CSE-ConnectionGUID: WjcCpxQqQquUszGOHiggvA== X-CSE-MsgGUID: E5o9Yaq+RPut2Qt95SiXQg== X-IronPort-AV: E=McAfee;i="6800,10657,11905"; a="93861372" X-IronPort-AV: E=Sophos;i="6.27,103,1787036400"; d="scan'208";a="93861372" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by orvoesa106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Sep 2026 16:13:33 -0700 X-CSE-ConnectionGUID: HzjHhHkkQPifTRhKz9ZJkw== X-CSE-MsgGUID: 3u4kX2keR/6YkA0Q3mj+Qw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,103,1787036400"; d="scan'208";a="277231446" Received: from khuang2-desk.gar.corp.intel.com (HELO agluck-desk3.home.arpa) ([10.124.223.219]) by orviesa004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Sep 2026 16:13:33 -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 v12 07/25] x86/resctrl: Update special case for Intel Haswell enumeration Date: Wed, 16 Sep 2026 16:13:02 -0700 Message-ID: <20260916231320.14502-8-tony.luck@intel.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260916231320.14502-1-tony.luck@intel.com> References: <20260916231320.14502-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" Certain Intel Haswell CPUs have support for resctrl L3 cache allocation but do not enumerate the feature. There is a quirk to check for support and provide hard-coded parameters. This quirk sets rdt_alloc_capable to indicate to get_rdt_alloc_resources() that normal enumeration is not needed. Drop setting of rdt_alloc_capable in cache_alloc_hsw_probe() in preparation for removal of this global variable. Signed-off-by: Tony Luck --- v12: Remove the new hsw_alloc_capable variable. --- arch/x86/kernel/cpu/resctrl/core.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resct= rl/core.c index f0cfb37482d3..f2bf160d01c1 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -177,8 +177,6 @@ static inline void cache_alloc_hsw_probe(void) r->cache.min_cbm_bits =3D 2; r->cache.arch_has_sparse_bitmasks =3D false; r->alloc_capable =3D true; - - rdt_alloc_capable =3D true; } =20 /* @@ -930,7 +928,11 @@ static __init bool get_rdt_alloc_resources(void) struct rdt_resource *r; bool ret =3D false; =20 - if (rdt_alloc_capable) + /* + * On Haswell systems cache_alloc_hsw_probe() already marked + * RDT_RESOURCE_L3 as alloc_capable. No further enumeration is needed. + */ + if (resctrl_alloc_capable()) return true; =20 if (!boot_cpu_has(X86_FEATURE_RDT_A)) --=20 2.55.0 From nobody Fri Sep 25 04:07:27 2026 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 09ADC4DE709 for ; Wed, 16 Sep 2026 23:13:38 +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=1789600422; cv=none; b=DznvJZYgXjw6dAQQSjDJTUUuPxO4WAsiD+gnpV2EJBdwFVZFtfd0JspN6u3YcXS+BiiXKY0tXcSt/w5T3ZeUjuZpXnQxGXwrS8fEJwqgKS3e3KWmqpiPnFCdRVoxRfxtfnNaC+b90JGRshzHT5t9+/H8dZ0z/RHo5RuSMv5Fv3I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789600422; c=relaxed/simple; bh=LkEGaL6edY32DUDcv/ylXMeVcz/O/JZteQw/+LK2t+w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KtDYR8TtK9qccb+1aC9rS8putTgpDZsUtKWvXZ+GHi7WTOwUB8h4cALCSn8CL0RW5sGWJChlf7V9moCaJZ9IP3PkJMOqbWpnPFbRqJLZII2p+u57xCpAq4QE3LtHcBhAXW/Kjy8WOsK6o57ADr8GylI3EEKHjLalkGctQxzy4EY= 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=SZatjaV7; 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="SZatjaV7" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1789600419; x=1821136419; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=LkEGaL6edY32DUDcv/ylXMeVcz/O/JZteQw/+LK2t+w=; b=SZatjaV7D3BjOdVOHntMAF55376o+ozahzTr2VkbiyHhNh737qk8/Kos 7b4QE1WEEX3Vqgfs3zjt9f+TI14sCpZWmSy5ZpdwR939YVtApyJXMX2Ol kenlaLLJ83V9xLKgr8/DmJMfbkq/wQ6URCoBrWheNTCZ5ro8imcFM5+LI X5Y/e0RPdS0giP7T2jsqOnHO22YGCZpN0GP2jM31j2TlVK7cv74ZAgv+T RE7Qik5t9srtmdm4D8NRTMEBWeO1AS1Gw8pvk0kz2bGeA3hArVCdausN6 UI9dNdCS0MMhblnARlodvtOCFs6tcY5LD6qZpxh0NqMyOFj+Lwcf4jwob g==; X-CSE-ConnectionGUID: 480cYj+UTcWl5A13Xv+rdQ== X-CSE-MsgGUID: /4gJhfV7Sv+rRvi6xbp1CA== X-IronPort-AV: E=McAfee;i="6800,10657,11905"; a="93861381" X-IronPort-AV: E=Sophos;i="6.27,103,1787036400"; d="scan'208";a="93861381" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by orvoesa106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Sep 2026 16:13:34 -0700 X-CSE-ConnectionGUID: w0y+UQK2T72Q+QD7KcCXCA== X-CSE-MsgGUID: Y8IF91JQQd2ymtNCSw7RLQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,103,1787036400"; d="scan'208";a="277231451" Received: from khuang2-desk.gar.corp.intel.com (HELO agluck-desk3.home.arpa) ([10.124.223.219]) by orviesa004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Sep 2026 16:13:33 -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 v12 08/25] x86/resctrl: Delete rdt_alloc_capable and rdt_mon_capable Date: Wed, 16 Sep 2026 16:13:03 -0700 Message-ID: <20260916231320.14502-9-tony.luck@intel.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260916231320.14502-1-tony.luck@intel.com> References: <20260916231320.14502-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" These globals are no longer needed, delete them. Signed-off-by: Tony Luck --- v12: Changed names of local variables in get_rdt_resources() --- arch/x86/include/asm/resctrl.h | 2 -- arch/x86/kernel/cpu/resctrl/core.c | 13 +++---------- arch/x86/kernel/cpu/resctrl/monitor.c | 6 ------ 3 files changed, 3 insertions(+), 18 deletions(-) diff --git a/arch/x86/include/asm/resctrl.h b/arch/x86/include/asm/resctrl.h index fb6cfff82e2f..49b5357e2e5c 100644 --- a/arch/x86/include/asm/resctrl.h +++ b/arch/x86/include/asm/resctrl.h @@ -42,8 +42,6 @@ struct resctrl_pqr_state { =20 DECLARE_PER_CPU(struct resctrl_pqr_state, pqr_state); =20 -extern bool rdt_alloc_capable; -extern bool rdt_mon_capable; extern unsigned int __ro_after_init rdt_l3_mon_scale; =20 DECLARE_STATIC_KEY_FALSE(rdt_enable_key); diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resct= rl/core.c index f2bf160d01c1..2e3b9c16cbda 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -45,12 +45,6 @@ static DEFINE_MUTEX(domain_list_lock); */ DEFINE_PER_CPU(struct resctrl_pqr_state, pqr_state); =20 -/* - * Global boolean for rdt_alloc which is true if any - * resource allocation is enabled. - */ -bool rdt_alloc_capable; - static void mba_wrmsr_intel(struct msr_param *m); static void cat_wrmsr(struct msr_param *m); static void mba_wrmsr_amd(struct msr_param *m); @@ -781,7 +775,6 @@ void resctrl_arch_pre_mount(void) cpus_read_lock(); mutex_lock(&domain_list_lock); r->mon_capable =3D true; - rdt_mon_capable =3D true; for_each_online_cpu(cpu) domain_add_cpu_mon(cpu, r); mutex_unlock(&domain_list_lock); @@ -1026,10 +1019,10 @@ static __init void check_quirks(void) =20 static __init bool get_rdt_resources(void) { - rdt_alloc_capable =3D get_rdt_alloc_resources(); - rdt_mon_capable =3D get_rdt_mon_resources(); + bool alloc =3D get_rdt_alloc_resources(); + bool mon =3D get_rdt_mon_resources(); =20 - return (rdt_mon_capable || rdt_alloc_capable); + return alloc || mon; } =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 ab9cb34145c5..2f3e5b89a7fc 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -26,12 +26,6 @@ =20 #include "internal.h" =20 -/* - * Global boolean for rdt_monitor which is true if any - * resource monitoring is enabled. - */ -bool rdt_mon_capable; - /* * Scale factor to convert L3 monitor events to bytes. */ --=20 2.55.0 From nobody Fri Sep 25 04:07:27 2026 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 0E8D44EA361 for ; Wed, 16 Sep 2026 23:13:38 +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=1789600422; cv=none; b=FjX88GEhvZy8xjl1DDQdYr7j0WadM396icZMWJba/5O4GCE3bfNBS7UHy5LQL6sO6J2i//Fs2+kqG2Z51T4taJNaPSqS5ROsesrH5TcPRrvxmRLyyDGVaC5iiKd4rK0feVdFHJjUGcmZqlSdFqZDVRU1odNnc7TJKus/8HHm28Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789600422; c=relaxed/simple; bh=3COoBJ2+XbV4ydXsJZZTt7bAu++18o363OAblyVTZkE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GYCrGJuCf7/zhRqDDK6ZrBWtPXZDdqHdMw7gSM4pyvjKe3+FdZxMbli9+l77+3TuV8BetnrruUe9E0YPM57OtbhjF/gpiFDs9y1o+BL8F6IGKyoQAZZJSsZpHcLnjt2k5G+J4E+6LqMlI2BHI/ndnNZaDdowji7pv1Q+v+rObVg= 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=m11jGAyZ; 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="m11jGAyZ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1789600419; x=1821136419; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=3COoBJ2+XbV4ydXsJZZTt7bAu++18o363OAblyVTZkE=; b=m11jGAyZbx7zpWNaSHGxipO8eeiWeJq39gnksPEo0vX1y1egVczuxU7D onGe16CYPJA6gXaFixMWgc+ZOpstAEwDLrnrZl9Af41X7QyTHWeYKdwIR Yf45+7f2CYsBAG7BEBt/rYbwNyA9TUzd9yPH+UiuxElHnNxsPb2mtsY5B zAlw0o+bgs5PYuz+F9RivxiCc+4RHm9Kd2lahZSM42UcIUa1jZp8Z28aR qJOXRt8YBnPDxsGUj6I0xarCQZGJ2ppgZUeTUMEZcVJOcXwSkIUqJTxOa IIcOKDMbomG+n1RhQF2XoZKTy8SKNQHIMBrj01HW7M4uz+NF7PAtQbB2w w==; X-CSE-ConnectionGUID: +YRcnhUlRIidpGfbtL8npg== X-CSE-MsgGUID: YxGsQkTcQDi/f6334G0Aqg== X-IronPort-AV: E=McAfee;i="6800,10657,11905"; a="93861393" X-IronPort-AV: E=Sophos;i="6.27,103,1787036400"; d="scan'208";a="93861393" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by orvoesa106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Sep 2026 16:13:34 -0700 X-CSE-ConnectionGUID: rsgGC0vKTka6Vtn/z02tKA== X-CSE-MsgGUID: EyNweaciT+yQWTG5F7LE9Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,103,1787036400"; d="scan'208";a="277231454" Received: from khuang2-desk.gar.corp.intel.com (HELO agluck-desk3.home.arpa) ([10.124.223.219]) by orviesa004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Sep 2026 16:13:34 -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 v12 09/25] fs/resctrl: Remove redundant calls to resctrl_{alloc,mon}_capable() Date: Wed, 16 Sep 2026 16:13:04 -0700 Message-ID: <20260916231320.14502-10-tony.luck@intel.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260916231320.14502-1-tony.luck@intel.com> References: <20260916231320.14502-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_mon_capable() indicates whether any monitoring resources are enabled on the system. It does this by scanning all resources. Redundant calls to resctrl_mon_capable() in hot code paths should be eliminated. There are two prime examples: 1) mbm_handle_overflow() This function is called once per second from worker threads running on each L3 domain. resctrl_mon_capable() is clearly redundant because worker threads are only created if the MBM monitoring feature is enabled. 2) is_rmid_match() This is called for every task on the system so making it less expensive is appealing. resctrl_mon_capable() is redundant because the function also checks "r->type =3D=3D RDTMON_GROUP" and this type of group can only be cre= ated on systems that support monitoring. 3) is_closid_match() The call to resctrl_alloc_capable() is not just redundant, it is wrong. On systems that only support monitoring it results in no tasks reported in the "tasks" file of the resctrl root directory. Remove the call to resctrl_{alloc,mon}_capable() from each of these functio= ns. Signed-off-by: Tony Luck --- v12: updated is_closid_match() per report by Sashiko s/resctrl_arch_mon_capable/resctrl_mon_capable/ Removed unnecessary line break. --- fs/resctrl/monitor.c | 2 +- fs/resctrl/rdtgroup.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c index 362737e13cd3..02e81fc82b14 100644 --- a/fs/resctrl/monitor.c +++ b/fs/resctrl/monitor.c @@ -888,7 +888,7 @@ void mbm_handle_overflow(struct work_struct *work) * If the filesystem has been unmounted this work no longer needs to * run. */ - if (!resctrl_mounted || !resctrl_mon_capable()) + if (!resctrl_mounted) goto out_unlock; =20 /* diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c index 79977200b1a0..c0b86ce05e50 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -685,13 +685,13 @@ static int __rdtgroup_move_task(struct task_struct *t= sk, =20 static bool is_closid_match(struct task_struct *t, struct rdtgroup *r) { - return (resctrl_alloc_capable() && (r->type =3D=3D RDTCTRL_GROUP) && + return (r->type =3D=3D RDTCTRL_GROUP && resctrl_arch_match_closid(t, r->closid)); } =20 static bool is_rmid_match(struct task_struct *t, struct rdtgroup *r) { - return (resctrl_mon_capable() && (r->type =3D=3D RDTMON_GROUP) && + return (r->type =3D=3D RDTMON_GROUP && resctrl_arch_match_rmid(t, r->mon.parent->closid, r->mon.rmid)); } --=20 2.55.0 From nobody Fri Sep 25 04:07:27 2026 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 118AF4CE677 for ; Wed, 16 Sep 2026 23:13:40 +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=1789600424; cv=none; b=iakX6t6x/21QxhHf3djzAMJFd1yarrXSWkFgKkcT/HNqbepB073xThyFsMoAalINSXTF49JwhFZFhbFNq2dd2JZzWp2WF4GdJ/0pd93DNguKYVc/VOCYsZKRD5ZD+zdxgFMfWcc+uugsCGaLPXWSPzqaLujd7DTj1OhMmnPUi1Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789600424; c=relaxed/simple; bh=GcxFliNTIAtRq7uiuS+67NRJavF9d5TyAC+yRtsjs+4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NG8oiqKZqcXlD6e4vFPr15n6yIKkVCbUf8FckhiOFgyMz21ejrGWcokdfqF3ZmpqKlxvw3Du9Yz0xir7NUnShpEcFlqW/jx4kyXMyz/LmXGgDo/CoxmAoTt8WdFpLDIU/FUJcD02n/3eG/MbZH3wKsTm9PkqX6sz3fEvV3prZkw= 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=ZpUGohQY; 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="ZpUGohQY" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1789600420; x=1821136420; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=GcxFliNTIAtRq7uiuS+67NRJavF9d5TyAC+yRtsjs+4=; b=ZpUGohQYBvZdvndZAqJb6tmrk6DsHsmxgiAjA9OWWu1NcYLa0v/TtIYu nvW6uhk/IUs/LJnxXJS4Wr2kDPPTWynh1+9zqI7DIBYrekUWuJOwO/0IZ emAxnkzLzkvfjuGF2O2MiOXFwe2mtogPtOK6qMIe8nDchjnwsrRMSrco6 hJe0L925xopyKXp9SrNABiRbmkb3WczJRB8C9czeGOimnZ9Z5q213V1Po NDPw+UrmG4oSJ+tm82THsanv83SZqnsKXkch581TOTMxYsvqEU1057EX9 K9b3nY3C0+H3buOLiKqTafFi3Xue/8SPQ33lz8etRc9uyJ+0LcW00V8MR Q==; X-CSE-ConnectionGUID: olmYedPxRsK2afTi7Fjslw== X-CSE-MsgGUID: RHOsxff7QgaqNuQVtmK2Mw== X-IronPort-AV: E=McAfee;i="6800,10657,11905"; a="93861404" X-IronPort-AV: E=Sophos;i="6.27,103,1787036400"; d="scan'208";a="93861404" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by orvoesa106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Sep 2026 16:13:35 -0700 X-CSE-ConnectionGUID: mXegwrkSScyepjynTHED1A== X-CSE-MsgGUID: kZgJRk6XQJ2jWjiMlOShMQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,103,1787036400"; d="scan'208";a="277231459" Received: from khuang2-desk.gar.corp.intel.com (HELO agluck-desk3.home.arpa) ([10.124.223.219]) by orviesa004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Sep 2026 16:13:34 -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 v12 10/25] x86/resctrl: Honor rdt=perf option to force enable AET perf events Date: Wed, 16 Sep 2026 16:13:05 -0700 Message-ID: <20260916231320.14502-11-tony.luck@intel.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260916231320.14502-1-tony.luck@intel.com> References: <20260916231320.14502-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 can disable ("force_off") a feature supported by the platform if, for example, there is an erratum related to the feature or, in the case of = AET (Application Energy Telemetry), when the event group has insufficient RMIDs= . The "rdt=3D" kernel command line option lets the user override ("force_on") when a feature is disabled in such case. Users may also disable ("force_off") individual supported resctrl features they do not need. Linux enumerates AET once on first mount and skips this enumeration if the associated event group is supported but disabled. Since AET is only enumerated once, this check is guaranteed to only consider disabling via the rdt=3D kernel parameter. However, when transitioning to enumerate AET on every mount, it is no longer correct to skip enumeration simply because an event group is marked as disabled. It is then possible for resctrl to have force-disabled the event group during an earlier enumeration due to insufficient RMIDs, which would improperly cause the kernel to ignore a user's explicit rdt=3D override on subsequent mounts. Ensure the user's command line choices take precedence over system-level li= mits. Reviewed-by: Reinette Chatre Signed-off-by: Tony Luck --- v12: No change --- arch/x86/kernel/cpu/resctrl/intel_aet.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kernel/cpu/resctrl/intel_aet.c b/arch/x86/kernel/cpu/= resctrl/intel_aet.c index c22c3cf5167d..4ad6ad78e93e 100644 --- a/arch/x86/kernel/cpu/resctrl/intel_aet.c +++ b/arch/x86/kernel/cpu/resctrl/intel_aet.c @@ -228,7 +228,7 @@ static bool enable_events(struct event_group *e, struct= pmt_feature_group *p) struct rdt_resource *r =3D &rdt_resources_all[RDT_RESOURCE_PERF_PKG].r_re= sctrl; int skipped_events =3D 0; =20 - if (e->force_off) + if (e->force_off && !e->force_on) return false; =20 if (!group_has_usable_regions(e, p)) --=20 2.55.0 From nobody Fri Sep 25 04:07:27 2026 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 4C7774E06E9 for ; Wed, 16 Sep 2026 23:13:42 +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=1789600426; cv=none; b=rPM9kURgWnxkLT0MgA/RgrRdnrVLiDvKOZ+82RS5PME1x9FwSXNvc5/i/ZShjZx9T6iYcZPMevFhjoeT/it2px8FMpS9uvSf278DycOwkyrdZL84zRlcPZBf6jIFDHUAbYhAc6eXq0B9tPBgBhu8MPl9XJwDo8pBHesLn6RBDFw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789600426; c=relaxed/simple; bh=AOTgnRzzoC8PIhxgcqVQ7yQ+PJ606+1nZeY+ZVMUtPE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SMq1fNrtLNm5F0E18QX5ByDFnPoCT2rdbVFFxk5gAYpgd/8uP+LohnUdmRnlH/J/SnTe1ZnH7YaShE66DS+BcZYVqQbRQYSh5vylJTolGZ+pPTGCr6KewWAoQL90l8n03IWx6F+ZrF7AT9qCQ6jg8xSO9fH9399QDE839GfwoDI= 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=OB/hgLst; 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="OB/hgLst" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1789600424; x=1821136424; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=AOTgnRzzoC8PIhxgcqVQ7yQ+PJ606+1nZeY+ZVMUtPE=; b=OB/hgLstu+/oQKMDqqW1eprsF3H8Oe2AMZXRW9wst0k5ryv+mhZU2v9Q /rKdQ0YzgbivxIxSEeqiS/CGYHtkDlPM6/ekiQjrFLiYDIG/XYG7NZHfc 7KhDuvrNNlDCPY7pNxmR7et6gInlfx129RBLIs4+SkBTa2rYSfzDMRRTF OTDMWXu8xbkoV93jhyht7etr3Ya68sAy+IJ9XA+iHzaU/x6WBr2LZ2lUr AvPhXu6G2ILRKvxiPxWzZA4gU/Wv0X+O64QdiNpUYx6ASfgXj8GZXS8EF FWe20Wi6F/us66B6mFeMoi+AP8qDke8WQAoc79o4xq8oGB62wNJmIDtRT A==; X-CSE-ConnectionGUID: m5JeQxeRQsWAeqYuMaoLng== X-CSE-MsgGUID: 5yoKQdPJTRSJT/rnZvR7Mg== X-IronPort-AV: E=McAfee;i="6800,10657,11905"; a="93861414" X-IronPort-AV: E=Sophos;i="6.27,103,1787036400"; d="scan'208";a="93861414" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by orvoesa106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Sep 2026 16:13:35 -0700 X-CSE-ConnectionGUID: L+oIe3ktQY66zA0YI57MkQ== X-CSE-MsgGUID: UeYhN7QdSWONac7nIkK10A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,103,1787036400"; d="scan'208";a="277231462" Received: from khuang2-desk.gar.corp.intel.com (HELO agluck-desk3.home.arpa) ([10.124.223.219]) by orviesa004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Sep 2026 16:13:35 -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 v12 11/25] fs/resctrl: Add interface to disable a monitor event Date: Wed, 16 Sep 2026 16:13:06 -0700 Message-ID: <20260916231320.14502-12-tony.luck@intel.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260916231320.14502-1-tony.luck@intel.com> References: <20260916231320.14502-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 currently assumes all monitor events are enabled before any domain is created, because per-domain state is allocated by the architecture's CPU hotplug callbacks. There is no way to disable an event once registered. AET events are enumerated by the INTEL_PMT_TELEMETRY driver. To allow that driver to be a loadable module, resctrl must tolerate AET events appearing and disappearing, which requires the ability to disable an event when the driver is unloaded. Add resctrl_disable_mon_event(). The architecture owns domain lifetime and knows mount state, so it is responsible for calling this only while resctrl is unmounted and for cleaning up any per-domain state. Document those requirements in the kerneldoc since they are not enforced in code. Signed-off-by: Tony Luck Reviewed-by: Reinette Chatre --- v12: Added Reinette RB tag (from v10 review). Better header comment for resctrl_disable_mon_event(). --- include/linux/resctrl.h | 34 ++++++++++++++++++++++++++++++++++ fs/resctrl/monitor.c | 15 +++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index 6b07ac2c8675..fbf737e884db 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -449,9 +449,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 + * + * Never disable an event that may be accessed while the file system is un= mounted. + * + * 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 02e81fc82b14..2a28fe04284b 100644 --- a/fs/resctrl/monitor.c +++ b/fs/resctrl/monitor.c @@ -1066,6 +1066,21 @@ 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("Event %d already disabled\n", eventid); + return; + } + + mon_event_all[eventid].any_cpu =3D false; + mon_event_all[eventid].binary_bits =3D 0; + mon_event_all[eventid].arch_priv =3D NULL; + 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.55.0 From nobody Fri Sep 25 04:07:27 2026 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 4B26A4DD3C9 for ; Wed, 16 Sep 2026 23:13:42 +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=1789600426; cv=none; b=mjw0vJSPI51Fgp+fDapQis7qWNN+PvWwGdriSH3VyKjDmNaadOJm8fwNwpqMpc7EiZ4VhWLJUYRQY5vqVepls8mJHCurUwY3ecmTooMR5lEuQFNodrUA6HTC3nKckg2uFXjtbH+WRuDY577bqu6j3LZObRQ434rWR2vZbGxG5t8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789600426; c=relaxed/simple; bh=tNMbExkvVFOJ1CKrMUqgJLqIQ8y5YPWxH/cuiLOMbVg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TJAM9lKKLYXE9mDSBUvlDH8Cu3T6OMZVOtMwEpU7w6d1Xiu/EzcAAxJqNsJYDgf1ysuuAthjBX1KWz0IT0WGQYzPuDvKI3CBmjHkJSzehBjJBv54KzlkK17SWmUkq5145l1mqnqqPoTqye2b2G7O26z57tJ3tenj/Kqrxpxvtrc= 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=lYHg1JWy; 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="lYHg1JWy" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1789600424; x=1821136424; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=tNMbExkvVFOJ1CKrMUqgJLqIQ8y5YPWxH/cuiLOMbVg=; b=lYHg1JWy2c8uXmCYqVyz1vhj5ia4z0u0k6LMn5apsVR6/fImXn2ErZbz 5p0Umtvy0nTxYAST//Wsduxcf7R/Fe2Lai1kdLk3GotOdg8l4VNDrzdam eLdbzYTY5lUyfFJmk30L65+U0g6+5DoJbvvbWJCLYBE6QIZOsz9YcRKXD 5LWKqepUzsGuC8qk3yNspx+9y/9HtupQHZpPlmU27lJ+BsL+cO9uZ/VPM /YPSLM4fAaC0rnTJfPhVVkJoG7BCdUSN6qPPdJ69IdvRqI3o3GC5UVzBN MmKPWaI7K/KeskMQ0bWHCIhYJMYO3rloIAyAo4ms7nyJUs0OeGDjhhQj7 w==; X-CSE-ConnectionGUID: bwK881J3TNOlLNtQ5+F6cw== X-CSE-MsgGUID: QnclBuTJRGe3chhzc4sY4Q== X-IronPort-AV: E=McAfee;i="6800,10657,11905"; a="93861423" X-IronPort-AV: E=Sophos;i="6.27,103,1787036400"; d="scan'208";a="93861423" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by orvoesa106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Sep 2026 16:13:35 -0700 X-CSE-ConnectionGUID: uI5VSaESQN+GAyHnb+X0UA== X-CSE-MsgGUID: RY3VMEigTPG9hx3XO5oqVQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,103,1787036400"; d="scan'208";a="277231465" Received: from khuang2-desk.gar.corp.intel.com (HELO agluck-desk3.home.arpa) ([10.124.223.219]) by orviesa004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Sep 2026 16:13:35 -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 v12 12/25] arm,x86,fs/resctrl: Allocate maximum needed rmid_ptrs[] Date: Wed, 16 Sep 2026 16:13:07 -0700 Message-ID: <20260916231320.14502-13-tony.luck@intel.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260916231320.14502-1-tony.luck@intel.com> References: <20260916231320.14502-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" File system code allocates the rmid_ptrs[] array once during initialization. The number of entries needed in this array is currently constant. When changes are made to allow Application Energy Telemetry (AET) to run with the pmt_telemetry driver as a module, then number of entries needed may change from one mount to the next. Allocate rmid_ptrs[] with enough entries for any future mount. Signed-off-by: Tony Luck --- v12: New patch. Split out from old patch 12. New global pqr_assoc_num_rmid to avoid repeat CPUID calls. --- include/linux/resctrl.h | 1 + arch/x86/kernel/cpu/resctrl/core.c | 27 +++++++++++++++++++++++++++ drivers/resctrl/mpam_resctrl.c | 9 +++++++++ fs/resctrl/monitor.c | 2 +- 4 files changed, 38 insertions(+), 1 deletion(-) diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index fbf737e884db..5535bde7b925 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -447,6 +447,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 2e3b9c16cbda..a9109f2bc43e 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -45,6 +45,9 @@ static DEFINE_MUTEX(domain_list_lock); */ DEFINE_PER_CPU(struct resctrl_pqr_state, pqr_state); =20 +/* Number of RMIDS values that can be written to IA32_PQR_ASSOC.RMID */ +static u32 pqr_assoc_num_rmid; + static void mba_wrmsr_intel(struct msr_param *m); static void cat_wrmsr(struct msr_param *m); static void mba_wrmsr_amd(struct msr_param *m); @@ -124,6 +127,28 @@ 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: Maximum possible number of RMIDs used for boot time allocations. + */ +u32 resctrl_arch_system_max_rmid_idx(void) +{ + struct rdt_resource *r =3D &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl; + u32 num_rmid =3D pqr_assoc_num_rmid; + + /* + * If the system is capable of L3 monitoring the maximum RMID value may + * be lower than the system maximum. Either because the L3 monitoring + * feature supports fewer RMIDs, or because SNC (Sub-NUMA Cluster) + * is enabled and divides RMIDs per cluster. + */ + if (r->mon_capable) + num_rmid =3D r->mon.num_rmid; + + return num_rmid; +} + struct rdt_resource *resctrl_arch_get_resource(enum resctrl_res_level l) { if (l >=3D RDT_NUM_RESOURCES) @@ -967,6 +992,8 @@ static __init bool get_rdt_mon_resources(void) if (!cpu_feature_enabled(X86_FEATURE_CQM)) return false; =20 + pqr_assoc_num_rmid =3D cpuid_ebx(0xf) + 1; + /* Any of the L3 monitoring features? */ if (!cpu_feature_enabled(X86_FEATURE_CQM_LLC)) return false; diff --git a/drivers/resctrl/mpam_resctrl.c b/drivers/resctrl/mpam_resctrl.c index 0db62dd2a71c..0ffa25199f74 100644 --- a/drivers/resctrl/mpam_resctrl.c +++ b/drivers/resctrl/mpam_resctrl.c @@ -252,6 +252,15 @@ u32 resctrl_arch_system_num_rmid_idx(void) return (mpam_pmg_max + 1) * (mpam_partid_max + 1); } =20 +/* + * File system calls this for one-time allocation of structures + * during initialization. Return the largest possible value. + */ +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 2a28fe04284b..e8775e08aa18 100644 --- a/fs/resctrl/monitor.c +++ b/fs/resctrl/monitor.c @@ -978,7 +978,7 @@ int setup_rmid_lru_list(void) if (rmid_ptrs) return 0; =20 - idx_limit =3D resctrl_arch_system_num_rmid_idx(); + idx_limit =3D resctrl_arch_system_max_rmid_idx(); rmid_ptrs =3D kzalloc_objs(struct rmid_entry, idx_limit); if (!rmid_ptrs) return -ENOMEM; --=20 2.55.0 From nobody Fri Sep 25 04:07:27 2026 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 DBDF850EC13 for ; Wed, 16 Sep 2026 23:13:44 +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=1789600428; cv=none; b=tBbj7vAhe65Sc6M+i2tRDg5P+/9hOAUf82Da9UIJ68zOztDZzX9e2xMPfCcDNeC/6tb1m3fU49VfgX9HbM/ScebGg7jebLqmTO5D3r/wPXmogcr7+FxHfjDzvy/1s1ICMhLaF5llqQQQpxUU9LU4dXcb/jX16Yp3yegYayMsOs4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789600428; c=relaxed/simple; bh=KxCx9yvhbpPkEYYZZKaBnBcf2ZVpf2zfr18lvf/o/qE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GmBhAcj5G4Bf+ujJzErAv9SMM0UOMIUP3XJLPQvWjjnRgJ6irtFJFomdB13IY5FtG4D7mvm3oPUrcZaYGyDuU2wq1j71je4H+ZRATK6V3y3lg6QpDKaigRqPxm9XHllVM5G12qxhHwCvSEWrjbx10JFBEMYDnBDv/uTsyT/+Z3s= 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=npgcuM9i; 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="npgcuM9i" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1789600425; x=1821136425; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=KxCx9yvhbpPkEYYZZKaBnBcf2ZVpf2zfr18lvf/o/qE=; b=npgcuM9i9oaxZZYJEvb/Pp2onO/DvIoumbrChvHhaPMbw6zwnimXlxB2 wIHCPAlpdqkWX1tIQC/cw/CrW9cUeQNn0v9A5ojjZINh+/xvFJhMZAiJB oOKPpuZ8wKn1w5otTmaBS6263UNlNNTqXzCaHVcdhcDSI5sMSx1sdv3mr JOi0Qim4HA/Pw0Z25uSv+rJkDzDUV+C033mKf58PKOowjfm4XstH22DGU 0KtggCW3Z3uE6wU7/47Te+sprntY3H3gkYpHxsG7QJCCwpvM4EirxfHxO vNDAB5BU/JFhl7TqKPiZAQa1aaTCTdxcDZdmr5Jvk02scSp97DHFJnbw1 A==; X-CSE-ConnectionGUID: hg7ceVSUTD+P3Sed62/cEw== X-CSE-MsgGUID: zTYWeDwyRnW9cKlTV2KibA== X-IronPort-AV: E=McAfee;i="6800,10657,11905"; a="93861433" X-IronPort-AV: E=Sophos;i="6.27,103,1787036400"; d="scan'208";a="93861433" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by orvoesa106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Sep 2026 16:13:36 -0700 X-CSE-ConnectionGUID: /6FQ/PLlT8mxSk45Zger7g== X-CSE-MsgGUID: x/cTe8LjTF2zkyyUbE3fsQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,103,1787036400"; d="scan'208";a="277231468" Received: from khuang2-desk.gar.corp.intel.com (HELO agluck-desk3.home.arpa) ([10.124.223.219]) by orviesa004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Sep 2026 16:13:36 -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 v12 13/25] arm,x86,fs/resctrl: Allocate right size for L3 monitor arrays Date: Wed, 16 Sep 2026 16:13:08 -0700 Message-ID: <20260916231320.14502-14-tony.luck@intel.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260916231320.14502-1-tony.luck@intel.com> References: <20260916231320.14502-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 number of RMIDs available may change from one mount to the next. The sizes of the rdt_l3_mon_domain::rmid_busy_llc bitmap and the rdt_l3_mon_domain::mbm_states array always depend on the number of RMIDs supported by RDT_RESOURCE_L3. Add resctrl_arch_get_num_rmid_idx(r) to report the maximum RMID index for a resource. Use it to allocate the rdt_l3_mon_domain::rmid_busy_llc bitmap and rdt_l3_mon_domain::mbm_states[] and when operating on these structures. The limbo code must deal with changes in the number of RMIDs from one mount to the next because some RMIDs may still be "busy" when the file system is unmounted, but be above resctrl_arch_system_num_rmid_idx() for the remount. In this case RMIDs that can be released are not put onto the rmid_free_lru list. Signed-off-by: Tony Luck --- v12: New patch. Split from patch 12. --- include/linux/resctrl.h | 7 +++++-- arch/x86/kernel/cpu/resctrl/core.c | 5 +++++ drivers/resctrl/mpam_resctrl.c | 5 +++++ fs/resctrl/monitor.c | 30 ++++++++++++++++++++++-------- fs/resctrl/rdtgroup.c | 6 +++--- 5 files changed, 40 insertions(+), 13 deletions(-) diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index 5535bde7b925..604ab7af7c2b 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -183,10 +183,12 @@ struct mbm_cntr_cfg { * struct rdt_l3_mon_domain - group of CPUs sharing RDT_RESOURCE_L3 monito= ring * @hdr: common header for different domain types * @ci_id: cache info id for this domain - * @rmid_busy_llc: bitmap of which limbo RMIDs are above threshold + * @rmid_busy_llc: bitmap of which limbo RMIDs are above threshold. Sized = for + * maximum supported RMIDs in L3 resource. * @mbm_states: Per-event pointer to the MBM event's saved state. * An MBM event's state is an array of struct mbm_state * indexed by RMID on x86 or combined CLOSID, RMID on Arm. + * Sized same as @rmid_busy_llc. * @mbm_over: worker to periodically read MBM h/w counters * @cqm_limbo: worker to periodically read CQM h/w counters * @mbm_work_cpu: worker CPU for MBM h/w counters @@ -444,8 +446,9 @@ static inline u32 resctrl_get_default_ctrl(struct rdt_r= esource *r) return WARN_ON_ONCE(1); } =20 -/* The number of closid supported by this resource regardless of CDP */ +/* The number of closid/rmid supported by this resource regardless of CDP = */ u32 resctrl_arch_get_num_closid(struct rdt_resource *r); +u32 resctrl_arch_get_num_rmid_idx(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); diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resct= rl/core.c index a9109f2bc43e..e633da548959 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -380,6 +380,11 @@ u32 resctrl_arch_get_num_closid(struct rdt_resource *r) return resctrl_to_arch_res(r)->num_closid; } =20 +u32 resctrl_arch_get_num_rmid_idx(struct rdt_resource *r) +{ + return r->mon.num_rmid; +} + void rdt_ctrl_update(void *arg) { struct rdt_hw_resource *hw_res; diff --git a/drivers/resctrl/mpam_resctrl.c b/drivers/resctrl/mpam_resctrl.c index 0ffa25199f74..69c9e02d2f40 100644 --- a/drivers/resctrl/mpam_resctrl.c +++ b/drivers/resctrl/mpam_resctrl.c @@ -247,6 +247,11 @@ u32 resctrl_arch_get_num_closid(struct rdt_resource *i= gnored) return mpam_partid_max + 1; } =20 +u32 resctrl_arch_get_num_rmid_idx(struct rdt_resource *ignored) +{ + return resctrl_arch_system_num_rmid_idx(); +} + u32 resctrl_arch_system_num_rmid_idx(void) { return (mpam_pmg_max + 1) * (mpam_partid_max + 1); diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c index e8775e08aa18..b8bd59c52c62 100644 --- a/fs/resctrl/monitor.c +++ b/fs/resctrl/monitor.c @@ -115,10 +115,18 @@ static inline struct rmid_entry *__rmid_entry(u32 idx) =20 static void limbo_release_entry(struct rmid_entry *entry) { + u32 cur_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) < cur_idx_li= mit) + 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 +141,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 l3_idx_limit =3D resctrl_arch_get_num_rmid_idx(r); struct rmid_entry *entry; bool rmid_dirty =3D true; u32 idx, cur_idx =3D 1; @@ -154,10 +162,15 @@ void __check_limbo(struct rdt_l3_mon_domain *d, bool = force_free) * are marked as busy for occupancy < threshold. If the occupancy * is less than the threshold decrement the busy counter of the * RMID and move it to the free list when the counter reaches 0. + * + * RMIDs will keep counts of allocated LLC entries after the resctrl + * file system is unmounted. So check all possible RMIDs since a + * previous mount cycle may have used more than are available in + * this mount cycle. */ for (;;) { - idx =3D find_next_bit(d->rmid_busy_llc, idx_limit, cur_idx); - if (idx >=3D idx_limit) + idx =3D find_next_bit(d->rmid_busy_llc, l3_idx_limit, cur_idx); + if (idx >=3D l3_idx_limit) break; =20 entry =3D __rmid_entry(idx); @@ -197,9 +210,10 @@ void __check_limbo(struct rdt_l3_mon_domain *d, bool f= orce_free) =20 bool has_busy_rmid(struct rdt_l3_mon_domain *d) { - u32 idx_limit =3D resctrl_arch_system_num_rmid_idx(); + struct rdt_resource *r =3D resctrl_arch_get_resource(RDT_RESOURCE_L3); + u32 l3_idx_limit =3D resctrl_arch_get_num_rmid_idx(r); =20 - return find_first_bit(d->rmid_busy_llc, idx_limit) !=3D idx_limit; + return find_first_bit(d->rmid_busy_llc, l3_idx_limit) !=3D l3_idx_limit; } =20 static struct rmid_entry *resctrl_find_free_rmid(u32 closid) @@ -1218,7 +1232,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 l3_idx_limit =3D resctrl_arch_get_num_rmid_idx(r); enum resctrl_event_id evt; int idx; =20 @@ -1226,7 +1240,7 @@ static void resctrl_reset_rmid_all(struct rdt_resourc= e *r, struct rdt_l3_mon_dom if (!resctrl_is_mon_event_enabled(evt)) continue; idx =3D MBM_STATE_IDX(evt); - memset(d->mbm_states[idx], 0, sizeof(*d->mbm_states[0]) * idx_limit); + memset(d->mbm_states[idx], 0, sizeof(*d->mbm_states[0]) * l3_idx_limit); } } =20 diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c index c0b86ce05e50..0c9c29037667 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -4621,13 +4621,13 @@ 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 l3_idx_limit =3D resctrl_arch_get_num_rmid_idx(r); size_t tsize =3D sizeof(*d->mbm_states[0]); enum resctrl_event_id eventid; int idx; =20 if (resctrl_is_mon_event_enabled(QOS_L3_OCCUP_EVENT_ID)) { - d->rmid_busy_llc =3D bitmap_zalloc(idx_limit, GFP_KERNEL); + d->rmid_busy_llc =3D bitmap_zalloc(l3_idx_limit, GFP_KERNEL); if (!d->rmid_busy_llc) return -ENOMEM; } @@ -4636,7 +4636,7 @@ static int domain_setup_l3_mon_state(struct rdt_resou= rce *r, struct rdt_l3_mon_d if (!resctrl_is_mon_event_enabled(eventid)) continue; idx =3D MBM_STATE_IDX(eventid); - d->mbm_states[idx] =3D kcalloc(idx_limit, tsize, GFP_KERNEL); + d->mbm_states[idx] =3D kcalloc(l3_idx_limit, tsize, GFP_KERNEL); if (!d->mbm_states[idx]) goto cleanup; } --=20 2.55.0 From nobody Fri Sep 25 04:07:27 2026 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 8E85A51FCA1 for ; Wed, 16 Sep 2026 23:13:46 +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=1789600428; cv=none; b=vBStSfRX/wxWiM5a1d6KjG5gQ6qmk0bzmDD8YV6smbeoKHp9gvBamftqm+Uev+iGjVLB+btK72LPGhvbGDcNyxRsDiJpmEyCrey0sVbTfuU50yQkSuppqsyzApYH7kSlOYppGMKIASkpB8SKqUep3UDln+zcmz6DiW1/9orlqcQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789600428; c=relaxed/simple; bh=bjl53x6ixGVQwtoXJbvhU84Wge/Z4FIAwJfWtvF1zdo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Wxv09dS3qzmicDtsrKk638LHC9fmOmrwR1vuTosDZO80yo2aELIojbE+O84FdLb3v0VgJYhax0AN177lR3lALFFwLmY9BPmkJEmd6lagpBrug0coZr3Oa3AgsO7pxDTrsOqGabw9yvS33+DC++1u4ajAqaG76ZvmnFxktr40Jbw= 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=KFyYFO9C; 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="KFyYFO9C" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1789600427; x=1821136427; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=bjl53x6ixGVQwtoXJbvhU84Wge/Z4FIAwJfWtvF1zdo=; b=KFyYFO9CD0DKVGZ/38FL5ch94QHLNLYbS1pqbLXBilU09+dNvBnc0JwW IqSJ/uOcNrTVyfyuno7+1rn7Kzy5aWUMFoQKo4WsIVuhzJCqUeEWVxf4w zlwoNtd1xdcJAcfe4jBFA6RaiospF3ktZMiD68aNI2DHVWIV5JOm0bw6k sbq13MM39zhkwkiNeleEGwfy9aDf4CFc83f+HGLI08V50nhr1gATJyhtB XWYK9LLsF77Q6GbmEicmLXSCbbtw8HTIoCveJVWEbjEg01A/RspNG4gaG M3+vc4fbPSLhzzcxzlpOiaF4QfZ0iQApvKi8NwCfClAd3jPjURTY18zIi w==; X-CSE-ConnectionGUID: doULrU+tT6WmT3aCtMSsWA== X-CSE-MsgGUID: Dy26DaO/SVWk4OMUj7JguQ== X-IronPort-AV: E=McAfee;i="6800,10657,11905"; a="93861443" X-IronPort-AV: E=Sophos;i="6.27,103,1787036400"; d="scan'208";a="93861443" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by orvoesa106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Sep 2026 16:13:36 -0700 X-CSE-ConnectionGUID: RT5IhKlMSmaXgZQnznc2Iw== X-CSE-MsgGUID: 2n05r5EDT42UKKmYE1PkeQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,103,1787036400"; d="scan'208";a="277231472" Received: from khuang2-desk.gar.corp.intel.com (HELO agluck-desk3.home.arpa) ([10.124.223.219]) by orviesa004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Sep 2026 16:13:36 -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 v12 14/25] fs/resctrl: Rebuild free RMID list on each mount Date: Wed, 16 Sep 2026 16:13:09 -0700 Message-ID: <20260916231320.14502-15-tony.luck@intel.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260916231320.14502-1-tony.luck@intel.com> References: <20260916231320.14502-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 off 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. Initialize rmid_free_lru based on the number of RMIDs available for the current mount cycle. Signed-off-by: Tony Luck --- v12: New patch. Split from patch 12. --- fs/resctrl/monitor.c | 64 +++++++++++++++++++++++++++++--------------- 1 file changed, 42 insertions(+), 22 deletions(-) diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c index b8bd59c52c62..8dde2b81b72f 100644 --- a/fs/resctrl/monitor.c +++ b/fs/resctrl/monitor.c @@ -75,6 +75,11 @@ static unsigned int rmid_limbo_count; */ static struct rmid_entry *rmid_ptrs; =20 +/* + * @num_rmid_ptrs - The number of elements in rmid_ptrs[]. + */ +static u32 num_rmid_ptrs; + /* * This is the threshold cache occupancy in bytes at which we will conside= r an * RMID available for re-allocation. @@ -975,45 +980,60 @@ void mbm_setup_overflow_handler(struct rdt_l3_mon_dom= ain *dom, unsigned long del =20 int setup_rmid_lru_list(void) { - struct rmid_entry *entry =3D NULL; - u32 idx_limit; - u32 idx; + struct rmid_entry *entry; + u32 cur_idx_limit; + u32 rsvd_idx; int i; =20 if (!resctrl_mon_capable()) 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) { + num_rmid_ptrs =3D resctrl_arch_system_max_rmid_idx(); + rmid_ptrs =3D kzalloc_objs(struct rmid_entry, num_rmid_ptrs); + if (!rmid_ptrs) { + num_rmid_ptrs =3D 0; + return -ENOMEM; + } =20 - 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 < num_rmid_ptrs; i++) { + entry =3D &rmid_ptrs[i]; + INIT_LIST_HEAD(&entry->list); =20 - 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 - resctrl_arch_rmid_idx_decode(i, &entry->closid, &entry->rmid); - list_add_tail(&entry->list, &rmid_free_lru); + /* Find how many RMIDs are available for this mount */ + cur_idx_limit =3D resctrl_arch_system_num_rmid_idx(); + if (cur_idx_limit > num_rmid_ptrs) { + pr_warn_once("RMID count %u exceeds allocated %u; capping\n", + cur_idx_limit, num_rmid_ptrs); + cur_idx_limit =3D num_rmid_ptrs; } =20 + INIT_LIST_HEAD(&rmid_free_lru); + /* * RESCTRL_RESERVED_CLOSID and RESCTRL_RESERVED_RMID are special and * are always allocated. These are used for the rdtgroup_default * control group, which was setup earlier in rdtgroup_setup_default(). */ - idx =3D resctrl_arch_rmid_idx_encode(RESCTRL_RESERVED_CLOSID, - RESCTRL_RESERVED_RMID); - entry =3D __rmid_entry(idx); - list_del(&entry->list); + rsvd_idx =3D resctrl_arch_rmid_idx_encode(RESCTRL_RESERVED_CLOSID, + RESCTRL_RESERVED_RMID); + + for (i =3D 0; i < cur_idx_limit; i++) { + entry =3D &rmid_ptrs[i]; + /* Don't add reserved or busy entries to free list */ + if (i =3D=3D rsvd_idx || entry->busy) + continue; + list_add_tail(&entry->list, &rmid_free_lru); + } =20 return 0; } --=20 2.55.0 From nobody Fri Sep 25 04:07:27 2026 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 B9EAA51FCD3 for ; Wed, 16 Sep 2026 23:13:46 +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=1789600429; cv=none; b=hl0f8l+WFS9WoKMqDveDnyJWwiA2WVZ1bN2IxLO0rTBjVIuX8WUu1IEWs1Qq+ci9+TAsNPtmkCmu3ZPXQnb+KtjtuAsnO89DIho46B1hyIlfnJXrfYus6ACGP7b9UMH7g6+YsZavQTRnakD1Vvsxax+4A6o9kyTnuXV6bR/lORU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789600429; c=relaxed/simple; bh=rDLLR0LDnRx/9atFQ+G3cGMZ7kZWOpg49SUEMq2vW0I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jX3IadwQp4AMWVLFLk/XYCN84EMIOs2CIskR5beRXZjIQllqS27qvL/CG71pthWPsMHRzscrx1rmxBouBZ96VR7CD1jy21KN85sTkx1OFNzTiv9rAokJdGvTbqeGBti2Zhxnz9HX71Hsgb48f0ZCKBivz9uWD4GPZj72uq/KQww= 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=byIUXC90; 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="byIUXC90" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1789600427; x=1821136427; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=rDLLR0LDnRx/9atFQ+G3cGMZ7kZWOpg49SUEMq2vW0I=; b=byIUXC907lvpl0RrpuD/wsh61bXQ2o9JgREiYEnxKgGe78ABUCrwZcyq kP+yAwihat+rNVGATIbGClszU1Ojp8wUzJ/6TcKYT311alRpreEzC6u5w UTPSNbZKbHVU5WBF5iTwPDAkwLbeKlFHD6WaW4wG+u5uER1+oAno00V17 s+lfNSp9PEz5hPWGDw9WcurCCddHU2e9yQa3+6KnsXwfJfZBrt9AblUdo Y8gjBABwkKKQVbJttxk7vDD6vS887hl9ty8LAiWTiAcPv9g40+rmTuDYp PpmTzLgq5NC0q8i0WaJnsWAbm3SnE2E9qSTIEwKeWsbSJG3tcfEmV6mQx w==; X-CSE-ConnectionGUID: WV7J0hriQZ+LELot/i41qg== X-CSE-MsgGUID: QMgypRhcSHSpSNtu3ESYlA== X-IronPort-AV: E=McAfee;i="6800,10657,11905"; a="93861452" X-IronPort-AV: E=Sophos;i="6.27,103,1787036400"; d="scan'208";a="93861452" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by orvoesa106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Sep 2026 16:13:37 -0700 X-CSE-ConnectionGUID: ilIvPQJaS5mmoc0aIfMOmA== X-CSE-MsgGUID: 1WnhJTtjTpCBX2LF8q692Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,103,1787036400"; d="scan'208";a="277231476" Received: from khuang2-desk.gar.corp.intel.com (HELO agluck-desk3.home.arpa) ([10.124.223.219]) by orviesa004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Sep 2026 16:13:37 -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 v12 15/25] x86,fs/resctrl: Handle systems where AET is the only resource Date: Wed, 16 Sep 2026 16:13:10 -0700 Message-ID: <20260916231320.14502-16-tony.luck@intel.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260916231320.14502-1-tony.luck@intel.com> References: <20260916231320.14502-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" On a system with no L3 monitor resources it should still be possible to run with just AET. Update get_rdt_mon_resources() to return true based on whether the system supports monitoring rather than on the presence of any of the L3 monitor features. Refuse to mount the resctrl file system if there are no monitoring or control features. Add invalfc() to rdt_get_tree() so the console log will let the user know why the mount failed. Signed-off-by: Tony Luck --- v12: Cleanups in get_rdt_mon_resources() Add invalfc() to rdt_get_tree() Change commit message with updated changes --- arch/x86/kernel/cpu/resctrl/internal.h | 2 +- arch/x86/kernel/cpu/resctrl/core.c | 20 +++++++++++--------- arch/x86/kernel/cpu/resctrl/monitor.c | 4 +--- fs/resctrl/rdtgroup.c | 8 ++++++-- 4 files changed, 19 insertions(+), 15 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/r= esctrl/internal.h index e46eb9a4c725..d70c8cb1cb81 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -226,7 +226,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 e633da548959..addcb2a19c98 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -991,7 +991,7 @@ static __init bool get_rdt_alloc_resources(void) static __init bool get_rdt_mon_resources(void) { struct rdt_resource *r =3D &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl; - bool ret =3D false; + bool l3_mon_found =3D false; =20 /* Any monitoring at all? */ if (!cpu_feature_enabled(X86_FEATURE_CQM)) @@ -1001,27 +1001,29 @@ static __init bool get_rdt_mon_resources(void) =20 /* Any of the L3 monitoring features? */ if (!cpu_feature_enabled(X86_FEATURE_CQM_LLC)) - return false; + goto skip_l3_feature_checks; =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; + l3_mon_found =3D true; } 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; + l3_mon_found =3D true; } 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; + l3_mon_found =3D true; } if (rdt_cpu_has(X86_FEATURE_ABMC)) - ret =3D true; + l3_mon_found =3D true; =20 - if (!ret) - return false; + if (l3_mon_found) + rdt_get_l3_mon_config(r); =20 - return !rdt_get_l3_mon_config(r); +skip_l3_feature_checks: + /* Even if there are no L3 monitor events, AET might be supported */ + return true; } =20 static __init void __check_quirks_intel(void) diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/re= sctrl/monitor.c index 2f3e5b89a7fc..e684353631de 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -431,7 +431,7 @@ static void __init intel_rdt_mbm_apply_quirk(u32 num_rm= id) mbm_cf =3D mbm_cf_table[cf_index].cf; } =20 -int __init rdt_get_l3_mon_config(struct rdt_resource *r) +void __init rdt_get_l3_mon_config(struct rdt_resource *r) { struct rdt_hw_resource *hw_res =3D resctrl_to_arch_res(r); unsigned int mbm_offset; @@ -514,8 +514,6 @@ int __init rdt_get_l3_mon_config(struct rdt_resource *r) intel_rdt_mbm_apply_quirk(r->mon.num_rmid); =20 r->mon_capable =3D true; - - return 0; } =20 static void resctrl_abmc_set_one_amd(void *arg) diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c index 0c9c29037667..2e9f71901f68 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -3195,6 +3195,11 @@ static int rdt_get_tree(struct fs_context *fc) goto out; } =20 + if (!resctrl_alloc_capable() && !resctrl_mon_capable()) { + ret =3D invalfc(fc, "No allocation or monitoring features are available = or enabled"); + goto out; + } + ret =3D setup_rmid_lru_list(); if (ret) goto out; @@ -3253,8 +3258,7 @@ static int rdt_get_tree(struct fs_context *fc) if (resctrl_mon_capable()) resctrl_arch_enable_mon(); =20 - if (resctrl_alloc_capable() || resctrl_mon_capable()) - resctrl_mounted =3D true; + resctrl_mounted =3D true; =20 if (resctrl_is_mbm_enabled()) { r =3D resctrl_arch_get_resource(RDT_RESOURCE_L3); --=20 2.55.0 From nobody Fri Sep 25 04:07:27 2026 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 A587C4E431B for ; Wed, 16 Sep 2026 23:13:48 +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=1789600433; cv=none; b=qEzUcLo1d7jVd07Fb2/lqP3DA9z/CG06Fpd3h0HBUXPZ1JNftygZjJF1OABkkaF4/ucwL/QUU7GPHyqvasVapZ0N3zjJUS4In1xwOTVYRN2NTMHfHMTW9625NWjxWEqSyyopBHEUqfa3eKFjXmc7PR/0WfzJwcAJIDBS6HAE81g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789600433; c=relaxed/simple; bh=BvIS2nxcl29o495YCUiPjDgsNeK5VhMEKlCbS6unozM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PyE/L+MOQvNDZdOn/YPZHZJedbydHtK9qWGZyikiQ2jhH+WuG9C+Gl11DYuHlDZHnvkorZq4y7FWN5yti3a9KHj/cdBMNMYIuxj5d3Aip3djFP0P9g6Fobj2Iu3fWnLyhElyaV/IS+o1YNqwiJNVDpufSxl71B2tdFT5jmqiQkc= 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=ccabOQAQ; 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="ccabOQAQ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1789600429; x=1821136429; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=BvIS2nxcl29o495YCUiPjDgsNeK5VhMEKlCbS6unozM=; b=ccabOQAQTfpe0C7BdRTB4qoN+zc6eRuWm4k9/aVK1hV7/g/M69xvJGCt u3bwKQb0Hx+pURd/yRZMpJ5PYq0/lQkcNQym4uZ9WEhFzfPND3mAcFBTh UdmrFXXiUteZvH8BKHi/wouiS0CBG70A0VPNZMZ60Qlv+v1ysiw4KW8sH XGy4EA7lTItvSz7Fy8oEBgy5b/B+A6DebdZqPQn+hsk1Ez65yzmFAKVTO 0eu/xSDeHzxvyP1EWS/kgrR/X09dk0HuulG5uNH/Ocj+z0HpsZEAcDYbp gJQEtau/3fTgywZ2fYfS2ooEejumPYWYBn2pWp3m0/Ql5eMem9NFIvf+L A==; X-CSE-ConnectionGUID: e4t4vR6rRySJChS0DtlXug== X-CSE-MsgGUID: awlTbT0mQLCnD4JLsriluA== X-IronPort-AV: E=McAfee;i="6800,10657,11905"; a="93861461" X-IronPort-AV: E=Sophos;i="6.27,103,1787036400"; d="scan'208";a="93861461" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by orvoesa106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Sep 2026 16:13:37 -0700 X-CSE-ConnectionGUID: GTU2xvclQDGq9DD4+h+TIw== X-CSE-MsgGUID: Tytxpl+0QyWVfrQGT8DS8A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,103,1787036400"; d="scan'208";a="277231480" Received: from khuang2-desk.gar.corp.intel.com (HELO agluck-desk3.home.arpa) ([10.124.223.219]) by orviesa004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Sep 2026 16:13:37 -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 v12 16/25] x86/resctrl: Add PMT registration API for AET enumeration callbacks Date: Wed, 16 Sep 2026 16:13:11 -0700 Message-ID: <20260916231320.14502-17-tony.luck@intel.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260916231320.14502-1-tony.luck@intel.com> References: <20260916231320.14502-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 --- v12: No change --- include/linux/intel_vsec.h | 12 ++++++++++++ arch/x86/kernel/cpu/resctrl/intel_aet.c | 24 ++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/include/linux/intel_vsec.h b/include/linux/intel_vsec.h index 843cda8f8644..c04b1d0f3143 100644 --- a/include/linux/intel_vsec.h +++ b/include/linux/intel_vsec.h @@ -257,4 +257,16 @@ static inline void intel_pmt_put_feature_group(struct pmt_feature_group *feature_group) {} #endif =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 */ + #endif diff --git a/arch/x86/kernel/cpu/resctrl/intel_aet.c b/arch/x86/kernel/cpu/= resctrl/intel_aet.c index 4ad6ad78e93e..6c4f0bf3b876 100644 --- a/arch/x86/kernel/cpu/resctrl/intel_aet.c +++ b/arch/x86/kernel/cpu/resctrl/intel_aet.c @@ -17,12 +17,14 @@ #include #include #include +#include #include #include #include #include #include #include +#include #include #include #include @@ -291,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, @@ -325,6 +331,24 @@ bool intel_aet_get_events(void) return ret; } =20 +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)) +{ + 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) +{ + 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.55.0 From nobody Fri Sep 25 04:07:27 2026 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 0987F52B1FB for ; Wed, 16 Sep 2026 23:13:48 +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=1789600431; cv=none; b=dpxlunByBwK1y3A0XCwUub7oGOc59qdIYsUSO4WzTGDlzUO2kiS/HXUjldXzolhtBoPsE4wvryCQFcg7XlVgZKjVQ4nWMNNibVHtcoHNEuQsIV97OBTpBV/y5wOMW/8ITrDua2vKWIPi00qLZ5DDM1Krg3xKdqD8xIZ6E+AoJ8E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789600431; c=relaxed/simple; bh=9CyekPmxUkpvx5IqdU7Rjc0F6QQlf4amQJEjXjx4+mI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JPfUjftefQ+LElWTPncaLxzczbv7TfgG/QVm8a56/jQ9sImkdrkITEaZfGMnOC4dKraT9rC5aasuZTdnb70h1qxw82d3TJP0Shfgn31DhKqGR8zKlMDXrVMTElKqQnnVZBgGI5QJNecRbnpPXIFqN5BDjjVt0UAOUPe1XuCpCpo= 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=nU77YMN8; 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="nU77YMN8" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1789600429; x=1821136429; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=9CyekPmxUkpvx5IqdU7Rjc0F6QQlf4amQJEjXjx4+mI=; b=nU77YMN8w/CjCzwmDatuFheaFvV6AsfyTZZ30+fg4aOXQWUWKQA4dyNN y+0peyPW1Uib+2gwRxgwDFaaYVF1/o4ARlvBHGc5k7hAXvP7pZe/U1PRa 80gyWiwPaRQc9IJ75upiyemcM8LX4i/S78McoqMBBvYC1U2mZhvCsVhxV w4FuhXoU344gqHM9ktAirCJelQq3ILBS2b+Uzp/yYXLUqXWHpXOOavM2I MQDanND+3WXdYH+ZoOPbOVDmUcJmLJ528xME31b6nV5NNrqqb/NlbQeob qCLI0PHj6doMdkW2e/yRaXJQDs9eRrHeeWqdhf6vxNwbMcSn9coFWe0L4 A==; X-CSE-ConnectionGUID: sKFFpImBSRyo/k65YCdo4g== X-CSE-MsgGUID: yDDQw8QLQJi5rEUwxKHe6Q== X-IronPort-AV: E=McAfee;i="6800,10657,11905"; a="93861470" X-IronPort-AV: E=Sophos;i="6.27,103,1787036400"; d="scan'208";a="93861470" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by orvoesa106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Sep 2026 16:13:38 -0700 X-CSE-ConnectionGUID: i+Qn/mRvRGOmj0VRlgeHzg== X-CSE-MsgGUID: 7bfyiY+tTmqaC5Do7ETucw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,103,1787036400"; d="scan'208";a="277231483" Received: from khuang2-desk.gar.corp.intel.com (HELO agluck-desk3.home.arpa) ([10.124.223.219]) by orviesa004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Sep 2026 16:13:38 -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 v12 17/25] platform/x86/intel/pmt: Register enumeration functions with resctrl Date: Wed, 16 Sep 2026 16:13:12 -0700 Message-ID: <20260916231320.14502-18-tony.luck@intel.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260916231320.14502-1-tony.luck@intel.com> References: <20260916231320.14502-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. Use ".probe_type =3D PROBE_FORCE_SYNCHRONOUS" to ensure sequential, synchro= nous calls to per-device .probe() functions. Register the telemetry enumeration function pointers at the end of pmt_telem_init() when all .probe() functions have run and enumeration is complete. Unregister at the start of pmt_telem_exit() before teardown of the auxiliary drivers. Suggested-by: Christoph Hellwig Signed-off-by: Tony Luck --- v12: No change --- drivers/platform/x86/intel/pmt/telemetry.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/drivers/platform/x86/intel/pmt/telemetry.c b/drivers/platform/= x86/intel/pmt/telemetry.c index 953f35b6daec..bf0c9295feb3 100644 --- a/drivers/platform/x86/intel/pmt/telemetry.c +++ b/drivers/platform/x86/intel/pmt/telemetry.c @@ -427,16 +427,30 @@ static struct auxiliary_driver pmt_telem_aux_driver = =3D { .id_table =3D pmt_telem_id_table, .remove =3D pmt_telem_remove, .probe =3D pmt_telem_probe, + .driver =3D { + .probe_type =3D PROBE_FORCE_SYNCHRONOUS, + }, }; =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.55.0 From nobody Fri Sep 25 04:07:27 2026 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 52A4B534472 for ; Wed, 16 Sep 2026 23:13:50 +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=1789600432; cv=none; b=sU1vt6b6QVS8BGp7+VNsb2t6JtSi+grkKb+aolZKlyeUAKWb8VaWfZwuWjPewqFpQcXjjp+GdvFwOUkP4IRXf0KpEM04bNyK5z7Q40QdKECS3O4q5uoeCKpTGnlyi5tt6mrMNaphoyIp9UQZuTF3kt+By6yASOfsxcZLR59qKmE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789600432; c=relaxed/simple; bh=88MyggT5anFVghCVKZ0w5+QpAf7rtxsu67L05dwPj80=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hnaYYOXcKnl2wR/QWX9H6u29I95IV4LYwlLLkaZ4KKOtDlI7uwxbp+HoKBjK9e8XK/zkB0n1aDbSxutywXf6ZMpzAUMKrqxHObcKZvXzHdoiG6K9DCXOCMhKFESZDTNEdmwmdgWLZYlRxlhuBnyPPGzg47cHJnfTIQWwKtrlQ2U= 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=YknMLVEk; 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="YknMLVEk" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1789600431; x=1821136431; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=88MyggT5anFVghCVKZ0w5+QpAf7rtxsu67L05dwPj80=; b=YknMLVEklTwUg/YyKWAhPQunqVsC+R8k5Iducswl5Y+joEIfDXtXavyE QsDqyvhpXuRwkwkG0qSSlSkVFF9wYI5RSjBrw0pkFIei2wrvKVfqr3DFr bPATBGx7QmiwAWSDpftaoyr47xzfdp0+ie0eNG3FLpKeJ3Cn3e3VJTmw2 wTbB799RohJm44ojrxTN2LuOPYCR2lLuA9bhhBNucm7pI7yXL4cSNKzqm oWQPF5276TOcCf6UHOsH7PVl+VQUeB/Zb4K/KAyqziGNRRTMCKBaTJe8b OSSD5hoszq6wXuOxdq+sVzHpXi0GwVsLixoMz9GdlNtBYv/dYyU9yjPGe Q==; X-CSE-ConnectionGUID: l9lvf2PMT1ak97sWakqS/w== X-CSE-MsgGUID: 3r55X60yROewYup2C1w+yw== X-IronPort-AV: E=McAfee;i="6800,10657,11905"; a="93861479" X-IronPort-AV: E=Sophos;i="6.27,103,1787036400"; d="scan'208";a="93861479" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by orvoesa106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Sep 2026 16:13:38 -0700 X-CSE-ConnectionGUID: 6dMgICLWQxO+TY6mgYv3kw== X-CSE-MsgGUID: ym67Hz2BRTWrsNrJTcOuTw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,103,1787036400"; d="scan'208";a="277231486" Received: from khuang2-desk.gar.corp.intel.com (HELO agluck-desk3.home.arpa) ([10.124.223.219]) by orviesa004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Sep 2026 16:13:38 -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 v12 18/25] x86/resctrl: Use registered function pointers for AET enumeration Date: Wed, 16 Sep 2026 16:13:13 -0700 Message-ID: <20260916231320.14502-19-tony.luck@intel.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260916231320.14502-1-tony.luck@intel.com> References: <20260916231320.14502-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_TELEMETRY driver registers enumeration functions with resctrl Application Energy Telemetry (AET) code. Use the function pointers instead of direct function calls in preparation for the telemetry driver to be a loadable module. In preparation for enumeration on each mount of the resctrl file system place a hold on the pmt_telemetry module while enumerating AET events during pre-mount processing. Release the hold if no events were enabled. This hold will be released when the per-mount code is added. Signed-off-by: Tony Luck --- v12: Split from part 17 --- arch/x86/kernel/cpu/resctrl/internal.h | 4 +-- arch/x86/kernel/cpu/resctrl/core.c | 2 +- arch/x86/kernel/cpu/resctrl/intel_aet.c | 35 ++++++++++++++++++++++--- 3 files changed, 35 insertions(+), 6 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/r= esctrl/internal.h index d70c8cb1cb81..fc60b0af250d 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); 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 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 addcb2a19c98..2fa4ebf7159a 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -795,7 +795,7 @@ 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()) + if (!intel_aet_pre_mount()) return; =20 /* diff --git a/arch/x86/kernel/cpu/resctrl/intel_aet.c b/arch/x86/kernel/cpu/= resctrl/intel_aet.c index 6c4f0bf3b876..32f3f30894a4 100644 --- a/arch/x86/kernel/cpu/resctrl/intel_aet.c +++ b/arch/x86/kernel/cpu/resctrl/intel_aet.c @@ -12,6 +12,7 @@ #define pr_fmt(fmt) "resctrl: " fmt =20 #include +#include #include #include #include @@ -25,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -293,6 +295,13 @@ static enum pmt_feature_id lookup_pfid(const char *pfn= ame) return FEATURE_INVALID; } =20 +/* + * Protects pmt_module, get_feature, put_feature against races between mod= ule + * load/unload of the pmt_telemetry module and mount/unmount of the resctrl + * file system. + */ +static DEFINE_MUTEX(aet_register_lock); + 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); @@ -308,7 +317,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 +326,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 @@ -335,6 +344,7 @@ void intel_aet_register_enumeration(struct module *modu= le, 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; @@ -343,12 +353,31 @@ EXPORT_SYMBOL_NS_GPL(intel_aet_register_enumeration, = "INTEL_PMT"); =20 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"); =20 +bool intel_aet_pre_mount(void) +{ + guard(mutex)(&aet_register_lock); + + if (!get_feature || !put_feature) + return false; + + if (!try_module_get(pmt_module)) + return false; + + if (!aet_get_events()) { + module_put(pmt_module); + return false; + } + + return true; +} + void __exit intel_aet_exit(void) { struct event_group **peg; --=20 2.55.0 From nobody Fri Sep 25 04:07:27 2026 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 7BAD05437E7 for ; Wed, 16 Sep 2026 23:13:51 +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=1789600435; cv=none; b=SRDPOKokbADLaRl8/gV9GVuGQZsVH63HRkOrgz2Hz7wAWcGczi0iTDcDAgK1Ka83qAze5M1HL64rkbmxd1hsESNuA27RmVEMuQbhAeewzjLn8/TEHgxezezYq2dooo0YFT1xYwhqaEK1bo1FtlWmoHdlMQVHVIpnBbsbann1zN0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789600435; c=relaxed/simple; bh=8+L2gR2Ss+gNnCnweaBzwESt6GJNv29K9n1V0EfSMa4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=T9vVnthIUpHzvU1SkPNDhf9jUkH4AoS4VcIk2IHw9lFdlWiWTLTZDkE/650SCYbYX+Pa9zcJzEjOQTHNWzNi/fy/wPUdE4COFMBABJes0BgGgCZNE05ETRKuqQkZo+45xEJFheF7ImQaoYEhgECpq2LhVEZTO9DH6T0BMyqiLnQ= 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=XZ66fDLn; 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="XZ66fDLn" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1789600432; x=1821136432; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=8+L2gR2Ss+gNnCnweaBzwESt6GJNv29K9n1V0EfSMa4=; b=XZ66fDLnszmk3eyNIcGbKRqNxkaDopEvwOEcrqq40S9K+E+PFC2fOWZ/ 1IgA6ZFx3eyKqScSfF6JAPMgQk/9NaZHXyQ81ch0FViKHUnv/LyxxzbiL vpZ25Af0taJgxqpZFIvmMH8C4mLUK476XyK1n+Lb43HT+6JNc/KbLV2+v bycdQfCnz60eU2IPB/ivevw2XSdH3jrDVtMilBTcc0gaA3MdQ1MraPTBE inG0AeMWCgHGjleNqSOPv3Eenn0s34cS8kHeCrlFun58j3YIaurgTtGWe JkmFEvytdATzIhdBQht/CenglMRHQ02u36AE3nQhlAWj+tKQNvthk376M A==; X-CSE-ConnectionGUID: GCScWmK/QTCdiNEuGrHYeQ== X-CSE-MsgGUID: gXCaIUa+QUuKRSKWdGdm8w== X-IronPort-AV: E=McAfee;i="6800,10657,11905"; a="93861488" X-IronPort-AV: E=Sophos;i="6.27,103,1787036400"; d="scan'208";a="93861488" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by orvoesa106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Sep 2026 16:13:39 -0700 X-CSE-ConnectionGUID: hVkVTmCsSy+s+luHCKEWoQ== X-CSE-MsgGUID: uqIdBX5pRpevzIXFaim2jQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,103,1787036400"; d="scan'208";a="277231489" Received: from khuang2-desk.gar.corp.intel.com (HELO agluck-desk3.home.arpa) ([10.124.223.219]) by orviesa004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Sep 2026 16:13: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 Subject: [PATCH v12 19/25] arm,x86,fs/resctrl: Enumerate AET on every resctrl mount Date: Wed, 16 Sep 2026 16:13:14 -0700 Message-ID: <20260916231320.14502-20-tony.luck@intel.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260916231320.14502-1-tony.luck@intel.com> References: <20260916231320.14502-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" Call resctrl_arch_pre_mount() for every mount protected by resctrl_mount_lock. Add matching resctrl_arch_unmount() path for architecture code to clean up on mount failure or unmount. Remove intel_aet_exit() after moving all the cleanup code into intel_aet_unmount(). Signed-off-by: Tony Luck --- v12: Rest of old patch 17 merged into patch 18 so the umount code path is complete. Fix rdt_get_tree() return value when kernfs_get_tree() fails. Move resctrl_arch_unmount() after cpus_read_unlock() in out: error path Update resctrl_arch_pre_mount() header comment to say it is now called for each mount, not just the first. Update comment for resctrl_mounted to say that both resctrl_mount_lock and rdtgroup_mutex must be help to change state. --- include/linux/resctrl.h | 10 ++++++-- arch/x86/kernel/cpu/resctrl/internal.h | 4 ++-- arch/x86/kernel/cpu/resctrl/core.c | 21 +++++++++++++++-- arch/x86/kernel/cpu/resctrl/intel_aet.c | 29 +++++++++++++++++++---- drivers/resctrl/mpam_resctrl.c | 4 ++++ fs/resctrl/rdtgroup.c | 31 ++++++++++++++++++++----- 6 files changed, 82 insertions(+), 17 deletions(-) diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index 604ab7af7c2b..5a975856f670 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -590,11 +590,17 @@ 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. - * No locks are held. + * Architecture hook called at beginning of each file system mount attempt. + * Called while holding resctrl_mount_lock. */ void resctrl_arch_pre_mount(void); =20 +/* + * Architecture hook called when mount fails, or on unmount. + * Called while holding resctrl_mount_lock. + */ +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 fc60b0af250d..5e71dd758624 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 -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 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 2fa4ebf7159a..3bf4d1a07593 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -811,6 +811,25 @@ 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; + + if (!r->mon_capable) + return; + + intel_aet_unmount(); + + cpus_read_lock(); + mutex_lock(&domain_list_lock); + for_each_online_cpu(cpu) + domain_remove_cpu_mon(cpu, r); + r->mon_capable =3D false; + mutex_unlock(&domain_list_lock); + cpus_read_unlock(); +} + enum { RDT_FLAG_CMT, RDT_FLAG_MBM_TOTAL, @@ -1159,8 +1178,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 32f3f30894a4..8aa2e18a6bbb 100644 --- a/arch/x86/kernel/cpu/resctrl/intel_aet.c +++ b/arch/x86/kernel/cpu/resctrl/intel_aet.c @@ -298,7 +298,7 @@ static enum pmt_feature_id lookup_pfid(const char *pfna= me) /* * Protects pmt_module, get_feature, put_feature against races between mod= ule * load/unload of the pmt_telemetry module and mount/unmount of the resctrl - * file system. + * file system. Also protects pmt_in_use. */ static DEFINE_MUTEX(aet_register_lock); =20 @@ -306,6 +306,11 @@ 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); =20 +/* + * Track whether pmt_telemetry enumeration succeeded during mount for use = during unmount. + */ +static bool pmt_in_use; + /* * 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, @@ -375,19 +380,33 @@ bool intel_aet_pre_mount(void) return false; } =20 + pmt_in_use =3D true; + return true; } =20 -void __exit intel_aet_exit(void) +void intel_aet_unmount(void) { + struct rdt_resource *r =3D &rdt_resources_all[RDT_RESOURCE_PERF_PKG].r_re= sctrl; struct event_group **peg; =20 + guard(mutex)(&aet_register_lock); + if (!pmt_in_use) + return; + for_each_event_group(peg) { - if ((*peg)->pfg) { - intel_pmt_put_feature_group((*peg)->pfg); - (*peg)->pfg =3D NULL; + struct event_group *e =3D *peg; + + if (e->pfg) { + for (int i =3D 0; i < e->num_events; i++) + resctrl_disable_mon_event(e->evts[i].id); + put_feature(e->pfg); + e->pfg =3D NULL; } } + module_put(pmt_module); + pmt_in_use =3D false; + r->mon.num_rmid =3D 0; } =20 #define DATA_VALID BIT_ULL(63) diff --git a/drivers/resctrl/mpam_resctrl.c b/drivers/resctrl/mpam_resctrl.c index 69c9e02d2f40..f42f98f89c38 100644 --- a/drivers/resctrl/mpam_resctrl.c +++ b/drivers/resctrl/mpam_resctrl.c @@ -121,6 +121,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; diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c index 2e9f71901f68..07fefa3c434e 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -30,6 +30,9 @@ =20 #include "internal.h" =20 +/* Mutex protecting resctrl_mounted and mount/unmount operations */ +static DEFINE_MUTEX(resctrl_mount_lock); + /* Mutex to protect rdtgroup access. */ DEFINE_MUTEX(rdtgroup_mutex); =20 @@ -48,7 +51,10 @@ LIST_HEAD(resctrl_schema_all); */ static LIST_HEAD(mon_data_kn_priv_list); =20 -/* The filesystem can only be mounted once. */ +/* + * The filesystem can only be mounted once. Can only be updated + * while holding both resctrl_mount_lock and rdtgroup_mutex. + */ bool resctrl_mounted; =20 /* Kernel fs node for "info" directory under root */ @@ -3149,6 +3155,7 @@ static void resctrl_unmount(void) { struct rdt_resource *r; =20 + mutex_lock(&resctrl_mount_lock); cpus_read_lock(); mutex_lock(&rdtgroup_mutex); =20 @@ -3166,6 +3173,8 @@ static void resctrl_unmount(void) resctrl_mounted =3D false; mutex_unlock(&rdtgroup_mutex); cpus_read_unlock(); + resctrl_arch_unmount(); + mutex_unlock(&resctrl_mount_lock); } =20 static int rdt_get_tree(struct fs_context *fc) @@ -3177,24 +3186,27 @@ static int rdt_get_tree(struct fs_context *fc) struct rdt_resource *r; int ret; =20 - DO_ONCE_SLEEPABLE(resctrl_arch_pre_mount); + mutex_lock(&resctrl_mount_lock); =20 - cpus_read_lock(); - mutex_lock(&rdtgroup_mutex); /* * resctrl file system can only be mounted once. */ if (resctrl_mounted) { ret =3D -EBUSY; - goto out; + goto out_mount_unlock; } =20 /* Avoid races from pending operations from a previous mount */ if (atomic_read(&rdtgroup_default.waitcount) !=3D 0) { ret =3D -EBUSY; - goto out; + goto out_mount_unlock; } =20 + resctrl_arch_pre_mount(); + + cpus_read_lock(); + mutex_lock(&rdtgroup_mutex); + if (!resctrl_alloc_capable() && !resctrl_mon_capable()) { ret =3D invalfc(fc, "No allocation or monitoring features are available = or enabled"); goto out; @@ -3289,6 +3301,8 @@ static int rdt_get_tree(struct fs_context *fc) mutex_unlock(&rdtgroup_mutex); cpus_read_unlock(); =20 + mutex_unlock(&resctrl_mount_lock); + ret =3D kernfs_get_tree(fc); /* * resctrl can only be mounted once, new superblock only expected @@ -3297,6 +3311,7 @@ static int rdt_get_tree(struct fs_context *fc) if (!ctx->kfc.new_sb_created) resctrl_unmount(); kernfs_put(rdt_root_kn); + return ret; =20 out_mondata: @@ -3320,6 +3335,10 @@ static int rdt_get_tree(struct fs_context *fc) out: mutex_unlock(&rdtgroup_mutex); cpus_read_unlock(); + resctrl_arch_unmount(); +out_mount_unlock: + mutex_unlock(&resctrl_mount_lock); + return ret; } =20 --=20 2.55.0 From nobody Fri Sep 25 04:07:27 2026 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 0F5D954CF5C for ; Wed, 16 Sep 2026 23:13:53 +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=1789600435; cv=none; b=HP2MVkvfVLb4flPqSvsbQpJ13hXzHcD4s2lbm0XE390Q2yIP9yEprJfD9cyH8IuOJBx+OUm9GylxQrVIO0eNxrej6iqOR4ntj0lpXUwTEEocu+hAOBPLQm/e/tHzaiHisEbxwMWG/hygQ28EL1r8PX6n7Qx0HP+WPEXoYA3xnRM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789600435; c=relaxed/simple; bh=ctBegGBZtB/D5EoHsAL2gv9lKuYA19IzLJVZ+J8QjRI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rHQWF0t2Rb6fOS62TZGyOg7+cH6nC0bJU/CtrALiMTwX99YJaFLAP/AniNupET7CMHRYVAELWtO7ILY8poej1ViEz+Ua09vAMjnLyhwxvCH/PR23ms9CRQARw5BXsSVWDo/zvgE5bMDsy3wNt5d1GbJOycgE/+lGSEqcwCsPH20= 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=kZ8nFMj2; 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="kZ8nFMj2" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1789600433; x=1821136433; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ctBegGBZtB/D5EoHsAL2gv9lKuYA19IzLJVZ+J8QjRI=; b=kZ8nFMj2thlFUKC8YNzYYenwfMC74jPZXG4BymdZIIuKHot2egFh0W1e 9G69hcQaybHqorFkYNfvyu4JSgDDaRXu33beeSyCa0/1bQFaoEK0EjedL x0kDg2nxx7s5OpJ0UGUBSJviHpzeVvSto0j+J9SszzJh2st3xzDM7pjCg hVbcwirs5kA/7vqqjcIoBMkSVQXyL+kXjU0srJ/vu9DAmVBVITLnFKLBC 7xONMsesmpY5nJBo5A+af00ku4AwKWgHk49qXr7J3/LKDjM7UXEndeIEb HbsgF+49YPunrMUvlaQ6ovstGo4vlWM6kX0b0ls9nZD4N2699C+eRMYcI Q==; X-CSE-ConnectionGUID: ciDSsqzgRQOQYJkOxpN1Dg== X-CSE-MsgGUID: WB1sRHrvTIeL67GiNogezg== X-IronPort-AV: E=McAfee;i="6800,10657,11905"; a="93861498" X-IronPort-AV: E=Sophos;i="6.27,103,1787036400"; d="scan'208";a="93861498" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by orvoesa106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Sep 2026 16:13:39 -0700 X-CSE-ConnectionGUID: 0TXb/eG/RUqKAr9Y8uri9g== X-CSE-MsgGUID: UJyFVRoVReqdVwXh3uGsUQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,103,1787036400"; d="scan'208";a="277231492" Received: from khuang2-desk.gar.corp.intel.com (HELO agluck-desk3.home.arpa) ([10.124.223.219]) by orviesa004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Sep 2026 16:13: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 Subject: [PATCH v12 20/25] x86/resctrl: Enforce system RMID limit on AET Date: Wed, 16 Sep 2026 16:13:15 -0700 Message-ID: <20260916231320.14502-21-tony.luck@intel.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260916231320.14502-1-tony.luck@intel.com> References: <20260916231320.14502-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) event groups each support a specific number of RMIDs. But that number may be lower than the number supported by the system. This is especially true on systems with SNC (Sub-NUMA Cluste= r) enabled as that reduces the number of supported RMIDs. Reduce r->mon.num_rmid if needed to ensure that info/PERF_PKG_MON/num_rmids does not display an unachievable value to users. Signed-off-by: Tony Luck --- v12: Replacement for v11 patch 14 "Enforce system RMID limit ..." --- arch/x86/kernel/cpu/resctrl/core.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resct= rl/core.c index 3bf4d1a07593..a20439a5099a 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -798,6 +798,12 @@ void resctrl_arch_pre_mount(void) if (!intel_aet_pre_mount()) return; =20 + /* + * AET may claim to support more RMIDs than are permitted to be + * assigned to IA32_PQR_ASSOC.RMID. Enforce this limit. + */ + r->mon.num_rmid =3D min(r->mon.num_rmid, pqr_assoc_num_rmid); + /* * Late discovery of telemetry events means the domains for the * resource were not built. Do that now. --=20 2.55.0 From nobody Fri Sep 25 04:07:27 2026 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 DE4E2554094 for ; Wed, 16 Sep 2026 23:13:53 +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=1789600436; cv=none; b=uXPSxy4QdNuDyBvTTXVVhRM1scSY+z2nRceZDBJ6WTa9VUBeTrmrVI3FhJDrZgxIrhOgQJSf+q+VdfZtQhwIeISlW0i+ySoG3e6si+KRR/ErHxFG8X4TE8Vaf1uPkaf7x4QEk+jOcmdZu7yblPRdmNkhESrfN8spN/EzJ4Ux5jI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789600436; c=relaxed/simple; bh=lRVnP8afGZ4YUcFwYEKeR0nKKES4JnyPNa7s7rP6ep8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nEuhyT6Os6daFMaUBoUVq5PU0p+1Q+LQ9Z/E6gTInqwO94ZzvWzoYZ5EFnYFAJYAcrreWuPzpPoZwJ1AhRv5jjucvg7OGtXJfzM+HCFKwuq2CyPCl2WcONNHMaNkSa2B3yu/PnUFLzqx6QvRpuGz25pc8SBG9C9W777gjn67sZY= 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=TCT7rm6w; 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="TCT7rm6w" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1789600434; x=1821136434; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=lRVnP8afGZ4YUcFwYEKeR0nKKES4JnyPNa7s7rP6ep8=; b=TCT7rm6wZ39IRDNekJMyTianGyHWQ5C/s1sPHGI9PkwDwo35pGRw+G0Y 9R13uJSGUv2If/jJzX62jecN6zSFdJ1SgyERV3y7mrAH+OjMqaEMcT2hN y5dAYIRsx3gvtmeelIUzzPZVPCWbR68z4KrncM8UxxQfEfXsyHbFYrSX7 3HVQsMj0ZyvWvNDIltCJWi2mEuc8ZSGUem+s3lTkBKtVKN/dy4NhMWshQ U8W08ievvMvC10ZMKTCBHQ9f+DdOBjJT7t8w78h2MQXD/EFifaZTqAj31 Puq3eu+f+2u1qNmfx/P3ymcaSYqeIhKlG2xOGCaDQ4uopW6+zL++W1/q7 A==; X-CSE-ConnectionGUID: KRr3sFlwQ0azc2or+m2E3A== X-CSE-MsgGUID: ogeMX9aDRA6yS6pvRjDyoA== X-IronPort-AV: E=McAfee;i="6800,10657,11905"; a="93861507" X-IronPort-AV: E=Sophos;i="6.27,103,1787036400"; d="scan'208";a="93861507" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by orvoesa106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Sep 2026 16:13:40 -0700 X-CSE-ConnectionGUID: jwP6xT9wSMO9d8sJ/h7dJg== X-CSE-MsgGUID: 7NzeNJXoRsS8WaEOc78FAg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,103,1787036400"; d="scan'208";a="277231496" Received: from khuang2-desk.gar.corp.intel.com (HELO agluck-desk3.home.arpa) ([10.124.223.219]) by orviesa004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Sep 2026 16:13: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 Subject: [PATCH v12 21/25] x86/resctrl: Export interface to report telemetry unbind/remove Date: Wed, 16 Sep 2026 16:13:16 -0700 Message-ID: <20260916231320.14502-22-tony.luck@intel.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260916231320.14502-1-tony.luck@intel.com> References: <20260916231320.14502-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" Linux allows devices to be unbound from drivers, even if the modules cannot be unloaded because of reference counts. For telemetry this results in teardown of the virtual address mappings of the MMIO regions which hold the event counters. Subsequent access to these counters will page fault. Export intel_aet_invalidate() for the pmt_telemetry module to inform resctrl when invalidation is about to happen. Signed-off-by: Tony Luck --- v12: Update comment on aet_register_lock --- include/linux/intel_vsec.h | 2 ++ arch/x86/kernel/cpu/resctrl/intel_aet.c | 28 ++++++++++++++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/include/linux/intel_vsec.h b/include/linux/intel_vsec.h index c04b1d0f3143..bcbf4937c71c 100644 --- a/include/linux/intel_vsec.h +++ b/include/linux/intel_vsec.h @@ -262,11 +262,13 @@ void intel_aet_register_enumeration(struct module *mo= dule, struct pmt_feature_group *(*get)(enum pmt_feature_id id), void (*put)(struct pmt_feature_group *p)); void intel_aet_unregister_enumeration(void); +void intel_aet_invalidate(u8 package_id); #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) { } +static inline void intel_aet_invalidate(u8 package_id) { } #endif /* CONFIG_X86_CPU_RESCTRL_INTEL_AET */ =20 #endif diff --git a/arch/x86/kernel/cpu/resctrl/intel_aet.c b/arch/x86/kernel/cpu/= resctrl/intel_aet.c index 8aa2e18a6bbb..1fd25fd9cd96 100644 --- a/arch/x86/kernel/cpu/resctrl/intel_aet.c +++ b/arch/x86/kernel/cpu/resctrl/intel_aet.c @@ -298,7 +298,7 @@ static enum pmt_feature_id lookup_pfid(const char *pfna= me) /* * Protects pmt_module, get_feature, put_feature against races between mod= ule * load/unload of the pmt_telemetry module and mount/unmount of the resctrl - * file system. Also protects pmt_in_use. + * file system. Also protects pmt_in_use telemetry_region::addr. */ static DEFINE_MUTEX(aet_register_lock); =20 @@ -365,6 +365,30 @@ void intel_aet_unregister_enumeration(void) } EXPORT_SYMBOL_NS_GPL(intel_aet_unregister_enumeration, "INTEL_PMT"); =20 +/* + * pmt_telemetry driver calls this for unbind/remove operations that + * will invalidate the virtual addresses of MMIO registers provided + * by intel_pmt_get_regions_by_feature(). + */ +void intel_aet_invalidate(u8 package_id) +{ + struct event_group **peg; + + guard(mutex)(&aet_register_lock); + + for_each_event_group(peg) { + struct event_group *e =3D *peg; + + if (!e->pfg) + continue; + for (int i =3D 0; i < e->pfg->count; i++) { + if (e->pfg->regions[i].plat_info.package_id =3D=3D package_id) + e->pfg->regions[i].addr =3D NULL; + } + } +} +EXPORT_SYMBOL_NS_GPL(intel_aet_invalidate, "INTEL_PMT"); + bool intel_aet_pre_mount(void) { guard(mutex)(&aet_register_lock); @@ -428,6 +452,8 @@ int intel_aet_read_event(int domid, u32 rmid, void *arc= h_priv, u64 *val) void *pevt0; u32 idx; =20 + guard(mutex)(&aet_register_lock); + pevt0 =3D pevt - pevt->idx; e =3D container_of(pevt0, struct event_group, evts); idx =3D rmid * e->num_events; --=20 2.55.0 From nobody Fri Sep 25 04:07:27 2026 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 5820156260A for ; Wed, 16 Sep 2026 23:13:55 +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=1789600437; cv=none; b=mBXOk1XNKIUdfjDvy/aRmx3pYPu4tJov54Zrka1y2oYrl8zjbRrzLpuUTzPBJr/2JTFvkhaeda1oDHG/9Hln4oufgZ86KfE6M6W7AcsTe4LXdMWJzAMjRjRqusLnBixrMG5kpg3axTKvtlliqm6lqUSf0OV25K/T21x/nvoAz30= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789600437; c=relaxed/simple; bh=eVmXOFlkRN5iaG26DigKaIsj/0UtV30S+C6g+/Kkx1s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=clWxde0KsbTxg5vVxXSFdMSKV4gYGRGZqfXyLd/UQBV634+AlQH1vcGPCr/Ad7uazKbC7uw8S5MZmvs7umPHzluSzyOPD7l/J6lrgQYsouRi3DZcnZ3A1bxMUzF6ArWcfLKNuoLzcGYPrSppTemXASprLwPYoZL0lmiuG6wCB6I= 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=KBrkYoC4; 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="KBrkYoC4" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1789600436; x=1821136436; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=eVmXOFlkRN5iaG26DigKaIsj/0UtV30S+C6g+/Kkx1s=; b=KBrkYoC4Dt934zedFe4gTfHJowTmc4aFlhDos/4yKp7rociQcoTs1RDd 1CHVXgJLvAytO0PQFclh1cIDxLWHS+SK/NQaTDyMueyPNA5t05ynm4LUm avzWBGN53oVLmn8FkYXaZ6nm1NC9d8tG20olYUWP0oKjyoWcVbxC9A2jl 2otmqxTzMXCMIPFaM+RxCySm6uJqqgl+pqJI/d4idf2qEP2hU1riNpxJG 91rmtPqFh6jUhLM2TJQMMsWNlz/DrqIrsEWzk7SpV6o2NUhB+teuuiXox ox4BCt6mCqgsgcE9inbg9alWcZ0nEjL6opDsht4x7YtCcvg2zhnufTYEP g==; X-CSE-ConnectionGUID: tVb1qJUaRn25PqkJH0wdzw== X-CSE-MsgGUID: 1z8oxs8TR2qpqxxNmc0/nA== X-IronPort-AV: E=McAfee;i="6800,10657,11905"; a="93861518" X-IronPort-AV: E=Sophos;i="6.27,103,1787036400"; d="scan'208";a="93861518" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by orvoesa106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Sep 2026 16:13:40 -0700 X-CSE-ConnectionGUID: gYXTOZHxTEm1wFn0kBsWQg== X-CSE-MsgGUID: YJz8K/Q5QYKeu1GlIvDOGQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,103,1787036400"; d="scan'208";a="277231501" Received: from khuang2-desk.gar.corp.intel.com (HELO agluck-desk3.home.arpa) ([10.124.223.219]) by orviesa004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Sep 2026 16:13: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 Subject: [PATCH v12 22/25] platform/x86/intel/pmt: Inform resctrl when MMIO maps are being removed Date: Wed, 16 Sep 2026 16:13:17 -0700 Message-ID: <20260916231320.14502-23-tony.luck@intel.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260916231320.14502-1-tony.luck@intel.com> References: <20260916231320.14502-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" Before destroying devices, tell resctrl that the virtual addresses supplied by an earlier call to intel_pmt_get_regions_by_feature() are about to be invalidated and should not be used again. Avoid A-B deadlock between ep_lock and aet_register_lock. Signed-off-by: Tony Luck --- v12: Ilpo: Downgrade "can't happen" dev_warn() to dev_debug() Ilpo's suggestion to use guard(mutex) moot due to refactor. Reinette: Refactor and eliminate "u32 ret" and s/packages/package/ Reinette: Explain ep_lock release/acquire. --- drivers/platform/x86/intel/pmt/telemetry.c | 31 ++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/drivers/platform/x86/intel/pmt/telemetry.c b/drivers/platform/= x86/intel/pmt/telemetry.c index bf0c9295feb3..527563043777 100644 --- a/drivers/platform/x86/intel/pmt/telemetry.c +++ b/drivers/platform/x86/intel/pmt/telemetry.c @@ -366,12 +366,43 @@ pmt_telem_find_and_register_endpoint(struct device *d= ev, u32 guid, u16 pos) } EXPORT_SYMBOL_NS_GPL(pmt_telem_find_and_register_endpoint, "INTEL_PMT_TELE= METRY"); =20 +static int pmt_telem_get_package_id(struct pmt_telem_priv *priv) +{ + int i; + + for (i =3D 0; i < priv->num_entries; i++) { + struct intel_pmt_entry *entry =3D &priv->entry[i]; + struct pci_dev *pdev =3D to_pci_dev(entry->ep->dev); + struct oobmsm_plat_info *plat_info; + + plat_info =3D intel_vsec_get_mapping(pdev); + if (!IS_ERR(plat_info)) + return plat_info->package_id; + } + + return -ENODEV; +} + static void pmt_telem_remove(struct auxiliary_device *auxdev) { struct pmt_telem_priv *priv =3D auxiliary_get_drvdata(auxdev); + int package_id; int i; =20 mutex_lock(&ep_lock); + package_id =3D pmt_telem_get_package_id(priv); + /* + * Tell resctrl/AET that virtual mappings for MMIO space in a CPU + * package are about to be torn down. + */ + if (package_id < 0) { + dev_dbg(&auxdev->dev, "Unable to determine package ID for removed device= \n"); + } else { + mutex_unlock(&ep_lock); + intel_aet_invalidate(package_id); + mutex_lock(&ep_lock); + } + for (i =3D 0; i < priv->num_entries; i++) { struct intel_pmt_entry *entry =3D &priv->entry[i]; =20 --=20 2.55.0 From nobody Fri Sep 25 04:07:27 2026 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 C5404568FA0 for ; Wed, 16 Sep 2026 23:13:55 +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=1789600438; cv=none; b=ZbXPwSoZ5rp+IzoSTKe/XIS0Ra/K+TqV635wlRAbIJkTVoSju+0xr6/ZGUGiYbvUGGe10Cf2rg9OeYSHPYzpDCNtq1myopsCW+385G10X9rR50OidB8HPLjbyOicVhtW28613hzG3myRnFTFqUSEHlzpXnDVTEvU4Zylf+cM1hg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789600438; c=relaxed/simple; bh=cAKIPPnEb03hnvVJ+fHsQBXdQnWtKOGKq+ZwQ8s/riA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sucNJfRj7SUQWXlqnjxR2i/oLD2qu6Ap7jALHXiXKh02OGmYro8756veEGa7wVDVLXbOZREzK9rZgqiDZLEyKT6MGXOHafXyiS8Jma9tzjseLxD/teS/rEGvMUuwU9Z5nCJVMWU1QKU2iZglaBfVr7MuzfzGXjUZ/ID8p/seZcs= 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=W7TcXRKe; 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="W7TcXRKe" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1789600436; x=1821136436; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=cAKIPPnEb03hnvVJ+fHsQBXdQnWtKOGKq+ZwQ8s/riA=; b=W7TcXRKeQMYDBN+FTQhUKGE2jRciJidC6DCXE0/CmBsxgMmXAryBhIdo l0AqFJkGjs/DmQWZ8iXBbXQh2+csib6aZSvDwPtAL8vkmm910Qi46ZfxD eYzupIMEVCShaFA9j4BhPIew598kUM59lqGqZlvDZecANYdpTrCedF8i/ cFzhB+cgpL46iikGkuYnEW43whXtU1e4aB1EZL0CFKm2mWCxtoh4xA75b UrVE0js+N6rESXIjTA8sinRZ9EV+jU1olv9loRwm0Z2lxJ/u9hVKyuUog L0s+0qlM9vm0JRbFQgeiOxc+PXR4UX5NANnQk6mF0WWOr0XjUcu/gM8HJ A==; X-CSE-ConnectionGUID: MwcbE1NlQFG3pGijR2Eokg== X-CSE-MsgGUID: IB36ll7VSj+X3B66vkE3bw== X-IronPort-AV: E=McAfee;i="6800,10657,11905"; a="93861528" X-IronPort-AV: E=Sophos;i="6.27,103,1787036400"; d="scan'208";a="93861528" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by orvoesa106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Sep 2026 16:13:41 -0700 X-CSE-ConnectionGUID: oHHs0ZqPRtKSfGY1etJdZA== X-CSE-MsgGUID: MrRe/7NgTxafyqZwqa9+Jg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,103,1787036400"; d="scan'208";a="277231504" Received: from khuang2-desk.gar.corp.intel.com (HELO agluck-desk3.home.arpa) ([10.124.223.219]) by orviesa004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Sep 2026 16:13: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 Subject: [PATCH v12 23/25] x86/resctrl: Require 64-bit x86 for resctrl support Date: Wed, 16 Sep 2026 16:13:18 -0700 Message-ID: <20260916231320.14502-24-tony.luck@intel.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260916231320.14502-1-tony.luck@intel.com> References: <20260916231320.14502-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 Application Energy Telemetry (AET) provides event counts in 64-bit registers in MMIO space. For accurate results these should be read with a single 64-bit load operation from the CPU. In preparation for the removal of the separate CONFIG_X86_CPU_RESCTRL_INTEL= _AET configuration option, move the X86_64 dependency to X86_CPU_RESCTRL. This in line with Dave Hansen's proposal[1] for an addition to Linux documentation that details the state of 32-bit x86 support. Link: https://lore.kernel.org/all/c6ab0c24-8931-4f0d-9be6-23498ab4c38b@inte= l.com/ # [1] Signed-off-by: Tony Luck --- v12: Added "#" to Link tag --- arch/x86/Kconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 15fd9ec5ecac..06b5d0c4633e 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -518,7 +518,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 @@ -541,7 +541,7 @@ config X86_CPU_RESCTRL =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 + depends on X86_CPU_RESCTRL && CPU_SUP_INTEL && INTEL_PMT_TELEMETRY=3Dy &&= INTEL_TPMI=3Dy help Enable per-RMID telemetry events in resctrl. =20 --=20 2.55.0 From nobody Fri Sep 25 04:07:27 2026 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 594FB563FD6 for ; Wed, 16 Sep 2026 23:13:56 +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=1789600438; cv=none; b=JYucoQ1GNJYf2tl1JfHV/HQE5tEcdGyRBJlh6U2QHb0e/0qzn/vTcJ5qbOoPOeXq5aHGwp4d43e/osgUxA0Qv7ZUUyF2n+eG/7uPrhZk1JORGJ4i7TgPk5e/eZSR9p50w2jq1A+nvZeRxufoumom140xHp5YSDZSaMetZVJTLko= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789600438; c=relaxed/simple; bh=hTr11v7wHlQ5Hv/kNGVDfeuTKIxCaC8hCsKMiFNheOQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Xh3741Unp9fBcRgNiaXpSft/VUPDeSrsViC9wsimuqEP78tcywTfGRyR0ObaP3yC883UmVQ10EC+4e3JgOPHeM4wi3orYvpg66dC4rsheHRYKFgLXqQPg2f4rq7J7EqJ4Nqzrc4lceC+pD4ZtaBDNf/5XDkDyVLQDK2Jo+mvXco= 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=BJbf598n; 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="BJbf598n" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1789600437; x=1821136437; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=hTr11v7wHlQ5Hv/kNGVDfeuTKIxCaC8hCsKMiFNheOQ=; b=BJbf598nrJU2qBrNK/NTxw+prXGxoeDju4QS10wZM8miuyYog6YK3l8X 2krVh5HjHv2ZDqF5IPuT1Qk810P3Rboza0zMJ3chU5Kn5GQbOwTKJwiHU MeRhTG/wgGHvYEvmYxQIUTqYEr7rKQqAp4PMaSbEUAiN+ROvaBoD9fTOw +wft8qJdN8HXH/82lJxVbHy+UGmJ0lkn1+tr2fa401MfbETY180frxyvF pAP4FnkCWbQMbzeu6pJ+WtvlCwLNxC2XJe7khnUyLJH21fHqfyNXsVugZ W084fuMvvl7fmwY3+RZElspZuJz09O2Yjd1O2CYi1kgIgM42ZiVXOCzI+ w==; X-CSE-ConnectionGUID: xJyuVlgoQxe+B14G3+11Tg== X-CSE-MsgGUID: 8+uHvKZkQjG8itUp01AJmg== X-IronPort-AV: E=McAfee;i="6800,10657,11905"; a="93861539" X-IronPort-AV: E=Sophos;i="6.27,103,1787036400"; d="scan'208";a="93861539" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by orvoesa106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Sep 2026 16:13:41 -0700 X-CSE-ConnectionGUID: NKId3sCRR6Kn2XU+lB1PBw== X-CSE-MsgGUID: L3XQfS0IQBizwhh6dsrPbw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,103,1787036400"; d="scan'208";a="277231508" Received: from khuang2-desk.gar.corp.intel.com (HELO agluck-desk3.home.arpa) ([10.124.223.219]) by orviesa004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Sep 2026 16:13: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 v12 24/25] x86/resctrl: Simplify Kconfig options for resctrl Date: Wed, 16 Sep 2026 16:13:19 -0700 Message-ID: <20260916231320.14502-25-tony.luck@intel.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260916231320.14502-1-tony.luck@intel.com> References: <20260916231320.14502-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 fir= st added as it required other config options to be set to "built-in". There is no longer a requirement that INTEL_PMT_TELEMETRY or INTEL_TPMI be built-in. Drop CONFIG_X86_CPU_RESCTRL_INTEL_AET and unconditionally include AET (Application Energy Telemetry) as part of X86_CPU_RESCTRL. Link: https://lore.kernel.org/all/CAHk-=3Dwhigg3hvOy7c1j1MXFy6o6CHp0g4Tc3Y-= MAk+XDssHU0A@mail.gmail.com # [1] Signed-off-by: Tony Luck --- v12: Added [] around "1" in Link tag. In resctrl Makefile add intel_aet.o to ctrlmondata.o line. Rewrite commit using imperative. --- include/linux/intel_vsec.h | 4 ++-- arch/x86/kernel/cpu/resctrl/internal.h | 13 ------------- arch/x86/Kconfig | 13 ------------- arch/x86/kernel/cpu/resctrl/Makefile | 3 +-- 4 files changed, 3 insertions(+), 30 deletions(-) diff --git a/include/linux/intel_vsec.h b/include/linux/intel_vsec.h index bcbf4937c71c..885f8e3ab057 100644 --- a/include/linux/intel_vsec.h +++ b/include/linux/intel_vsec.h @@ -257,7 +257,7 @@ static inline void intel_pmt_put_feature_group(struct pmt_feature_group *feature_group) {} #endif =20 -#ifdef CONFIG_X86_CPU_RESCTRL_INTEL_AET +#ifdef CONFIG_X86_CPU_RESCTRL 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)); @@ -269,6 +269,6 @@ static inline void intel_aet_register_enumeration(struc= t module *module, void (*put)(struct pmt_feature_group *p)) { } static inline void intel_aet_unregister_enumeration(void) { } static inline void intel_aet_invalidate(u8 package_id) { } -#endif /* CONFIG_X86_CPU_RESCTRL_INTEL_AET */ +#endif /* CONFIG_X86_CPU_RESCTRL */ =20 #endif diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/r= esctrl/internal.h index 5e71dd758624..93d36fa8c638 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -233,24 +233,11 @@ bool rdt_cpu_has(int flag); 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 06b5d0c4633e..47f92613434e 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -539,19 +539,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_CPU_RESCTRL && CPU_SUP_INTEL && INTEL_PMT_TELEMETRY=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..9daf1c0abb80 100644 --- a/arch/x86/kernel/cpu/resctrl/Makefile +++ b/arch/x86/kernel/cpu/resctrl/Makefile @@ -1,7 +1,6 @@ # 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 ctrlmondata.o intel_aet.o obj-$(CONFIG_RESCTRL_FS_PSEUDO_LOCK) +=3D pseudo_lock.o =20 # To allow define_trace.h's recursive include: --=20 2.55.0 From nobody Fri Sep 25 04:07:27 2026 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 769D558FD22 for ; Wed, 16 Sep 2026 23:13:57 +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=1789600439; cv=none; b=rVe3Ut+haFqU6ciCW0xD3uJVmNfJ26ws9zU1TpxQudC9QkyBY0yuD6lfCwbhICTbPFb5JeVs7uj3usy1W05BqS8fcdmkHALkUTxE7H2lY9c+XaUtIuSLAQAoXEaNkdNrpIm6XBuzJDmYwextLoFyKLqBDpk58eRARPA7v7TreYI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789600439; c=relaxed/simple; bh=ydpynI7FWRcDuv3jJBE/xxqcbkyClGw2KGJIvYL2PfA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=V6Qsb09yvGnp3G9K4YkS2BfKPMrWgIyMmxjkWtic8U7UduHJ+X7aGSD9N2rXcq39hR13tgaaYBMjQkd0CiOhSzFpUMMdnsje4kzdh537VtwfZuBVUWjMDnw6hh1m0w44eGj0oHsRAco5+LKBxdpXxfDMUTDh6ylZthShx/H8uY8= 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=PfrSFRfF; 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="PfrSFRfF" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1789600438; x=1821136438; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ydpynI7FWRcDuv3jJBE/xxqcbkyClGw2KGJIvYL2PfA=; b=PfrSFRfFal9U9CTQ8dtC9C++Vbyz3hnG+BXUpx6+yWj77zwradePgf1N TPR4IJWw6S/blc0KX+ZS9m7eVWY0oUO5A8a+PsPhEFHLGf5lUQg1c6Su3 3trcpuZTYN1SF2oBh6PuGyw5l9RG9LibajUy/WAUyMmG7D3dsEvKEaQc0 OkCDWGqHc6XS33a0t/HppAzEplJ9K6XTqXByXWyv2nQFmYGt9fuxlYrAd xS8nh1VDkdhSgmziqZkG6s5az1NE0z8CLPC+70E0KWeSloIrZhsQX9Y3j s4XxiihUNAfY7w7YMMGb6TW6ZkTOgI0Xiyk9sHX+gL6SceYfbqFaTtFZn w==; X-CSE-ConnectionGUID: dxJyyyBCRY2yQm9HetLoRw== X-CSE-MsgGUID: iPU3cyivQzOCPnCaGW1aEQ== X-IronPort-AV: E=McAfee;i="6800,10657,11905"; a="93861549" X-IronPort-AV: E=Sophos;i="6.27,103,1787036400"; d="scan'208";a="93861549" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by orvoesa106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Sep 2026 16:13:41 -0700 X-CSE-ConnectionGUID: 6uAJXPrqTSOky6uUNq5jBA== X-CSE-MsgGUID: sJ7fYBpYSqqIeQApm81J5w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,103,1787036400"; d="scan'208";a="277231511" Received: from khuang2-desk.gar.corp.intel.com (HELO agluck-desk3.home.arpa) ([10.124.223.219]) by orviesa004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Sep 2026 16:13: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 v12 25/25] x86,fs/resctrl: Document telemetry mount timing caveat Date: Wed, 16 Sep 2026 16:13:20 -0700 Message-ID: <20260916231320.14502-26-tony.luck@intel.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260916231320.14502-1-tony.luck@intel.com> References: <20260916231320.14502-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 PMT driver enumerates telemetry features asynchronously, so an automatic mount of resctrl from /etc/fstab early in boot may occur before those features are available, resulting in them not being enabled in the mounted instance. Add a footnote to the 'If telemetry monitoring is enabled' sentence pointing readers to a new "Mounting resctrl with telemetry" section. That section explains the race. Signed-off-by: Tony Luck --- v12: Drop problematic examples of systemd/udev rules. --- Documentation/filesystems/resctrl.rst | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/Documentation/filesystems/resctrl.rst b/Documentation/filesyst= ems/resctrl.rst index e4b66af55ffb..91a2ab0fa027 100644 --- a/Documentation/filesystems/resctrl.rst +++ b/Documentation/filesystems/resctrl.rst @@ -630,7 +630,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.) @@ -669,6 +669,10 @@ 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,= so + an automatic mount of resctrl from ``/etc/fstab`` at boot may not enable + them. See `Mounting resctrl with telemetry`_ below. + "mon_hw_id": Available only with debug option. The identifier used by hardware for the monitor group. On x86 this is the RMID. @@ -1898,6 +1902,18 @@ m. Unmount the resctrl filesystem. =20 # umount /sys/fs/resctrl/ =20 +Mounting resctrl with telemetry +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D + +Telemetry features (e.g. the ``mon_PERF_PKG_YY`` events) are enumerated +asynchronously by the PMT driver. If resctrl is mounted before that +enumeration completes (for example, when mounted automatically from +``/etc/fstab`` early in boot) the telemetry features will not be available +at mount time and will therefore not be enabled in the mounted instance. + +To avoid this race, defer the mount until after the ``pmt_telemetry`` modu= le +has loaded. + Intel RDT Errata =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =20 --=20 2.55.0