From nobody Tue Dec 2 00:25:23 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6A5E12D46DD for ; Mon, 24 Nov 2025 18:54:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764010485; cv=none; b=dShziT/KhpStfd4keXSZrhf1LtUALYy3cSGJsyRk5DdkTFGBOJlTkKlFZloWDslhapAAPnxBpcRtEyqG1ejitFOWx2IuUtxsGoW8mBy7gDvAwa8Sa/lzNT2gIWlLZTfQswesqjcOaVOXlVRQSloRhuNb+3lY5RFnJQcyZrXdwDk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764010485; c=relaxed/simple; bh=uG7+YqtEtzVlwaBgTbjM4zxMwbqEfXKjC407S1dGiWg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MKqLymdXHi5FhRULL/DH2MwJpxnOhDA05xQGGQPkqsd25qOTs/cSS65pcysm2Dft0bq56AKZD9OCptbIWTz0Bz0JpNwV8V/Hkmf02nbBVH7w1RfFXRG6HaELF7V/i1ferEGm8DWHI3USPynEskJbrznAR1nX6oVBY/e/jTjWQXY= 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=kzC4QQ+8; arc=none smtp.client-ip=192.198.163.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="kzC4QQ+8" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1764010483; x=1795546483; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=uG7+YqtEtzVlwaBgTbjM4zxMwbqEfXKjC407S1dGiWg=; b=kzC4QQ+84BkCyP97f1HVuSDTzbSECXNaFVDUDGga+OJU/TMnO1pEcOgT dtL+JXK43nnr1kySeJItjoL+a4FicpKFur8v3tLZ5mMy/UC7IHtiF71S1 xfi6QcYUihp5GSYJI5EIggT6cVnKd9O7vaJw0F2SAtpBe9WVUUXaiYKeu N0l22yHlZPscrn8waLSATaotHjdU8NKOny4hUV+oAQctWyrjSrP9u/Cyg nw55h47QSx63s8Yc2WvALOPhZhQG6QaTJWOrfuPLwtezrwqE3CuH9tnR/ XOg058dxmmOvQO4dqT3SPI3Cfl1g3Rzyu+mV/yMoY6Mpp7Y9s7QlU8HUq Q==; X-CSE-ConnectionGUID: D9xDATOoTiGJed4qrqCJFw== X-CSE-MsgGUID: YGeyULkaSl+YGyKgZUBuDQ== X-IronPort-AV: E=McAfee;i="6800,10657,11623"; a="76636454" X-IronPort-AV: E=Sophos;i="6.20,223,1758610800"; d="scan'208";a="76636454" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Nov 2025 10:54:22 -0800 X-CSE-ConnectionGUID: XrFBZJLdQyuSxJrwXsGRrw== X-CSE-MsgGUID: 5HzuIdybQnqGWsYeZwU1XA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.20,223,1758610800"; d="scan'208";a="192224940" Received: from rfrazer-mobl3.amr.corp.intel.com (HELO agluck-desk3.home.arpa) ([10.124.222.153]) by orviesa009-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Nov 2025 10:54:21 -0800 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Maciej Wieczor-Retman , Peter Newman , James Morse , Babu Moger , Drew Fustini , Dave Martin , Chen Yu Cc: x86@kernel.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [PATCH v14 01/32] x86,fs/resctrl: Improve domain type checking Date: Mon, 24 Nov 2025 10:53:38 -0800 Message-ID: <20251124185412.24155-2-tony.luck@intel.com> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251124185412.24155-1-tony.luck@intel.com> References: <20251124185412.24155-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" Every resctrl resource has a list of domain structures. struct rdt_ctrl_dom= ain and struct rdt_mon_domain both begin with struct rdt_domain_hdr with rdt_domain_hdr::type used in validity checks before accessing the domain of= a particular type. Add the resource id to struct rdt_domain_hdr in preparation for a new monit= oring domain structure that will be associated with a new monitoring resource. Im= prove existing domain validity checks with a new helper domain_header_is_valid() that checks both domain type and resource id. domain_header_is_valid() sho= uld be used before every call to container_of() that accesses a domain structur= e. Signed-off-by: Tony Luck Reviewed-by: Reinette Chatre --- include/linux/resctrl.h | 9 +++++++++ arch/x86/kernel/cpu/resctrl/core.c | 10 ++++++---- fs/resctrl/ctrlmondata.c | 2 +- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index 54701668b3df..e7c218f8d4f7 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -131,15 +131,24 @@ enum resctrl_domain_type { * @list: all instances of this resource * @id: unique id for this instance * @type: type of this instance + * @rid: resource id for this instance * @cpu_mask: which CPUs share this resource */ struct rdt_domain_hdr { struct list_head list; int id; enum resctrl_domain_type type; + enum resctrl_res_level rid; struct cpumask cpu_mask; }; =20 +static inline bool domain_header_is_valid(struct rdt_domain_hdr *hdr, + enum resctrl_domain_type type, + enum resctrl_res_level rid) +{ + return !WARN_ON_ONCE(hdr->type !=3D type || hdr->rid !=3D rid); +} + /** * struct rdt_ctrl_domain - group of CPUs sharing a resctrl control resour= ce * @hdr: common header for different domain types diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resct= rl/core.c index 3792ab4819dc..0b8b7b8697a7 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -464,7 +464,7 @@ static void domain_add_cpu_ctrl(int cpu, struct rdt_res= ource *r) =20 hdr =3D resctrl_find_domain(&r->ctrl_domains, id, &add_pos); if (hdr) { - if (WARN_ON_ONCE(hdr->type !=3D RESCTRL_CTRL_DOMAIN)) + if (!domain_header_is_valid(hdr, RESCTRL_CTRL_DOMAIN, r->rid)) return; d =3D container_of(hdr, struct rdt_ctrl_domain, hdr); =20 @@ -481,6 +481,7 @@ static void domain_add_cpu_ctrl(int cpu, struct rdt_res= ource *r) d =3D &hw_dom->d_resctrl; d->hdr.id =3D id; d->hdr.type =3D RESCTRL_CTRL_DOMAIN; + d->hdr.rid =3D r->rid; cpumask_set_cpu(cpu, &d->hdr.cpu_mask); =20 rdt_domain_reconfigure_cdp(r); @@ -520,7 +521,7 @@ static void domain_add_cpu_mon(int cpu, struct rdt_reso= urce *r) =20 hdr =3D resctrl_find_domain(&r->mon_domains, id, &add_pos); if (hdr) { - if (WARN_ON_ONCE(hdr->type !=3D RESCTRL_MON_DOMAIN)) + if (!domain_header_is_valid(hdr, RESCTRL_MON_DOMAIN, r->rid)) return; d =3D container_of(hdr, struct rdt_mon_domain, hdr); =20 @@ -538,6 +539,7 @@ static void domain_add_cpu_mon(int cpu, struct rdt_reso= urce *r) d =3D &hw_dom->d_resctrl; d->hdr.id =3D id; d->hdr.type =3D RESCTRL_MON_DOMAIN; + d->hdr.rid =3D r->rid; ci =3D get_cpu_cacheinfo_level(cpu, RESCTRL_L3_CACHE); if (!ci) { pr_warn_once("Can't find L3 cache for CPU:%d resource %s\n", cpu, r->nam= e); @@ -598,7 +600,7 @@ static void domain_remove_cpu_ctrl(int cpu, struct rdt_= resource *r) return; } =20 - if (WARN_ON_ONCE(hdr->type !=3D RESCTRL_CTRL_DOMAIN)) + if (!domain_header_is_valid(hdr, RESCTRL_CTRL_DOMAIN, r->rid)) return; =20 d =3D container_of(hdr, struct rdt_ctrl_domain, hdr); @@ -644,7 +646,7 @@ static void domain_remove_cpu_mon(int cpu, struct rdt_r= esource *r) return; } =20 - if (WARN_ON_ONCE(hdr->type !=3D RESCTRL_MON_DOMAIN)) + if (!domain_header_is_valid(hdr, RESCTRL_MON_DOMAIN, r->rid)) return; =20 d =3D container_of(hdr, struct rdt_mon_domain, hdr); diff --git a/fs/resctrl/ctrlmondata.c b/fs/resctrl/ctrlmondata.c index b2d178d3556e..905c310de573 100644 --- a/fs/resctrl/ctrlmondata.c +++ b/fs/resctrl/ctrlmondata.c @@ -653,7 +653,7 @@ int rdtgroup_mondata_show(struct seq_file *m, void *arg) * the resource to find the domain with "domid". */ hdr =3D resctrl_find_domain(&r->mon_domains, domid, NULL); - if (!hdr || WARN_ON_ONCE(hdr->type !=3D RESCTRL_MON_DOMAIN)) { + if (!hdr || !domain_header_is_valid(hdr, RESCTRL_MON_DOMAIN, resid)) { ret =3D -ENOENT; goto out; } --=20 2.51.1 From nobody Tue Dec 2 00:25:23 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 41A302D97AF for ; Mon, 24 Nov 2025 18:54:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764010486; cv=none; b=GSR+9xyn6L2JlgKX2f3DBqPuLvzKvqtpnHN/CwYoImV4p8os7qTq7FSkCyE425+J8NuKoqVXHxb4DCW2kn1oKsCgMVskeBUWg/XoXwSsTJZyiTodymWlJpzKOIt9zuUPVPxYHgoI6h5UrHR0bNr8R8HHAVKvHomFqMFQXuCTjDM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764010486; c=relaxed/simple; bh=LlRdkmpBiMV2KJh/axg+W+2z6l7UPK5CIKtf/6Q8CGY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Vvd9+Apk+Y8eGIGDdARibIZ9jn8yuPAV9EBph85VUZDK/7aImCnH2SZwgL1sFieWR0IyHwhcOAJfG77k+K96GwxHYZRx+b01+EPWdRPfs2IN/8b0nYqtTOdamI1tCk0Lvvmikjp2pnXDcdJnY10TKxeppuvfGsDs5bLa5dz0fZ8= 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=gJSkAJai; arc=none smtp.client-ip=192.198.163.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="gJSkAJai" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1764010485; x=1795546485; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=LlRdkmpBiMV2KJh/axg+W+2z6l7UPK5CIKtf/6Q8CGY=; b=gJSkAJaimf7FPpfBeAzd35MiF2GuDSrO/2NcNF+YlBc1N6GvgIUx8116 3L2iaRAJ/CPQsRk1nrVPJjRzE3ehhVOrgatAmYsSyTUJ7oCfaDAfGXwRg ehBh1TtKiPwScR75pOyhiEX2S043Jo61AtijE7j5RgjfpQL0oP6L0sIx/ PDoOjbQ7QVZqfQsFVqJIQtwTmLGj4fcvQs5i14H1Rzfrnrldpv5wShDJ5 WvvSPa1/X2AbB8RI+uozFt/GP8mNCTMCHMEsWq6JxakGoKMrKrdKA7Z5Z KYb0OKo4oLQHMPg9NLsbGd2F+VKKUOU6Ru7j+EjXJ5aJkEZP8NmarjrZ/ A==; X-CSE-ConnectionGUID: 4guSN0KcRZWVj0pnIuslDA== X-CSE-MsgGUID: Fk2oUWC9SLuhgu7VPX6Y1g== X-IronPort-AV: E=McAfee;i="6800,10657,11623"; a="76636462" X-IronPort-AV: E=Sophos;i="6.20,223,1758610800"; d="scan'208";a="76636462" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Nov 2025 10:54:22 -0800 X-CSE-ConnectionGUID: nZjLJhW4TjOjV2FxGa/91g== X-CSE-MsgGUID: a3JtKyx4QF2Mm0pNm0+IjA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.20,223,1758610800"; d="scan'208";a="192224944" Received: from rfrazer-mobl3.amr.corp.intel.com (HELO agluck-desk3.home.arpa) ([10.124.222.153]) by orviesa009-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Nov 2025 10:54:21 -0800 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Maciej Wieczor-Retman , Peter Newman , James Morse , Babu Moger , Drew Fustini , Dave Martin , Chen Yu Cc: x86@kernel.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [PATCH v14 02/32] x86/resctrl: Move L3 initialization into new helper function Date: Mon, 24 Nov 2025 10:53:39 -0800 Message-ID: <20251124185412.24155-3-tony.luck@intel.com> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251124185412.24155-1-tony.luck@intel.com> References: <20251124185412.24155-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" Carve out the resource monitoring domain init code into a separate helper in order to be able to initialize new types of monitoring domains besides the usual L3 ones. Signed-off-by: Tony Luck Reviewed-by: Reinette Chatre --- arch/x86/kernel/cpu/resctrl/core.c | 64 ++++++++++++++++-------------- 1 file changed, 34 insertions(+), 30 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resct= rl/core.c index 0b8b7b8697a7..2a568b316711 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -501,37 +501,13 @@ static void domain_add_cpu_ctrl(int cpu, struct rdt_r= esource *r) } } =20 -static void domain_add_cpu_mon(int cpu, struct rdt_resource *r) +static void l3_mon_domain_setup(int cpu, int id, struct rdt_resource *r, s= truct list_head *add_pos) { - int id =3D get_domain_id_from_scope(cpu, r->mon_scope); - struct list_head *add_pos =3D NULL; struct rdt_hw_mon_domain *hw_dom; - struct rdt_domain_hdr *hdr; struct rdt_mon_domain *d; struct cacheinfo *ci; int err; =20 - lockdep_assert_held(&domain_list_lock); - - if (id < 0) { - pr_warn_once("Can't find monitor domain id for CPU:%d scope:%d for resou= rce %s\n", - cpu, r->mon_scope, r->name); - return; - } - - hdr =3D resctrl_find_domain(&r->mon_domains, id, &add_pos); - if (hdr) { - if (!domain_header_is_valid(hdr, RESCTRL_MON_DOMAIN, r->rid)) - return; - d =3D container_of(hdr, struct rdt_mon_domain, hdr); - - cpumask_set_cpu(cpu, &d->hdr.cpu_mask); - /* Update the mbm_assign_mode state for the CPU if supported */ - if (r->mon.mbm_cntr_assignable) - resctrl_arch_mbm_cntr_assign_set_one(r); - return; - } - hw_dom =3D kzalloc_node(sizeof(*hw_dom), GFP_KERNEL, cpu_to_node(cpu)); if (!hw_dom) return; @@ -539,7 +515,7 @@ static void domain_add_cpu_mon(int cpu, struct rdt_reso= urce *r) d =3D &hw_dom->d_resctrl; d->hdr.id =3D id; d->hdr.type =3D RESCTRL_MON_DOMAIN; - d->hdr.rid =3D r->rid; + d->hdr.rid =3D RDT_RESOURCE_L3; ci =3D get_cpu_cacheinfo_level(cpu, RESCTRL_L3_CACHE); if (!ci) { pr_warn_once("Can't find L3 cache for CPU:%d resource %s\n", cpu, r->nam= e); @@ -549,10 +525,6 @@ static void domain_add_cpu_mon(int cpu, struct rdt_res= ource *r) d->ci_id =3D ci->id; cpumask_set_cpu(cpu, &d->hdr.cpu_mask); =20 - /* Update the mbm_assign_mode state for the CPU if supported */ - if (r->mon.mbm_cntr_assignable) - resctrl_arch_mbm_cntr_assign_set_one(r); - arch_mon_domain_online(r, d); =20 if (arch_domain_mbm_alloc(r->mon.num_rmid, hw_dom)) { @@ -570,6 +542,38 @@ static void domain_add_cpu_mon(int cpu, struct rdt_res= ource *r) } } =20 +static void domain_add_cpu_mon(int cpu, struct rdt_resource *r) +{ + int id =3D get_domain_id_from_scope(cpu, r->mon_scope); + struct list_head *add_pos =3D NULL; + struct rdt_domain_hdr *hdr; + + lockdep_assert_held(&domain_list_lock); + + if (id < 0) { + pr_warn_once("Can't find monitor domain id for CPU:%d scope:%d for resou= rce %s\n", + cpu, r->mon_scope, r->name); + return; + } + + hdr =3D resctrl_find_domain(&r->mon_domains, id, &add_pos); + if (hdr) + cpumask_set_cpu(cpu, &hdr->cpu_mask); + + switch (r->rid) { + case RDT_RESOURCE_L3: + /* Update the mbm_assign_mode state for the CPU if supported */ + if (r->mon.mbm_cntr_assignable) + resctrl_arch_mbm_cntr_assign_set_one(r); + if (!hdr) + l3_mon_domain_setup(cpu, id, r, add_pos); + break; + default: + pr_warn_once("Unknown resource rid=3D%d\n", r->rid); + break; + } +} + static void domain_add_cpu(int cpu, struct rdt_resource *r) { if (r->alloc_capable) --=20 2.51.1 From nobody Tue Dec 2 00:25:23 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AF8C53168EE for ; Mon, 24 Nov 2025 18:54:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764010487; cv=none; b=oigEp39BF8UEdcyknkOceL13zjNrMv0Swx5aQljmE3Z9iKTDDE4n0e+CwZ0x/I1qpeYibLliRm5LRXXQrU0vOHEtuK6hKluhSpN/Lcvj1q8rcVsHUVpLSibqgMzxP8/yzwEOtb6c4rGZhNnoyx+h6GHO7ba15yagWIfMmlSr4r4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764010487; c=relaxed/simple; bh=2QSZ+iQh8XbZwvpPzBCkKPoQpx6hD8+W+fzq0/XIfY4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KEOe39j0wQDnudYuKMYBtmK5TR0uTAUR2erGqIVQk38k6ykbeBPuYrcRlfHnTC1ZY9BLLC+XCeaEXhC0FHNKHSFfctNkrbU0Yy+2+yhw6qlW+8wAprvJakvk0n4RC2qNWETllAN9wLyQM2Jiu7MS/OCOxp1cmbSDt/jn3Bq477g= 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=RLpK9VBr; arc=none smtp.client-ip=192.198.163.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="RLpK9VBr" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1764010486; x=1795546486; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=2QSZ+iQh8XbZwvpPzBCkKPoQpx6hD8+W+fzq0/XIfY4=; b=RLpK9VBrQTiMg4QsoZ37biB4YqUv7I56lY18ci69/A4LlLy+CpFZp0ry FIu3InHNWMWmaQPN2tKMefOIRwny+5xNAVUG6xgzc9Di70ovUzmeS3lk3 tTHKfy8I62ufepAw5ZloZqlPMvkZSZoiTrJpnpYDuNZzkZudoG5Dd48w0 rhTmhvrgf1S+4Or03L9hGtPNU3J+S2P8Kp/61SrWNNykgpvAUMLJzec+q rn4x52+UnMYrF71rOcnerJElX2iQrUee5IqdgOhGodgjfVJBChag8SvDq pQz366ZnSEtSh31e4hLqHkJ/HCjKq+paTIHJFw1zR2NiWnVPmpIjYx8Mu Q==; X-CSE-ConnectionGUID: kZUm5o5MTYqTLQXMiaxrVQ== X-CSE-MsgGUID: 4rC8RTs3ToCZrmDin6DInw== X-IronPort-AV: E=McAfee;i="6800,10657,11623"; a="76636467" X-IronPort-AV: E=Sophos;i="6.20,223,1758610800"; d="scan'208";a="76636467" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Nov 2025 10:54:22 -0800 X-CSE-ConnectionGUID: DeI8KOmCTU+eMwO041mgVQ== X-CSE-MsgGUID: mmwNsk/vQBGqbooCVTncrg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.20,223,1758610800"; d="scan'208";a="192224947" Received: from rfrazer-mobl3.amr.corp.intel.com (HELO agluck-desk3.home.arpa) ([10.124.222.153]) by orviesa009-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Nov 2025 10:54:22 -0800 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Maciej Wieczor-Retman , Peter Newman , James Morse , Babu Moger , Drew Fustini , Dave Martin , Chen Yu Cc: x86@kernel.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [PATCH v14 03/32] x86/resctrl: Refactor domain_remove_cpu_mon() ready for new domain types Date: Mon, 24 Nov 2025 10:53:40 -0800 Message-ID: <20251124185412.24155-4-tony.luck@intel.com> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251124185412.24155-1-tony.luck@intel.com> References: <20251124185412.24155-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" New telemetry events will be associated with a new package scoped resource = with new domain structures. Refactor domain_remove_cpu_mon() so all the L3 domain processing is separate from general domain actions of clearing the CPU bit in the mask. Signed-off-by: Tony Luck Reviewed-by: Reinette Chatre --- arch/x86/kernel/cpu/resctrl/core.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resct= rl/core.c index 2a568b316711..49b133e847d4 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -631,9 +631,7 @@ static void domain_remove_cpu_ctrl(int cpu, struct rdt_= resource *r) static void domain_remove_cpu_mon(int cpu, struct rdt_resource *r) { int id =3D get_domain_id_from_scope(cpu, r->mon_scope); - struct rdt_hw_mon_domain *hw_dom; struct rdt_domain_hdr *hdr; - struct rdt_mon_domain *d; =20 lockdep_assert_held(&domain_list_lock); =20 @@ -650,20 +648,29 @@ static void domain_remove_cpu_mon(int cpu, struct rdt= _resource *r) return; } =20 - if (!domain_header_is_valid(hdr, RESCTRL_MON_DOMAIN, r->rid)) + cpumask_clear_cpu(cpu, &hdr->cpu_mask); + if (!cpumask_empty(&hdr->cpu_mask)) return; =20 - d =3D container_of(hdr, struct rdt_mon_domain, hdr); - hw_dom =3D resctrl_to_arch_mon_dom(d); + switch (r->rid) { + case RDT_RESOURCE_L3: { + struct rdt_hw_mon_domain *hw_dom; + struct rdt_mon_domain *d; =20 - cpumask_clear_cpu(cpu, &d->hdr.cpu_mask); - if (cpumask_empty(&d->hdr.cpu_mask)) { + if (!domain_header_is_valid(hdr, RESCTRL_MON_DOMAIN, RDT_RESOURCE_L3)) + return; + + d =3D container_of(hdr, struct rdt_mon_domain, hdr); + hw_dom =3D resctrl_to_arch_mon_dom(d); resctrl_offline_mon_domain(r, d); - list_del_rcu(&d->hdr.list); + list_del_rcu(&hdr->list); synchronize_rcu(); mon_domain_free(hw_dom); - - return; + break; + } + default: + pr_warn_once("Unknown resource rid=3D%d\n", r->rid); + break; } } =20 --=20 2.51.1 From nobody Tue Dec 2 00:25:23 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 274832D5A0C for ; Mon, 24 Nov 2025 18:54:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764010486; cv=none; b=qAM0y0vAmoCpB/LKCOEUwI70YsNrjiEoma3u3OLViedNB5uruGAPMam+4PzdHGrwyr0OyMkCAxFG/5/9CB9w4KFsjMTg3vON1+WZCyjE0+AqutMestEatl1VTNv9rB2yA0ASQn3mC3SGJLpNH7UWk64wMQKDtBG6TOgOilX/UJ4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764010486; c=relaxed/simple; bh=u7RmMkbdyc5QHVMIPLc9Jc97zGTH0J2VNf3TiEGFH8k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HIDlWDyRe8G8htnlv8v54WZGsfvFn87dahgKAgcrefrbrQfgfOnVvATg1tZ0aUt7AYk3Qee2KHGMj0MIslQCOgON5k8zEfwDHj/DOU84ybKhOQV+LELwbixFcnBwCMfBeUnd/ZBYyEiFxj/jyYjSTox/mbfqyRkJOUEOIiPVuPY= 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=M/g4z9T3; arc=none smtp.client-ip=192.198.163.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="M/g4z9T3" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1764010485; x=1795546485; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=u7RmMkbdyc5QHVMIPLc9Jc97zGTH0J2VNf3TiEGFH8k=; b=M/g4z9T3Apdwb67bzsXnwmXKMcbnveMSKH6UsazknQTENWGRR+5D3/bp UbTZYCavFLbPKjHOEhSdbj0fR+NNIhyqXmNtbHvTKYOfrXhp+DyQE9bHi nsibq89cg9atziR9QHVSvkuHIH/PPaWPRFMbfQoWejcpcnnK9o2gjS4fs JbaYJBHF8ed/e5znxWsGThICgoo0ThX1UYkNbTqnplhju3YOsRt48/K9A j5u+uDlUP1NCDKr3+gzsgSYlgIXIsqe65MVk0GHoyfJchHEYYf3YBHUZ0 tQns2UaSIo8eYBGAse/zPpGipmH6iyQFCAumRjhBNkXOdKV0a4h7zcnXQ A==; X-CSE-ConnectionGUID: lg0sq2x1QMet/WRiDemc3w== X-CSE-MsgGUID: FQy4H10oQMalhZndkzfQHA== X-IronPort-AV: E=McAfee;i="6800,10657,11623"; a="76636472" X-IronPort-AV: E=Sophos;i="6.20,223,1758610800"; d="scan'208";a="76636472" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Nov 2025 10:54:22 -0800 X-CSE-ConnectionGUID: CL9bpNl/S3Gdy8yQrZIztQ== X-CSE-MsgGUID: eqTSDx6uRUujtASb+Whxbw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.20,223,1758610800"; d="scan'208";a="192224952" Received: from rfrazer-mobl3.amr.corp.intel.com (HELO agluck-desk3.home.arpa) ([10.124.222.153]) by orviesa009-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Nov 2025 10:54:22 -0800 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Maciej Wieczor-Retman , Peter Newman , James Morse , Babu Moger , Drew Fustini , Dave Martin , Chen Yu Cc: x86@kernel.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [PATCH v14 04/32] x86/resctrl: Clean up domain_remove_cpu_ctrl() Date: Mon, 24 Nov 2025 10:53:41 -0800 Message-ID: <20251124185412.24155-5-tony.luck@intel.com> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251124185412.24155-1-tony.luck@intel.com> References: <20251124185412.24155-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" For symmetry with domain_remove_cpu_mon() refactor domain_remove_cpu_ctrl() to take an early return when removing a CPU does not empty the domain. Signed-off-by: Tony Luck Reviewed-by: Reinette Chatre --- arch/x86/kernel/cpu/resctrl/core.c | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resct= rl/core.c index 49b133e847d4..64ed81cbf8bf 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -604,28 +604,27 @@ static void domain_remove_cpu_ctrl(int cpu, struct rd= t_resource *r) return; } =20 + cpumask_clear_cpu(cpu, &hdr->cpu_mask); + if (!cpumask_empty(&hdr->cpu_mask)) + return; + if (!domain_header_is_valid(hdr, RESCTRL_CTRL_DOMAIN, r->rid)) return; =20 d =3D container_of(hdr, struct rdt_ctrl_domain, hdr); hw_dom =3D resctrl_to_arch_ctrl_dom(d); =20 - cpumask_clear_cpu(cpu, &d->hdr.cpu_mask); - if (cpumask_empty(&d->hdr.cpu_mask)) { - resctrl_offline_ctrl_domain(r, d); - list_del_rcu(&d->hdr.list); - synchronize_rcu(); - - /* - * rdt_ctrl_domain "d" is going to be freed below, so clear - * its pointer from pseudo_lock_region struct. - */ - if (d->plr) - d->plr->d =3D NULL; - ctrl_domain_free(hw_dom); + resctrl_offline_ctrl_domain(r, d); + list_del_rcu(&hdr->list); + synchronize_rcu(); =20 - return; - } + /* + * rdt_ctrl_domain "d" is going to be freed below, so clear + * its pointer from pseudo_lock_region struct. + */ + if (d->plr) + d->plr->d =3D NULL; + ctrl_domain_free(hw_dom); } =20 static void domain_remove_cpu_mon(int cpu, struct rdt_resource *r) --=20 2.51.1 From nobody Tue Dec 2 00:25:23 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3B70531B80E for ; Mon, 24 Nov 2025 18:54:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764010490; cv=none; b=Y1w5resz0GSpBHCAwI4SqmkwAvd+xa7YZu+HtWyGSk33PhL9YO9m+CmlPzxpkI2qNnrfW77GoRy4UsdF4+a8Q0cZMFGH9U11fBp6omq4/vEZK621k5mxZxULtAeM45yWuPAay19YHi7GWTrr/5Uc9OGRO6EgxuRAigC1jmslIdo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764010490; c=relaxed/simple; bh=ut3ntBOtGFL/qpU8N426fpMB4ZSPqzVYTWwh5afQaeg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bgVK1Q26t1GZwMyWQ7YH4VOcDb5t7GLsVGMI3FEAppduxUk2RNZ3WUTQPitdW62RbmUShoaH4EPqjAmshxPP2v37RtEUWoJoNq7ESAwOSAMYnpGR9OUluVcZl9WEqSIuMZ3CmxwbGM0SbmQ3zAvWVI3jI9OjlWkD1ceZzyFtsmg= 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=WDx7Z0OT; arc=none smtp.client-ip=192.198.163.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="WDx7Z0OT" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1764010487; x=1795546487; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ut3ntBOtGFL/qpU8N426fpMB4ZSPqzVYTWwh5afQaeg=; b=WDx7Z0OTcbsOrGeZHkrYyVC1xhwdInHQEQW0A2WH+bMG7c5RNj1M4QL1 ktniTGQ0ty4EaO/xIyomTr/1azUW/ARXU/gVMrhcqd3S0avvWTqCdhf7l qXSflowx/DEn5QHZoQh/AUJLYGWXqUNhiypyR4SQffsg4K+6MjVtHy6Js wB3vPhYgyCw6jfpN6efnCo6cdVqLNcvY6dRBGRcujhN3TCcorLWyic+38 0Z7WXVkku/KKWtek+p1pJFVD6IaW6ISKV8uF1JC8rz4lwOc40c1fkbDST 4jPOW1b1htS4QWRtEW8jlsmDwqS0Yw05Imn8cHjFgHKwxxsgZTinVi1hM w==; X-CSE-ConnectionGUID: 0/DtiekwT3q926YQpu8CCg== X-CSE-MsgGUID: w2fTpViLRQa4XB6305so+g== X-IronPort-AV: E=McAfee;i="6800,10657,11623"; a="76636493" X-IronPort-AV: E=Sophos;i="6.20,223,1758610800"; d="scan'208";a="76636493" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Nov 2025 10:54:23 -0800 X-CSE-ConnectionGUID: sfBOnDw/Qv22jMX6m7P6aQ== X-CSE-MsgGUID: nb6ZgI0iSVu+8r53o93bPQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.20,223,1758610800"; d="scan'208";a="192224956" Received: from rfrazer-mobl3.amr.corp.intel.com (HELO agluck-desk3.home.arpa) ([10.124.222.153]) by orviesa009-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Nov 2025 10:54:23 -0800 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Maciej Wieczor-Retman , Peter Newman , James Morse , Babu Moger , Drew Fustini , Dave Martin , Chen Yu Cc: x86@kernel.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [PATCH v14 05/32] x86,fs/resctrl: Refactor domain create/remove using struct rdt_domain_hdr Date: Mon, 24 Nov 2025 10:53:42 -0800 Message-ID: <20251124185412.24155-6-tony.luck@intel.com> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251124185412.24155-1-tony.luck@intel.com> References: <20251124185412.24155-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" Up until now, all monitoring events were associated with the L3 resource an= d it made sense to use the L3 specific "struct rdt_mon_domain *" argument to fun= ctions operating on domains. Telemetry events will be tied to a new resource with its instances represen= ted by a new domain structure that, just like struct rdt_mon_domain, starts with the generic struct rdt_domain_hdr. Prepare to support domains belonging to different resources by changing the calling convention of functions operating on domains. Pass the generic hea= der and use that to find the domain specific structure where needed. Signed-off-by: Tony Luck --- include/linux/resctrl.h | 4 +- fs/resctrl/internal.h | 2 +- arch/x86/kernel/cpu/resctrl/core.c | 4 +- fs/resctrl/ctrlmondata.c | 14 ++++-- fs/resctrl/rdtgroup.c | 69 +++++++++++++++++++++--------- 5 files changed, 63 insertions(+), 30 deletions(-) diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index e7c218f8d4f7..5db37c7e89c5 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -507,9 +507,9 @@ int resctrl_arch_update_one(struct rdt_resource *r, str= uct rdt_ctrl_domain *d, u32 resctrl_arch_get_config(struct rdt_resource *r, struct rdt_ctrl_domain= *d, u32 closid, enum resctrl_conf_type type); int resctrl_online_ctrl_domain(struct rdt_resource *r, struct rdt_ctrl_dom= ain *d); -int resctrl_online_mon_domain(struct rdt_resource *r, struct rdt_mon_domai= n *d); +int resctrl_online_mon_domain(struct rdt_resource *r, struct rdt_domain_hd= r *hdr); void resctrl_offline_ctrl_domain(struct rdt_resource *r, struct rdt_ctrl_d= omain *d); -void resctrl_offline_mon_domain(struct rdt_resource *r, struct rdt_mon_dom= ain *d); +void resctrl_offline_mon_domain(struct rdt_resource *r, struct rdt_domain_= hdr *hdr); void resctrl_online_cpu(unsigned int cpu); void resctrl_offline_cpu(unsigned int cpu); =20 diff --git a/fs/resctrl/internal.h b/fs/resctrl/internal.h index bff4a54ae333..5e52269b391e 100644 --- a/fs/resctrl/internal.h +++ b/fs/resctrl/internal.h @@ -362,7 +362,7 @@ void mon_event_count(void *info); int rdtgroup_mondata_show(struct seq_file *m, void *arg); =20 void mon_event_read(struct rmid_read *rr, struct rdt_resource *r, - struct rdt_mon_domain *d, struct rdtgroup *rdtgrp, + struct rdt_domain_hdr *hdr, struct rdtgroup *rdtgrp, cpumask_t *cpumask, int evtid, int first); =20 int resctrl_mon_resource_init(void); diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resct= rl/core.c index 64ed81cbf8bf..1fab4c67d273 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -534,7 +534,7 @@ static void l3_mon_domain_setup(int cpu, int id, struct= rdt_resource *r, struct =20 list_add_tail_rcu(&d->hdr.list, add_pos); =20 - err =3D resctrl_online_mon_domain(r, d); + err =3D resctrl_online_mon_domain(r, &d->hdr); if (err) { list_del_rcu(&d->hdr.list); synchronize_rcu(); @@ -661,7 +661,7 @@ static void domain_remove_cpu_mon(int cpu, struct rdt_r= esource *r) =20 d =3D container_of(hdr, struct rdt_mon_domain, hdr); hw_dom =3D resctrl_to_arch_mon_dom(d); - resctrl_offline_mon_domain(r, d); + resctrl_offline_mon_domain(r, hdr); list_del_rcu(&hdr->list); synchronize_rcu(); mon_domain_free(hw_dom); diff --git a/fs/resctrl/ctrlmondata.c b/fs/resctrl/ctrlmondata.c index 905c310de573..3154cdc98a31 100644 --- a/fs/resctrl/ctrlmondata.c +++ b/fs/resctrl/ctrlmondata.c @@ -551,14 +551,21 @@ struct rdt_domain_hdr *resctrl_find_domain(struct lis= t_head *h, int id, } =20 void mon_event_read(struct rmid_read *rr, struct rdt_resource *r, - struct rdt_mon_domain *d, struct rdtgroup *rdtgrp, + struct rdt_domain_hdr *hdr, struct rdtgroup *rdtgrp, cpumask_t *cpumask, int evtid, int first) { + struct rdt_mon_domain *d =3D NULL; int cpu; =20 /* When picking a CPU from cpu_mask, ensure it can't race with cpuhp */ lockdep_assert_cpus_held(); =20 + if (hdr) { + if (!domain_header_is_valid(hdr, RESCTRL_MON_DOMAIN, RDT_RESOURCE_L3)) + return; + d =3D container_of(hdr, struct rdt_mon_domain, hdr); + } + /* * Setup the parameters to pass to mon_event_count() to read the data. */ @@ -653,12 +660,11 @@ int rdtgroup_mondata_show(struct seq_file *m, void *a= rg) * the resource to find the domain with "domid". */ hdr =3D resctrl_find_domain(&r->mon_domains, domid, NULL); - if (!hdr || !domain_header_is_valid(hdr, RESCTRL_MON_DOMAIN, resid)) { + if (!hdr) { ret =3D -ENOENT; goto out; } - d =3D container_of(hdr, struct rdt_mon_domain, hdr); - mon_event_read(&rr, r, d, rdtgrp, &d->hdr.cpu_mask, evtid, false); + mon_event_read(&rr, r, hdr, rdtgrp, &hdr->cpu_mask, evtid, false); } =20 checkresult: diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c index 8e39dfda56bc..89ffe54fb0fc 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -3229,17 +3229,22 @@ static void mon_rmdir_one_subdir(struct kernfs_node= *pkn, char *name, char *subn * when last domain being summed is removed. */ static void rmdir_mondata_subdir_allrdtgrp(struct rdt_resource *r, - struct rdt_mon_domain *d) + struct rdt_domain_hdr *hdr) { struct rdtgroup *prgrp, *crgrp; + struct rdt_mon_domain *d; char subname[32]; bool snc_mode; char name[32]; =20 + if (!domain_header_is_valid(hdr, RESCTRL_MON_DOMAIN, RDT_RESOURCE_L3)) + return; + + d =3D container_of(hdr, struct rdt_mon_domain, hdr); snc_mode =3D r->mon_scope =3D=3D RESCTRL_L3_NODE; - sprintf(name, "mon_%s_%02d", r->name, snc_mode ? d->ci_id : d->hdr.id); + sprintf(name, "mon_%s_%02d", r->name, snc_mode ? d->ci_id : hdr->id); if (snc_mode) - sprintf(subname, "mon_sub_%s_%02d", r->name, d->hdr.id); + sprintf(subname, "mon_sub_%s_%02d", r->name, hdr->id); =20 list_for_each_entry(prgrp, &rdt_all_groups, rdtgroup_list) { mon_rmdir_one_subdir(prgrp->mon.mon_data_kn, name, subname); @@ -3249,15 +3254,20 @@ static void rmdir_mondata_subdir_allrdtgrp(struct r= dt_resource *r, } } =20 -static int mon_add_all_files(struct kernfs_node *kn, struct rdt_mon_domain= *d, +static int mon_add_all_files(struct kernfs_node *kn, struct rdt_domain_hdr= *hdr, struct rdt_resource *r, struct rdtgroup *prgrp, bool do_sum) { struct rmid_read rr =3D {0}; + struct rdt_mon_domain *d; struct mon_data *priv; struct mon_evt *mevt; int ret, domid; =20 + if (!domain_header_is_valid(hdr, RESCTRL_MON_DOMAIN, RDT_RESOURCE_L3)) + return -EINVAL; + + d =3D container_of(hdr, struct rdt_mon_domain, hdr); for_each_mon_event(mevt) { if (mevt->rid !=3D r->rid || !mevt->enabled) continue; @@ -3271,23 +3281,28 @@ static int mon_add_all_files(struct kernfs_node *kn= , struct rdt_mon_domain *d, return ret; =20 if (!do_sum && resctrl_is_mbm_event(mevt->evtid)) - mon_event_read(&rr, r, d, prgrp, &d->hdr.cpu_mask, mevt->evtid, true); + mon_event_read(&rr, r, hdr, prgrp, &hdr->cpu_mask, mevt->evtid, true); } =20 return 0; } =20 static int mkdir_mondata_subdir(struct kernfs_node *parent_kn, - struct rdt_mon_domain *d, + struct rdt_domain_hdr *hdr, struct rdt_resource *r, struct rdtgroup *prgrp) { struct kernfs_node *kn, *ckn; + struct rdt_mon_domain *d; char name[32]; bool snc_mode; int ret =3D 0; =20 lockdep_assert_held(&rdtgroup_mutex); =20 + if (!domain_header_is_valid(hdr, RESCTRL_MON_DOMAIN, RDT_RESOURCE_L3)) + return -EINVAL; + + d =3D container_of(hdr, struct rdt_mon_domain, hdr); snc_mode =3D r->mon_scope =3D=3D RESCTRL_L3_NODE; sprintf(name, "mon_%s_%02d", r->name, snc_mode ? d->ci_id : d->hdr.id); kn =3D kernfs_find_and_get(parent_kn, name); @@ -3305,13 +3320,13 @@ static int mkdir_mondata_subdir(struct kernfs_node = *parent_kn, ret =3D rdtgroup_kn_set_ugid(kn); if (ret) goto out_destroy; - ret =3D mon_add_all_files(kn, d, r, prgrp, snc_mode); + ret =3D mon_add_all_files(kn, hdr, r, prgrp, snc_mode); if (ret) goto out_destroy; } =20 if (snc_mode) { - sprintf(name, "mon_sub_%s_%02d", r->name, d->hdr.id); + sprintf(name, "mon_sub_%s_%02d", r->name, hdr->id); ckn =3D kernfs_create_dir(kn, name, parent_kn->mode, prgrp); if (IS_ERR(ckn)) { ret =3D -EINVAL; @@ -3322,7 +3337,7 @@ static int mkdir_mondata_subdir(struct kernfs_node *p= arent_kn, if (ret) goto out_destroy; =20 - ret =3D mon_add_all_files(ckn, d, r, prgrp, false); + ret =3D mon_add_all_files(ckn, hdr, r, prgrp, false); if (ret) goto out_destroy; } @@ -3340,7 +3355,7 @@ static int mkdir_mondata_subdir(struct kernfs_node *p= arent_kn, * and "monitor" groups with given domain id. */ static void mkdir_mondata_subdir_allrdtgrp(struct rdt_resource *r, - struct rdt_mon_domain *d) + struct rdt_domain_hdr *hdr) { struct kernfs_node *parent_kn; struct rdtgroup *prgrp, *crgrp; @@ -3348,12 +3363,12 @@ static void mkdir_mondata_subdir_allrdtgrp(struct r= dt_resource *r, =20 list_for_each_entry(prgrp, &rdt_all_groups, rdtgroup_list) { parent_kn =3D prgrp->mon.mon_data_kn; - mkdir_mondata_subdir(parent_kn, d, r, prgrp); + mkdir_mondata_subdir(parent_kn, hdr, r, prgrp); =20 head =3D &prgrp->mon.crdtgrp_list; list_for_each_entry(crgrp, head, mon.crdtgrp_list) { parent_kn =3D crgrp->mon.mon_data_kn; - mkdir_mondata_subdir(parent_kn, d, r, crgrp); + mkdir_mondata_subdir(parent_kn, hdr, r, crgrp); } } } @@ -3362,14 +3377,14 @@ static int mkdir_mondata_subdir_alldom(struct kernf= s_node *parent_kn, struct rdt_resource *r, struct rdtgroup *prgrp) { - struct rdt_mon_domain *dom; + struct rdt_domain_hdr *hdr; int ret; =20 /* Walking r->domains, ensure it can't race with cpuhp */ lockdep_assert_cpus_held(); =20 - list_for_each_entry(dom, &r->mon_domains, hdr.list) { - ret =3D mkdir_mondata_subdir(parent_kn, dom, r, prgrp); + list_for_each_entry(hdr, &r->mon_domains, list) { + ret =3D mkdir_mondata_subdir(parent_kn, hdr, r, prgrp); if (ret) return ret; } @@ -4253,16 +4268,23 @@ void resctrl_offline_ctrl_domain(struct rdt_resourc= e *r, struct rdt_ctrl_domain mutex_unlock(&rdtgroup_mutex); } =20 -void resctrl_offline_mon_domain(struct rdt_resource *r, struct rdt_mon_dom= ain *d) +void resctrl_offline_mon_domain(struct rdt_resource *r, struct rdt_domain_= hdr *hdr) { + struct rdt_mon_domain *d; + mutex_lock(&rdtgroup_mutex); =20 + if (!domain_header_is_valid(hdr, RESCTRL_MON_DOMAIN, RDT_RESOURCE_L3)) + goto out_unlock; + + d =3D container_of(hdr, struct rdt_mon_domain, hdr); + /* * If resctrl is mounted, remove all the * per domain monitor data directories. */ if (resctrl_mounted && resctrl_arch_mon_capable()) - rmdir_mondata_subdir_allrdtgrp(r, d); + rmdir_mondata_subdir_allrdtgrp(r, hdr); =20 if (resctrl_is_mbm_enabled()) cancel_delayed_work(&d->mbm_over); @@ -4280,7 +4302,7 @@ void resctrl_offline_mon_domain(struct rdt_resource *= r, struct rdt_mon_domain *d } =20 domain_destroy_mon_state(d); - +out_unlock: mutex_unlock(&rdtgroup_mutex); } =20 @@ -4353,12 +4375,17 @@ int resctrl_online_ctrl_domain(struct rdt_resource = *r, struct rdt_ctrl_domain *d return err; } =20 -int resctrl_online_mon_domain(struct rdt_resource *r, struct rdt_mon_domai= n *d) +int resctrl_online_mon_domain(struct rdt_resource *r, struct rdt_domain_hd= r *hdr) { - int err; + struct rdt_mon_domain *d; + int err =3D -EINVAL; =20 mutex_lock(&rdtgroup_mutex); =20 + if (!domain_header_is_valid(hdr, RESCTRL_MON_DOMAIN, RDT_RESOURCE_L3)) + goto out_unlock; + + d =3D container_of(hdr, struct rdt_mon_domain, hdr); err =3D domain_setup_mon_state(r, d); if (err) goto out_unlock; @@ -4379,7 +4406,7 @@ int resctrl_online_mon_domain(struct rdt_resource *r,= struct rdt_mon_domain *d) * If resctrl is mounted, add per domain monitor data directories. */ if (resctrl_mounted && resctrl_arch_mon_capable()) - mkdir_mondata_subdir_allrdtgrp(r, d); + mkdir_mondata_subdir_allrdtgrp(r, hdr); =20 out_unlock: mutex_unlock(&rdtgroup_mutex); --=20 2.51.1 From nobody Tue Dec 2 00:25:23 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EDC7B31B122 for ; Mon, 24 Nov 2025 18:54:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764010488; cv=none; b=oc50fo8411cQD1orBMmisYW+fLo/xOOq1in7wF3oK87xNzr2OSHABTvpulEYnpCdezXjMMAjXgb5bryDg8H7qcSrGC2RZdc1xPXYmUVBUppOu3P/gcFCk0yrNbkTCwC6vCMVOP4p9WQ/3kHw/tra6K/A58K6qVA4pBE7fHnqZmE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764010488; c=relaxed/simple; bh=T0pledc9NIwFCM7bjxrvqASAAUwPfvukY1vMLOaAJq4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cqfcbeDdVzwLUa624guyhIMDI5rKiMco2RiN80Z2dL/erbfcp7AG+trcg0XTXmCXjkKEeCrhIT1kj/Lt264e6KfS7CARMxcXnV5qkcjnRsShVgmVg+muNzvjiOdkuLyrxeBdRX2q9xuJ0txTAaUW+Yo4Q4KKMzrsIMJr4Xjd/W0= 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=bDjQgZEJ; arc=none smtp.client-ip=192.198.163.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="bDjQgZEJ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1764010487; x=1795546487; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=T0pledc9NIwFCM7bjxrvqASAAUwPfvukY1vMLOaAJq4=; b=bDjQgZEJLxkUnkcuEJyitB3koztJQVn3aBNK1JSobAkRFbrHEl+cHCK2 Aph8pshbzTf2J6HN3FIwPoTpwJlpOAUOyfaXYAA1d8/EdiWdLcrD3tLox IqCNRno2RQwegMjv373EA4ZR4jjOcyifWnPlqTo7Oxqt6BPqxY60PdrN2 m6LwjgRFG9WNV9eRiCCExfdg3YQzxD+RsnqGg5A+64I081k0Z0sETdD8b /zWUTOD6eBX7X7VNsUmpfKoUhBDZf/3WFyR19qJroWwUxc2yAojKDBsKw I356NuTm5Zz/GwUlMhCZknvsKOUvDOZCLiUCsNM6MvgmsdJTTCneCAAef w==; X-CSE-ConnectionGUID: ynHhq5diTE6oaijwGkGZzQ== X-CSE-MsgGUID: vWPgsAA7T7mjHVDF1XZSVA== X-IronPort-AV: E=McAfee;i="6800,10657,11623"; a="76636498" X-IronPort-AV: E=Sophos;i="6.20,223,1758610800"; d="scan'208";a="76636498" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Nov 2025 10:54:23 -0800 X-CSE-ConnectionGUID: QNjlbCW6TBita6Ye6YgUHQ== X-CSE-MsgGUID: RGJvCF8LRNuR7a1Qsf+T+g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.20,223,1758610800"; d="scan'208";a="192224959" Received: from rfrazer-mobl3.amr.corp.intel.com (HELO agluck-desk3.home.arpa) ([10.124.222.153]) by orviesa009-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Nov 2025 10:54:23 -0800 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Maciej Wieczor-Retman , Peter Newman , James Morse , Babu Moger , Drew Fustini , Dave Martin , Chen Yu Cc: x86@kernel.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [PATCH v14 06/32] fs/resctrl: Split L3 dependent parts out of __mon_event_count() Date: Mon, 24 Nov 2025 10:53:43 -0800 Message-ID: <20251124185412.24155-7-tony.luck@intel.com> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251124185412.24155-1-tony.luck@intel.com> References: <20251124185412.24155-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" Carve out the L3 resource specific event reading code into a separate helper to support reading event data from a new monitoring resource. Suggested-by: Reinette Chatre Signed-off-by: Tony Luck --- fs/resctrl/monitor.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c index 572a9925bd6c..179962a81362 100644 --- a/fs/resctrl/monitor.c +++ b/fs/resctrl/monitor.c @@ -413,7 +413,7 @@ static void mbm_cntr_free(struct rdt_mon_domain *d, int= cntr_id) memset(&d->cntr_cfg[cntr_id], 0, sizeof(*d->cntr_cfg)); } =20 -static int __mon_event_count(struct rdtgroup *rdtgrp, struct rmid_read *rr) +static int __l3_mon_event_count(struct rdtgroup *rdtgrp, struct rmid_read = *rr) { int cpu =3D smp_processor_id(); u32 closid =3D rdtgrp->closid; @@ -494,6 +494,18 @@ static int __mon_event_count(struct rdtgroup *rdtgrp, = struct rmid_read *rr) return ret; } =20 +static int __mon_event_count(struct rdtgroup *rdtgrp, struct rmid_read *rr) +{ + switch (rr->r->rid) { + case RDT_RESOURCE_L3: + return __l3_mon_event_count(rdtgrp, rr); + + default: + rr->err =3D -EINVAL; + return -EINVAL; + } +} + /* * mbm_bw_count() - Update bw count from values previously read by * __mon_event_count(). --=20 2.51.1 From nobody Tue Dec 2 00:25:23 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7963431C567 for ; Mon, 24 Nov 2025 18:54:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764010490; cv=none; b=EmuvmgPzHxaBDFdGtjMp2FZ10c9paPyKy+kZAUqZhSC/k/miCshM28zE01jXr/r6129PUSQAgIVXLiHppFBa9713/+cKB/l3iCLUFcEvSRIFWdqJN+AvgH5fzhSSwKTqv+Fovmqtiy7JNKdn643M4r4SBU4B4POa72GyvA00pHs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764010490; c=relaxed/simple; bh=eOCoKsoV5cP5MAWG4ZVEVrCDCAab/3aeP6x7Owf3cfM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nIGgJqXXh3sLSAtPxWx7+7X2nyF0BA+SmMJTcPeRAzwPqwjcNOUmxD8k7sHozBkE5R2Hk+mBVU/DCy5PxKKBB7DnbKQKmv+TUYW93W3uz4myLa/n8Re1sFNRAXMqqGWSW4v3pkd9Aayvow4NAKrj9FEvW/arKuPjhwzRW49GJgY= 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=A9vGs1qO; arc=none smtp.client-ip=192.198.163.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="A9vGs1qO" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1764010488; x=1795546488; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=eOCoKsoV5cP5MAWG4ZVEVrCDCAab/3aeP6x7Owf3cfM=; b=A9vGs1qOkmh26zSfLYqL5uACCINpT+sPnktkBUKjRK9wZzdslGtpYHZv ZvPqSs0qD1KCrQW1WkHDjnC5KW/1/TaQDevxmHbEUpzRtLV42q5cXHFOH X/7nW+ViTl+leAkHABuQzFKOrTmPqXBDec/qNrUJouwwilQrNAQrvQknO nUfrg9skAb14rc+29vVcQj9oRjcrpUKgNSHCFYc7Z4E65cNAx0z5sJvT2 9/v27dQndCXyVjz6o7HCRZFoFJz7lf5NEcAiiMjbtEndgwzxawkxQoibu 9cJwAvuLTQmIsucDR1pkBeyFaIs+In0+OhfZQ7/tdo5i37dTPPJwWHci6 g==; X-CSE-ConnectionGUID: OoZrJrM5SKOhB/Opy2/yhg== X-CSE-MsgGUID: ggE8XB0uQoq1pPtCdSj7Eg== X-IronPort-AV: E=McAfee;i="6800,10657,11623"; a="76636525" X-IronPort-AV: E=Sophos;i="6.20,223,1758610800"; d="scan'208";a="76636525" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Nov 2025 10:54:24 -0800 X-CSE-ConnectionGUID: L1u0A+GiT5q0KLbizbb+6w== X-CSE-MsgGUID: 16XPu04oTpuIr2VIQzCVyg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.20,223,1758610800"; d="scan'208";a="192224962" Received: from rfrazer-mobl3.amr.corp.intel.com (HELO agluck-desk3.home.arpa) ([10.124.222.153]) by orviesa009-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Nov 2025 10:54:23 -0800 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Maciej Wieczor-Retman , Peter Newman , James Morse , Babu Moger , Drew Fustini , Dave Martin , Chen Yu Cc: x86@kernel.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [PATCH v14 07/32] x86,fs/resctrl: Use struct rdt_domain_hdr when reading counters Date: Mon, 24 Nov 2025 10:53:44 -0800 Message-ID: <20251124185412.24155-8-tony.luck@intel.com> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251124185412.24155-1-tony.luck@intel.com> References: <20251124185412.24155-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" Convert the whole call sequence from mon_event_read() to resctrl_arch_rmid_= read() to pass resource independent struct rdt_domain_hdr instead of an L3 specific domain structure to prepare for monitoring events in other resources. Signed-off-by: Tony Luck --- include/linux/resctrl.h | 4 +- fs/resctrl/internal.h | 18 ++++--- arch/x86/kernel/cpu/resctrl/monitor.c | 12 +++-- fs/resctrl/ctrlmondata.c | 9 +--- fs/resctrl/monitor.c | 72 +++++++++++++++++---------- 5 files changed, 68 insertions(+), 47 deletions(-) diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index 5db37c7e89c5..9b9877fb3238 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -517,7 +517,7 @@ void resctrl_offline_cpu(unsigned int cpu); * resctrl_arch_rmid_read() - Read the eventid counter corresponding to rm= id * for this resource and domain. * @r: resource that the counter should be read from. - * @d: domain that the counter should be read from. + * @hdr: Header of domain that the counter should be read from. * @closid: closid that matches the rmid. Depending on the architecture, = the * counter may match traffic of both @closid and @rmid, or @rmid * only. @@ -538,7 +538,7 @@ void resctrl_offline_cpu(unsigned int cpu); * Return: * 0 on success, or -EIO, -EINVAL etc on error. */ -int resctrl_arch_rmid_read(struct rdt_resource *r, struct rdt_mon_domain *= d, +int resctrl_arch_rmid_read(struct rdt_resource *r, struct rdt_domain_hdr *= hdr, u32 closid, u32 rmid, enum resctrl_event_id eventid, u64 *val, void *arch_mon_ctx); =20 diff --git a/fs/resctrl/internal.h b/fs/resctrl/internal.h index 5e52269b391e..9912b774a580 100644 --- a/fs/resctrl/internal.h +++ b/fs/resctrl/internal.h @@ -106,24 +106,26 @@ struct mon_data { * resource group then its event count is summed with the count from all * its child resource groups. * @r: Resource describing the properties of the event being read. - * @d: Domain that the counter should be read from. If NULL then sum all - * domains in @r sharing L3 @ci.id + * @hdr: Header of domain that the counter should be read from. If NULL = then + * sum all domains in @r sharing L3 @ci.id * @evtid: Which monitor event to read. * @first: Initialize MBM counter when true. - * @ci: Cacheinfo for L3. Only set when @d is NULL. Used when summing d= omains. + * @ci: Cacheinfo for L3. Only set when @hdr is NULL. Used when summing + * domains. * @is_mbm_cntr: true if "mbm_event" counter assignment mode is enabled an= d it * is an MBM event. * @err: Error encountered when reading counter. - * @val: Returned value of event counter. If @rgrp is a parent resource = group, - * @val includes the sum of event counts from its child resource groups. - * If @d is NULL, @val includes the sum of all domains in @r sharing @c= i.id, - * (summed across child resource groups if @rgrp is a parent resource g= roup). + * @val: Returned value of event counter. If @rgrp is a parent resource + * group, @val includes the sum of event counts from its child + * resource groups. If @hdr is NULL, @val includes the sum of all + * domains in @r sharing @ci.id, (summed across child resource groups + * if @rgrp is a parent resource group). * @arch_mon_ctx: Hardware monitor allocated for this read request (MPAM o= nly). */ struct rmid_read { struct rdtgroup *rgrp; struct rdt_resource *r; - struct rdt_mon_domain *d; + struct rdt_domain_hdr *hdr; enum resctrl_event_id evtid; bool first; struct cacheinfo *ci; diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/re= sctrl/monitor.c index dffcc8307500..3da970ea1903 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -238,19 +238,25 @@ static u64 get_corrected_val(struct rdt_resource *r, = struct rdt_mon_domain *d, return chunks * hw_res->mon_scale; } =20 -int resctrl_arch_rmid_read(struct rdt_resource *r, struct rdt_mon_domain *= d, +int resctrl_arch_rmid_read(struct rdt_resource *r, struct rdt_domain_hdr *= hdr, u32 unused, u32 rmid, enum resctrl_event_id eventid, u64 *val, void *ignored) { - struct rdt_hw_mon_domain *hw_dom =3D resctrl_to_arch_mon_dom(d); - int cpu =3D cpumask_any(&d->hdr.cpu_mask); + struct rdt_hw_mon_domain *hw_dom; struct arch_mbm_state *am; + struct rdt_mon_domain *d; u64 msr_val; u32 prmid; + int cpu; int ret; =20 resctrl_arch_rmid_read_context_check(); + if (!domain_header_is_valid(hdr, RESCTRL_MON_DOMAIN, RDT_RESOURCE_L3)) + return -EINVAL; =20 + d =3D container_of(hdr, struct rdt_mon_domain, hdr); + hw_dom =3D resctrl_to_arch_mon_dom(d); + cpu =3D cpumask_any(&hdr->cpu_mask); prmid =3D logical_rmid_to_physical_rmid(cpu, rmid); ret =3D __rmid_read_phys(prmid, eventid, &msr_val); =20 diff --git a/fs/resctrl/ctrlmondata.c b/fs/resctrl/ctrlmondata.c index 3154cdc98a31..9242a2982e77 100644 --- a/fs/resctrl/ctrlmondata.c +++ b/fs/resctrl/ctrlmondata.c @@ -554,25 +554,18 @@ void mon_event_read(struct rmid_read *rr, struct rdt_= resource *r, struct rdt_domain_hdr *hdr, struct rdtgroup *rdtgrp, cpumask_t *cpumask, int evtid, int first) { - struct rdt_mon_domain *d =3D NULL; int cpu; =20 /* When picking a CPU from cpu_mask, ensure it can't race with cpuhp */ lockdep_assert_cpus_held(); =20 - if (hdr) { - if (!domain_header_is_valid(hdr, RESCTRL_MON_DOMAIN, RDT_RESOURCE_L3)) - return; - d =3D container_of(hdr, struct rdt_mon_domain, hdr); - } - /* * Setup the parameters to pass to mon_event_count() to read the data. */ rr->rgrp =3D rdtgrp; rr->evtid =3D evtid; rr->r =3D r; - rr->d =3D d; + rr->hdr =3D hdr; rr->first =3D first; if (resctrl_arch_mbm_cntr_assign_enabled(r) && resctrl_is_mbm_event(evtid)) { diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c index 179962a81362..7765491ddb4c 100644 --- a/fs/resctrl/monitor.c +++ b/fs/resctrl/monitor.c @@ -159,7 +159,7 @@ void __check_limbo(struct rdt_mon_domain *d, bool force= _free) break; =20 entry =3D __rmid_entry(idx); - if (resctrl_arch_rmid_read(r, d, entry->closid, entry->rmid, + if (resctrl_arch_rmid_read(r, &d->hdr, entry->closid, entry->rmid, QOS_L3_OCCUP_EVENT_ID, &val, arch_mon_ctx)) { rmid_dirty =3D true; @@ -421,11 +421,16 @@ static int __l3_mon_event_count(struct rdtgroup *rdtg= rp, struct rmid_read *rr) struct rdt_mon_domain *d; int cntr_id =3D -ENOENT; struct mbm_state *m; - int err, ret; u64 tval =3D 0; =20 + if (!domain_header_is_valid(rr->hdr, RESCTRL_MON_DOMAIN, RDT_RESOURCE_L3)= ) { + rr->err =3D -EIO; + return -EINVAL; + } + d =3D container_of(rr->hdr, struct rdt_mon_domain, hdr); + if (rr->is_mbm_cntr) { - cntr_id =3D mbm_cntr_get(rr->r, rr->d, rdtgrp, rr->evtid); + cntr_id =3D mbm_cntr_get(rr->r, d, rdtgrp, rr->evtid); if (cntr_id < 0) { rr->err =3D -ENOENT; return -EINVAL; @@ -434,32 +439,41 @@ static int __l3_mon_event_count(struct rdtgroup *rdtg= rp, struct rmid_read *rr) =20 if (rr->first) { if (rr->is_mbm_cntr) - resctrl_arch_reset_cntr(rr->r, rr->d, closid, rmid, cntr_id, rr->evtid); + resctrl_arch_reset_cntr(rr->r, d, closid, rmid, cntr_id, rr->evtid); else - resctrl_arch_reset_rmid(rr->r, rr->d, closid, rmid, rr->evtid); - m =3D get_mbm_state(rr->d, closid, rmid, rr->evtid); + resctrl_arch_reset_rmid(rr->r, d, closid, rmid, rr->evtid); + m =3D get_mbm_state(d, closid, rmid, rr->evtid); if (m) memset(m, 0, sizeof(struct mbm_state)); return 0; } =20 - if (rr->d) { - /* Reading a single domain, must be on a CPU in that domain. */ - if (!cpumask_test_cpu(cpu, &rr->d->hdr.cpu_mask)) - return -EINVAL; - if (rr->is_mbm_cntr) - rr->err =3D resctrl_arch_cntr_read(rr->r, rr->d, closid, rmid, cntr_id, - rr->evtid, &tval); - else - rr->err =3D resctrl_arch_rmid_read(rr->r, rr->d, closid, rmid, - rr->evtid, &tval, rr->arch_mon_ctx); - if (rr->err) - return rr->err; + /* Reading a single domain, must be on a CPU in that domain. */ + if (!cpumask_test_cpu(cpu, &d->hdr.cpu_mask)) + return -EINVAL; + if (rr->is_mbm_cntr) + rr->err =3D resctrl_arch_cntr_read(rr->r, d, closid, rmid, cntr_id, + rr->evtid, &tval); + else + rr->err =3D resctrl_arch_rmid_read(rr->r, rr->hdr, closid, rmid, + rr->evtid, &tval, rr->arch_mon_ctx); + if (rr->err) + return rr->err; =20 - rr->val +=3D tval; + rr->val +=3D tval; =20 - return 0; - } + return 0; +} + +static int __l3_mon_event_count_sum(struct rdtgroup *rdtgrp, struct rmid_r= ead *rr) +{ + int cpu =3D smp_processor_id(); + u32 closid =3D rdtgrp->closid; + u32 rmid =3D rdtgrp->mon.rmid; + struct rdt_mon_domain *d; + int cntr_id =3D -ENOENT; + u64 tval =3D 0; + int err, ret; =20 /* Summing domains that share a cache, must be on a CPU for that cache. */ if (!cpumask_test_cpu(cpu, &rr->ci->shared_cpu_map)) @@ -480,7 +494,7 @@ static int __l3_mon_event_count(struct rdtgroup *rdtgrp= , struct rmid_read *rr) err =3D resctrl_arch_cntr_read(rr->r, d, closid, rmid, cntr_id, rr->evtid, &tval); else - err =3D resctrl_arch_rmid_read(rr->r, d, closid, rmid, + err =3D resctrl_arch_rmid_read(rr->r, &d->hdr, closid, rmid, rr->evtid, &tval, rr->arch_mon_ctx); if (!err) { rr->val +=3D tval; @@ -498,8 +512,10 @@ static int __mon_event_count(struct rdtgroup *rdtgrp, = struct rmid_read *rr) { switch (rr->r->rid) { case RDT_RESOURCE_L3: - return __l3_mon_event_count(rdtgrp, rr); - + if (rr->hdr) + return __l3_mon_event_count(rdtgrp, rr); + else + return __l3_mon_event_count_sum(rdtgrp, rr); default: rr->err =3D -EINVAL; return -EINVAL; @@ -523,9 +539,13 @@ static void mbm_bw_count(struct rdtgroup *rdtgrp, stru= ct rmid_read *rr) u64 cur_bw, bytes, cur_bytes; u32 closid =3D rdtgrp->closid; u32 rmid =3D rdtgrp->mon.rmid; + struct rdt_mon_domain *d; struct mbm_state *m; =20 - m =3D get_mbm_state(rr->d, closid, rmid, rr->evtid); + if (!domain_header_is_valid(rr->hdr, RESCTRL_MON_DOMAIN, RDT_RESOURCE_L3)) + return; + d =3D container_of(rr->hdr, struct rdt_mon_domain, hdr); + m =3D get_mbm_state(d, closid, rmid, rr->evtid); if (WARN_ON_ONCE(!m)) return; =20 @@ -698,7 +718,7 @@ static void mbm_update_one_event(struct rdt_resource *r= , struct rdt_mon_domain * struct rmid_read rr =3D {0}; =20 rr.r =3D r; - rr.d =3D d; + rr.hdr =3D &d->hdr; rr.evtid =3D evtid; if (resctrl_arch_mbm_cntr_assign_enabled(r)) { rr.is_mbm_cntr =3D true; --=20 2.51.1 From nobody Tue Dec 2 00:25:23 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0FDF931D375 for ; Mon, 24 Nov 2025 18:54:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764010492; cv=none; b=eCUvHydhwZK6ZfFKVuIUvfDxLutKP8bGjqAOeQkQ7O3CSGEWhBc8khL8Dl+iUlPTbsW3uMFKOKKypVrg3rKIhzzgYhmXDQv2N+cd6mF8ojI3PK0Y8Mf753/dyau+AoZWaw3LIh/8X3lpI+SFah4Hnuzpgbn8CRx+3TnNZBeL9/M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764010492; c=relaxed/simple; bh=riS5EtIYmAyU3+f+/YZrotybldk8wLZDNLY1Qq9Ehp0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=V2wZ9iAVA5FOWwACNH6+8A2c+Yz3iGe3Q/yYqfGYetlo02embeAFwFr1nDBDyixRONXL3s6kmsJMU+46G0EebR8jnteByN20990cSx/CEoLCuF7BHaaIiZ2kVwJ9RF0MwLAbGu7qcSU1hLA42tUeRfxXTpA2xUu/u3IArFNwrcE= 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=HTZ87q1K; arc=none smtp.client-ip=192.198.163.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="HTZ87q1K" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1764010489; x=1795546489; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=riS5EtIYmAyU3+f+/YZrotybldk8wLZDNLY1Qq9Ehp0=; b=HTZ87q1KcuBb3KkOG0UogzKcoznmwbf5zXGoYqWBi3enl2x7xgHEhUyS 2PNcLGoCzhUqJBBrCrx07HtOPTzJ1OBTk95uzhAZyM48s3M2L0z1kFZaK 34NOtPJQz5fgLUzYnxmJxSNkDtlolY27R5vIprWpPqke8YU1bo5mZMbZX CP6Yb2ar43/4UeNlKaLntgq64HAvvtVkus4kJfBgZ2U9wtZfRwx0knX6p Kz3vAbw+uHSsFg7BuykPr3oKfUZT4dQ/dqI/jpenqBQDxmo3ddAiBORlX RkoEtOMnlMr+l4nJG5FDZMmmIX4CY5v/v9qcASkSMAe3Dg+JzLnUIioTJ A==; X-CSE-ConnectionGUID: QS+Y/JU2QNKmzTHbhmZEWw== X-CSE-MsgGUID: ouCG7ZORQr2WQoCgFmUDPw== X-IronPort-AV: E=McAfee;i="6800,10657,11623"; a="76636535" X-IronPort-AV: E=Sophos;i="6.20,223,1758610800"; d="scan'208";a="76636535" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Nov 2025 10:54:24 -0800 X-CSE-ConnectionGUID: EzhWRvS7S3uipC8iqRrNpw== X-CSE-MsgGUID: 27UzUeOmSiuBfv77mtYI2Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.20,223,1758610800"; d="scan'208";a="192224966" Received: from rfrazer-mobl3.amr.corp.intel.com (HELO agluck-desk3.home.arpa) ([10.124.222.153]) by orviesa009-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Nov 2025 10:54:24 -0800 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Maciej Wieczor-Retman , Peter Newman , James Morse , Babu Moger , Drew Fustini , Dave Martin , Chen Yu Cc: x86@kernel.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [PATCH v14 08/32] x86,fs/resctrl: Rename struct rdt_mon_domain and rdt_hw_mon_domain Date: Mon, 24 Nov 2025 10:53:45 -0800 Message-ID: <20251124185412.24155-9-tony.luck@intel.com> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251124185412.24155-1-tony.luck@intel.com> References: <20251124185412.24155-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 upcoming telemetry event monitoring is not tied to the L3 resource and will have new domain structures. Rename the L3 resource specific domain data structures to include "l3_" in their names to avoid confusion between the different resource specific domain structures: rdt_mon_domain -> rdt_l3_mon_domain rdt_hw_mon_domain -> rdt_hw_l3_mon_domain No functional change. Signed-off-by: Tony Luck --- include/linux/resctrl.h | 22 ++++---- arch/x86/kernel/cpu/resctrl/internal.h | 20 ++++---- fs/resctrl/internal.h | 8 +-- arch/x86/kernel/cpu/resctrl/core.c | 14 +++--- arch/x86/kernel/cpu/resctrl/monitor.c | 36 ++++++------- fs/resctrl/ctrlmondata.c | 2 +- fs/resctrl/monitor.c | 70 +++++++++++++------------- fs/resctrl/rdtgroup.c | 40 +++++++-------- 8 files changed, 106 insertions(+), 106 deletions(-) diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index 9b9877fb3238..79aaaabcdd3f 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -178,7 +178,7 @@ struct mbm_cntr_cfg { }; =20 /** - * struct rdt_mon_domain - group of CPUs sharing a resctrl monitor resource + * 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 @@ -192,7 +192,7 @@ struct mbm_cntr_cfg { * @cntr_cfg: array of assignable counters' configuration (indexed * by counter ID) */ -struct rdt_mon_domain { +struct rdt_l3_mon_domain { struct rdt_domain_hdr hdr; unsigned int ci_id; unsigned long *rmid_busy_llc; @@ -367,10 +367,10 @@ struct resctrl_cpu_defaults { }; =20 struct resctrl_mon_config_info { - struct rdt_resource *r; - struct rdt_mon_domain *d; - u32 evtid; - u32 mon_config; + struct rdt_resource *r; + struct rdt_l3_mon_domain *d; + u32 evtid; + u32 mon_config; }; =20 /** @@ -585,7 +585,7 @@ struct rdt_domain_hdr *resctrl_find_domain(struct list_= head *h, int id, * * This can be called from any CPU. */ -void resctrl_arch_reset_rmid(struct rdt_resource *r, struct rdt_mon_domain= *d, +void resctrl_arch_reset_rmid(struct rdt_resource *r, struct rdt_l3_mon_dom= ain *d, u32 closid, u32 rmid, enum resctrl_event_id eventid); =20 @@ -598,7 +598,7 @@ void resctrl_arch_reset_rmid(struct rdt_resource *r, st= ruct rdt_mon_domain *d, * * This can be called from any CPU. */ -void resctrl_arch_reset_rmid_all(struct rdt_resource *r, struct rdt_mon_do= main *d); +void resctrl_arch_reset_rmid_all(struct rdt_resource *r, struct rdt_l3_mon= _domain *d); =20 /** * resctrl_arch_reset_all_ctrls() - Reset the control for each CLOSID to i= ts @@ -624,7 +624,7 @@ void resctrl_arch_reset_all_ctrls(struct rdt_resource *= r); * * This can be called from any CPU. */ -void resctrl_arch_config_cntr(struct rdt_resource *r, struct rdt_mon_domai= n *d, +void resctrl_arch_config_cntr(struct rdt_resource *r, struct rdt_l3_mon_do= main *d, enum resctrl_event_id evtid, u32 rmid, u32 closid, u32 cntr_id, bool assign); =20 @@ -647,7 +647,7 @@ void resctrl_arch_config_cntr(struct rdt_resource *r, s= truct rdt_mon_domain *d, * Return: * 0 on success, or -EIO, -EINVAL etc on error. */ -int resctrl_arch_cntr_read(struct rdt_resource *r, struct rdt_mon_domain *= d, +int resctrl_arch_cntr_read(struct rdt_resource *r, struct rdt_l3_mon_domai= n *d, u32 closid, u32 rmid, int cntr_id, enum resctrl_event_id eventid, u64 *val); =20 @@ -662,7 +662,7 @@ int resctrl_arch_cntr_read(struct rdt_resource *r, stru= ct rdt_mon_domain *d, * * This can be called from any CPU. */ -void resctrl_arch_reset_cntr(struct rdt_resource *r, struct rdt_mon_domain= *d, +void resctrl_arch_reset_cntr(struct rdt_resource *r, struct rdt_l3_mon_dom= ain *d, u32 closid, u32 rmid, int cntr_id, enum resctrl_event_id eventid); =20 diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/r= esctrl/internal.h index 4a916c84a322..d6da21d4684b 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -50,8 +50,8 @@ struct arch_mbm_state { #define SDCIAE_ENABLE_BIT 1 =20 /** - * struct rdt_hw_ctrl_domain - Arch private attributes of a set of CPUs th= at share - * a resource for a control function + * struct rdt_hw_ctrl_domain - Arch private attributes of a set of CPUs sh= aring + * RDT_RESOURCE_L3 monitoring * @d_resctrl: Properties exposed to the resctrl file system * @ctrl_val: array of cache or mem ctrl values (indexed by CLOSID) * @@ -63,17 +63,17 @@ struct rdt_hw_ctrl_domain { }; =20 /** - * struct rdt_hw_mon_domain - Arch private attributes of a set of CPUs tha= t share - * a resource for a monitor function - * @d_resctrl: Properties exposed to the resctrl file system + * struct rdt_hw_l3_mon_domain - Arch private attributes of a set of CPUs = that share + * a resource for a monitor function + * @d_resctrl: Properties exposed to the resctrl file system * @arch_mbm_states: Per-event pointer to the MBM event's saved state. * An MBM event's state is an array of struct arch_mbm_state * indexed by RMID on x86. * * Members of this structure are accessed via helpers that provide abstrac= tion. */ -struct rdt_hw_mon_domain { - struct rdt_mon_domain d_resctrl; +struct rdt_hw_l3_mon_domain { + struct rdt_l3_mon_domain d_resctrl; struct arch_mbm_state *arch_mbm_states[QOS_NUM_L3_MBM_EVENTS]; }; =20 @@ -82,9 +82,9 @@ static inline struct rdt_hw_ctrl_domain *resctrl_to_arch_= ctrl_dom(struct rdt_ctr return container_of(r, struct rdt_hw_ctrl_domain, d_resctrl); } =20 -static inline struct rdt_hw_mon_domain *resctrl_to_arch_mon_dom(struct rdt= _mon_domain *r) +static inline struct rdt_hw_l3_mon_domain *resctrl_to_arch_mon_dom(struct = rdt_l3_mon_domain *r) { - return container_of(r, struct rdt_hw_mon_domain, d_resctrl); + return container_of(r, struct rdt_hw_l3_mon_domain, d_resctrl); } =20 /** @@ -140,7 +140,7 @@ 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 -void arch_mon_domain_online(struct rdt_resource *r, struct rdt_mon_domain = *d); +void arch_mon_domain_online(struct rdt_resource *r, struct rdt_l3_mon_doma= in *d); =20 /* CPUID.(EAX=3D10H, ECX=3DResID=3D1).EAX */ union cpuid_0x10_1_eax { diff --git a/fs/resctrl/internal.h b/fs/resctrl/internal.h index 9912b774a580..af47b6ddef62 100644 --- a/fs/resctrl/internal.h +++ b/fs/resctrl/internal.h @@ -369,7 +369,7 @@ void mon_event_read(struct rmid_read *rr, struct rdt_re= source *r, =20 int resctrl_mon_resource_init(void); =20 -void mbm_setup_overflow_handler(struct rdt_mon_domain *dom, +void mbm_setup_overflow_handler(struct rdt_l3_mon_domain *dom, unsigned long delay_ms, int exclude_cpu); =20 @@ -377,14 +377,14 @@ void mbm_handle_overflow(struct work_struct *work); =20 bool is_mba_sc(struct rdt_resource *r); =20 -void cqm_setup_limbo_handler(struct rdt_mon_domain *dom, unsigned long del= ay_ms, +void cqm_setup_limbo_handler(struct rdt_l3_mon_domain *dom, unsigned long = delay_ms, int exclude_cpu); =20 void cqm_handle_limbo(struct work_struct *work); =20 -bool has_busy_rmid(struct rdt_mon_domain *d); +bool has_busy_rmid(struct rdt_l3_mon_domain *d); =20 -void __check_limbo(struct rdt_mon_domain *d, bool force_free); +void __check_limbo(struct rdt_l3_mon_domain *d, bool force_free); =20 void resctrl_file_fflags_init(const char *config, unsigned long fflags); =20 diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resct= rl/core.c index 1fab4c67d273..cc1b846f9645 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -368,7 +368,7 @@ static void ctrl_domain_free(struct rdt_hw_ctrl_domain = *hw_dom) kfree(hw_dom); } =20 -static void mon_domain_free(struct rdt_hw_mon_domain *hw_dom) +static void mon_domain_free(struct rdt_hw_l3_mon_domain *hw_dom) { int idx; =20 @@ -405,7 +405,7 @@ static int domain_setup_ctrlval(struct rdt_resource *r,= struct rdt_ctrl_domain * * @num_rmid: The size of the MBM counter array * @hw_dom: The domain that owns the allocated arrays */ -static int arch_domain_mbm_alloc(u32 num_rmid, struct rdt_hw_mon_domain *h= w_dom) +static int arch_domain_mbm_alloc(u32 num_rmid, struct rdt_hw_l3_mon_domain= *hw_dom) { size_t tsize =3D sizeof(*hw_dom->arch_mbm_states[0]); enum resctrl_event_id eventid; @@ -503,8 +503,8 @@ static void domain_add_cpu_ctrl(int cpu, struct rdt_res= ource *r) =20 static void l3_mon_domain_setup(int cpu, int id, struct rdt_resource *r, s= truct list_head *add_pos) { - struct rdt_hw_mon_domain *hw_dom; - struct rdt_mon_domain *d; + struct rdt_hw_l3_mon_domain *hw_dom; + struct rdt_l3_mon_domain *d; struct cacheinfo *ci; int err; =20 @@ -653,13 +653,13 @@ static void domain_remove_cpu_mon(int cpu, struct rdt= _resource *r) =20 switch (r->rid) { case RDT_RESOURCE_L3: { - struct rdt_hw_mon_domain *hw_dom; - struct rdt_mon_domain *d; + struct rdt_hw_l3_mon_domain *hw_dom; + struct rdt_l3_mon_domain *d; =20 if (!domain_header_is_valid(hdr, RESCTRL_MON_DOMAIN, RDT_RESOURCE_L3)) return; =20 - d =3D container_of(hdr, struct rdt_mon_domain, hdr); + d =3D container_of(hdr, struct rdt_l3_mon_domain, hdr); hw_dom =3D resctrl_to_arch_mon_dom(d); resctrl_offline_mon_domain(r, hdr); list_del_rcu(&hdr->list); diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/re= sctrl/monitor.c index 3da970ea1903..04b8f1e1f314 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -109,7 +109,7 @@ static inline u64 get_corrected_mbm_count(u32 rmid, uns= igned long val) * * In RMID sharing mode there are fewer "logical RMID" values available * to accumulate data ("physical RMIDs" are divided evenly between SNC - * nodes that share an L3 cache). Linux creates an rdt_mon_domain for + * nodes that share an L3 cache). Linux creates an rdt_l3_mon_domain for * each SNC node. * * The value loaded into IA32_PQR_ASSOC is the "logical RMID". @@ -157,7 +157,7 @@ static int __rmid_read_phys(u32 prmid, enum resctrl_eve= nt_id eventid, u64 *val) return 0; } =20 -static struct arch_mbm_state *get_arch_mbm_state(struct rdt_hw_mon_domain = *hw_dom, +static struct arch_mbm_state *get_arch_mbm_state(struct rdt_hw_l3_mon_doma= in *hw_dom, u32 rmid, enum resctrl_event_id eventid) { @@ -171,11 +171,11 @@ static struct arch_mbm_state *get_arch_mbm_state(stru= ct rdt_hw_mon_domain *hw_do return state ? &state[rmid] : NULL; } =20 -void resctrl_arch_reset_rmid(struct rdt_resource *r, struct rdt_mon_domain= *d, +void resctrl_arch_reset_rmid(struct rdt_resource *r, struct rdt_l3_mon_dom= ain *d, u32 unused, u32 rmid, enum resctrl_event_id eventid) { - struct rdt_hw_mon_domain *hw_dom =3D resctrl_to_arch_mon_dom(d); + struct rdt_hw_l3_mon_domain *hw_dom =3D resctrl_to_arch_mon_dom(d); int cpu =3D cpumask_any(&d->hdr.cpu_mask); struct arch_mbm_state *am; u32 prmid; @@ -194,9 +194,9 @@ void resctrl_arch_reset_rmid(struct rdt_resource *r, st= ruct rdt_mon_domain *d, * Assumes that hardware counters are also reset and thus that there is * no need to record initial non-zero counts. */ -void resctrl_arch_reset_rmid_all(struct rdt_resource *r, struct rdt_mon_do= main *d) +void resctrl_arch_reset_rmid_all(struct rdt_resource *r, struct rdt_l3_mon= _domain *d) { - struct rdt_hw_mon_domain *hw_dom =3D resctrl_to_arch_mon_dom(d); + struct rdt_hw_l3_mon_domain *hw_dom =3D resctrl_to_arch_mon_dom(d); enum resctrl_event_id eventid; int idx; =20 @@ -217,10 +217,10 @@ static u64 mbm_overflow_count(u64 prev_msr, u64 cur_m= sr, unsigned int width) return chunks >> shift; } =20 -static u64 get_corrected_val(struct rdt_resource *r, struct rdt_mon_domain= *d, +static u64 get_corrected_val(struct rdt_resource *r, struct rdt_l3_mon_dom= ain *d, u32 rmid, enum resctrl_event_id eventid, u64 msr_val) { - struct rdt_hw_mon_domain *hw_dom =3D resctrl_to_arch_mon_dom(d); + struct rdt_hw_l3_mon_domain *hw_dom =3D resctrl_to_arch_mon_dom(d); struct rdt_hw_resource *hw_res =3D resctrl_to_arch_res(r); struct arch_mbm_state *am; u64 chunks; @@ -242,9 +242,9 @@ int resctrl_arch_rmid_read(struct rdt_resource *r, stru= ct rdt_domain_hdr *hdr, u32 unused, u32 rmid, enum resctrl_event_id eventid, u64 *val, void *ignored) { - struct rdt_hw_mon_domain *hw_dom; + struct rdt_hw_l3_mon_domain *hw_dom; + struct rdt_l3_mon_domain *d; struct arch_mbm_state *am; - struct rdt_mon_domain *d; u64 msr_val; u32 prmid; int cpu; @@ -254,7 +254,7 @@ int resctrl_arch_rmid_read(struct rdt_resource *r, stru= ct rdt_domain_hdr *hdr, if (!domain_header_is_valid(hdr, RESCTRL_MON_DOMAIN, RDT_RESOURCE_L3)) return -EINVAL; =20 - d =3D container_of(hdr, struct rdt_mon_domain, hdr); + d =3D container_of(hdr, struct rdt_l3_mon_domain, hdr); hw_dom =3D resctrl_to_arch_mon_dom(d); cpu =3D cpumask_any(&hdr->cpu_mask); prmid =3D logical_rmid_to_physical_rmid(cpu, rmid); @@ -308,11 +308,11 @@ static int __cntr_id_read(u32 cntr_id, u64 *val) return 0; } =20 -void resctrl_arch_reset_cntr(struct rdt_resource *r, struct rdt_mon_domain= *d, +void resctrl_arch_reset_cntr(struct rdt_resource *r, struct rdt_l3_mon_dom= ain *d, u32 unused, u32 rmid, int cntr_id, enum resctrl_event_id eventid) { - struct rdt_hw_mon_domain *hw_dom =3D resctrl_to_arch_mon_dom(d); + struct rdt_hw_l3_mon_domain *hw_dom =3D resctrl_to_arch_mon_dom(d); struct arch_mbm_state *am; =20 am =3D get_arch_mbm_state(hw_dom, rmid, eventid); @@ -324,7 +324,7 @@ void resctrl_arch_reset_cntr(struct rdt_resource *r, st= ruct rdt_mon_domain *d, } } =20 -int resctrl_arch_cntr_read(struct rdt_resource *r, struct rdt_mon_domain *= d, +int resctrl_arch_cntr_read(struct rdt_resource *r, struct rdt_l3_mon_domai= n *d, u32 unused, u32 rmid, int cntr_id, enum resctrl_event_id eventid, u64 *val) { @@ -354,7 +354,7 @@ int resctrl_arch_cntr_read(struct rdt_resource *r, stru= ct rdt_mon_domain *d, * must adjust RMID counter numbers based on SNC node. See * logical_rmid_to_physical_rmid() for code that does this. */ -void arch_mon_domain_online(struct rdt_resource *r, struct rdt_mon_domain = *d) +void arch_mon_domain_online(struct rdt_resource *r, struct rdt_l3_mon_doma= in *d) { if (snc_nodes_per_l3_cache > 1) msr_clear_bit(MSR_RMID_SNC_CONFIG, 0); @@ -516,7 +516,7 @@ static void resctrl_abmc_set_one_amd(void *arg) */ static void _resctrl_abmc_enable(struct rdt_resource *r, bool enable) { - struct rdt_mon_domain *d; + struct rdt_l3_mon_domain *d; =20 lockdep_assert_cpus_held(); =20 @@ -555,11 +555,11 @@ static void resctrl_abmc_config_one_amd(void *info) /* * Send an IPI to the domain to assign the counter to RMID, event pair. */ -void resctrl_arch_config_cntr(struct rdt_resource *r, struct rdt_mon_domai= n *d, +void resctrl_arch_config_cntr(struct rdt_resource *r, struct rdt_l3_mon_do= main *d, enum resctrl_event_id evtid, u32 rmid, u32 closid, u32 cntr_id, bool assign) { - struct rdt_hw_mon_domain *hw_dom =3D resctrl_to_arch_mon_dom(d); + struct rdt_hw_l3_mon_domain *hw_dom =3D resctrl_to_arch_mon_dom(d); union l3_qos_abmc_cfg abmc_cfg =3D { 0 }; struct arch_mbm_state *am; =20 diff --git a/fs/resctrl/ctrlmondata.c b/fs/resctrl/ctrlmondata.c index 9242a2982e77..a3c734fe656e 100644 --- a/fs/resctrl/ctrlmondata.c +++ b/fs/resctrl/ctrlmondata.c @@ -600,9 +600,9 @@ int rdtgroup_mondata_show(struct seq_file *m, void *arg) struct kernfs_open_file *of =3D m->private; enum resctrl_res_level resid; enum resctrl_event_id evtid; + struct rdt_l3_mon_domain *d; struct rdt_domain_hdr *hdr; struct rmid_read rr =3D {0}; - struct rdt_mon_domain *d; struct rdtgroup *rdtgrp; int domid, cpu, ret =3D 0; struct rdt_resource *r; diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c index 7765491ddb4c..f90609212c86 100644 --- a/fs/resctrl/monitor.c +++ b/fs/resctrl/monitor.c @@ -130,7 +130,7 @@ static void limbo_release_entry(struct rmid_entry *entr= y) * decrement the count. If the busy count gets to zero on an RMID, we * free the RMID */ -void __check_limbo(struct rdt_mon_domain *d, bool force_free) +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(); @@ -188,7 +188,7 @@ void __check_limbo(struct rdt_mon_domain *d, bool force= _free) resctrl_arch_mon_ctx_free(r, QOS_L3_OCCUP_EVENT_ID, arch_mon_ctx); } =20 -bool has_busy_rmid(struct rdt_mon_domain *d) +bool has_busy_rmid(struct rdt_l3_mon_domain *d) { u32 idx_limit =3D resctrl_arch_system_num_rmid_idx(); =20 @@ -289,7 +289,7 @@ int alloc_rmid(u32 closid) static void add_rmid_to_limbo(struct rmid_entry *entry) { struct rdt_resource *r =3D resctrl_arch_get_resource(RDT_RESOURCE_L3); - struct rdt_mon_domain *d; + struct rdt_l3_mon_domain *d; u32 idx; =20 lockdep_assert_held(&rdtgroup_mutex); @@ -342,7 +342,7 @@ void free_rmid(u32 closid, u32 rmid) list_add_tail(&entry->list, &rmid_free_lru); } =20 -static struct mbm_state *get_mbm_state(struct rdt_mon_domain *d, u32 closi= d, +static struct mbm_state *get_mbm_state(struct rdt_l3_mon_domain *d, u32 cl= osid, u32 rmid, enum resctrl_event_id evtid) { u32 idx =3D resctrl_arch_rmid_idx_encode(closid, rmid); @@ -362,7 +362,7 @@ static struct mbm_state *get_mbm_state(struct rdt_mon_d= omain *d, u32 closid, * Return: * Valid counter ID on success, or -ENOENT on failure. */ -static int mbm_cntr_get(struct rdt_resource *r, struct rdt_mon_domain *d, +static int mbm_cntr_get(struct rdt_resource *r, struct rdt_l3_mon_domain *= d, struct rdtgroup *rdtgrp, enum resctrl_event_id evtid) { int cntr_id; @@ -389,7 +389,7 @@ static int mbm_cntr_get(struct rdt_resource *r, struct = rdt_mon_domain *d, * Return: * Valid counter ID on success, or -ENOSPC on failure. */ -static int mbm_cntr_alloc(struct rdt_resource *r, struct rdt_mon_domain *d, +static int mbm_cntr_alloc(struct rdt_resource *r, struct rdt_l3_mon_domain= *d, struct rdtgroup *rdtgrp, enum resctrl_event_id evtid) { int cntr_id; @@ -408,7 +408,7 @@ static int mbm_cntr_alloc(struct rdt_resource *r, struc= t rdt_mon_domain *d, /* * mbm_cntr_free() - Clear the counter ID configuration details in the dom= ain @d. */ -static void mbm_cntr_free(struct rdt_mon_domain *d, int cntr_id) +static void mbm_cntr_free(struct rdt_l3_mon_domain *d, int cntr_id) { memset(&d->cntr_cfg[cntr_id], 0, sizeof(*d->cntr_cfg)); } @@ -418,7 +418,7 @@ static int __l3_mon_event_count(struct rdtgroup *rdtgrp= , struct rmid_read *rr) int cpu =3D smp_processor_id(); u32 closid =3D rdtgrp->closid; u32 rmid =3D rdtgrp->mon.rmid; - struct rdt_mon_domain *d; + struct rdt_l3_mon_domain *d; int cntr_id =3D -ENOENT; struct mbm_state *m; u64 tval =3D 0; @@ -427,7 +427,7 @@ static int __l3_mon_event_count(struct rdtgroup *rdtgrp= , struct rmid_read *rr) rr->err =3D -EIO; return -EINVAL; } - d =3D container_of(rr->hdr, struct rdt_mon_domain, hdr); + d =3D container_of(rr->hdr, struct rdt_l3_mon_domain, hdr); =20 if (rr->is_mbm_cntr) { cntr_id =3D mbm_cntr_get(rr->r, d, rdtgrp, rr->evtid); @@ -470,7 +470,7 @@ static int __l3_mon_event_count_sum(struct rdtgroup *rd= tgrp, struct rmid_read *r int cpu =3D smp_processor_id(); u32 closid =3D rdtgrp->closid; u32 rmid =3D rdtgrp->mon.rmid; - struct rdt_mon_domain *d; + struct rdt_l3_mon_domain *d; int cntr_id =3D -ENOENT; u64 tval =3D 0; int err, ret; @@ -539,12 +539,12 @@ static void mbm_bw_count(struct rdtgroup *rdtgrp, str= uct rmid_read *rr) u64 cur_bw, bytes, cur_bytes; u32 closid =3D rdtgrp->closid; u32 rmid =3D rdtgrp->mon.rmid; - struct rdt_mon_domain *d; + struct rdt_l3_mon_domain *d; struct mbm_state *m; =20 if (!domain_header_is_valid(rr->hdr, RESCTRL_MON_DOMAIN, RDT_RESOURCE_L3)) return; - d =3D container_of(rr->hdr, struct rdt_mon_domain, hdr); + d =3D container_of(rr->hdr, struct rdt_l3_mon_domain, hdr); m =3D get_mbm_state(d, closid, rmid, rr->evtid); if (WARN_ON_ONCE(!m)) return; @@ -644,7 +644,7 @@ static struct rdt_ctrl_domain *get_ctrl_domain_from_cpu= (int cpu, * throttle MSRs already have low percentage values. To avoid * unnecessarily restricting such rdtgroups, we also increase the bandwidt= h. */ -static void update_mba_bw(struct rdtgroup *rgrp, struct rdt_mon_domain *do= m_mbm) +static void update_mba_bw(struct rdtgroup *rgrp, struct rdt_l3_mon_domain = *dom_mbm) { u32 closid, rmid, cur_msr_val, new_msr_val; struct mbm_state *pmbm_data, *cmbm_data; @@ -712,7 +712,7 @@ static void update_mba_bw(struct rdtgroup *rgrp, struct= rdt_mon_domain *dom_mbm) resctrl_arch_update_one(r_mba, dom_mba, closid, CDP_NONE, new_msr_val); } =20 -static void mbm_update_one_event(struct rdt_resource *r, struct rdt_mon_do= main *d, +static void mbm_update_one_event(struct rdt_resource *r, struct rdt_l3_mon= _domain *d, struct rdtgroup *rdtgrp, enum resctrl_event_id evtid) { struct rmid_read rr =3D {0}; @@ -744,7 +744,7 @@ static void mbm_update_one_event(struct rdt_resource *r= , struct rdt_mon_domain * resctrl_arch_mon_ctx_free(rr.r, rr.evtid, rr.arch_mon_ctx); } =20 -static void mbm_update(struct rdt_resource *r, struct rdt_mon_domain *d, +static void mbm_update(struct rdt_resource *r, struct rdt_l3_mon_domain *d, struct rdtgroup *rdtgrp) { /* @@ -765,12 +765,12 @@ static void mbm_update(struct rdt_resource *r, struct= rdt_mon_domain *d, void cqm_handle_limbo(struct work_struct *work) { unsigned long delay =3D msecs_to_jiffies(CQM_LIMBOCHECK_INTERVAL); - struct rdt_mon_domain *d; + struct rdt_l3_mon_domain *d; =20 cpus_read_lock(); mutex_lock(&rdtgroup_mutex); =20 - d =3D container_of(work, struct rdt_mon_domain, cqm_limbo.work); + d =3D container_of(work, struct rdt_l3_mon_domain, cqm_limbo.work); =20 __check_limbo(d, false); =20 @@ -793,7 +793,7 @@ void cqm_handle_limbo(struct work_struct *work) * @exclude_cpu: Which CPU the handler should not run on, * RESCTRL_PICK_ANY_CPU to pick any CPU. */ -void cqm_setup_limbo_handler(struct rdt_mon_domain *dom, unsigned long del= ay_ms, +void cqm_setup_limbo_handler(struct rdt_l3_mon_domain *dom, unsigned long = delay_ms, int exclude_cpu) { unsigned long delay =3D msecs_to_jiffies(delay_ms); @@ -810,7 +810,7 @@ void mbm_handle_overflow(struct work_struct *work) { unsigned long delay =3D msecs_to_jiffies(MBM_OVERFLOW_INTERVAL); struct rdtgroup *prgrp, *crgrp; - struct rdt_mon_domain *d; + struct rdt_l3_mon_domain *d; struct list_head *head; struct rdt_resource *r; =20 @@ -825,7 +825,7 @@ void mbm_handle_overflow(struct work_struct *work) goto out_unlock; =20 r =3D resctrl_arch_get_resource(RDT_RESOURCE_L3); - d =3D container_of(work, struct rdt_mon_domain, mbm_over.work); + d =3D container_of(work, struct rdt_l3_mon_domain, mbm_over.work); =20 list_for_each_entry(prgrp, &rdt_all_groups, rdtgroup_list) { mbm_update(r, d, prgrp); @@ -859,7 +859,7 @@ void mbm_handle_overflow(struct work_struct *work) * @exclude_cpu: Which CPU the handler should not run on, * RESCTRL_PICK_ANY_CPU to pick any CPU. */ -void mbm_setup_overflow_handler(struct rdt_mon_domain *dom, unsigned long = delay_ms, +void mbm_setup_overflow_handler(struct rdt_l3_mon_domain *dom, unsigned lo= ng delay_ms, int exclude_cpu) { unsigned long delay =3D msecs_to_jiffies(delay_ms); @@ -1114,7 +1114,7 @@ ssize_t resctrl_mbm_assign_on_mkdir_write(struct kern= fs_open_file *of, char *buf * mbm_cntr_free_all() - Clear all the counter ID configuration details in= the * domain @d. Called when mbm_assign_mode is changed. */ -static void mbm_cntr_free_all(struct rdt_resource *r, struct rdt_mon_domai= n *d) +static void mbm_cntr_free_all(struct rdt_resource *r, struct rdt_l3_mon_do= main *d) { memset(d->cntr_cfg, 0, sizeof(*d->cntr_cfg) * r->mon.num_mbm_cntrs); } @@ -1123,7 +1123,7 @@ static void mbm_cntr_free_all(struct rdt_resource *r,= struct rdt_mon_domain *d) * resctrl_reset_rmid_all() - Reset all non-architecture states for all the * supported RMIDs. */ -static void resctrl_reset_rmid_all(struct rdt_resource *r, struct rdt_mon_= domain *d) +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(); enum resctrl_event_id evt; @@ -1144,7 +1144,7 @@ static void resctrl_reset_rmid_all(struct rdt_resourc= e *r, struct rdt_mon_domain * Assign the counter if @assign is true else unassign the counter. Reset = the * associated non-architectural state. */ -static void rdtgroup_assign_cntr(struct rdt_resource *r, struct rdt_mon_do= main *d, +static void rdtgroup_assign_cntr(struct rdt_resource *r, struct rdt_l3_mon= _domain *d, enum resctrl_event_id evtid, u32 rmid, u32 closid, u32 cntr_id, bool assign) { @@ -1164,7 +1164,7 @@ static void rdtgroup_assign_cntr(struct rdt_resource = *r, struct rdt_mon_domain * * Return: * 0 on success, < 0 on failure. */ -static int rdtgroup_alloc_assign_cntr(struct rdt_resource *r, struct rdt_m= on_domain *d, +static int rdtgroup_alloc_assign_cntr(struct rdt_resource *r, struct rdt_l= 3_mon_domain *d, struct rdtgroup *rdtgrp, struct mon_evt *mevt) { int cntr_id; @@ -1199,7 +1199,7 @@ static int rdtgroup_alloc_assign_cntr(struct rdt_reso= urce *r, struct rdt_mon_dom * Return: * 0 on success, < 0 on failure. */ -static int rdtgroup_assign_cntr_event(struct rdt_mon_domain *d, struct rdt= group *rdtgrp, +static int rdtgroup_assign_cntr_event(struct rdt_l3_mon_domain *d, struct = rdtgroup *rdtgrp, struct mon_evt *mevt) { struct rdt_resource *r =3D resctrl_arch_get_resource(mevt->rid); @@ -1249,7 +1249,7 @@ void rdtgroup_assign_cntrs(struct rdtgroup *rdtgrp) * rdtgroup_free_unassign_cntr() - Unassign and reset the counter ID confi= guration * for the event pointed to by @mevt within the domain @d and resctrl grou= p @rdtgrp. */ -static void rdtgroup_free_unassign_cntr(struct rdt_resource *r, struct rdt= _mon_domain *d, +static void rdtgroup_free_unassign_cntr(struct rdt_resource *r, struct rdt= _l3_mon_domain *d, struct rdtgroup *rdtgrp, struct mon_evt *mevt) { int cntr_id; @@ -1270,7 +1270,7 @@ static void rdtgroup_free_unassign_cntr(struct rdt_re= source *r, struct rdt_mon_d * the event structure @mevt from the domain @d and the group @rdtgrp. Una= ssign * the counters from all the domains if @d is NULL else unassign from @d. */ -static void rdtgroup_unassign_cntr_event(struct rdt_mon_domain *d, struct = rdtgroup *rdtgrp, +static void rdtgroup_unassign_cntr_event(struct rdt_l3_mon_domain *d, stru= ct rdtgroup *rdtgrp, struct mon_evt *mevt) { struct rdt_resource *r =3D resctrl_arch_get_resource(mevt->rid); @@ -1345,7 +1345,7 @@ static int resctrl_parse_mem_transactions(char *tok, = u32 *val) static void rdtgroup_update_cntr_event(struct rdt_resource *r, struct rdtg= roup *rdtgrp, enum resctrl_event_id evtid) { - struct rdt_mon_domain *d; + struct rdt_l3_mon_domain *d; int cntr_id; =20 list_for_each_entry(d, &r->mon_domains, hdr.list) { @@ -1451,7 +1451,7 @@ ssize_t resctrl_mbm_assign_mode_write(struct kernfs_o= pen_file *of, char *buf, size_t nbytes, loff_t off) { struct rdt_resource *r =3D rdt_kn_parent_priv(of->kn); - struct rdt_mon_domain *d; + struct rdt_l3_mon_domain *d; int ret =3D 0; bool enable; =20 @@ -1524,7 +1524,7 @@ int resctrl_num_mbm_cntrs_show(struct kernfs_open_fil= e *of, struct seq_file *s, void *v) { struct rdt_resource *r =3D rdt_kn_parent_priv(of->kn); - struct rdt_mon_domain *dom; + struct rdt_l3_mon_domain *dom; bool sep =3D false; =20 cpus_read_lock(); @@ -1548,7 +1548,7 @@ int resctrl_available_mbm_cntrs_show(struct kernfs_op= en_file *of, struct seq_file *s, void *v) { struct rdt_resource *r =3D rdt_kn_parent_priv(of->kn); - struct rdt_mon_domain *dom; + struct rdt_l3_mon_domain *dom; bool sep =3D false; u32 cntrs, i; int ret =3D 0; @@ -1589,7 +1589,7 @@ int resctrl_available_mbm_cntrs_show(struct kernfs_op= en_file *of, int mbm_L3_assignments_show(struct kernfs_open_file *of, struct seq_file *= s, void *v) { struct rdt_resource *r =3D resctrl_arch_get_resource(RDT_RESOURCE_L3); - struct rdt_mon_domain *d; + struct rdt_l3_mon_domain *d; struct rdtgroup *rdtgrp; struct mon_evt *mevt; int ret =3D 0; @@ -1652,7 +1652,7 @@ static struct mon_evt *mbm_get_mon_event_by_name(stru= ct rdt_resource *r, char *n return NULL; } =20 -static int rdtgroup_modify_assign_state(char *assign, struct rdt_mon_domai= n *d, +static int rdtgroup_modify_assign_state(char *assign, struct rdt_l3_mon_do= main *d, struct rdtgroup *rdtgrp, struct mon_evt *mevt) { int ret =3D 0; @@ -1678,7 +1678,7 @@ static int rdtgroup_modify_assign_state(char *assign,= struct rdt_mon_domain *d, static int resctrl_parse_mbm_assignment(struct rdt_resource *r, struct rdt= group *rdtgrp, char *event, char *tok) { - struct rdt_mon_domain *d; + struct rdt_l3_mon_domain *d; unsigned long dom_id =3D 0; char *dom_str, *id_str; struct mon_evt *mevt; diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c index 89ffe54fb0fc..2ed435db1923 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -1640,7 +1640,7 @@ static void mondata_config_read(struct resctrl_mon_co= nfig_info *mon_info) static int mbm_config_show(struct seq_file *s, struct rdt_resource *r, u32= evtid) { struct resctrl_mon_config_info mon_info; - struct rdt_mon_domain *dom; + struct rdt_l3_mon_domain *dom; bool sep =3D false; =20 cpus_read_lock(); @@ -1688,7 +1688,7 @@ static int mbm_local_bytes_config_show(struct kernfs_= open_file *of, } =20 static void mbm_config_write_domain(struct rdt_resource *r, - struct rdt_mon_domain *d, u32 evtid, u32 val) + struct rdt_l3_mon_domain *d, u32 evtid, u32 val) { struct resctrl_mon_config_info mon_info =3D {0}; =20 @@ -1729,8 +1729,8 @@ static void mbm_config_write_domain(struct rdt_resour= ce *r, static int mon_config_write(struct rdt_resource *r, char *tok, u32 evtid) { char *dom_str =3D NULL, *id_str; + struct rdt_l3_mon_domain *d; unsigned long dom_id, val; - struct rdt_mon_domain *d; =20 /* Walking r->domains, ensure it can't race with cpuhp */ lockdep_assert_cpus_held(); @@ -2781,7 +2781,7 @@ static int rdt_get_tree(struct fs_context *fc) { struct rdt_fs_context *ctx =3D rdt_fc2context(fc); unsigned long flags =3D RFTYPE_CTRL_BASE; - struct rdt_mon_domain *dom; + struct rdt_l3_mon_domain *dom; struct rdt_resource *r; int ret; =20 @@ -3232,7 +3232,7 @@ static void rmdir_mondata_subdir_allrdtgrp(struct rdt= _resource *r, struct rdt_domain_hdr *hdr) { struct rdtgroup *prgrp, *crgrp; - struct rdt_mon_domain *d; + struct rdt_l3_mon_domain *d; char subname[32]; bool snc_mode; char name[32]; @@ -3240,7 +3240,7 @@ static void rmdir_mondata_subdir_allrdtgrp(struct rdt= _resource *r, if (!domain_header_is_valid(hdr, RESCTRL_MON_DOMAIN, RDT_RESOURCE_L3)) return; =20 - d =3D container_of(hdr, struct rdt_mon_domain, hdr); + d =3D container_of(hdr, struct rdt_l3_mon_domain, hdr); snc_mode =3D r->mon_scope =3D=3D RESCTRL_L3_NODE; sprintf(name, "mon_%s_%02d", r->name, snc_mode ? d->ci_id : hdr->id); if (snc_mode) @@ -3258,8 +3258,8 @@ static int mon_add_all_files(struct kernfs_node *kn, = struct rdt_domain_hdr *hdr, struct rdt_resource *r, struct rdtgroup *prgrp, bool do_sum) { + struct rdt_l3_mon_domain *d; struct rmid_read rr =3D {0}; - struct rdt_mon_domain *d; struct mon_data *priv; struct mon_evt *mevt; int ret, domid; @@ -3267,7 +3267,7 @@ static int mon_add_all_files(struct kernfs_node *kn, = struct rdt_domain_hdr *hdr, if (!domain_header_is_valid(hdr, RESCTRL_MON_DOMAIN, RDT_RESOURCE_L3)) return -EINVAL; =20 - d =3D container_of(hdr, struct rdt_mon_domain, hdr); + d =3D container_of(hdr, struct rdt_l3_mon_domain, hdr); for_each_mon_event(mevt) { if (mevt->rid !=3D r->rid || !mevt->enabled) continue; @@ -3292,7 +3292,7 @@ static int mkdir_mondata_subdir(struct kernfs_node *p= arent_kn, struct rdt_resource *r, struct rdtgroup *prgrp) { struct kernfs_node *kn, *ckn; - struct rdt_mon_domain *d; + struct rdt_l3_mon_domain *d; char name[32]; bool snc_mode; int ret =3D 0; @@ -3302,7 +3302,7 @@ static int mkdir_mondata_subdir(struct kernfs_node *p= arent_kn, if (!domain_header_is_valid(hdr, RESCTRL_MON_DOMAIN, RDT_RESOURCE_L3)) return -EINVAL; =20 - d =3D container_of(hdr, struct rdt_mon_domain, hdr); + d =3D container_of(hdr, struct rdt_l3_mon_domain, hdr); snc_mode =3D r->mon_scope =3D=3D RESCTRL_L3_NODE; sprintf(name, "mon_%s_%02d", r->name, snc_mode ? d->ci_id : d->hdr.id); kn =3D kernfs_find_and_get(parent_kn, name); @@ -4246,7 +4246,7 @@ static void rdtgroup_setup_default(void) mutex_unlock(&rdtgroup_mutex); } =20 -static void domain_destroy_mon_state(struct rdt_mon_domain *d) +static void domain_destroy_mon_state(struct rdt_l3_mon_domain *d) { int idx; =20 @@ -4270,14 +4270,14 @@ void resctrl_offline_ctrl_domain(struct rdt_resourc= e *r, struct rdt_ctrl_domain =20 void resctrl_offline_mon_domain(struct rdt_resource *r, struct rdt_domain_= hdr *hdr) { - struct rdt_mon_domain *d; + struct rdt_l3_mon_domain *d; =20 mutex_lock(&rdtgroup_mutex); =20 if (!domain_header_is_valid(hdr, RESCTRL_MON_DOMAIN, RDT_RESOURCE_L3)) goto out_unlock; =20 - d =3D container_of(hdr, struct rdt_mon_domain, hdr); + d =3D container_of(hdr, struct rdt_l3_mon_domain, hdr); =20 /* * If resctrl is mounted, remove all the @@ -4319,7 +4319,7 @@ void resctrl_offline_mon_domain(struct rdt_resource *= r, struct rdt_domain_hdr *h * * Returns 0 for success, or -ENOMEM. */ -static int domain_setup_mon_state(struct rdt_resource *r, struct rdt_mon_d= omain *d) +static int domain_setup_mon_state(struct rdt_resource *r, struct rdt_l3_mo= n_domain *d) { u32 idx_limit =3D resctrl_arch_system_num_rmid_idx(); size_t tsize =3D sizeof(*d->mbm_states[0]); @@ -4377,7 +4377,7 @@ int resctrl_online_ctrl_domain(struct rdt_resource *r= , struct rdt_ctrl_domain *d =20 int resctrl_online_mon_domain(struct rdt_resource *r, struct rdt_domain_hd= r *hdr) { - struct rdt_mon_domain *d; + struct rdt_l3_mon_domain *d; int err =3D -EINVAL; =20 mutex_lock(&rdtgroup_mutex); @@ -4385,7 +4385,7 @@ int resctrl_online_mon_domain(struct rdt_resource *r,= struct rdt_domain_hdr *hdr if (!domain_header_is_valid(hdr, RESCTRL_MON_DOMAIN, RDT_RESOURCE_L3)) goto out_unlock; =20 - d =3D container_of(hdr, struct rdt_mon_domain, hdr); + d =3D container_of(hdr, struct rdt_l3_mon_domain, hdr); err =3D domain_setup_mon_state(r, d); if (err) goto out_unlock; @@ -4432,10 +4432,10 @@ static void clear_childcpus(struct rdtgroup *r, uns= igned int cpu) } } =20 -static struct rdt_mon_domain *get_mon_domain_from_cpu(int cpu, - struct rdt_resource *r) +static struct rdt_l3_mon_domain *get_mon_domain_from_cpu(int cpu, + struct rdt_resource *r) { - struct rdt_mon_domain *d; + struct rdt_l3_mon_domain *d; =20 lockdep_assert_cpus_held(); =20 @@ -4451,7 +4451,7 @@ static struct rdt_mon_domain *get_mon_domain_from_cpu= (int cpu, void resctrl_offline_cpu(unsigned int cpu) { struct rdt_resource *l3 =3D resctrl_arch_get_resource(RDT_RESOURCE_L3); - struct rdt_mon_domain *d; + struct rdt_l3_mon_domain *d; struct rdtgroup *rdtgrp; =20 mutex_lock(&rdtgroup_mutex); --=20 2.51.1 From nobody Tue Dec 2 00:25:23 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 61E3F31ED86 for ; Mon, 24 Nov 2025 18:54:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764010492; cv=none; b=lZ4FwWy22KgY+nTTt+RUotIVhA0fF6XkC74kUXjQ1xabZxNW9jx68N29zQq33BZiWUXTlaXKbHEYapKMcJ3/op7rlJAKigCO//VNK/yN5ZgEFGFIfaFlnjZ1/F0a5FLQYGnvjmX7UjMBSLSmSMTpD6PbtedvgTx2J9mbshkrLQc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764010492; c=relaxed/simple; bh=ef6nO40LtM4aQkzZYnZnb01vK8vpsMZNATtiZokKjdQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MdJG7rOEwM6Vq3eM8plASFv7cz2v7Y2YUSHmwxhdsZsx5O9boVfaJbWtKjXczSEmUJBt74cS1r+3f5YoYewQ42BQwdNyr07t66bTcJrbEaxVSC4TRzMLFLqiA48XZuSXN33B7EwO/6d3TJfscApjzcc5uthMeEzBv4J6+b8b+lY= 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=fzwQDiix; arc=none smtp.client-ip=192.198.163.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="fzwQDiix" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1764010490; x=1795546490; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ef6nO40LtM4aQkzZYnZnb01vK8vpsMZNATtiZokKjdQ=; b=fzwQDiixocb6TceLgdTF6XIIkauFo2DwkFWZMSBuZVAGEe6RTM81XIc7 weLEkJthPTUc2HDKt93Z16TmqRO3bEajCpjchEty9cmTa1Ctt/HQcIF3A hYY5sS7oEqtisI4w1WLZevVmcl9tCvzGXh0rBRKvTbvVhA3VD1Flw9O2Y VdqrY3HPw2Ry8m4DenQQ6FCI2yJz9ZjnkSpqYBT6tY4ZiXcgNHrFtaz1s MOK1p3h6Gjby2awg+UoOu6BwBKBMpQiZ9aPklOwMHiwGWSput7yZywEm/ e2y2R8kFl9eQzEFL8AmT66EzwLWy+jRe8/GBIjjzdp/X1xBvxHWjiywl4 A==; X-CSE-ConnectionGUID: htFjhaueThW47IsgmjcCnA== X-CSE-MsgGUID: XdB0m7V6StWL2K/3uMNmuQ== X-IronPort-AV: E=McAfee;i="6800,10657,11623"; a="76636563" X-IronPort-AV: E=Sophos;i="6.20,223,1758610800"; d="scan'208";a="76636563" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Nov 2025 10:54:24 -0800 X-CSE-ConnectionGUID: 1JPrWc9vQf6Prh6Aga3zSw== X-CSE-MsgGUID: pFXHpdd4Qs+Jx18BZDPzgA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.20,223,1758610800"; d="scan'208";a="192224969" Received: from rfrazer-mobl3.amr.corp.intel.com (HELO agluck-desk3.home.arpa) ([10.124.222.153]) by orviesa009-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Nov 2025 10:54:24 -0800 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Maciej Wieczor-Retman , Peter Newman , James Morse , Babu Moger , Drew Fustini , Dave Martin , Chen Yu Cc: x86@kernel.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [PATCH v14 09/32] x86,fs/resctrl: Rename some L3 specific functions Date: Mon, 24 Nov 2025 10:53:46 -0800 Message-ID: <20251124185412.24155-10-tony.luck@intel.com> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251124185412.24155-1-tony.luck@intel.com> References: <20251124185412.24155-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" With the arrival of monitor events tied to new domains associated with a different resource it would be clearer if the L3 resource specific functions are more accurately named. Rename three groups of functions: Functions that allocate/free architecture per-RMID MBM state information: arch_domain_mbm_alloc() -> l3_mon_domain_mbm_alloc() mon_domain_free() -> l3_mon_domain_free() Functions that allocate/free filesystem per-RMID MBM state information: domain_setup_mon_state() -> domain_setup_l3_mon_state() domain_destroy_mon_state() -> domain_destroy_l3_mon_state() Initialization/exit: rdt_get_mon_l3_config() -> rdt_get_l3_mon_config() resctrl_mon_resource_init() -> resctrl_l3_mon_resource_init() resctrl_mon_resource_exit() -> resctrl_l3_mon_resource_exit() Ensure kernel-doc descriptions of these functions' return values are present and correctly formatted. Signed-off-by: Tony Luck Reviewed-by: Reinette Chatre --- arch/x86/kernel/cpu/resctrl/internal.h | 2 +- fs/resctrl/internal.h | 6 +++--- arch/x86/kernel/cpu/resctrl/core.c | 20 +++++++++++--------- arch/x86/kernel/cpu/resctrl/monitor.c | 2 +- fs/resctrl/monitor.c | 8 ++++---- fs/resctrl/rdtgroup.c | 24 ++++++++++++------------ 6 files changed, 32 insertions(+), 30 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/r= esctrl/internal.h index d6da21d4684b..ae182b5f9a3c 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -213,7 +213,7 @@ union l3_qos_abmc_cfg { =20 void rdt_ctrl_update(void *arg); =20 -int rdt_get_mon_l3_config(struct rdt_resource *r); +int rdt_get_l3_mon_config(struct rdt_resource *r); =20 bool rdt_cpu_has(int flag); =20 diff --git a/fs/resctrl/internal.h b/fs/resctrl/internal.h index af47b6ddef62..9768341aa21c 100644 --- a/fs/resctrl/internal.h +++ b/fs/resctrl/internal.h @@ -357,7 +357,9 @@ int alloc_rmid(u32 closid); =20 void free_rmid(u32 closid, u32 rmid); =20 -void resctrl_mon_resource_exit(void); +int resctrl_l3_mon_resource_init(void); + +void resctrl_l3_mon_resource_exit(void); =20 void mon_event_count(void *info); =20 @@ -367,8 +369,6 @@ void mon_event_read(struct rmid_read *rr, struct rdt_re= source *r, struct rdt_domain_hdr *hdr, struct rdtgroup *rdtgrp, cpumask_t *cpumask, int evtid, int first); =20 -int resctrl_mon_resource_init(void); - void mbm_setup_overflow_handler(struct rdt_l3_mon_domain *dom, unsigned long delay_ms, int exclude_cpu); diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resct= rl/core.c index cc1b846f9645..b3a2dc56155d 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -368,7 +368,7 @@ static void ctrl_domain_free(struct rdt_hw_ctrl_domain = *hw_dom) kfree(hw_dom); } =20 -static void mon_domain_free(struct rdt_hw_l3_mon_domain *hw_dom) +static void l3_mon_domain_free(struct rdt_hw_l3_mon_domain *hw_dom) { int idx; =20 @@ -401,11 +401,13 @@ static int domain_setup_ctrlval(struct rdt_resource *= r, struct rdt_ctrl_domain * } =20 /** - * arch_domain_mbm_alloc() - Allocate arch private storage for the MBM cou= nters + * l3_mon_domain_mbm_alloc() - Allocate arch private storage for the MBM c= ounters * @num_rmid: The size of the MBM counter array * @hw_dom: The domain that owns the allocated arrays + * + * Return: 0 for success, or -ENOMEM. */ -static int arch_domain_mbm_alloc(u32 num_rmid, struct rdt_hw_l3_mon_domain= *hw_dom) +static int l3_mon_domain_mbm_alloc(u32 num_rmid, struct rdt_hw_l3_mon_doma= in *hw_dom) { size_t tsize =3D sizeof(*hw_dom->arch_mbm_states[0]); enum resctrl_event_id eventid; @@ -519,7 +521,7 @@ static void l3_mon_domain_setup(int cpu, int id, struct= rdt_resource *r, struct ci =3D get_cpu_cacheinfo_level(cpu, RESCTRL_L3_CACHE); if (!ci) { pr_warn_once("Can't find L3 cache for CPU:%d resource %s\n", cpu, r->nam= e); - mon_domain_free(hw_dom); + l3_mon_domain_free(hw_dom); return; } d->ci_id =3D ci->id; @@ -527,8 +529,8 @@ static void l3_mon_domain_setup(int cpu, int id, struct= rdt_resource *r, struct =20 arch_mon_domain_online(r, d); =20 - if (arch_domain_mbm_alloc(r->mon.num_rmid, hw_dom)) { - mon_domain_free(hw_dom); + if (l3_mon_domain_mbm_alloc(r->mon.num_rmid, hw_dom)) { + l3_mon_domain_free(hw_dom); return; } =20 @@ -538,7 +540,7 @@ static void l3_mon_domain_setup(int cpu, int id, struct= rdt_resource *r, struct if (err) { list_del_rcu(&d->hdr.list); synchronize_rcu(); - mon_domain_free(hw_dom); + l3_mon_domain_free(hw_dom); } } =20 @@ -664,7 +666,7 @@ static void domain_remove_cpu_mon(int cpu, struct rdt_r= esource *r) resctrl_offline_mon_domain(r, hdr); list_del_rcu(&hdr->list); synchronize_rcu(); - mon_domain_free(hw_dom); + l3_mon_domain_free(hw_dom); break; } default: @@ -917,7 +919,7 @@ static __init bool get_rdt_mon_resources(void) if (!ret) return false; =20 - return !rdt_get_mon_l3_config(r); + return !rdt_get_l3_mon_config(r); } =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 04b8f1e1f314..20605212656c 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -424,7 +424,7 @@ static __init int snc_get_config(void) return ret; } =20 -int __init rdt_get_mon_l3_config(struct rdt_resource *r) +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); diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c index f90609212c86..cbd9dd5656af 100644 --- a/fs/resctrl/monitor.c +++ b/fs/resctrl/monitor.c @@ -1774,7 +1774,7 @@ ssize_t mbm_L3_assignments_write(struct kernfs_open_f= ile *of, char *buf, } =20 /** - * resctrl_mon_resource_init() - Initialise global monitoring structures. + * resctrl_l3_mon_resource_init() - Initialise global monitoring structure= s. * * Allocate and initialise global monitor resources that do not belong to a * specific domain. i.e. the rmid_ptrs[] used for the limbo and free lists. @@ -1783,9 +1783,9 @@ ssize_t mbm_L3_assignments_write(struct kernfs_open_f= ile *of, char *buf, * Resctrl's cpuhp callbacks may be called before this point to bring a do= main * online. * - * Returns 0 for success, or -ENOMEM. + * Return: 0 for success, or -ENOMEM. */ -int resctrl_mon_resource_init(void) +int resctrl_l3_mon_resource_init(void) { struct rdt_resource *r =3D resctrl_arch_get_resource(RDT_RESOURCE_L3); int ret; @@ -1835,7 +1835,7 @@ int resctrl_mon_resource_init(void) return 0; } =20 -void resctrl_mon_resource_exit(void) +void resctrl_l3_mon_resource_exit(void) { struct rdt_resource *r =3D resctrl_arch_get_resource(RDT_RESOURCE_L3); =20 diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c index 2ed435db1923..b57e1e78bbc2 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -4246,7 +4246,7 @@ static void rdtgroup_setup_default(void) mutex_unlock(&rdtgroup_mutex); } =20 -static void domain_destroy_mon_state(struct rdt_l3_mon_domain *d) +static void domain_destroy_l3_mon_state(struct rdt_l3_mon_domain *d) { int idx; =20 @@ -4301,13 +4301,13 @@ void resctrl_offline_mon_domain(struct rdt_resource= *r, struct rdt_domain_hdr *h cancel_delayed_work(&d->cqm_limbo); } =20 - domain_destroy_mon_state(d); + domain_destroy_l3_mon_state(d); out_unlock: mutex_unlock(&rdtgroup_mutex); } =20 /** - * domain_setup_mon_state() - Initialise domain monitoring structures. + * domain_setup_l3_mon_state() - Initialise domain monitoring structures. * @r: The resource for the newly online domain. * @d: The newly online domain. * @@ -4315,11 +4315,11 @@ void resctrl_offline_mon_domain(struct rdt_resource= *r, struct rdt_domain_hdr *h * Called when the first CPU of a domain comes online, regardless of wheth= er * the filesystem is mounted. * During boot this may be called before global allocations have been made= by - * resctrl_mon_resource_init(). + * resctrl_l3_mon_resource_init(). * - * Returns 0 for success, or -ENOMEM. + * Return: 0 for success, or -ENOMEM. */ -static int domain_setup_mon_state(struct rdt_resource *r, struct rdt_l3_mo= n_domain *d) +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(); size_t tsize =3D sizeof(*d->mbm_states[0]); @@ -4386,7 +4386,7 @@ int resctrl_online_mon_domain(struct rdt_resource *r,= struct rdt_domain_hdr *hdr goto out_unlock; =20 d =3D container_of(hdr, struct rdt_l3_mon_domain, hdr); - err =3D domain_setup_mon_state(r, d); + err =3D domain_setup_l3_mon_state(r, d); if (err) goto out_unlock; =20 @@ -4503,13 +4503,13 @@ int resctrl_init(void) =20 io_alloc_init(); =20 - ret =3D resctrl_mon_resource_init(); + ret =3D resctrl_l3_mon_resource_init(); if (ret) return ret; =20 ret =3D sysfs_create_mount_point(fs_kobj, "resctrl"); if (ret) { - resctrl_mon_resource_exit(); + resctrl_l3_mon_resource_exit(); return ret; } =20 @@ -4544,7 +4544,7 @@ int resctrl_init(void) =20 cleanup_mountpoint: sysfs_remove_mount_point(fs_kobj, "resctrl"); - resctrl_mon_resource_exit(); + resctrl_l3_mon_resource_exit(); =20 return ret; } @@ -4580,7 +4580,7 @@ static bool resctrl_online_domains_exist(void) * When called by the architecture code, all CPUs and resctrl domains must= be * offline. This ensures the limbo and overflow handlers are not scheduled= to * run, meaning the data structures they access can be freed by - * resctrl_mon_resource_exit(). + * resctrl_l3_mon_resource_exit(). * * After resctrl_exit() returns, the architecture code should return an * error from all resctrl_arch_ functions that can do this. @@ -4607,5 +4607,5 @@ void resctrl_exit(void) * it can be used to umount resctrl. */ =20 - resctrl_mon_resource_exit(); + resctrl_l3_mon_resource_exit(); } --=20 2.51.1 From nobody Tue Dec 2 00:25:23 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 518C7320A09 for ; Mon, 24 Nov 2025 18:54:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764010494; cv=none; b=fd4Khhx4xnBB5uVisFKE00h/VIgoyF0i038aseK/OYefWs3CBKJxShSvoxOPrnE2dq6qVJAqLwrIgcR1xB3hWeHPwtaByaOsnFnb2U2EpPFe8I2hnEjYBrjiQxwaQZlzfK9QR4BUYqnGqcM39z3ue1ZvPN+1GrOycJ255MYjv1M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764010494; c=relaxed/simple; bh=1Lg9QO4b0dxS8GCGSgAmVs74S3fikL9rrwIzqra9kZM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=o3ZSQkcPGcZ7l843n//tzwbe5k3wqKCbjBTZUtGq/+hMcBhWVa3eIMJSZv9f/soZ6RlzKka/+fz2Q/KPOiGZUuU3eLqNx/dz6hIkuvdKszBIx575qUsruqR26ARuLRgpSUY21K82h5k6jRnTOhupSc6srlrDbVBs4OMRGqZN/n8= 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=XnkEmgnP; arc=none smtp.client-ip=192.198.163.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="XnkEmgnP" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1764010492; x=1795546492; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=1Lg9QO4b0dxS8GCGSgAmVs74S3fikL9rrwIzqra9kZM=; b=XnkEmgnPVWmsE0tg8bC0OjPXSCEl+s2oeHwzZloHUYe+r2aqtJNfPbD8 Pn+L9gkhzwQiLTH0emr7li/iqyhEwg9sIxYhky7B/WwzwhnUx6HQO6gic iE1syulOk3iWf/hFELNcn+DwZJtlhBWzExhyAhebsU713BxpTxlQ8hTpe AG4NnStmguv1L+6JyK8dHKj9fby7fXqhCemSbOZMSk4tYIydVjUGsJqns vXWkOn3MWmFRhmtdrLdGJtfx7bJbVxoAHXj20a1nduFgD/UtftuIJfrUx LnmjQE4YkGfFYZQDbH4/+7IBvXqReTzvd8OgU9SMASrmroGKHorh+T83N Q==; X-CSE-ConnectionGUID: J7WfyqSyRTmaFnd/SlVXPw== X-CSE-MsgGUID: 2Mleh9q/Thq0/S3zOjqc0A== X-IronPort-AV: E=McAfee;i="6800,10657,11623"; a="76636579" X-IronPort-AV: E=Sophos;i="6.20,223,1758610800"; d="scan'208";a="76636579" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Nov 2025 10:54:25 -0800 X-CSE-ConnectionGUID: 7F19BqNoT2auQCwsXLSzIA== X-CSE-MsgGUID: iBajUwzGQ9GLJ/DxtCWHqg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.20,223,1758610800"; d="scan'208";a="192224973" Received: from rfrazer-mobl3.amr.corp.intel.com (HELO agluck-desk3.home.arpa) ([10.124.222.153]) by orviesa009-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Nov 2025 10:54:25 -0800 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Maciej Wieczor-Retman , Peter Newman , James Morse , Babu Moger , Drew Fustini , Dave Martin , Chen Yu Cc: x86@kernel.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [PATCH v14 10/32] fs/resctrl: Make event details accessible to functions when reading events Date: Mon, 24 Nov 2025 10:53:47 -0800 Message-ID: <20251124185412.24155-11-tony.luck@intel.com> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251124185412.24155-1-tony.luck@intel.com> References: <20251124185412.24155-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" Reading monitoring event data from MMIO requires more context than the even= t id to be able to read the correct memory location. struct mon_evt is the appro= priate place for this event specific context. Prepare for addition of extra fields to struct mon_evt by changing the call= ing conventions to pass a pointer to the mon_evt structure instead of just the event id. Signed-off-by: Tony Luck Reviewed-by: Reinette Chatre --- fs/resctrl/internal.h | 10 +++++----- fs/resctrl/ctrlmondata.c | 18 +++++++++--------- fs/resctrl/monitor.c | 24 ++++++++++++------------ fs/resctrl/rdtgroup.c | 6 +++--- 4 files changed, 29 insertions(+), 29 deletions(-) diff --git a/fs/resctrl/internal.h b/fs/resctrl/internal.h index 9768341aa21c..86cf38ab08a7 100644 --- a/fs/resctrl/internal.h +++ b/fs/resctrl/internal.h @@ -81,7 +81,7 @@ extern struct mon_evt mon_event_all[QOS_NUM_EVENTS]; * struct mon_data - Monitoring details for each event file. * @list: Member of the global @mon_data_kn_priv_list list. * @rid: Resource id associated with the event file. - * @evtid: Event id associated with the event file. + * @evt: Event structure associated with the event file. * @sum: Set when event must be summed across multiple * domains. * @domid: When @sum is zero this is the domain to which @@ -95,7 +95,7 @@ extern struct mon_evt mon_event_all[QOS_NUM_EVENTS]; struct mon_data { struct list_head list; enum resctrl_res_level rid; - enum resctrl_event_id evtid; + struct mon_evt *evt; int domid; bool sum; }; @@ -108,7 +108,7 @@ struct mon_data { * @r: Resource describing the properties of the event being read. * @hdr: Header of domain that the counter should be read from. If NULL = then * sum all domains in @r sharing L3 @ci.id - * @evtid: Which monitor event to read. + * @evt: Which monitor event to read. * @first: Initialize MBM counter when true. * @ci: Cacheinfo for L3. Only set when @hdr is NULL. Used when summing * domains. @@ -126,7 +126,7 @@ struct rmid_read { struct rdtgroup *rgrp; struct rdt_resource *r; struct rdt_domain_hdr *hdr; - enum resctrl_event_id evtid; + struct mon_evt *evt; bool first; struct cacheinfo *ci; bool is_mbm_cntr; @@ -367,7 +367,7 @@ int rdtgroup_mondata_show(struct seq_file *m, void *arg= ); =20 void mon_event_read(struct rmid_read *rr, struct rdt_resource *r, struct rdt_domain_hdr *hdr, struct rdtgroup *rdtgrp, - cpumask_t *cpumask, int evtid, int first); + cpumask_t *cpumask, struct mon_evt *evt, int first); =20 void mbm_setup_overflow_handler(struct rdt_l3_mon_domain *dom, unsigned long delay_ms, diff --git a/fs/resctrl/ctrlmondata.c b/fs/resctrl/ctrlmondata.c index a3c734fe656e..7f9b2fed117a 100644 --- a/fs/resctrl/ctrlmondata.c +++ b/fs/resctrl/ctrlmondata.c @@ -552,7 +552,7 @@ struct rdt_domain_hdr *resctrl_find_domain(struct list_= head *h, int id, =20 void mon_event_read(struct rmid_read *rr, struct rdt_resource *r, struct rdt_domain_hdr *hdr, struct rdtgroup *rdtgrp, - cpumask_t *cpumask, int evtid, int first) + cpumask_t *cpumask, struct mon_evt *evt, int first) { int cpu; =20 @@ -563,15 +563,15 @@ void mon_event_read(struct rmid_read *rr, struct rdt_= resource *r, * Setup the parameters to pass to mon_event_count() to read the data. */ rr->rgrp =3D rdtgrp; - rr->evtid =3D evtid; + rr->evt =3D evt; rr->r =3D r; rr->hdr =3D hdr; rr->first =3D first; if (resctrl_arch_mbm_cntr_assign_enabled(r) && - resctrl_is_mbm_event(evtid)) { + resctrl_is_mbm_event(evt->evtid)) { rr->is_mbm_cntr =3D true; } else { - rr->arch_mon_ctx =3D resctrl_arch_mon_ctx_alloc(r, evtid); + rr->arch_mon_ctx =3D resctrl_arch_mon_ctx_alloc(r, evt->evtid); if (IS_ERR(rr->arch_mon_ctx)) { rr->err =3D -EINVAL; return; @@ -592,14 +592,13 @@ void mon_event_read(struct rmid_read *rr, struct rdt_= resource *r, smp_call_on_cpu(cpu, smp_mon_event_count, rr, false); =20 if (rr->arch_mon_ctx) - resctrl_arch_mon_ctx_free(r, evtid, rr->arch_mon_ctx); + resctrl_arch_mon_ctx_free(r, evt->evtid, rr->arch_mon_ctx); } =20 int rdtgroup_mondata_show(struct seq_file *m, void *arg) { struct kernfs_open_file *of =3D m->private; enum resctrl_res_level resid; - enum resctrl_event_id evtid; struct rdt_l3_mon_domain *d; struct rdt_domain_hdr *hdr; struct rmid_read rr =3D {0}; @@ -607,6 +606,7 @@ int rdtgroup_mondata_show(struct seq_file *m, void *arg) int domid, cpu, ret =3D 0; struct rdt_resource *r; struct cacheinfo *ci; + struct mon_evt *evt; struct mon_data *md; =20 rdtgrp =3D rdtgroup_kn_lock_live(of->kn); @@ -623,7 +623,7 @@ int rdtgroup_mondata_show(struct seq_file *m, void *arg) =20 resid =3D md->rid; domid =3D md->domid; - evtid =3D md->evtid; + evt =3D md->evt; r =3D resctrl_arch_get_resource(resid); =20 if (md->sum) { @@ -641,7 +641,7 @@ int rdtgroup_mondata_show(struct seq_file *m, void *arg) continue; rr.ci =3D ci; mon_event_read(&rr, r, NULL, rdtgrp, - &ci->shared_cpu_map, evtid, false); + &ci->shared_cpu_map, evt, false); goto checkresult; } } @@ -657,7 +657,7 @@ int rdtgroup_mondata_show(struct seq_file *m, void *arg) ret =3D -ENOENT; goto out; } - mon_event_read(&rr, r, hdr, rdtgrp, &hdr->cpu_mask, evtid, false); + mon_event_read(&rr, r, hdr, rdtgrp, &hdr->cpu_mask, evt, false); } =20 checkresult: diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c index cbd9dd5656af..9f78ea17c825 100644 --- a/fs/resctrl/monitor.c +++ b/fs/resctrl/monitor.c @@ -430,7 +430,7 @@ static int __l3_mon_event_count(struct rdtgroup *rdtgrp= , struct rmid_read *rr) d =3D container_of(rr->hdr, struct rdt_l3_mon_domain, hdr); =20 if (rr->is_mbm_cntr) { - cntr_id =3D mbm_cntr_get(rr->r, d, rdtgrp, rr->evtid); + cntr_id =3D mbm_cntr_get(rr->r, d, rdtgrp, rr->evt->evtid); if (cntr_id < 0) { rr->err =3D -ENOENT; return -EINVAL; @@ -439,10 +439,10 @@ static int __l3_mon_event_count(struct rdtgroup *rdtg= rp, struct rmid_read *rr) =20 if (rr->first) { if (rr->is_mbm_cntr) - resctrl_arch_reset_cntr(rr->r, d, closid, rmid, cntr_id, rr->evtid); + resctrl_arch_reset_cntr(rr->r, d, closid, rmid, cntr_id, rr->evt->evtid= ); else - resctrl_arch_reset_rmid(rr->r, d, closid, rmid, rr->evtid); - m =3D get_mbm_state(d, closid, rmid, rr->evtid); + resctrl_arch_reset_rmid(rr->r, d, closid, rmid, rr->evt->evtid); + m =3D get_mbm_state(d, closid, rmid, rr->evt->evtid); if (m) memset(m, 0, sizeof(struct mbm_state)); return 0; @@ -453,10 +453,10 @@ static int __l3_mon_event_count(struct rdtgroup *rdtg= rp, struct rmid_read *rr) return -EINVAL; if (rr->is_mbm_cntr) rr->err =3D resctrl_arch_cntr_read(rr->r, d, closid, rmid, cntr_id, - rr->evtid, &tval); + rr->evt->evtid, &tval); else rr->err =3D resctrl_arch_rmid_read(rr->r, rr->hdr, closid, rmid, - rr->evtid, &tval, rr->arch_mon_ctx); + rr->evt->evtid, &tval, rr->arch_mon_ctx); if (rr->err) return rr->err; =20 @@ -492,10 +492,10 @@ static int __l3_mon_event_count_sum(struct rdtgroup *= rdtgrp, struct rmid_read *r continue; if (rr->is_mbm_cntr) err =3D resctrl_arch_cntr_read(rr->r, d, closid, rmid, cntr_id, - rr->evtid, &tval); + rr->evt->evtid, &tval); else err =3D resctrl_arch_rmid_read(rr->r, &d->hdr, closid, rmid, - rr->evtid, &tval, rr->arch_mon_ctx); + rr->evt->evtid, &tval, rr->arch_mon_ctx); if (!err) { rr->val +=3D tval; ret =3D 0; @@ -545,7 +545,7 @@ static void mbm_bw_count(struct rdtgroup *rdtgrp, struc= t rmid_read *rr) if (!domain_header_is_valid(rr->hdr, RESCTRL_MON_DOMAIN, RDT_RESOURCE_L3)) return; d =3D container_of(rr->hdr, struct rdt_l3_mon_domain, hdr); - m =3D get_mbm_state(d, closid, rmid, rr->evtid); + m =3D get_mbm_state(d, closid, rmid, rr->evt->evtid); if (WARN_ON_ONCE(!m)) return; =20 @@ -719,11 +719,11 @@ static void mbm_update_one_event(struct rdt_resource = *r, struct rdt_l3_mon_domai =20 rr.r =3D r; rr.hdr =3D &d->hdr; - rr.evtid =3D evtid; + rr.evt =3D &mon_event_all[evtid]; if (resctrl_arch_mbm_cntr_assign_enabled(r)) { rr.is_mbm_cntr =3D true; } else { - rr.arch_mon_ctx =3D resctrl_arch_mon_ctx_alloc(rr.r, rr.evtid); + rr.arch_mon_ctx =3D resctrl_arch_mon_ctx_alloc(rr.r, evtid); if (IS_ERR(rr.arch_mon_ctx)) { pr_warn_ratelimited("Failed to allocate monitor context: %ld", PTR_ERR(rr.arch_mon_ctx)); @@ -741,7 +741,7 @@ static void mbm_update_one_event(struct rdt_resource *r= , struct rdt_l3_mon_domai mbm_bw_count(rdtgrp, &rr); =20 if (rr.arch_mon_ctx) - resctrl_arch_mon_ctx_free(rr.r, rr.evtid, rr.arch_mon_ctx); + resctrl_arch_mon_ctx_free(rr.r, evtid, rr.arch_mon_ctx); } =20 static void mbm_update(struct rdt_resource *r, struct rdt_l3_mon_domain *d, diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c index b57e1e78bbc2..771e40f02ba6 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -3103,7 +3103,7 @@ static struct mon_data *mon_get_kn_priv(enum resctrl_= res_level rid, int domid, =20 list_for_each_entry(priv, &mon_data_kn_priv_list, list) { if (priv->rid =3D=3D rid && priv->domid =3D=3D domid && - priv->sum =3D=3D do_sum && priv->evtid =3D=3D mevt->evtid) + priv->sum =3D=3D do_sum && priv->evt =3D=3D mevt) return priv; } =20 @@ -3114,7 +3114,7 @@ static struct mon_data *mon_get_kn_priv(enum resctrl_= res_level rid, int domid, priv->rid =3D rid; priv->domid =3D domid; priv->sum =3D do_sum; - priv->evtid =3D mevt->evtid; + priv->evt =3D mevt; list_add_tail(&priv->list, &mon_data_kn_priv_list); =20 return priv; @@ -3281,7 +3281,7 @@ static int mon_add_all_files(struct kernfs_node *kn, = struct rdt_domain_hdr *hdr, return ret; =20 if (!do_sum && resctrl_is_mbm_event(mevt->evtid)) - mon_event_read(&rr, r, hdr, prgrp, &hdr->cpu_mask, mevt->evtid, true); + mon_event_read(&rr, r, hdr, prgrp, &hdr->cpu_mask, mevt, true); } =20 return 0; --=20 2.51.1 From nobody Tue Dec 2 00:25:23 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 18BD0320A10 for ; Mon, 24 Nov 2025 18:54:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764010493; cv=none; b=CXPfl4mRapyI80flVNQnLv4bEQwgk/d9uI88s2yKlA71YODwvHaCvV76bTy2ZwDDBEmNXPN3RsqxZBrjzkvlwQCPaM6JBZy+1DrcrKTXT2VGouyAwEEjhOHLxl/dHriLcCkd5C2a0rlWDcEhZow+speSLlV5TjRCMD8E3erGLgM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764010493; c=relaxed/simple; bh=SyYCwtOZTaDXsXXpoKZ5vF1vrbpqwxs2p9inu/VN0zw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tG8FSkuAjR931Zb+927K8vuPccPH6ZcK/z3jKI11QwO8irE4zelpfc4RGFbeF56WZNioENUBRKdqkH+HoZUq/UBmjcnijNsFzJx+yvBheVd/6YrT2FCHpwlV4gQXx1LUmcS0myvnXPeQPp8+2DHr+MwVh2eHXYRgfYur6T3rBsk= 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=CfuF59QI; arc=none smtp.client-ip=192.198.163.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="CfuF59QI" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1764010492; x=1795546492; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=SyYCwtOZTaDXsXXpoKZ5vF1vrbpqwxs2p9inu/VN0zw=; b=CfuF59QIQsavHBHZgnxtSKT0VIWniJvWjH4fJh/KcHGc90XuhAXBKstc IOtCA1sRD6U/wQ9OX2YGOfpsDvLn+ywMDTF/HXTT82lKTKuCX0Iguhc3L PwRdwd7MQaxNQjrOfgDM0JLIt7cL7KszaGO40p7LBcOQbOqHHYojyAbQf gFGHBALIOnzCqIjUE6aOfbHb6q28N02vdoksdzYX0aZ6GA/FlUpBNBSHW 8KFeMByQ/DtKDeSgryQgpXEY/YDSHSSKAmuokzLUVY+VWPdXCtXIZDaqH 9HY2//FIDx8Yh08x1TOjxMRxaLLI/kFQ8D7jHNHRZxhyMpOC1uHnVIzt2 A==; X-CSE-ConnectionGUID: HjLbmwBrR+Gy12jMwXdS/A== X-CSE-MsgGUID: ytyfs134Qaeb6x5Ynzpf4g== X-IronPort-AV: E=McAfee;i="6800,10657,11623"; a="76636594" X-IronPort-AV: E=Sophos;i="6.20,223,1758610800"; d="scan'208";a="76636594" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Nov 2025 10:54:25 -0800 X-CSE-ConnectionGUID: CGAOnjALQNKsODLPPmoyBQ== X-CSE-MsgGUID: ne5pTmn6RZymOerdoNPg/g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.20,223,1758610800"; d="scan'208";a="192224976" Received: from rfrazer-mobl3.amr.corp.intel.com (HELO agluck-desk3.home.arpa) ([10.124.222.153]) by orviesa009-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Nov 2025 10:54:25 -0800 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Maciej Wieczor-Retman , Peter Newman , James Morse , Babu Moger , Drew Fustini , Dave Martin , Chen Yu Cc: x86@kernel.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [PATCH v14 11/32] x86,fs/resctrl: Handle events that can be read from any CPU Date: Mon, 24 Nov 2025 10:53:48 -0800 Message-ID: <20251124185412.24155-12-tony.luck@intel.com> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251124185412.24155-1-tony.luck@intel.com> References: <20251124185412.24155-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 assumes that monitor events can only be read from a CPU in the cpumask_t set of each domain. This is true for x86 events accessed with an MSR interface, but may not be true for other access methods such as MMIO. Introduce and use flag mon_evt::any_cpu, settable by architecture, that indicates there are no restrictions on which CPU can read that event. Signed-off-by: Tony Luck --- include/linux/resctrl.h | 2 +- fs/resctrl/internal.h | 2 ++ arch/x86/kernel/cpu/resctrl/core.c | 6 +++--- fs/resctrl/ctrlmondata.c | 6 ++++++ fs/resctrl/monitor.c | 3 ++- 5 files changed, 14 insertions(+), 5 deletions(-) diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index 79aaaabcdd3f..22c5d07fe9ff 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -412,7 +412,7 @@ 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 -void resctrl_enable_mon_event(enum resctrl_event_id eventid); +void resctrl_enable_mon_event(enum resctrl_event_id eventid, bool any_cpu); =20 bool resctrl_is_mon_event_enabled(enum resctrl_event_id eventid); =20 diff --git a/fs/resctrl/internal.h b/fs/resctrl/internal.h index 86cf38ab08a7..fb0b6e40d022 100644 --- a/fs/resctrl/internal.h +++ b/fs/resctrl/internal.h @@ -61,6 +61,7 @@ static inline struct rdt_fs_context *rdt_fc2context(struc= t fs_context *fc) * READS_TO_REMOTE_MEM) being tracked by @evtid. * Only valid if @evtid is an MBM event. * @configurable: true if the event is configurable + * @any_cpu: true if the event can be read from any CPU * @enabled: true if the event is enabled */ struct mon_evt { @@ -69,6 +70,7 @@ struct mon_evt { char *name; u32 evt_cfg; bool configurable; + bool any_cpu; bool enabled; }; =20 diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resct= rl/core.c index b3a2dc56155d..bd4a98106153 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -902,15 +902,15 @@ static __init bool get_rdt_mon_resources(void) bool ret =3D false; =20 if (rdt_cpu_has(X86_FEATURE_CQM_OCCUP_LLC)) { - resctrl_enable_mon_event(QOS_L3_OCCUP_EVENT_ID); + resctrl_enable_mon_event(QOS_L3_OCCUP_EVENT_ID, false); ret =3D true; } if (rdt_cpu_has(X86_FEATURE_CQM_MBM_TOTAL)) { - resctrl_enable_mon_event(QOS_L3_MBM_TOTAL_EVENT_ID); + resctrl_enable_mon_event(QOS_L3_MBM_TOTAL_EVENT_ID, false); ret =3D true; } if (rdt_cpu_has(X86_FEATURE_CQM_MBM_LOCAL)) { - resctrl_enable_mon_event(QOS_L3_MBM_LOCAL_EVENT_ID); + resctrl_enable_mon_event(QOS_L3_MBM_LOCAL_EVENT_ID, false); ret =3D true; } if (rdt_cpu_has(X86_FEATURE_ABMC)) diff --git a/fs/resctrl/ctrlmondata.c b/fs/resctrl/ctrlmondata.c index 7f9b2fed117a..2c69fcd70eeb 100644 --- a/fs/resctrl/ctrlmondata.c +++ b/fs/resctrl/ctrlmondata.c @@ -578,6 +578,11 @@ void mon_event_read(struct rmid_read *rr, struct rdt_r= esource *r, } } =20 + if (evt->any_cpu) { + mon_event_count(rr); + goto out_ctx_free; + } + cpu =3D cpumask_any_housekeeping(cpumask, RESCTRL_PICK_ANY_CPU); =20 /* @@ -591,6 +596,7 @@ void mon_event_read(struct rmid_read *rr, struct rdt_re= source *r, else smp_call_on_cpu(cpu, smp_mon_event_count, rr, false); =20 +out_ctx_free: if (rr->arch_mon_ctx) resctrl_arch_mon_ctx_free(r, evt->evtid, rr->arch_mon_ctx); } diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c index 9f78ea17c825..a503ddd159fd 100644 --- a/fs/resctrl/monitor.c +++ b/fs/resctrl/monitor.c @@ -981,7 +981,7 @@ struct mon_evt mon_event_all[QOS_NUM_EVENTS] =3D { }, }; =20 -void resctrl_enable_mon_event(enum resctrl_event_id eventid) +void resctrl_enable_mon_event(enum resctrl_event_id eventid, bool any_cpu) { if (WARN_ON_ONCE(eventid < QOS_FIRST_EVENT || eventid >=3D QOS_NUM_EVENTS= )) return; @@ -990,6 +990,7 @@ void resctrl_enable_mon_event(enum resctrl_event_id eve= ntid) return; } =20 + mon_event_all[eventid].any_cpu =3D any_cpu; mon_event_all[eventid].enabled =3D true; } =20 --=20 2.51.1 From nobody Tue Dec 2 00:25:23 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 63BCC31A55B for ; Mon, 24 Nov 2025 18:54:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764010495; cv=none; b=SUpV/NsVso2Wh/E8OUiXsG10WEQUs53MI0aPsa+/ib81Nad0iR4Wn8vaPswghTlPfvHM8RbAUBjAcx13HiYoMsEs/S5C7HaS+bl+uP7uOkXG/xQipdWEOWPUejJTd9/wfy6ZClrwEV5ZI/4KQbDDjPqgzxHoQg7sUtPZUB/hbtQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764010495; c=relaxed/simple; bh=BHW2P22nkzgIe9yBxx11bv1THtGmQBmLC7K8mfk28uY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TnuCfCB5tdGgUTt3FLoZAuhEHyuGZMw0DP/h83r6lBMC9k8FJMzQyLNHsWiSeqUCfxmmZqWxZis7FabS4+sdFDSyLMHxkHhNke1G1GUoVk0KYZcYmI8M97RgTvVqmJT0Kip6U1qvrnqx5bGNo6WM/wm2aOliRZgMd78C2fe71Jg= 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=TD25OiSe; arc=none smtp.client-ip=192.198.163.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="TD25OiSe" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1764010493; x=1795546493; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=BHW2P22nkzgIe9yBxx11bv1THtGmQBmLC7K8mfk28uY=; b=TD25OiSeuKqJ8hWYJoaSqOCc8zpq/Xw/Q/+pOwXg9Q8IQibxnXcsOcMJ vitgkj6Trs9Dk8NmPtu077JW91YJwgsQgeKPmb0Ie04ma+W02xthsTinO mKEln7HM6QC/81M/OMAuafcDhY1mgpkLDVF3QWcZEmcqDeVGS8xljmvUf TxvtXw2YKhYV0TAtRLYToOmtaLr4Peedh1Dq2+2AvLKXNVkvCvGV2k4Ag IA9my6e8348y75qhGgSo9iazPoDn955T9PNLhx1kVWy1YXlLSFw3YL86D joAcZUTVxSYgY2gJPr46N/VfiVo1BEbeom1gqVoeYljz3P3tZ0QoqSG+6 w==; X-CSE-ConnectionGUID: mskRewjQShuh/d7FrK9y9Q== X-CSE-MsgGUID: OSxheWriT+e1XKoFnQ9FKg== X-IronPort-AV: E=McAfee;i="6800,10657,11623"; a="76636615" X-IronPort-AV: E=Sophos;i="6.20,223,1758610800"; d="scan'208";a="76636615" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Nov 2025 10:54:25 -0800 X-CSE-ConnectionGUID: 5BXxuvzrQTaWTk8qgnmpbg== X-CSE-MsgGUID: /MmFPJjITlecRwTcJQEe/g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.20,223,1758610800"; d="scan'208";a="192224979" Received: from rfrazer-mobl3.amr.corp.intel.com (HELO agluck-desk3.home.arpa) ([10.124.222.153]) by orviesa009-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Nov 2025 10:54:25 -0800 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Maciej Wieczor-Retman , Peter Newman , James Morse , Babu Moger , Drew Fustini , Dave Martin , Chen Yu Cc: x86@kernel.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [PATCH v14 12/32] x86,fs/resctrl: Support binary fixed point event counters Date: Mon, 24 Nov 2025 10:53:49 -0800 Message-ID: <20251124185412.24155-13-tony.luck@intel.com> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251124185412.24155-1-tony.luck@intel.com> References: <20251124185412.24155-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 assumes that all monitor events can be displayed as unsigned decimal integers. Hardware architecture counters may provide some telemetry events with great= er precision where the event is not a simple count, but is a measurement of some sort (e.g. Joules for energy consumed). Add a new argument to resctrl_enable_mon_event() for architecture code to inform the file system that the value for a counter is a fixed-point value with a specific number of binary places. Display fixed point values with values rounded to ceil(binary_bits * log10(= 2)) decimal places. Special case for zero binary bits to print "{value}.0". Only allow architecture to use floating point format on events that the file system has marked with mon_evt::is_floating_point. Signed-off-by: Tony Luck Reviewed-by: Reinette Chatre --- include/linux/resctrl.h | 3 +- fs/resctrl/internal.h | 8 ++++ arch/x86/kernel/cpu/resctrl/core.c | 6 +-- fs/resctrl/ctrlmondata.c | 74 ++++++++++++++++++++++++++++++ fs/resctrl/monitor.c | 10 +++- 5 files changed, 95 insertions(+), 6 deletions(-) diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index 22c5d07fe9ff..c43526cdf304 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -412,7 +412,8 @@ 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 -void resctrl_enable_mon_event(enum resctrl_event_id eventid, bool any_cpu); +void resctrl_enable_mon_event(enum resctrl_event_id eventid, bool any_cpu, + unsigned int binary_bits); =20 bool resctrl_is_mon_event_enabled(enum resctrl_event_id eventid); =20 diff --git a/fs/resctrl/internal.h b/fs/resctrl/internal.h index fb0b6e40d022..14e5a9ed1fbd 100644 --- a/fs/resctrl/internal.h +++ b/fs/resctrl/internal.h @@ -62,6 +62,9 @@ static inline struct rdt_fs_context *rdt_fc2context(struc= t fs_context *fc) * Only valid if @evtid is an MBM event. * @configurable: true if the event is configurable * @any_cpu: true if the event can be read from any CPU + * @is_floating_point: event values are displayed in floating point format + * @binary_bits: number of fixed-point binary bits from architecture, + * only valid if @is_floating_point is true * @enabled: true if the event is enabled */ struct mon_evt { @@ -71,6 +74,8 @@ struct mon_evt { u32 evt_cfg; bool configurable; bool any_cpu; + bool is_floating_point; + unsigned int binary_bits; bool enabled; }; =20 @@ -79,6 +84,9 @@ extern struct mon_evt mon_event_all[QOS_NUM_EVENTS]; #define for_each_mon_event(mevt) for (mevt =3D &mon_event_all[QOS_FIRST_EV= ENT]; \ mevt < &mon_event_all[QOS_NUM_EVENTS]; mevt++) =20 +/* Limit for mon_evt::binary_bits */ +#define MAX_BINARY_BITS 27 + /** * struct mon_data - Monitoring details for each event file. * @list: Member of the global @mon_data_kn_priv_list list. diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resct= rl/core.c index bd4a98106153..9222eee7ce07 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -902,15 +902,15 @@ static __init bool get_rdt_mon_resources(void) bool ret =3D false; =20 if (rdt_cpu_has(X86_FEATURE_CQM_OCCUP_LLC)) { - resctrl_enable_mon_event(QOS_L3_OCCUP_EVENT_ID, false); + resctrl_enable_mon_event(QOS_L3_OCCUP_EVENT_ID, false, 0); ret =3D true; } if (rdt_cpu_has(X86_FEATURE_CQM_MBM_TOTAL)) { - resctrl_enable_mon_event(QOS_L3_MBM_TOTAL_EVENT_ID, false); + resctrl_enable_mon_event(QOS_L3_MBM_TOTAL_EVENT_ID, false, 0); ret =3D true; } if (rdt_cpu_has(X86_FEATURE_CQM_MBM_LOCAL)) { - resctrl_enable_mon_event(QOS_L3_MBM_LOCAL_EVENT_ID, false); + resctrl_enable_mon_event(QOS_L3_MBM_LOCAL_EVENT_ID, false, 0); ret =3D true; } if (rdt_cpu_has(X86_FEATURE_ABMC)) diff --git a/fs/resctrl/ctrlmondata.c b/fs/resctrl/ctrlmondata.c index 2c69fcd70eeb..f319fd1a6de3 100644 --- a/fs/resctrl/ctrlmondata.c +++ b/fs/resctrl/ctrlmondata.c @@ -17,6 +17,7 @@ =20 #include #include +#include #include #include #include @@ -601,6 +602,77 @@ void mon_event_read(struct rmid_read *rr, struct rdt_r= esource *r, resctrl_arch_mon_ctx_free(r, evt->evtid, rr->arch_mon_ctx); } =20 +/* + * Decimal place precision to use for each number of fixed-point + * binary bits computed from ceil(binary_bits * log10(2)) except + * binary_bits =3D=3D 0 which will print "value.0" + */ +static const unsigned int decplaces[MAX_BINARY_BITS + 1] =3D { + [0] =3D 1, + [1] =3D 1, + [2] =3D 1, + [3] =3D 1, + [4] =3D 2, + [5] =3D 2, + [6] =3D 2, + [7] =3D 3, + [8] =3D 3, + [9] =3D 3, + [10] =3D 4, + [11] =3D 4, + [12] =3D 4, + [13] =3D 4, + [14] =3D 5, + [15] =3D 5, + [16] =3D 5, + [17] =3D 6, + [18] =3D 6, + [19] =3D 6, + [20] =3D 7, + [21] =3D 7, + [22] =3D 7, + [23] =3D 7, + [24] =3D 8, + [25] =3D 8, + [26] =3D 8, + [27] =3D 9 +}; + +static void print_event_value(struct seq_file *m, unsigned int binary_bits= , u64 val) +{ + unsigned long long frac =3D 0; + + if (binary_bits) { + /* Mask off the integer part of the fixed-point value. */ + frac =3D val & GENMASK_ULL(binary_bits - 1, 0); + + /* + * Multiply by 10^{desired decimal places}. The integer part of + * the fixed point value is now almost what is needed. + */ + frac *=3D int_pow(10ull, decplaces[binary_bits]); + + /* + * Round to nearest by adding a value that would be a "1" in the + * binary_bits + 1 place. Integer part of fixed point value is + * now the needed value. + */ + frac +=3D 1ull << (binary_bits - 1); + + /* + * Extract the integer part of the value. This is the decimal + * representation of the original fixed-point fractional value. + */ + frac >>=3D binary_bits; + } + + /* + * "frac" is now in the range [0 .. 10^decplaces). I.e. string + * representation will fit into chosen number of decimal places. + */ + seq_printf(m, "%llu.%0*llu\n", val >> binary_bits, decplaces[binary_bits]= , frac); +} + int rdtgroup_mondata_show(struct seq_file *m, void *arg) { struct kernfs_open_file *of =3D m->private; @@ -678,6 +750,8 @@ int rdtgroup_mondata_show(struct seq_file *m, void *arg) seq_puts(m, "Unavailable\n"); else if (rr.err =3D=3D -ENOENT) seq_puts(m, "Unassigned\n"); + else if (evt->is_floating_point) + print_event_value(m, evt->binary_bits, rr.val); else seq_printf(m, "%llu\n", rr.val); =20 diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c index a503ddd159fd..9c316b714968 100644 --- a/fs/resctrl/monitor.c +++ b/fs/resctrl/monitor.c @@ -981,16 +981,22 @@ struct mon_evt mon_event_all[QOS_NUM_EVENTS] =3D { }, }; =20 -void resctrl_enable_mon_event(enum resctrl_event_id eventid, bool any_cpu) +void resctrl_enable_mon_event(enum resctrl_event_id eventid, bool any_cpu,= unsigned int binary_bits) { - if (WARN_ON_ONCE(eventid < QOS_FIRST_EVENT || eventid >=3D QOS_NUM_EVENTS= )) + if (WARN_ON_ONCE(eventid < QOS_FIRST_EVENT || eventid >=3D QOS_NUM_EVENTS= || + binary_bits > MAX_BINARY_BITS)) return; if (mon_event_all[eventid].enabled) { pr_warn("Duplicate enable for event %d\n", eventid); return; } + if (binary_bits && !mon_event_all[eventid].is_floating_point) { + pr_warn("Event %d may not be floating point\n", eventid); + return; + } =20 mon_event_all[eventid].any_cpu =3D any_cpu; + mon_event_all[eventid].binary_bits =3D binary_bits; mon_event_all[eventid].enabled =3D true; } =20 --=20 2.51.1 From nobody Tue Dec 2 00:25:23 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C52C8321F48 for ; Mon, 24 Nov 2025 18:54:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764010497; cv=none; b=rPJ/tw27CQQKFRv+3qv4aEWJMOpW1wcCHkatc03uxF1j8aagPFuG5qBgSytbniPoKCjaCWe9mR7aKUCF8cM4o6vde+KT8/2i5WuVQICFN8izDbElhbt+hyD+iPdmQf9cu8iajPJVFdULTolKbhUZ793DrMBFxS51X1GvWA901ik= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764010497; c=relaxed/simple; bh=vrL7JfY3s49csiMkieoQzxc27A+XOltjUvm7AN7IfJk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GtsRZ0sWcninLsqvBMnCgzYyRXGkzFP/8nPlyIvNSjx/lN7itV9e8AFvNjnZXSP6muucrPkP1p6c72GttocFs1H2bOeFA7tpkMatqpRMZpRCLGWDtCmrSNbsA1a6krYLskO1eyxFCYH2bf/ICGNV6/pVL5jJgR/UibhlbBW+xDY= 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=bTVT1t4I; arc=none smtp.client-ip=192.198.163.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="bTVT1t4I" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1764010496; x=1795546496; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=vrL7JfY3s49csiMkieoQzxc27A+XOltjUvm7AN7IfJk=; b=bTVT1t4IhG5NFdO5XawJ+NZGhPzh1842Gi18OmNzDGlOCPdPbh/kyfpU WLyaeyHsXBcyGVQ1Gw26RA0dW8K5uj6oQ3oCCEibihXAxN1tizw09dWsO vpaHt4xpv9HeCbPOIVW89wLJSyZYDccOMoSRcrtcnOEzOUJl6ZQKAYZ8f vSx0lgIi4ADZrCliLoWB8AhwOXmOlYCH0GsJR6Ak9yzjefUit8TvUxuGI +/RJIIDbFn0svYX+KZsihxLddiREQZQXIfDn8lcKdzI8rdhQDKhlR/Ohx uaL3oURGhmnKaskMFMFDoe7oPLrJTNZGBQmiY2x0iG1Z3x17X+0NU4e13 Q==; X-CSE-ConnectionGUID: 3Sl8snFtQNO6/QW59ci2Vg== X-CSE-MsgGUID: 68i1w9BRT5aDi8gW5NUYaA== X-IronPort-AV: E=McAfee;i="6800,10657,11623"; a="76636632" X-IronPort-AV: E=Sophos;i="6.20,223,1758610800"; d="scan'208";a="76636632" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Nov 2025 10:54:26 -0800 X-CSE-ConnectionGUID: uRCHphlSRdKicO5nOUxWCw== X-CSE-MsgGUID: laNvu1i8Qqmpis/M5wPOwA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.20,223,1758610800"; d="scan'208";a="192224983" Received: from rfrazer-mobl3.amr.corp.intel.com (HELO agluck-desk3.home.arpa) ([10.124.222.153]) by orviesa009-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Nov 2025 10:54:26 -0800 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Maciej Wieczor-Retman , Peter Newman , James Morse , Babu Moger , Drew Fustini , Dave Martin , Chen Yu Cc: x86@kernel.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [PATCH v14 13/32] x86,fs/resctrl: Add an architectural hook called for each mount Date: Mon, 24 Nov 2025 10:53:50 -0800 Message-ID: <20251124185412.24155-14-tony.luck@intel.com> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251124185412.24155-1-tony.luck@intel.com> References: <20251124185412.24155-1-tony.luck@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Enumeration of Intel telemetry events is an asynchronous process involving several mutually dependent drivers added as auxiliary devices during the device_initcall() phase of Linux boot. The process finishes after the probe functions of these drivers completes. But this happens after resctrl_arch_late_init() is executed. Tracing the enumeration process shows that it does complete a full seven seconds before the earliest possible mount of the resctrl file system (when included in /etc/fstab for automatic mount by systemd). Add a hook at the beginning of the mount code that will be used to check for telemetry events and initialize if any are found. Call the hook on every attempted mount. Expectations are that most actions (like enumeration) will only need to be performed on the first call. resctrl filesystem calls the hook with no locks held. Architecture code is responsible for any required locking. Signed-off-by: Tony Luck Reviewed-by: Reinette Chatre --- include/linux/resctrl.h | 6 ++++++ arch/x86/kernel/cpu/resctrl/core.c | 9 +++++++++ fs/resctrl/rdtgroup.c | 2 ++ 3 files changed, 17 insertions(+) diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index c43526cdf304..dc148b7feb71 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -514,6 +514,12 @@ void resctrl_offline_mon_domain(struct rdt_resource *r= , struct rdt_domain_hdr *h void resctrl_online_cpu(unsigned int cpu); void resctrl_offline_cpu(unsigned int cpu); =20 +/* + * Architecture hook called at beginning of each file system mount attempt. + * No locks are held. + */ +void resctrl_arch_pre_mount(void); + /** * resctrl_arch_rmid_read() - Read the eventid counter corresponding to rm= id * for this resource and domain. diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resct= rl/core.c index 9222eee7ce07..2dd48b59ba9b 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -726,6 +726,15 @@ static int resctrl_arch_offline_cpu(unsigned int cpu) return 0; } =20 +void resctrl_arch_pre_mount(void) +{ + static atomic_t only_once =3D ATOMIC_INIT(0); + int old =3D 0; + + if (!atomic_try_cmpxchg(&only_once, &old, 1)) + return; +} + enum { RDT_FLAG_CMT, RDT_FLAG_MBM_TOTAL, diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c index 771e40f02ba6..b20d104ea0c9 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -2785,6 +2785,8 @@ static int rdt_get_tree(struct fs_context *fc) struct rdt_resource *r; int ret; =20 + resctrl_arch_pre_mount(); + cpus_read_lock(); mutex_lock(&rdtgroup_mutex); /* --=20 2.51.1 From nobody Tue Dec 2 00:25:23 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 582D8321445 for ; Mon, 24 Nov 2025 18:54:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764010498; cv=none; b=ANWCkgqRTxBAFmfqIgbS1bLHKJru2d+Dhx/5ORQafwM+t4ZDhOzHpOUP0tTRHkPETAPMJWPfRKMWdsusInB37p/j4Hvn/2otqAPjhoD/EC4apt6PTrghdIbbhAq9jF8G+J+rHlV5NhifgiHaepTcNaps9RLJ0ubEBbbY9ohj68A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764010498; c=relaxed/simple; bh=hyL2/X8OODb/MAa6mAq8coFobmArLr4dQvg/AGa1bOs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WpXt7qWsW88fjYK9Mtu3RN54CKc/PHdRby5j0UFskDT1ITL251ijDgwH1R4cjDk8koRBDocUZp6x7atm/KbNtFfZxCA8/rhshg3bZGbS2Lp2/Oflfy7ihp7o9jmNFvZIawjyEMGNi6RWvUwE2kAfDj9uSY57TOwHwtNc7Kd1YwA= 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=AP6b1lCw; arc=none smtp.client-ip=192.198.163.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="AP6b1lCw" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1764010495; x=1795546495; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=hyL2/X8OODb/MAa6mAq8coFobmArLr4dQvg/AGa1bOs=; b=AP6b1lCwIhj2dNrLDzAOmYeJqeFKeI9LSf91h8hJhJEt+nG6kWdmQ3Yz 6Eravp73Sp5xf2nyxKj4sGyuBUNT6EezOnWVTWJ2NO0MiNobKtmlqfYFg gMe10EoDej7WjjJX383ZC2Egas8uVrt5v1rACfeVAmh++P0hoYsNaL0zO k3oOsgWFjWtUt7taqtFna4TXJmd+1PKLwhtr10z3HGAk2YGbiIA0wpaho hcc6hHGKia2Y1HtNzCTTrWQiODH9rTHMNMFIr5qQGZcsLmI5XllYt+WAS gBnzBDTaLeEG7rr+yLd1GvsTImMIp51CTn6FANMmFLftW+dvZEOCSWgJz Q==; X-CSE-ConnectionGUID: pSzNwezeQueKSkeNXtoGMA== X-CSE-MsgGUID: aTddgtQuRxyDHfdERrHcgA== X-IronPort-AV: E=McAfee;i="6800,10657,11623"; a="76636654" X-IronPort-AV: E=Sophos;i="6.20,223,1758610800"; d="scan'208";a="76636654" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Nov 2025 10:54:26 -0800 X-CSE-ConnectionGUID: 9xxc5uxuRIyLkD67glSt0w== X-CSE-MsgGUID: 6tfZIdutQd6/sVtt7ri/Kw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.20,223,1758610800"; d="scan'208";a="192224987" Received: from rfrazer-mobl3.amr.corp.intel.com (HELO agluck-desk3.home.arpa) ([10.124.222.153]) by orviesa009-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Nov 2025 10:54:26 -0800 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Maciej Wieczor-Retman , Peter Newman , James Morse , Babu Moger , Drew Fustini , Dave Martin , Chen Yu Cc: x86@kernel.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [PATCH v14 14/32] x86,fs/resctrl: Add and initialize rdt_resource for package scope monitor Date: Mon, 24 Nov 2025 10:53:51 -0800 Message-ID: <20251124185412.24155-15-tony.luck@intel.com> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251124185412.24155-1-tony.luck@intel.com> References: <20251124185412.24155-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" Add a new PERF_PKG resource and introduce package level scope for monitoring telemetry events so that CPU hot plug notifiers can build domains at the package granularity. Use the physical package ID available via topology_physical_package_id() to identify the monitoring domains with package level scope. This enables user space to use: /sys/devices/system/cpu/cpuX/topology/physical_package_id to identify the monitoring domain a CPU is associated with. Signed-off-by: Tony Luck --- include/linux/resctrl.h | 2 ++ fs/resctrl/internal.h | 2 ++ arch/x86/kernel/cpu/resctrl/core.c | 10 ++++++++++ fs/resctrl/rdtgroup.c | 2 ++ 4 files changed, 16 insertions(+) diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index dc148b7feb71..2a3613f27274 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -53,6 +53,7 @@ enum resctrl_res_level { RDT_RESOURCE_L2, RDT_RESOURCE_MBA, RDT_RESOURCE_SMBA, + RDT_RESOURCE_PERF_PKG, =20 /* Must be the last */ RDT_NUM_RESOURCES, @@ -270,6 +271,7 @@ enum resctrl_scope { RESCTRL_L2_CACHE =3D 2, RESCTRL_L3_CACHE =3D 3, RESCTRL_L3_NODE, + RESCTRL_PACKAGE, }; =20 /** diff --git a/fs/resctrl/internal.h b/fs/resctrl/internal.h index 14e5a9ed1fbd..0110d1175398 100644 --- a/fs/resctrl/internal.h +++ b/fs/resctrl/internal.h @@ -255,6 +255,8 @@ struct rdtgroup { =20 #define RFTYPE_ASSIGN_CONFIG BIT(11) =20 +#define RFTYPE_RES_PERF_PKG BIT(12) + #define RFTYPE_CTRL_INFO (RFTYPE_INFO | RFTYPE_CTRL) =20 #define RFTYPE_MON_INFO (RFTYPE_INFO | RFTYPE_MON) diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resct= rl/core.c index 2dd48b59ba9b..986b1303efb9 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -100,6 +100,14 @@ struct rdt_hw_resource rdt_resources_all[RDT_NUM_RESOU= RCES] =3D { .schema_fmt =3D RESCTRL_SCHEMA_RANGE, }, }, + [RDT_RESOURCE_PERF_PKG] =3D + { + .r_resctrl =3D { + .name =3D "PERF_PKG", + .mon_scope =3D RESCTRL_PACKAGE, + .mon_domains =3D mon_domain_init(RDT_RESOURCE_PERF_PKG), + }, + }, }; =20 u32 resctrl_arch_system_num_rmid_idx(void) @@ -440,6 +448,8 @@ static int get_domain_id_from_scope(int cpu, enum resct= rl_scope scope) return get_cpu_cacheinfo_id(cpu, scope); case RESCTRL_L3_NODE: return cpu_to_node(cpu); + case RESCTRL_PACKAGE: + return topology_physical_package_id(cpu); default: break; } diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c index b20d104ea0c9..4952ba6b8609 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -2395,6 +2395,8 @@ static unsigned long fflags_from_resource(struct rdt_= resource *r) case RDT_RESOURCE_MBA: case RDT_RESOURCE_SMBA: return RFTYPE_RES_MB; + case RDT_RESOURCE_PERF_PKG: + return RFTYPE_RES_PERF_PKG; } =20 return WARN_ON_ONCE(1); --=20 2.51.1 From nobody Tue Dec 2 00:25:23 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7AE44322C88 for ; Mon, 24 Nov 2025 18:54:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764010499; cv=none; b=UZD07d9cht/+u0tMm7CUstFLKyuFtv1efsgfX3h/9uQHrskn0+GAEQR813znDEZTXGSG1UjEpM/NvUuHYtXTDPYVwYAS+uQhgajWzyEvy5lvX3902zkxvTx9Zi7RK50x56c2qHyjtc0PO236D7n1ds5Izezhqq76+Oi06H2XMoc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764010499; c=relaxed/simple; bh=9KtQhAEuNacTIhDtiaux0qfjZKcSMZhDOZ14EYOTjwQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UdYtI886mnbGYwnIF22a5jnZUfYrigpBTC8e6WRw88Wtno6hJvSIEJM6yo7uFCWF2MEGHjFB65azirm/7R41ZQwe0bCQ4MmFpeNNjIdG7EOiSDg1tX9pjABjzhurUm3Su+LyvPKteiGkPRGvcTwSfIgpd3w6IJZVplpQEgO8jkM= 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=CZpObWiG; arc=none smtp.client-ip=192.198.163.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="CZpObWiG" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1764010497; x=1795546497; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=9KtQhAEuNacTIhDtiaux0qfjZKcSMZhDOZ14EYOTjwQ=; b=CZpObWiGnw2GzR8QMTdAEtoZdA2oh8RbYDDuKnTKCsPJowviXiBMuw60 3/rvRNpgqhgb9ZGe+6PIzBl7+WOY2KdTPZL3vs63jc6BHmfpDokble4v+ 9hqhM63IwfYNczE0EfRtkkWGFZ/oX9UUF3F94spqcz+hTtN5n/QBY8WhM f8FHmhw7UL+5njMsRSbHmNjX4eWAvIFOMoyeFsRx2YWsrRqEKtN9ETFFz /BObolH2mITivD2AoQZrLFk2N66fTBOCM3hD1twB07CeFn/c+MoSv83vw R8LAQiRDh0jTezeV3x5NRnot3LrG62DvMe6By4bsydGp/CS8dX4A+AcJ4 w==; X-CSE-ConnectionGUID: ZzJ5F5zhTyStWEVm0yaA/Q== X-CSE-MsgGUID: tVhtu1EvRwqpjUAZF/MPpQ== X-IronPort-AV: E=McAfee;i="6800,10657,11623"; a="76636674" X-IronPort-AV: E=Sophos;i="6.20,223,1758610800"; d="scan'208";a="76636674" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Nov 2025 10:54:27 -0800 X-CSE-ConnectionGUID: 9Yll61mjQU+Eb3283ZWC+Q== X-CSE-MsgGUID: Bxf/fMdCTYiiAEtH8Xs9hg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.20,223,1758610800"; d="scan'208";a="192224990" Received: from rfrazer-mobl3.amr.corp.intel.com (HELO agluck-desk3.home.arpa) ([10.124.222.153]) by orviesa009-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Nov 2025 10:54:26 -0800 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Maciej Wieczor-Retman , Peter Newman , James Morse , Babu Moger , Drew Fustini , Dave Martin , Chen Yu Cc: x86@kernel.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [PATCH v14 15/32] fs/resctrl: Emphasize that L3 monitoring resource is required for summing domains Date: Mon, 24 Nov 2025 10:53:52 -0800 Message-ID: <20251124185412.24155-16-tony.luck@intel.com> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251124185412.24155-1-tony.luck@intel.com> References: <20251124185412.24155-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 feature to sum event data across multiple domains supports systems with Sub-NUMA Cluster (SNC) mode enabled. The top-level monitoring files in each "mon_L3_XX" directory provide the sum of data across all SNC nodes sharing an L3 cache instance while the "mon_sub_L3_YY" sub-directories provide the event data of the individual nodes. SNC is only associated with the L3 resource and domains and as a result the flow handling the sum of event data implicitly assumes it is working with the L3 resource and domains. Reading of telemetry events do not require to sum event data so this feature can remain dedicated to SNC and keep the implicit assumption of working with the L3 resource and domains. Add a WARN to where the implicit assumption of working with the L3 resource is made and add comments on how the structure controlling the event sum feature is used. Suggested-by: Reinette Chatre Signed-off-by: Tony Luck Reviewed-by: Reinette Chatre --- fs/resctrl/internal.h | 4 ++-- fs/resctrl/ctrlmondata.c | 8 +++++++- fs/resctrl/rdtgroup.c | 3 ++- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/fs/resctrl/internal.h b/fs/resctrl/internal.h index 0110d1175398..50d88e91e0da 100644 --- a/fs/resctrl/internal.h +++ b/fs/resctrl/internal.h @@ -92,8 +92,8 @@ extern struct mon_evt mon_event_all[QOS_NUM_EVENTS]; * @list: Member of the global @mon_data_kn_priv_list list. * @rid: Resource id associated with the event file. * @evt: Event structure associated with the event file. - * @sum: Set when event must be summed across multiple - * domains. + * @sum: Set for RDT_RESOURCE_L3 when event must be summed + * across multiple domains. * @domid: When @sum is zero this is the domain to which * the event file belongs. When @sum is one this * is the id of the L3 cache that all domains to be diff --git a/fs/resctrl/ctrlmondata.c b/fs/resctrl/ctrlmondata.c index f319fd1a6de3..cc4237c57cbe 100644 --- a/fs/resctrl/ctrlmondata.c +++ b/fs/resctrl/ctrlmondata.c @@ -677,7 +677,6 @@ int rdtgroup_mondata_show(struct seq_file *m, void *arg) { struct kernfs_open_file *of =3D m->private; enum resctrl_res_level resid; - struct rdt_l3_mon_domain *d; struct rdt_domain_hdr *hdr; struct rmid_read rr =3D {0}; struct rdtgroup *rdtgrp; @@ -705,6 +704,13 @@ int rdtgroup_mondata_show(struct seq_file *m, void *ar= g) r =3D resctrl_arch_get_resource(resid); =20 if (md->sum) { + struct rdt_l3_mon_domain *d; + + if (WARN_ON_ONCE(resid !=3D RDT_RESOURCE_L3)) { + ret =3D -EINVAL; + goto out; + } + /* * This file requires summing across all domains that share * the L3 cache id that was provided in the "domid" field of the diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c index 4952ba6b8609..dce1f0a6d40b 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -3095,7 +3095,8 @@ static void rmdir_all_sub(void) * @rid: The resource id for the event file being created. * @domid: The domain id for the event file being created. * @mevt: The type of event file being created. - * @do_sum: Whether SNC summing monitors are being created. + * @do_sum: Whether SNC summing monitors are being created. Only set + * when @rid =3D=3D RDT_RESOURCE_L3. */ static struct mon_data *mon_get_kn_priv(enum resctrl_res_level rid, int do= mid, struct mon_evt *mevt, --=20 2.51.1 From nobody Tue Dec 2 00:25:23 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F393A322DC1 for ; Mon, 24 Nov 2025 18:54:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764010500; cv=none; b=HRch3JU6a2YpNAbOIlG2WYdeqASRUWi3+mYa1AB0Xw/9gpC2FNrsnFbGkAKFF9KxlDaWPhizYRf1j2ZNfWsnNUcES5ONrDSjzlpMBayp/MbUw6y0MGg8MXdF/GDb5PDl5bfQtGQYcUC3FytEQl7yvXV7kRg9c/lttWZhDQMqV9E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764010500; c=relaxed/simple; bh=TqE0lSTrmVhNm8MzvF+QTISBEL6UB2WoMYgF2IXEwpg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fAlvt3I5/ZhqDzrpgDL5abmn8EJ+LSlkraOeoAPNGzSJW4x2YO1zv0zlpXegP4v7afR8wFepnDanrGENQAoKLQhRqyarjNBW662IN9BE+P0CXt9rw55EfOV1p109U3XswdSXn3Nd/DYUV9NLRLwUxwQgpVCKK1QjwDDoPaNmUtk= 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=i0CdHD8E; arc=none smtp.client-ip=192.198.163.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="i0CdHD8E" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1764010498; x=1795546498; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=TqE0lSTrmVhNm8MzvF+QTISBEL6UB2WoMYgF2IXEwpg=; b=i0CdHD8EvTG1nDN9ZX+mN3pncuVFIYGbHjSATZSeDJwyer14CXh4pOHM +u14Kr4yTGgBJt2Du1nhGwFHeg8Ph1j6cIljImzi0yxkavS7xaL4ZSdAs FFuqWL549tmEm4iyv42FhjcChOTx+2BUhEEi3eGEwfmg3r0pv6I1bDfx7 SLb+VxrugubI4pHPdyX1S2LlQc3f9Zgd39g1eWaOlVfkcPwJZjUGQUCnT hXy7KcRezEjT6i/RioNXJYS6CgA/U0IyxIcOb6Wo/+/peWSvcb9HDjpZA nf6QixWe6uqtQO5XCKtF4SG15puM9CM6r3DNat+BVkpJ8VBdkvM5N8lry g==; X-CSE-ConnectionGUID: 544CRAXjRSmz2elU4pWrGA== X-CSE-MsgGUID: uikg7PYlQLSlP3OJFlCqDQ== X-IronPort-AV: E=McAfee;i="6800,10657,11623"; a="76636696" X-IronPort-AV: E=Sophos;i="6.20,223,1758610800"; d="scan'208";a="76636696" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Nov 2025 10:54:27 -0800 X-CSE-ConnectionGUID: zJi2zUmzTKK9F0tPPcy5Aw== X-CSE-MsgGUID: UAkPwoiMQmWuGHBxZuCejw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.20,223,1758610800"; d="scan'208";a="192224994" Received: from rfrazer-mobl3.amr.corp.intel.com (HELO agluck-desk3.home.arpa) ([10.124.222.153]) by orviesa009-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Nov 2025 10:54:27 -0800 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Maciej Wieczor-Retman , Peter Newman , James Morse , Babu Moger , Drew Fustini , Dave Martin , Chen Yu Cc: x86@kernel.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [PATCH v14 16/32] x86/resctrl: Discover hardware telemetry events Date: Mon, 24 Nov 2025 10:53:53 -0800 Message-ID: <20251124185412.24155-17-tony.luck@intel.com> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251124185412.24155-1-tony.luck@intel.com> References: <20251124185412.24155-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" Each CPU collects data for telemetry events that it sends to the nearest telemetry event aggregator either when the value of MSR_IA32_PQR_ASSOC.RMID changes, or when a two millisecond timer expires. There is a feature type ("energy" or "perf"), guid, and MMIO region associa= ted with each aggregator. This combination links to an XML description of the set of telemetry events tracked by the aggregator. XML files are published by Intel in a GitHub repository [1]. The telemetry event aggregators maintain per-RMID per-event counts of the total seen for all the CPUs. There may be multiple telemetry event aggregat= ors per package. There are separate sets of aggregators for each feature type. Aggregators in a set may have different guids. All aggregators with the same feature type and guid are symmetric keeping counts for the same set of events for the CPUs that provide data to them. The XML file for each aggregator provides the following information: 0) Feature type of the events ("perf" or "energy") 1) Which telemetry events are tracked by the aggregator. 2) The order in which the event counters appear for each RMID. 3) The value type of each event counter (integer or fixed-point). 4) The number of RMIDs supported. 5) Which additional aggregator status registers are included. 6) The total size of the MMIO region for an aggregator. Introduce struct event_group that condenses the relevant information from an XML file. Hereafter an "event group" refers to a group of events of a particular feature type ("energy" or "perf") with a particular guid. The INTEL_PMT_TELEMETRY driver enumerates support for telemetry events. This driver provides intel_pmt_get_regions_by_feature() to list all availab= le telemetry event aggregators of a given feature type. The list includes the "guid", the base address in MMIO space for the region where the event count= ers are exposed, and the package id where the all the CPUs that report to this aggregator are located. Call INTEL_PMT_TELEMETRY's intel_pmt_get_regions_by_feature() for each event group to obtain a private copy of that event group's aggregator data. Dupli= cate the aggregator data between event groups that have the same feature type but different guid. Further processing on this private copy will be unique to the event group. Return the aggregator data to INTEL_PMT_TELEMETRY at resctrl exit time. resctrl will silently ignore unknown guid values. Add a new Kconfig option CONFIG_X86_CPU_RESCTRL_INTEL_AET for the Intel spe= cific parts of telemetry code. This depends on the INTEL_PMT_TELEMETRY and INTEL_= TPMI drivers being built-in to the kernel for enumeration of telemetry features. Signed-off-by: Tony Luck Link: https://github.com/intel/Intel-PMT # [1] --- arch/x86/kernel/cpu/resctrl/internal.h | 8 ++ arch/x86/kernel/cpu/resctrl/core.c | 5 ++ arch/x86/kernel/cpu/resctrl/intel_aet.c | 98 +++++++++++++++++++++++++ arch/x86/Kconfig | 13 ++++ arch/x86/kernel/cpu/resctrl/Makefile | 1 + 5 files changed, 125 insertions(+) create mode 100644 arch/x86/kernel/cpu/resctrl/intel_aet.c diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/r= esctrl/internal.h index ae182b5f9a3c..e15300b6bae9 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -222,4 +222,12 @@ 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 +#ifdef CONFIG_X86_CPU_RESCTRL_INTEL_AET +bool intel_aet_get_events(void); +void __exit intel_aet_exit(void); +#else +static inline bool intel_aet_get_events(void) { return false; } +static inline void __exit intel_aet_exit(void) { } +#endif + #endif /* _ASM_X86_RESCTRL_INTERNAL_H */ diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resct= rl/core.c index 986b1303efb9..88be77d5d20d 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -743,6 +743,9 @@ void resctrl_arch_pre_mount(void) =20 if (!atomic_try_cmpxchg(&only_once, &old, 1)) return; + + if (!intel_aet_get_events()) + return; } =20 enum { @@ -1104,6 +1107,8 @@ 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 new file mode 100644 index 000000000000..5d34c7349b02 --- /dev/null +++ b/arch/x86/kernel/cpu/resctrl/intel_aet.c @@ -0,0 +1,98 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Resource Director Technology(RDT) + * - Intel Application Energy Telemetry + * + * Copyright (C) 2025 Intel Corporation + * + * Author: + * Tony Luck + */ + +#define pr_fmt(fmt) "resctrl: " fmt + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "internal.h" + +/** + * struct event_group - Events with the same feature type ("energy" or "pe= rf") and guid. + * @feature: Type of events, for example FEATURE_PER_RMID_PERF_TELEM or + * FEATURE_PER_RMID_ENERGY_TELEM, in this group. + * @pfg: Points to the aggregated telemetry space information + * returned by the intel_pmt_get_regions_by_feature() + * call to the INTEL_PMT_TELEMETRY driver that contains + * data for all telemetry regions type @feature. + * Valid if the system supports the event group. + * NULL otherwise. + */ +struct event_group { + /* Data fields for additional structures to manage this group. */ + enum pmt_feature_id feature; + struct pmt_feature_group *pfg; +}; + +static struct event_group *known_event_groups[] =3D { +}; + +#define for_each_event_group(_peg) \ + for (_peg =3D known_event_groups; \ + _peg < &known_event_groups[ARRAY_SIZE(known_event_groups)]; \ + _peg++) + +/* Stub for now */ +static bool enable_events(struct event_group *e, struct pmt_feature_group = *p) +{ + return false; +} + +/* + * Make a request to the INTEL_PMT_TELEMETRY driver for a copy of the + * pmt_feature_group for each known feature. If there is one, the returned + * structure has an array of telemetry_region structures, each element of + * the array describes one telemetry aggregator. + * A single pmt_feature_group may include multiple different guids. + * Save the pmt_feature_group for enabled events. + */ +bool intel_aet_get_events(void) +{ + struct pmt_feature_group *p; + struct event_group **peg; + bool ret =3D false; + + for_each_event_group(peg) { + p =3D intel_pmt_get_regions_by_feature((*peg)->feature); + 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); + } + } + + return ret; +} + +void __exit intel_aet_exit(void) +{ + struct event_group **peg; + + for_each_event_group(peg) { + if ((*peg)->pfg) { + intel_pmt_put_feature_group((*peg)->pfg); + (*peg)->pfg =3D NULL; + } + } +} diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index c4c21e8d0772..126c89afcf69 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -538,6 +538,19 @@ 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 d8a04b195da2..273ddfa30836 100644 --- a/arch/x86/kernel/cpu/resctrl/Makefile +++ b/arch/x86/kernel/cpu/resctrl/Makefile @@ -1,6 +1,7 @@ # 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_RESCTRL_FS_PSEUDO_LOCK) +=3D pseudo_lock.o =20 # To allow define_trace.h's recursive include: --=20 2.51.1 From nobody Tue Dec 2 00:25:23 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3FD15322A1D for ; Mon, 24 Nov 2025 18:54:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764010501; cv=none; b=EaAGlq+XQz0LaqmGDrv9/FV9ZBrrCSaOqQHr0zYHhWye7/w/gotJKFsoi9xlxs4waltOo7sqGWTWe38aXVXj1gCdc1lcCbkKbeokHUQZh/NPxouEhQhrE+D5tbqJP5xOYC6k3y6o5KlYZGS5SNJhoDkmTEocvOm6WmZccKlWPYA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764010501; c=relaxed/simple; bh=CTxvWcE/OJjq2RZ9bDpSbXPA0iuN5U6X9B4UhOlAc+g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=I4EsocA714ycGYcqpihfCx/Gd/CSIZEZkKKoo/sUJbrn8Wt3sUou92zJV4L6i9r+srdUlCqu9+cQqmYUQorBdxlgczBqVJtKGZXm/9Wb8p4p4QBop3pMIxkUJwTkRKkxI3dWKQX431dNauMN8m7IEb2igkGRFLSFInisKwhABh4= 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=Jqpxh5cO; arc=none smtp.client-ip=192.198.163.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Jqpxh5cO" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1764010499; x=1795546499; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=CTxvWcE/OJjq2RZ9bDpSbXPA0iuN5U6X9B4UhOlAc+g=; b=Jqpxh5cOYaUF7H1tY+TBZWxYtedP7D8p0xX3gmUl9ByJ5G5s2D3AYWhC uknuJ7DT+/XTBSJK8QXpA29EWQK1UToudj5z5Uexar40emweYtt2KYXWs X2Xm8519aOl3JEJOBUvbxAtVaFY1A88rKDFScVBuQVspQi9pGH3SAtS2i 7h2j0qg1MY1a5uRtUYtKIDWLJTZ/jzlt1L4jGzCOWuEgjD3cazVfbv9Bc zUHukAJ0EoLSkb/I4N9nNWuTDq27oJWABrL4zApMe0xzJgIIyTvQ7Yv/U oLya2Uni40HYkRoo6Qnr5HWPTnoS04kAtOgRuErc7D0TlVMgRhjNraZo+ w==; X-CSE-ConnectionGUID: X2u7BLHWQRKuAPzMEsBKvg== X-CSE-MsgGUID: 9qiJPSiITJmOQRy8Ega8fw== X-IronPort-AV: E=McAfee;i="6800,10657,11623"; a="76636716" X-IronPort-AV: E=Sophos;i="6.20,223,1758610800"; d="scan'208";a="76636716" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Nov 2025 10:54:27 -0800 X-CSE-ConnectionGUID: k5TsHJ//R7mKhdRKkOrp3Q== X-CSE-MsgGUID: 84m505RcRlKtu6tI+VYVgA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.20,223,1758610800"; d="scan'208";a="192224999" Received: from rfrazer-mobl3.amr.corp.intel.com (HELO agluck-desk3.home.arpa) ([10.124.222.153]) by orviesa009-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Nov 2025 10:54:27 -0800 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Maciej Wieczor-Retman , Peter Newman , James Morse , Babu Moger , Drew Fustini , Dave Martin , Chen Yu Cc: x86@kernel.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [PATCH v14 17/32] x86,fs/resctrl: Fill in details of events for guid 0x26696143 and 0x26557651 Date: Mon, 24 Nov 2025 10:53:54 -0800 Message-ID: <20251124185412.24155-18-tony.luck@intel.com> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251124185412.24155-1-tony.luck@intel.com> References: <20251124185412.24155-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 telemetry event aggregators of the Intel Clearwater Forest CPU support two RMID-based feature types: "energy" with guid 0x26696143 [1], and "perf" with guid 0x26557651 [2]. The event counter offsets in an aggregator's MMIO space are arranged in groups for each RMID. E.g the "energy" counters for guid 0x26696143 are arranged like this: MMIO offset:0x0000 Counter for RMID 0 PMT_EVENT_ENERGY MMIO offset:0x0008 Counter for RMID 0 PMT_EVENT_ACTIVITY MMIO offset:0x0010 Counter for RMID 1 PMT_EVENT_ENERGY MMIO offset:0x0018 Counter for RMID 1 PMT_EVENT_ACTIVITY ... MMIO offset:0x23F0 Counter for RMID 575 PMT_EVENT_ENERGY MMIO offset:0x23F8 Counter for RMID 575 PMT_EVENT_ACTIVITY After all counters there are three status registers that provide indications of how many times an aggregator was unable to process event counts, the time stamp for the most recent loss of data, and the time stamp of the most recent successful update. MMIO offset:0x2400 AGG_DATA_LOSS_COUNT MMIO offset:0x2408 AGG_DATA_LOSS_TIMESTAMP MMIO offset:0x2410 LAST_UPDATE_TIMESTAMP Define event_group structures for both of these events and define the events tracked by the aggregators in the file system code. PMT_EVENT_ENERGY and PMT_EVENT_ACTIVITY are produced in fixed point format. File system code must output as floating point values. Signed-off-by: Tony Luck Link: https://github.com/intel/Intel-PMT/blob/main/xml/CWF/OOBMSM/RMID-ENER= GY/cwf_aggregator.xml # [1] Link: https://github.com/intel/Intel-PMT/blob/main/xml/CWF/OOBMSM/RMID-PERF= /cwf_aggregator.xml # [2] --- include/linux/resctrl_types.h | 11 ++++ arch/x86/kernel/cpu/resctrl/intel_aet.c | 67 +++++++++++++++++++++++++ fs/resctrl/monitor.c | 35 +++++++------ 3 files changed, 98 insertions(+), 15 deletions(-) diff --git a/include/linux/resctrl_types.h b/include/linux/resctrl_types.h index acfe07860b34..a5f56faa18d2 100644 --- a/include/linux/resctrl_types.h +++ b/include/linux/resctrl_types.h @@ -50,6 +50,17 @@ enum resctrl_event_id { QOS_L3_MBM_TOTAL_EVENT_ID =3D 0x02, QOS_L3_MBM_LOCAL_EVENT_ID =3D 0x03, =20 + /* Intel Telemetry Events */ + PMT_EVENT_ENERGY, + PMT_EVENT_ACTIVITY, + PMT_EVENT_STALLS_LLC_HIT, + PMT_EVENT_C1_RES, + PMT_EVENT_UNHALTED_CORE_CYCLES, + PMT_EVENT_STALLS_LLC_MISS, + PMT_EVENT_AUTO_C6_RES, + PMT_EVENT_UNHALTED_REF_CYCLES, + PMT_EVENT_UOPS_RETIRED, + /* Must be the last */ QOS_NUM_EVENTS, }; diff --git a/arch/x86/kernel/cpu/resctrl/intel_aet.c b/arch/x86/kernel/cpu/= resctrl/intel_aet.c index 5d34c7349b02..bb080bdde190 100644 --- a/arch/x86/kernel/cpu/resctrl/intel_aet.c +++ b/arch/x86/kernel/cpu/resctrl/intel_aet.c @@ -13,6 +13,7 @@ =20 #include #include +#include #include #include #include @@ -20,11 +21,27 @@ #include #include #include +#include #include #include =20 #include "internal.h" =20 +/** + * struct pmt_event - Telemetry event. + * @id: Resctrl event id. + * @idx: Counter index within each per-RMID block of counters. + * @bin_bits: Zero for integer valued events, else number bits in fraction + * part of fixed-point. + */ +struct pmt_event { + enum resctrl_event_id id; + unsigned int idx; + unsigned int bin_bits; +}; + +#define EVT(_id, _idx, _bits) { .id =3D _id, .idx =3D _idx, .bin_bits =3D = _bits } + /** * struct event_group - Events with the same feature type ("energy" or "pe= rf") and guid. * @feature: Type of events, for example FEATURE_PER_RMID_PERF_TELEM or @@ -35,14 +52,64 @@ * data for all telemetry regions type @feature. * Valid if the system supports the event group. * NULL otherwise. + * @guid: Unique number per XML description file. + * @mmio_size: Number of bytes of MMIO registers for this group. + * @num_events: Number of events in this group. + * @evts: Array of event descriptors. */ struct event_group { /* Data fields for additional structures to manage this group. */ enum pmt_feature_id feature; struct pmt_feature_group *pfg; + + /* Remaining fields initialized from XML file. */ + u32 guid; + size_t mmio_size; + unsigned int num_events; + struct pmt_event evts[] __counted_by(num_events); +}; + +#define XML_MMIO_SIZE(num_rmids, num_events, num_extra_status) \ + (((num_rmids) * (num_events) + (num_extra_status)) * sizeof(u64)) + +/* + * Link: https://github.com/intel/Intel-PMT + * File: xml/CWF/OOBMSM/RMID-ENERGY/cwf_aggregator.xml + */ +static struct event_group energy_0x26696143 =3D { + .feature =3D FEATURE_PER_RMID_ENERGY_TELEM, + .guid =3D 0x26696143, + .mmio_size =3D XML_MMIO_SIZE(576, 2, 3), + .num_events =3D 2, + .evts =3D { + EVT(PMT_EVENT_ENERGY, 0, 18), + EVT(PMT_EVENT_ACTIVITY, 1, 18), + } +}; + +/* + * Link: https://github.com/intel/Intel-PMT + * File: xml/CWF/OOBMSM/RMID-PERF/cwf_aggregator.xml + */ +static struct event_group perf_0x26557651 =3D { + .feature =3D FEATURE_PER_RMID_PERF_TELEM, + .guid =3D 0x26557651, + .mmio_size =3D XML_MMIO_SIZE(576, 7, 3), + .num_events =3D 7, + .evts =3D { + EVT(PMT_EVENT_STALLS_LLC_HIT, 0, 0), + EVT(PMT_EVENT_C1_RES, 1, 0), + EVT(PMT_EVENT_UNHALTED_CORE_CYCLES, 2, 0), + EVT(PMT_EVENT_STALLS_LLC_MISS, 3, 0), + EVT(PMT_EVENT_AUTO_C6_RES, 4, 0), + EVT(PMT_EVENT_UNHALTED_REF_CYCLES, 5, 0), + EVT(PMT_EVENT_UOPS_RETIRED, 6, 0), + } }; =20 static struct event_group *known_event_groups[] =3D { + &energy_0x26696143, + &perf_0x26557651, }; =20 #define for_each_event_group(_peg) \ diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c index 9c316b714968..df80eac48be6 100644 --- a/fs/resctrl/monitor.c +++ b/fs/resctrl/monitor.c @@ -958,27 +958,32 @@ static void dom_data_exit(struct rdt_resource *r) mutex_unlock(&rdtgroup_mutex); } =20 +#define MON_EVENT(_eventid, _name, _res, _fp) \ + [_eventid] =3D { \ + .name =3D _name, \ + .evtid =3D _eventid, \ + .rid =3D _res, \ + .is_floating_point =3D _fp, \ +} + /* * All available events. Architecture code marks the ones that * are supported by a system using resctrl_enable_mon_event() * to set .enabled. */ struct mon_evt mon_event_all[QOS_NUM_EVENTS] =3D { - [QOS_L3_OCCUP_EVENT_ID] =3D { - .name =3D "llc_occupancy", - .evtid =3D QOS_L3_OCCUP_EVENT_ID, - .rid =3D RDT_RESOURCE_L3, - }, - [QOS_L3_MBM_TOTAL_EVENT_ID] =3D { - .name =3D "mbm_total_bytes", - .evtid =3D QOS_L3_MBM_TOTAL_EVENT_ID, - .rid =3D RDT_RESOURCE_L3, - }, - [QOS_L3_MBM_LOCAL_EVENT_ID] =3D { - .name =3D "mbm_local_bytes", - .evtid =3D QOS_L3_MBM_LOCAL_EVENT_ID, - .rid =3D RDT_RESOURCE_L3, - }, + MON_EVENT(QOS_L3_OCCUP_EVENT_ID, "llc_occupancy", RDT_RESOURCE_L3, false= ), + MON_EVENT(QOS_L3_MBM_TOTAL_EVENT_ID, "mbm_total_bytes", RDT_RESOURCE_L3,= false), + MON_EVENT(QOS_L3_MBM_LOCAL_EVENT_ID, "mbm_local_bytes", RDT_RESOURCE_L3,= false), + MON_EVENT(PMT_EVENT_ENERGY, "core_energy", RDT_RESOURCE_PERF_PKG, true= ), + MON_EVENT(PMT_EVENT_ACTIVITY, "activity", RDT_RESOURCE_PERF_PKG, true), + MON_EVENT(PMT_EVENT_STALLS_LLC_HIT, "stalls_llc_hit", RDT_RESOURCE_PERF_= PKG, false), + MON_EVENT(PMT_EVENT_C1_RES, "c1_res", RDT_RESOURCE_PERF_PKG, false), + MON_EVENT(PMT_EVENT_UNHALTED_CORE_CYCLES, "unhalted_core_cycles", RDT_RES= OURCE_PERF_PKG, false), + MON_EVENT(PMT_EVENT_STALLS_LLC_MISS, "stalls_llc_miss", RDT_RESOURCE_PER= F_PKG, false), + MON_EVENT(PMT_EVENT_AUTO_C6_RES, "c6_res", RDT_RESOURCE_PERF_PKG, false= ), + MON_EVENT(PMT_EVENT_UNHALTED_REF_CYCLES, "unhalted_ref_cycles", RDT_RESOU= RCE_PERF_PKG, false), + MON_EVENT(PMT_EVENT_UOPS_RETIRED, "uops_retired", RDT_RESOURCE_PERF_PKG= , false), }; =20 void resctrl_enable_mon_event(enum resctrl_event_id eventid, bool any_cpu,= unsigned int binary_bits) --=20 2.51.1 From nobody Tue Dec 2 00:25:23 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7DD1B31AF16 for ; Mon, 24 Nov 2025 18:55:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764010502; cv=none; b=BfiFNrCThzar1sC6Ou3YDIlS8qOCSozSTgh8+GwJib+jh+EifsBbb/7Lk/uQdjHhhUA3Xw7CBOFnjGX3nJbsYHmDsXGQrdTs2cGbxD9+v4JnQabX+aZ5uyUYR394PJ5xcQZhCGSjjqIBxHwOVIyz2I1f1cMFFBxU+yGgsHw/6cE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764010502; c=relaxed/simple; bh=6GrPylPFisdcurseo1AGNjm1a3TuTazSYkfuPBSGenw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XqfA2a0GAQ543cg+I3fuqYm64oJ8HFPCbx8/TTQPWt5PtnOdmEgZEba4LgM+On1hCk8ExPHsSX682IXWr2N10Trmz7GlvI+/paAma7kM5JhCBO7pZ7hQqJSOOjvyo/To9+LEVWj3k0VC1pY5YlwRHTQd8kqu1BNPBAThMwjink0= 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=G9LJ2L60; arc=none smtp.client-ip=192.198.163.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="G9LJ2L60" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1764010500; x=1795546500; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=6GrPylPFisdcurseo1AGNjm1a3TuTazSYkfuPBSGenw=; b=G9LJ2L60znsDBcg3qDfyS52Ox1ca/gl9MP/SPpvRWh6doLdEQ+yZxVqW TCxEBij0YhHvh+luAOVukAc9N3Qowo8L5amIGWcEQglCQ1WuH43rccXZ6 w0sMinnW7bExEpshnzDGhduFo8rwHIozFKEJlSyqkuj3PzBY8UIwWCtsy AmPGKvBK+abonGyF3uiuU//QWW+rLOEvd1+rmRsvoeO1LaiJyNz7OOML8 l5GmkT/l+revqrwxCi5BaxgzxNZshfFpUp6+0A/gJYPfo0tXl54go4qoa XKvcYIBlqlNHLH0QI5bSoS8p9iHTXpx4BfA/kJXjQ6A2GNl7cfB3b70UY w==; X-CSE-ConnectionGUID: 0T5+QSK+ThCtWCw+clHKEA== X-CSE-MsgGUID: clYEgiUhRTKPaH3h3jxayQ== X-IronPort-AV: E=McAfee;i="6800,10657,11623"; a="76636735" X-IronPort-AV: E=Sophos;i="6.20,223,1758610800"; d="scan'208";a="76636735" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Nov 2025 10:54:28 -0800 X-CSE-ConnectionGUID: Hxvd4eSxTvaq0u3TRnQK/A== X-CSE-MsgGUID: RePiIoMERhiGEQvTSeujng== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.20,223,1758610800"; d="scan'208";a="192225003" Received: from rfrazer-mobl3.amr.corp.intel.com (HELO agluck-desk3.home.arpa) ([10.124.222.153]) by orviesa009-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Nov 2025 10:54:28 -0800 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Maciej Wieczor-Retman , Peter Newman , James Morse , Babu Moger , Drew Fustini , Dave Martin , Chen Yu Cc: x86@kernel.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [PATCH v14 18/32] x86,fs/resctrl: Add architectural event pointer Date: Mon, 24 Nov 2025 10:53:55 -0800 Message-ID: <20251124185412.24155-19-tony.luck@intel.com> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251124185412.24155-1-tony.luck@intel.com> References: <20251124185412.24155-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 resctrl file system layer passes the domain, RMID, and event id to the architecture to fetch an event counter. Fetching a telemetry event counter requires additional information that is private to the architecture, for example, the offset into MMIO space from where the counter should be read. Add mon_evt::arch_priv that architecture can use for any private data relat= ed to the event. resctrl filesystem initializes mon_evt::arch_priv when the architecture enables the event and passes it back to architecture when needing to fetch an event counter. Suggested-by: Reinette Chatre Signed-off-by: Tony Luck Reviewed-by: Reinette Chatre --- include/linux/resctrl.h | 7 +++++-- fs/resctrl/internal.h | 4 ++++ arch/x86/kernel/cpu/resctrl/core.c | 6 +++--- arch/x86/kernel/cpu/resctrl/monitor.c | 2 +- fs/resctrl/monitor.c | 14 ++++++++++---- 5 files changed, 23 insertions(+), 10 deletions(-) diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index 2a3613f27274..b30f99335bbe 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -415,7 +415,7 @@ u32 resctrl_arch_system_num_rmid_idx(void); int resctrl_arch_update_domains(struct rdt_resource *r, u32 closid); =20 void resctrl_enable_mon_event(enum resctrl_event_id eventid, bool any_cpu, - unsigned int binary_bits); + unsigned int binary_bits, void *arch_priv); =20 bool resctrl_is_mon_event_enabled(enum resctrl_event_id eventid); =20 @@ -532,6 +532,9 @@ void resctrl_arch_pre_mount(void); * only. * @rmid: rmid of the counter to read. * @eventid: eventid to read, e.g. L3 occupancy. + * @arch_priv: Architecture private data for this event. + * The @arch_priv provided by the architecture via + * resctrl_enable_mon_event(). * @val: result of the counter read in bytes. * @arch_mon_ctx: An architecture specific value from * resctrl_arch_mon_ctx_alloc(), for MPAM this identifies @@ -549,7 +552,7 @@ void resctrl_arch_pre_mount(void); */ int resctrl_arch_rmid_read(struct rdt_resource *r, struct rdt_domain_hdr *= hdr, u32 closid, u32 rmid, enum resctrl_event_id eventid, - u64 *val, void *arch_mon_ctx); + void *arch_priv, u64 *val, void *arch_mon_ctx); =20 /** * resctrl_arch_rmid_read_context_check() - warn about invalid contexts diff --git a/fs/resctrl/internal.h b/fs/resctrl/internal.h index 50d88e91e0da..399f625be67d 100644 --- a/fs/resctrl/internal.h +++ b/fs/resctrl/internal.h @@ -66,6 +66,9 @@ static inline struct rdt_fs_context *rdt_fc2context(struc= t fs_context *fc) * @binary_bits: number of fixed-point binary bits from architecture, * only valid if @is_floating_point is true * @enabled: true if the event is enabled + * @arch_priv: Architecture private data for this event. + * The @arch_priv provided by the architecture via + * resctrl_enable_mon_event(). */ struct mon_evt { enum resctrl_event_id evtid; @@ -77,6 +80,7 @@ struct mon_evt { bool is_floating_point; unsigned int binary_bits; bool enabled; + void *arch_priv; }; =20 extern struct mon_evt mon_event_all[QOS_NUM_EVENTS]; diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resct= rl/core.c index 88be77d5d20d..3c6946a5ff1b 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -924,15 +924,15 @@ static __init bool get_rdt_mon_resources(void) bool ret =3D false; =20 if (rdt_cpu_has(X86_FEATURE_CQM_OCCUP_LLC)) { - resctrl_enable_mon_event(QOS_L3_OCCUP_EVENT_ID, false, 0); + resctrl_enable_mon_event(QOS_L3_OCCUP_EVENT_ID, false, 0, NULL); ret =3D true; } if (rdt_cpu_has(X86_FEATURE_CQM_MBM_TOTAL)) { - resctrl_enable_mon_event(QOS_L3_MBM_TOTAL_EVENT_ID, false, 0); + resctrl_enable_mon_event(QOS_L3_MBM_TOTAL_EVENT_ID, false, 0, NULL); ret =3D true; } if (rdt_cpu_has(X86_FEATURE_CQM_MBM_LOCAL)) { - resctrl_enable_mon_event(QOS_L3_MBM_LOCAL_EVENT_ID, false, 0); + resctrl_enable_mon_event(QOS_L3_MBM_LOCAL_EVENT_ID, false, 0, NULL); ret =3D true; } if (rdt_cpu_has(X86_FEATURE_ABMC)) diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/re= sctrl/monitor.c index 20605212656c..6929614ba6e6 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -240,7 +240,7 @@ static u64 get_corrected_val(struct rdt_resource *r, st= ruct rdt_l3_mon_domain *d =20 int resctrl_arch_rmid_read(struct rdt_resource *r, struct rdt_domain_hdr *= hdr, u32 unused, u32 rmid, enum resctrl_event_id eventid, - u64 *val, void *ignored) + void *arch_priv, u64 *val, void *ignored) { struct rdt_hw_l3_mon_domain *hw_dom; struct rdt_l3_mon_domain *d; diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c index df80eac48be6..4ef91fc09070 100644 --- a/fs/resctrl/monitor.c +++ b/fs/resctrl/monitor.c @@ -137,9 +137,11 @@ void __check_limbo(struct rdt_l3_mon_domain *d, bool f= orce_free) struct rmid_entry *entry; u32 idx, cur_idx =3D 1; void *arch_mon_ctx; + void *arch_priv; bool rmid_dirty; u64 val =3D 0; =20 + arch_priv =3D mon_event_all[QOS_L3_OCCUP_EVENT_ID].arch_priv; arch_mon_ctx =3D resctrl_arch_mon_ctx_alloc(r, QOS_L3_OCCUP_EVENT_ID); if (IS_ERR(arch_mon_ctx)) { pr_warn_ratelimited("Failed to allocate monitor context: %ld", @@ -160,7 +162,7 @@ void __check_limbo(struct rdt_l3_mon_domain *d, bool fo= rce_free) =20 entry =3D __rmid_entry(idx); if (resctrl_arch_rmid_read(r, &d->hdr, entry->closid, entry->rmid, - QOS_L3_OCCUP_EVENT_ID, &val, + QOS_L3_OCCUP_EVENT_ID, arch_priv, &val, arch_mon_ctx)) { rmid_dirty =3D true; } else { @@ -456,7 +458,8 @@ static int __l3_mon_event_count(struct rdtgroup *rdtgrp= , struct rmid_read *rr) rr->evt->evtid, &tval); else rr->err =3D resctrl_arch_rmid_read(rr->r, rr->hdr, closid, rmid, - rr->evt->evtid, &tval, rr->arch_mon_ctx); + rr->evt->evtid, rr->evt->arch_priv, + &tval, rr->arch_mon_ctx); if (rr->err) return rr->err; =20 @@ -495,7 +498,8 @@ static int __l3_mon_event_count_sum(struct rdtgroup *rd= tgrp, struct rmid_read *r rr->evt->evtid, &tval); else err =3D resctrl_arch_rmid_read(rr->r, &d->hdr, closid, rmid, - rr->evt->evtid, &tval, rr->arch_mon_ctx); + rr->evt->evtid, rr->evt->arch_priv, + &tval, rr->arch_mon_ctx); if (!err) { rr->val +=3D tval; ret =3D 0; @@ -986,7 +990,8 @@ struct mon_evt mon_event_all[QOS_NUM_EVENTS] =3D { MON_EVENT(PMT_EVENT_UOPS_RETIRED, "uops_retired", RDT_RESOURCE_PERF_PKG= , false), }; =20 -void resctrl_enable_mon_event(enum resctrl_event_id eventid, bool any_cpu,= unsigned int binary_bits) +void resctrl_enable_mon_event(enum resctrl_event_id eventid, bool any_cpu, + unsigned int binary_bits, void *arch_priv) { if (WARN_ON_ONCE(eventid < QOS_FIRST_EVENT || eventid >=3D QOS_NUM_EVENTS= || binary_bits > MAX_BINARY_BITS)) @@ -1002,6 +1007,7 @@ void resctrl_enable_mon_event(enum resctrl_event_id e= ventid, bool any_cpu, unsig =20 mon_event_all[eventid].any_cpu =3D any_cpu; mon_event_all[eventid].binary_bits =3D binary_bits; + mon_event_all[eventid].arch_priv =3D arch_priv; mon_event_all[eventid].enabled =3D true; } =20 --=20 2.51.1 From nobody Tue Dec 2 00:25:23 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 54E2932470C for ; Mon, 24 Nov 2025 18:55:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764010503; cv=none; b=Qnqz8LhiZKwrvpbdnyd7oTbv+EVVnIPzWlMUb52hV697cIMrmpk64vXRtrtK0Qz0gIfSpdMOK61AI/Ymu4bLjIjyp/YzNbR4/k1Au6aI2MPA8MlMDueJPoR2GoPLiAyNCdDGUmIGOFTVMOM2z0T0N2TYP6i/y9445Ynw7u3W1/I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764010503; c=relaxed/simple; bh=1/7YjHVOswPHiSd8P5BTn0s80BzXAbC++aIrzSo0rdg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pfnwa0TvqogvfcJHOXsX+S6Jl9sUtxztcXK1TizqkQsQmki0tfHlOik7a+1Q/SN6Gjo5ebvMCE2AVouUx2M86gx41w4uCZmjBwrmk5R/VYAcyugyGHvoTK7kZ91qhPtH2IloWVIaEwnb+vGw+iadV9vEdXEwUlBzemIxPdH+AB4= 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=m4zDDRwI; arc=none smtp.client-ip=192.198.163.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="m4zDDRwI" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1764010501; x=1795546501; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=1/7YjHVOswPHiSd8P5BTn0s80BzXAbC++aIrzSo0rdg=; b=m4zDDRwIKq+aJy8879nfl7breHA0gN9OyvhP6uxpm+YEyrpZhv9jaY+R hVRZuUAquZkhGgZH8Z1mkbODcCm00CXYjNvFwWt3muT5IDvmRe3XtaxkZ QohjeN2a+V87xeYsYjTJinB70ydfclR/GrV61UV+PkgwpkH4b5qDwv1YM WhrQ0vM5Ec6FKxMDtzGO70/WFeTQXDQiSYpOc5kv9X112jATohZ7c5hbX kq3nkNPhjpAlnzCcUTbOzv58e4v6BNtah9V9r+HuJN0erdIiOqJFoUeky tVv34/9nnLyW4eZwPzsIL61TEejIuwlDsSbDURwnbtf/h8ymEtkq6fSfO Q==; X-CSE-ConnectionGUID: LEQLjK9lQg2S/8jVlQroxQ== X-CSE-MsgGUID: r6yczpMTSAyy0+hB453p8A== X-IronPort-AV: E=McAfee;i="6800,10657,11623"; a="76636754" X-IronPort-AV: E=Sophos;i="6.20,223,1758610800"; d="scan'208";a="76636754" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Nov 2025 10:54:28 -0800 X-CSE-ConnectionGUID: 9zqU/LEfSzSb94AtyEst5g== X-CSE-MsgGUID: 2CVvVsE3TLyeTG3ALRI5AQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.20,223,1758610800"; d="scan'208";a="192225008" Received: from rfrazer-mobl3.amr.corp.intel.com (HELO agluck-desk3.home.arpa) ([10.124.222.153]) by orviesa009-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Nov 2025 10:54:28 -0800 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Maciej Wieczor-Retman , Peter Newman , James Morse , Babu Moger , Drew Fustini , Dave Martin , Chen Yu Cc: x86@kernel.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [PATCH v14 19/32] x86/resctrl: Find and enable usable telemetry events Date: Mon, 24 Nov 2025 10:53:56 -0800 Message-ID: <20251124185412.24155-20-tony.luck@intel.com> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251124185412.24155-1-tony.luck@intel.com> References: <20251124185412.24155-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" Every event group has a private copy of the data of all telemetry event aggregators (aka "telemetry regions") tracking its feature type. Included may be regions that have the same feature type but tracking different guid from the event group's. Traverse the event group's telemetry region data and mark all regions that are not usable by the event group as unusable by clearing those regions' MMIO addresses. A region is considered unusable if: 1) guid does not match the guid of the event group. 2) Package ID is invalid. 3) The enumerated size of the MMIO region does not match the expected value from the XML description file. Hereafter any telemetry region with an MMIO address is considered valid for the event group it is associated with. Enable all the event group's events as long as there is at least one usable region from where data for its events can be read. Note that it is architecturally possible that some telemetry events are only supported by a subset of the packages in the system. It is not expected that systems will ever do this. If they do the user will see event files in resctrl that always return "Unavailable". Signed-off-by: Tony Luck --- include/linux/resctrl.h | 2 +- arch/x86/kernel/cpu/resctrl/intel_aet.c | 62 ++++++++++++++++++++++++- fs/resctrl/monitor.c | 10 ++-- 3 files changed, 67 insertions(+), 7 deletions(-) diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index b30f99335bbe..14126d228e61 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -414,7 +414,7 @@ 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 -void resctrl_enable_mon_event(enum resctrl_event_id eventid, bool any_cpu, +bool resctrl_enable_mon_event(enum resctrl_event_id eventid, bool any_cpu, unsigned int binary_bits, void *arch_priv); =20 bool resctrl_is_mon_event_enabled(enum resctrl_event_id eventid); diff --git a/arch/x86/kernel/cpu/resctrl/intel_aet.c b/arch/x86/kernel/cpu/= resctrl/intel_aet.c index bb080bdde190..b6b50650e634 100644 --- a/arch/x86/kernel/cpu/resctrl/intel_aet.c +++ b/arch/x86/kernel/cpu/resctrl/intel_aet.c @@ -20,9 +20,11 @@ #include #include #include +#include #include #include #include +#include #include =20 #include "internal.h" @@ -117,12 +119,68 @@ static struct event_group *known_event_groups[] =3D { _peg < &known_event_groups[ARRAY_SIZE(known_event_groups)]; \ _peg++) =20 -/* Stub for now */ -static bool enable_events(struct event_group *e, struct pmt_feature_group = *p) +/* + * Clear the address field of regions that did not pass the checks in + * skip_telem_region() so they will not be used by intel_aet_read_event(). + * This is safe to do because intel_pmt_get_regions_by_feature() allocates + * a new pmt_feature_group structure to return to each caller and only mak= es + * use of the pmt_feature_group::kref field when intel_pmt_put_feature_gro= up() + * returns the structure. + */ +static void mark_telem_region_unusable(struct telemetry_region *tr) { + tr->addr =3D NULL; +} + +static bool skip_telem_region(struct telemetry_region *tr, struct event_gr= oup *e) +{ + if (tr->guid !=3D e->guid) + return true; + if (tr->plat_info.package_id >=3D topology_max_packages()) { + pr_warn("Bad package %u in guid 0x%x\n", tr->plat_info.package_id, + tr->guid); + return true; + } + if (tr->size !=3D e->mmio_size) { + pr_warn("MMIO space wrong size (%zu bytes) for guid 0x%x. Expected %zu b= ytes.\n", + tr->size, e->guid, e->mmio_size); + return true; + } + return false; } =20 +static bool group_has_usable_regions(struct event_group *e, struct pmt_fea= ture_group *p) +{ + bool usable_regions =3D false; + + for (int i =3D 0; i < p->count; i++) { + if (skip_telem_region(&p->regions[i], e)) { + mark_telem_region_unusable(&p->regions[i]); + continue; + } + usable_regions =3D true; + } + + return usable_regions; +} + +static bool enable_events(struct event_group *e, struct pmt_feature_group = *p) +{ + int skipped_events =3D 0; + + if (!group_has_usable_regions(e, p)) + return false; + + for (int j =3D 0; j < e->num_events; j++) { + if (!resctrl_enable_mon_event(e->evts[j].id, true, + e->evts[j].bin_bits, &e->evts[j])) + skipped_events++; + } + + return skipped_events < e->num_events; +} + /* * Make a request to the INTEL_PMT_TELEMETRY driver for a copy of the * pmt_feature_group for each known feature. If there is one, the returned diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c index 4ef91fc09070..338a122dfcff 100644 --- a/fs/resctrl/monitor.c +++ b/fs/resctrl/monitor.c @@ -990,25 +990,27 @@ struct mon_evt mon_event_all[QOS_NUM_EVENTS] =3D { MON_EVENT(PMT_EVENT_UOPS_RETIRED, "uops_retired", RDT_RESOURCE_PERF_PKG= , false), }; =20 -void resctrl_enable_mon_event(enum resctrl_event_id eventid, bool any_cpu, +bool resctrl_enable_mon_event(enum resctrl_event_id eventid, bool any_cpu, unsigned int binary_bits, void *arch_priv) { if (WARN_ON_ONCE(eventid < QOS_FIRST_EVENT || eventid >=3D QOS_NUM_EVENTS= || binary_bits > MAX_BINARY_BITS)) - return; + return false; if (mon_event_all[eventid].enabled) { pr_warn("Duplicate enable for event %d\n", eventid); - return; + return false; } if (binary_bits && !mon_event_all[eventid].is_floating_point) { pr_warn("Event %d may not be floating point\n", eventid); - return; + return false; } =20 mon_event_all[eventid].any_cpu =3D any_cpu; mon_event_all[eventid].binary_bits =3D binary_bits; mon_event_all[eventid].arch_priv =3D arch_priv; mon_event_all[eventid].enabled =3D true; + + return true; } =20 bool resctrl_is_mon_event_enabled(enum resctrl_event_id eventid) --=20 2.51.1 From nobody Tue Dec 2 00:25:23 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 42705321F48 for ; Mon, 24 Nov 2025 18:55:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764010504; cv=none; b=nMK2yN5wW3NTjkJsInHZOrIa0i876geLH70joZ2QVthgjt1cSvJXcNZ2Ta7TKw7jOg1PsQZkW5G/RO2u/dZ5fG7ZQv2NwWt3NYmVaeMrjGk8xjxdTd/4BmLnQGJOXVh6pbBMXqnaQUDUXBPwIgvQu4c8tparhOUGWJoH2BkHlCI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764010504; c=relaxed/simple; bh=elSTMcZpYXJ1U1xYtin17erduBVFEv4aqYAbm0URDn0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Gc+uerl6WTXuXVndrYJI/vKKvtZXmC1XTYIZ8mDXuABZbbP2613Q2O8KLKuzALsIYCoyBgmnWWkwMUSUOn2lVfcpa8LRojoH6O3kEGzTnhNBCOWSl2v32qTwkdq00Jkj+a0iUdXpIOpz7mdqnso871UWV7tqOsTMFp7LefALv3E= 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=BiZXUW9Y; arc=none smtp.client-ip=192.198.163.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="BiZXUW9Y" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1764010502; x=1795546502; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=elSTMcZpYXJ1U1xYtin17erduBVFEv4aqYAbm0URDn0=; b=BiZXUW9Yhefm6l905X+fSNXn/mC5i238Uz4soh7QeB9HBwS6JSgKkLNk 4rxrzXywZUVKdYIej0sHtZEF0b3BJiKSUj60rSussduHmk7p+Oyv9C4DU R4ohhlEZ5hMMYFTXpvTlfheHZmA32hnfcSthFmHB02rAPdcwIZGtUwf7h veNcSVWlCgCLMsTZr3xzedE0CbyuNLNVtvcXXkCL6qtYxXCAu9eu1GDCO wN80HsEQGsRXSn/pGZVJLsFt/vSLnf8NcMPGkcjPVE2lvnRDXsUe5DpHI oS6svWyKy2mYz1yVj+NJK4/Hc+pZ69DEg7Xi9p0kbMo0wqBoWVdF0UXWy g==; X-CSE-ConnectionGUID: OVSqKfkHQmanqSHN2D+6tQ== X-CSE-MsgGUID: ERDa5HIMSdad/zjpexhtMA== X-IronPort-AV: E=McAfee;i="6800,10657,11623"; a="76636770" X-IronPort-AV: E=Sophos;i="6.20,223,1758610800"; d="scan'208";a="76636770" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Nov 2025 10:54:29 -0800 X-CSE-ConnectionGUID: hG7iwNwoRAWn8Er2/HK+pQ== X-CSE-MsgGUID: nvyew+SYRgWLcQ3Q/ggTTQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.20,223,1758610800"; d="scan'208";a="192225011" Received: from rfrazer-mobl3.amr.corp.intel.com (HELO agluck-desk3.home.arpa) ([10.124.222.153]) by orviesa009-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Nov 2025 10:54:28 -0800 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Maciej Wieczor-Retman , Peter Newman , James Morse , Babu Moger , Drew Fustini , Dave Martin , Chen Yu Cc: x86@kernel.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [PATCH v14 20/32] x86/resctrl: Read telemetry events Date: Mon, 24 Nov 2025 10:53:57 -0800 Message-ID: <20251124185412.24155-21-tony.luck@intel.com> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251124185412.24155-1-tony.luck@intel.com> References: <20251124185412.24155-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" Introduce intel_aet_read_event() to read telemetry events for resource RDT_RESOURCE_PERF_PKG. There may be multiple aggregators tracking each pack= age, so scan all of them and add up all counters. Aggregators may return an inva= lid data indication if they have received no records for a given RMID. User will see "Unavailable" if none of the aggregators on a package provide valid cou= nts. Resctrl now uses readq() so depends on X86_64. Update Kconfig. Signed-off-by: Tony Luck --- arch/x86/kernel/cpu/resctrl/internal.h | 5 +++ arch/x86/kernel/cpu/resctrl/intel_aet.c | 51 +++++++++++++++++++++++++ arch/x86/kernel/cpu/resctrl/monitor.c | 4 ++ fs/resctrl/monitor.c | 14 +++++++ arch/x86/Kconfig | 2 +- 5 files changed, 75 insertions(+), 1 deletion(-) diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/r= esctrl/internal.h index e15300b6bae9..88095cae4ac2 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -225,9 +225,14 @@ void resctrl_arch_mbm_cntr_assign_set_one(struct rdt_r= esource *r); #ifdef CONFIG_X86_CPU_RESCTRL_INTEL_AET bool intel_aet_get_events(void); void __exit intel_aet_exit(void); +int intel_aet_read_event(int domid, u32 rmid, void *arch_priv, u64 *val); #else static inline bool intel_aet_get_events(void) { return false; } static inline void __exit intel_aet_exit(void) { } +static inline int intel_aet_read_event(int domid, u32 rmid, void *arch_pri= v, u64 *val) +{ + return -EINVAL; +} #endif =20 #endif /* _ASM_X86_RESCTRL_INTERNAL_H */ diff --git a/arch/x86/kernel/cpu/resctrl/intel_aet.c b/arch/x86/kernel/cpu/= resctrl/intel_aet.c index b6b50650e634..bf3c70590d4c 100644 --- a/arch/x86/kernel/cpu/resctrl/intel_aet.c +++ b/arch/x86/kernel/cpu/resctrl/intel_aet.c @@ -12,13 +12,17 @@ #define pr_fmt(fmt) "resctrl: " fmt =20 #include +#include #include #include +#include #include #include +#include #include #include #include +#include #include #include #include @@ -221,3 +225,50 @@ void __exit intel_aet_exit(void) } } } + +#define DATA_VALID BIT_ULL(63) +#define DATA_BITS GENMASK_ULL(62, 0) + +/* + * Read counter for an event on a domain (summing all aggregators + * on the domain). If an aggregator hasn't received any data for a + * specific RMID, the MMIO read indicates that data is not valid. + * Return success if at least one aggregator has valid data. + */ +int intel_aet_read_event(int domid, u32 rmid, void *arch_priv, u64 *val) +{ + struct pmt_event *pevt =3D arch_priv; + struct event_group *e; + bool valid =3D false; + u64 total =3D 0; + u64 evtcount; + void *pevt0; + u32 idx; + + pevt0 =3D pevt - pevt->idx; + e =3D container_of(pevt0, struct event_group, evts); + idx =3D rmid * e->num_events; + idx +=3D pevt->idx; + + if (idx * sizeof(u64) + sizeof(u64) > e->mmio_size) { + pr_warn_once("MMIO index %u out of range\n", idx); + return -EIO; + } + + for (int i =3D 0; i < e->pfg->count; i++) { + if (!e->pfg->regions[i].addr) + continue; + if (e->pfg->regions[i].plat_info.package_id !=3D domid) + continue; + evtcount =3D readq(e->pfg->regions[i].addr + idx * sizeof(u64)); + if (!(evtcount & DATA_VALID)) + continue; + total +=3D evtcount & DATA_BITS; + valid =3D true; + } + + if (valid) + *val =3D total; + + return valid ? 0 : -EINVAL; +} diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/re= sctrl/monitor.c index 6929614ba6e6..e6a154240b8d 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -251,6 +251,10 @@ int resctrl_arch_rmid_read(struct rdt_resource *r, str= uct rdt_domain_hdr *hdr, int ret; =20 resctrl_arch_rmid_read_context_check(); + + if (r->rid =3D=3D RDT_RESOURCE_PERF_PKG) + return intel_aet_read_event(hdr->id, rmid, arch_priv, val); + if (!domain_header_is_valid(hdr, RESCTRL_MON_DOMAIN, RDT_RESOURCE_L3)) return -EINVAL; =20 diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c index 338a122dfcff..8c90a24ae0d0 100644 --- a/fs/resctrl/monitor.c +++ b/fs/resctrl/monitor.c @@ -520,6 +520,20 @@ static int __mon_event_count(struct rdtgroup *rdtgrp, = struct rmid_read *rr) return __l3_mon_event_count(rdtgrp, rr); else return __l3_mon_event_count_sum(rdtgrp, rr); + case RDT_RESOURCE_PERF_PKG: { + u64 tval =3D 0; + + rr->err =3D resctrl_arch_rmid_read(rr->r, rr->hdr, rdtgrp->closid, + rdtgrp->mon.rmid, rr->evt->evtid, + rr->evt->arch_priv, + &tval, rr->arch_mon_ctx); + if (rr->err) + return rr->err; + + rr->val +=3D tval; + + return 0; + } default: rr->err =3D -EINVAL; return -EINVAL; diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 126c89afcf69..afd32ca41c72 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -540,7 +540,7 @@ config X86_CPU_RESCTRL =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 + depends on X86_64 && X86_CPU_RESCTRL && CPU_SUP_INTEL && INTEL_PMT_TELEME= TRY=3Dy && INTEL_TPMI=3Dy help Enable per-RMID telemetry events in resctrl. =20 --=20 2.51.1 From nobody Tue Dec 2 00:25:23 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D1FE8324B3C for ; Mon, 24 Nov 2025 18:55:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764010504; cv=none; b=o0aXFW0bnIgDqdOPo9cV7HPsrH7FD3heZaxgUcazeRSH8nrDCVDfswDdsBXK3GaxjeWnnfgmbqs8vQCcc6AwHpi7krkLjHljM+ncIvx1xuGMPL8Tb5w7pFEbUMjgm+ssF/1RpGZMwoIE5Cw6l3ho7SHwSy59rcIcvbSn7jhL2ro= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764010504; c=relaxed/simple; bh=n+gg9cG6VstFpoCB6IkctOIGC7MzoledoWWzPFL/JkU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=F89WvQDIRSAbr+oHL/2ebCYoS5J4g6o60+5ir70W5aGiiHGGHTs4HfOtNa0vlMN9PcpOVPTpFbC9jSMNZq6fMuVRXgEhri2M1Zr+NEjyVU5y7vpNDf1LzWpddSUph2X86EkQ7ZhrYjI54wuvndWer0G/XXo+HDtkDpwFYEDItcM= 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=UjJl0vfy; arc=none smtp.client-ip=192.198.163.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="UjJl0vfy" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1764010503; x=1795546503; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=n+gg9cG6VstFpoCB6IkctOIGC7MzoledoWWzPFL/JkU=; b=UjJl0vfyeG7Cg3JBOcJ8zA1UbNO1+ZHPtd5TiaMr74px5NkwJnnQ7P0C A9rA3a81RqaJ06hSYIPhhz9d9WLwTiN+2y2hprS4NEV+5pRHfpc8rsJmo Pfq8vxl1j0lupQPVlRBXzZHRAJ1fVPY8dgXeAmNMn7empEr8QiNljDgIJ 6TZcQ3DgZk3kvtjXbOg2WZ+fPh3v9XUyl4aJ6lniBLUzsq/gRgYYnfiKa lSBO8qGjCT5+EkFegQKodXD8q7nrGEKRfVKjMUILoEHPXZx/ze5rqD1sz ZMZSK0JJ1jA2QXY9RoIX1cf9kQ6JG3ZwpDrY9JsfXWB1eAXTudJIdNRRO g==; X-CSE-ConnectionGUID: d4DTYu+wQyW6ZIjuWaQW+w== X-CSE-MsgGUID: TAm1IocvRYK+pB/g2PCQ0Q== X-IronPort-AV: E=McAfee;i="6800,10657,11623"; a="76636787" X-IronPort-AV: E=Sophos;i="6.20,223,1758610800"; d="scan'208";a="76636787" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Nov 2025 10:54:29 -0800 X-CSE-ConnectionGUID: id7eI2XmSXGIWufSUd6amg== X-CSE-MsgGUID: BkIN99UwTDO/9DuGGI8Shw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.20,223,1758610800"; d="scan'208";a="192225015" Received: from rfrazer-mobl3.amr.corp.intel.com (HELO agluck-desk3.home.arpa) ([10.124.222.153]) by orviesa009-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Nov 2025 10:54:29 -0800 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Maciej Wieczor-Retman , Peter Newman , James Morse , Babu Moger , Drew Fustini , Dave Martin , Chen Yu Cc: x86@kernel.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [PATCH v14 21/32] fs/resctrl: Refactor mkdir_mondata_subdir() Date: Mon, 24 Nov 2025 10:53:58 -0800 Message-ID: <20251124185412.24155-22-tony.luck@intel.com> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251124185412.24155-1-tony.luck@intel.com> References: <20251124185412.24155-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" Population of a monitor group's mon_data directory is unreasonably complica= ted because of the support for Sub-NUMA Cluster (SNC) mode. Split out the SNC code into a helper function to make it easier to add supp= ort for a new telemetry resource. Move all the duplicated code to make and set owner of domain directories into the mon_add_all_files() helper and rename to _mkdir_mondata_subdir(). Suggested-by: Reinette Chatre Signed-off-by: Tony Luck Reviewed-by: Reinette Chatre --- fs/resctrl/rdtgroup.c | 108 +++++++++++++++++++++++------------------- 1 file changed, 58 insertions(+), 50 deletions(-) diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c index dce1f0a6d40b..c0db5d8999ee 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -3259,57 +3259,65 @@ static void rmdir_mondata_subdir_allrdtgrp(struct r= dt_resource *r, } } =20 -static int mon_add_all_files(struct kernfs_node *kn, struct rdt_domain_hdr= *hdr, - struct rdt_resource *r, struct rdtgroup *prgrp, - bool do_sum) +/* + * Create a directory for a domain and populate it with monitor files. Cre= ate + * summing monitors when @hdr is NULL. No need to initialize summing monit= ors. + */ +static struct kernfs_node *_mkdir_mondata_subdir(struct kernfs_node *paren= t_kn, char *name, + struct rdt_domain_hdr *hdr, + struct rdt_resource *r, + struct rdtgroup *prgrp, int domid) { - struct rdt_l3_mon_domain *d; struct rmid_read rr =3D {0}; + struct kernfs_node *kn; struct mon_data *priv; struct mon_evt *mevt; - int ret, domid; + int ret; =20 - if (!domain_header_is_valid(hdr, RESCTRL_MON_DOMAIN, RDT_RESOURCE_L3)) - return -EINVAL; + kn =3D kernfs_create_dir(parent_kn, name, parent_kn->mode, prgrp); + if (IS_ERR(kn)) + return kn; + + ret =3D rdtgroup_kn_set_ugid(kn); + if (ret) + goto out_destroy; =20 - d =3D container_of(hdr, struct rdt_l3_mon_domain, hdr); for_each_mon_event(mevt) { if (mevt->rid !=3D r->rid || !mevt->enabled) continue; - domid =3D do_sum ? d->ci_id : d->hdr.id; - priv =3D mon_get_kn_priv(r->rid, domid, mevt, do_sum); - if (WARN_ON_ONCE(!priv)) - return -EINVAL; + priv =3D mon_get_kn_priv(r->rid, domid, mevt, !hdr); + if (WARN_ON_ONCE(!priv)) { + ret =3D -EINVAL; + goto out_destroy; + } =20 ret =3D mon_addfile(kn, mevt->name, priv); if (ret) - return ret; + goto out_destroy; =20 - if (!do_sum && resctrl_is_mbm_event(mevt->evtid)) + if (hdr && resctrl_is_mbm_event(mevt->evtid)) mon_event_read(&rr, r, hdr, prgrp, &hdr->cpu_mask, mevt, true); } =20 - return 0; + return kn; +out_destroy: + kernfs_remove(kn); + return ERR_PTR(ret); } =20 -static int mkdir_mondata_subdir(struct kernfs_node *parent_kn, - struct rdt_domain_hdr *hdr, - struct rdt_resource *r, struct rdtgroup *prgrp) +static int mkdir_mondata_subdir_snc(struct kernfs_node *parent_kn, + struct rdt_domain_hdr *hdr, + struct rdt_resource *r, struct rdtgroup *prgrp) { - struct kernfs_node *kn, *ckn; + struct kernfs_node *ckn, *kn; struct rdt_l3_mon_domain *d; char name[32]; - bool snc_mode; - int ret =3D 0; - - lockdep_assert_held(&rdtgroup_mutex); =20 if (!domain_header_is_valid(hdr, RESCTRL_MON_DOMAIN, RDT_RESOURCE_L3)) return -EINVAL; =20 d =3D container_of(hdr, struct rdt_l3_mon_domain, hdr); - snc_mode =3D r->mon_scope =3D=3D RESCTRL_L3_NODE; - sprintf(name, "mon_%s_%02d", r->name, snc_mode ? d->ci_id : d->hdr.id); + sprintf(name, "mon_%s_%02d", r->name, d->ci_id); kn =3D kernfs_find_and_get(parent_kn, name); if (kn) { /* @@ -3318,41 +3326,41 @@ static int mkdir_mondata_subdir(struct kernfs_node = *parent_kn, */ kernfs_put(kn); } else { - kn =3D kernfs_create_dir(parent_kn, name, parent_kn->mode, prgrp); + kn =3D _mkdir_mondata_subdir(parent_kn, name, NULL, r, prgrp, d->ci_id); if (IS_ERR(kn)) return PTR_ERR(kn); + } =20 - ret =3D rdtgroup_kn_set_ugid(kn); - if (ret) - goto out_destroy; - ret =3D mon_add_all_files(kn, hdr, r, prgrp, snc_mode); - if (ret) - goto out_destroy; + sprintf(name, "mon_sub_%s_%02d", r->name, hdr->id); + ckn =3D _mkdir_mondata_subdir(kn, name, hdr, r, prgrp, hdr->id); + if (IS_ERR(ckn)) { + kernfs_remove(kn); + return PTR_ERR(ckn); } =20 - if (snc_mode) { - sprintf(name, "mon_sub_%s_%02d", r->name, hdr->id); - ckn =3D kernfs_create_dir(kn, name, parent_kn->mode, prgrp); - if (IS_ERR(ckn)) { - ret =3D -EINVAL; - goto out_destroy; - } + kernfs_activate(kn); + return 0; +} =20 - ret =3D rdtgroup_kn_set_ugid(ckn); - if (ret) - goto out_destroy; +static int mkdir_mondata_subdir(struct kernfs_node *parent_kn, + struct rdt_domain_hdr *hdr, + struct rdt_resource *r, struct rdtgroup *prgrp) +{ + struct kernfs_node *kn; + char name[32]; =20 - ret =3D mon_add_all_files(ckn, hdr, r, prgrp, false); - if (ret) - goto out_destroy; - } + lockdep_assert_held(&rdtgroup_mutex); + + if (r->rid =3D=3D RDT_RESOURCE_L3 && r->mon_scope =3D=3D RESCTRL_L3_NODE) + return mkdir_mondata_subdir_snc(parent_kn, hdr, r, prgrp); + + sprintf(name, "mon_%s_%02d", r->name, hdr->id); + kn =3D _mkdir_mondata_subdir(parent_kn, name, hdr, r, prgrp, hdr->id); + if (IS_ERR(kn)) + return PTR_ERR(kn); =20 kernfs_activate(kn); return 0; - -out_destroy: - kernfs_remove(kn); - return ret; } =20 /* --=20 2.51.1 From nobody Tue Dec 2 00:25:23 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 066183254AD for ; Mon, 24 Nov 2025 18:55:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764010505; cv=none; b=Pck+59GGYFOlB2gCbC0ermF6T6eZudjkbRw/WefSFHXiAA5fspwZzozaj3AREHl0rGgar+u92selORrhhbwMXXuXCK6ELqh0XeJ4phF5j82MkQv/REUPpHMaQjGgNhK4JWC9PCNrdsp7uoRJfcKdtD1E4R+kRGWTXU1/fNOjW7g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764010505; c=relaxed/simple; bh=miRJzo1AWfZUKy+ImvgvbTXaJITzgINN7ynFnTS9zo4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jQI48H1xbcL8oGKo36kNUAXqPGB9RpHqNQMqo1uPNTfVsrP1swWSGFZBc24QiuIU4CBtjZG/hHJwPb8Qh7X7Muiq+AXEPTAAwUn2gLGhsVCUPEiHjXfyORNRSiwMiyptuotMQ2xin7Np5tTXG9c34u80PMLV7abfdFCs7fbUQuw= 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=QrwOQqHV; arc=none smtp.client-ip=192.198.163.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="QrwOQqHV" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1764010504; x=1795546504; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=miRJzo1AWfZUKy+ImvgvbTXaJITzgINN7ynFnTS9zo4=; b=QrwOQqHVwEDUa1xbgGmRzVFmZ2zB1brO9fn5R9w47nhJiS0HROrGdsKE zNdzTTFK+7d/X0bpA4fBvkQFn0jvD0H0vxck0pNpdDD7uI0MVDNeynVGN aUmwtzcj3jIauTQtjys6uzl/S5ROTzWmgiJZgeyPUCoQju1ZAhnDJ2kDa zjAGOHZbbeLS2uOTugSv9E+JZP4AsjdiRiAiJEECJRdL2yZvtPJ/dFKgc PEHmYTwqYv0VzYZP80hLfbKU2RqIx/SvYqFshILy0QCLX0kOXfKHSp8K1 4MxrREB6B73GLUAqfYdQefCjNPs3FAtW9xYpNysqfbhSpBQuhQg9PFuCn Q==; X-CSE-ConnectionGUID: BZ5QyEGcQ2Ku6jSkwem28g== X-CSE-MsgGUID: 7yZHs0FmSv2fTaHTRfeZsg== X-IronPort-AV: E=McAfee;i="6800,10657,11623"; a="76636804" X-IronPort-AV: E=Sophos;i="6.20,223,1758610800"; d="scan'208";a="76636804" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Nov 2025 10:54:29 -0800 X-CSE-ConnectionGUID: mfqs0ANwRl+oo9PDmzgKoQ== X-CSE-MsgGUID: toEiwPaeTlqZCgAZy4TDBA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.20,223,1758610800"; d="scan'208";a="192225018" Received: from rfrazer-mobl3.amr.corp.intel.com (HELO agluck-desk3.home.arpa) ([10.124.222.153]) by orviesa009-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Nov 2025 10:54:29 -0800 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Maciej Wieczor-Retman , Peter Newman , James Morse , Babu Moger , Drew Fustini , Dave Martin , Chen Yu Cc: x86@kernel.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [PATCH v14 22/32] fs/resctrl: Refactor rmdir_mondata_subdir_allrdtgrp() Date: Mon, 24 Nov 2025 10:53:59 -0800 Message-ID: <20251124185412.24155-23-tony.luck@intel.com> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251124185412.24155-1-tony.luck@intel.com> References: <20251124185412.24155-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" Clearing a monitor group's mon_data directory is complicated because of the support for Sub-NUMA Cluster (SNC) mode. Refactor the SNC case into a helper function to make it easier to add suppo= rt for a new telemetry resource. Suggested-by: Reinette Chatre Signed-off-by: Tony Luck Reviewed-by: Reinette Chatre --- fs/resctrl/rdtgroup.c | 42 +++++++++++++++++++++++++++++++----------- 1 file changed, 31 insertions(+), 11 deletions(-) diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c index c0db5d8999ee..679247c43b1a 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -3228,28 +3228,24 @@ static void mon_rmdir_one_subdir(struct kernfs_node= *pkn, char *name, char *subn } =20 /* - * Remove all subdirectories of mon_data of ctrl_mon groups - * and monitor groups for the given domain. - * Remove files and directories containing "sum" of domain data - * when last domain being summed is removed. + * Remove files and directories for one SNC node. If it is the last node + * sharing an L3 cache, then remove the upper level directory containing + * the "sum" files too. */ -static void rmdir_mondata_subdir_allrdtgrp(struct rdt_resource *r, - struct rdt_domain_hdr *hdr) +static void rmdir_mondata_subdir_allrdtgrp_snc(struct rdt_resource *r, + struct rdt_domain_hdr *hdr) { struct rdtgroup *prgrp, *crgrp; struct rdt_l3_mon_domain *d; char subname[32]; - bool snc_mode; char name[32]; =20 if (!domain_header_is_valid(hdr, RESCTRL_MON_DOMAIN, RDT_RESOURCE_L3)) return; =20 d =3D container_of(hdr, struct rdt_l3_mon_domain, hdr); - snc_mode =3D r->mon_scope =3D=3D RESCTRL_L3_NODE; - sprintf(name, "mon_%s_%02d", r->name, snc_mode ? d->ci_id : hdr->id); - if (snc_mode) - sprintf(subname, "mon_sub_%s_%02d", r->name, hdr->id); + sprintf(name, "mon_%s_%02d", r->name, d->ci_id); + sprintf(subname, "mon_sub_%s_%02d", r->name, hdr->id); =20 list_for_each_entry(prgrp, &rdt_all_groups, rdtgroup_list) { mon_rmdir_one_subdir(prgrp->mon.mon_data_kn, name, subname); @@ -3259,6 +3255,30 @@ static void rmdir_mondata_subdir_allrdtgrp(struct rd= t_resource *r, } } =20 +/* + * Remove all subdirectories of mon_data of ctrl_mon groups + * and monitor groups for the given domain. + */ +static void rmdir_mondata_subdir_allrdtgrp(struct rdt_resource *r, + struct rdt_domain_hdr *hdr) +{ + struct rdtgroup *prgrp, *crgrp; + char name[32]; + + if (r->rid =3D=3D RDT_RESOURCE_L3 && r->mon_scope =3D=3D RESCTRL_L3_NODE)= { + rmdir_mondata_subdir_allrdtgrp_snc(r, hdr); + return; + } + + sprintf(name, "mon_%s_%02d", r->name, hdr->id); + list_for_each_entry(prgrp, &rdt_all_groups, rdtgroup_list) { + kernfs_remove_by_name(prgrp->mon.mon_data_kn, name); + + list_for_each_entry(crgrp, &prgrp->mon.crdtgrp_list, mon.crdtgrp_list) + kernfs_remove_by_name(crgrp->mon.mon_data_kn, name); + } +} + /* * Create a directory for a domain and populate it with monitor files. Cre= ate * summing monitors when @hdr is NULL. No need to initialize summing monit= ors. --=20 2.51.1 From nobody Tue Dec 2 00:25:23 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E44C0325707 for ; Mon, 24 Nov 2025 18:55:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764010507; cv=none; b=tZ90877hodJRJS6ilMTJCqkwKPlWSVTauaGfp3lRENdRQQtN0F4B47hOvVdPRXktYzMPk2SXhYIeN9938jRH+itwoxcIA9agbjqM05HhgedYudJOF+kiZmx4vAJC5x5U9lYBD+Wd3qeJ6M8ll67otOIm8Qxmwh0D7s2hIpZcJhA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764010507; c=relaxed/simple; bh=49dyEqlqxNf3V4nckpzlQiTO61DAIVHzMgWHnRTZQ9o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nZIjRqmmpPNNXG3YNJBp5q/nlyJdwkUjPegiJxEFhRUBp1bniDLLlCuC6xy7E1m6pUvb2Tb88dmeVkSl6flXggzF8ay3FotlWAmSaRi8ZigTIrLk/Qp7jqsYWvw6ByNU1KPERiwjdjS3RWevT0yFszFziocMoAErTUuYhK/bG4U= 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=hnQV9y9g; arc=none smtp.client-ip=192.198.163.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="hnQV9y9g" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1764010505; x=1795546505; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=49dyEqlqxNf3V4nckpzlQiTO61DAIVHzMgWHnRTZQ9o=; b=hnQV9y9gm0Kye4PFF5NVWRzPxGIjlpRzJd3GbMrdm14ZXiHeXbGerpvH fqUB4J1SL7UdOqs9E3j/qRcsGtszbfLAT3/7Xnn/U3uUr1djQu24nNYMh IG3uOLFteyrcUGA71sUDJkoeDOyHu6UChYuoxUuEHhmUmPzcoPCu9vUQU q+7Ts3v/Zdcqw+KTRHNToC0eIFAOSba8+yZq71ISb6BXIOYQgPtv1HyHl 25HrCtmbXvRjSoE3kgjE9ceC6Iv4kB2nskUWMA+qcFVdDGACI28FX3Ezh 1BEaRafXl8c4Bn+HuuK1V5s2yNRgLpGrEY/pefC80ECwSqXtQsT9IrfWK w==; X-CSE-ConnectionGUID: wgVACNMPRICRSntTPFCnbQ== X-CSE-MsgGUID: igrk84uKSeeVterNBl36Dg== X-IronPort-AV: E=McAfee;i="6800,10657,11623"; a="76636820" X-IronPort-AV: E=Sophos;i="6.20,223,1758610800"; d="scan'208";a="76636820" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Nov 2025 10:54:30 -0800 X-CSE-ConnectionGUID: LwjJCmUuTDKkw+HTGCM8QQ== X-CSE-MsgGUID: Y+HrEEI3TIy60lvcFd522w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.20,223,1758610800"; d="scan'208";a="192225021" Received: from rfrazer-mobl3.amr.corp.intel.com (HELO agluck-desk3.home.arpa) ([10.124.222.153]) by orviesa009-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Nov 2025 10:54:30 -0800 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Maciej Wieczor-Retman , Peter Newman , James Morse , Babu Moger , Drew Fustini , Dave Martin , Chen Yu Cc: x86@kernel.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [PATCH v14 23/32] x86,fs/resctrl: Handle domain creation/deletion for RDT_RESOURCE_PERF_PKG Date: Mon, 24 Nov 2025 10:54:00 -0800 Message-ID: <20251124185412.24155-24-tony.luck@intel.com> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251124185412.24155-1-tony.luck@intel.com> References: <20251124185412.24155-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 L3 resource has several requirements for domains. There are per-domain structures that hold the 64-bit values of counters, and elements to keep track of the overflow and limbo threads. None of these are needed for the PERF_PKG resource. The hardware counters are wide enough that they do not wrap around for decades. Define a new rdt_perf_pkg_mon_domain structure which just consists of the standard rdt_domain_hdr to keep track of domain id and CPU mask. Update resctrl_online_mon_domain() for RDT_RESOURCE_PERF_PKG. The only acti= on needed for this resource is to create and populate domain directories if a domain is added while resctrl is mounted. Similarly resctrl_offline_mon_domain() only needs to remove domain director= ies. Signed-off-by: Tony Luck Reviewed-by: Reinette Chatre --- arch/x86/kernel/cpu/resctrl/internal.h | 13 +++++++++++ arch/x86/kernel/cpu/resctrl/core.c | 17 +++++++++++++++ arch/x86/kernel/cpu/resctrl/intel_aet.c | 29 +++++++++++++++++++++++++ fs/resctrl/rdtgroup.c | 17 ++++++++++----- 4 files changed, 71 insertions(+), 5 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/r= esctrl/internal.h index 88095cae4ac2..0b7f8317be14 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -87,6 +87,14 @@ static inline struct rdt_hw_l3_mon_domain *resctrl_to_ar= ch_mon_dom(struct rdt_l3 return container_of(r, struct rdt_hw_l3_mon_domain, d_resctrl); } =20 +/** + * struct rdt_perf_pkg_mon_domain - CPUs sharing an package scoped resctrl= monitor resource + * @hdr: common header for different domain types + */ +struct rdt_perf_pkg_mon_domain { + struct rdt_domain_hdr hdr; +}; + /** * struct msr_param - set a range of MSRs from a domain * @res: The resource to use @@ -226,6 +234,8 @@ void resctrl_arch_mbm_cntr_assign_set_one(struct rdt_re= source *r); bool intel_aet_get_events(void); void __exit intel_aet_exit(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); #else static inline bool intel_aet_get_events(void) { return false; } static inline void __exit intel_aet_exit(void) { } @@ -233,6 +243,9 @@ static inline int intel_aet_read_event(int domid, u32 r= mid, void *arch_priv, u64 { return -EINVAL; } + +static inline void intel_aet_mon_domain_setup(int cpu, int id, struct rdt_= resource *r, + struct list_head *add_pos) { } #endif =20 #endif /* _ASM_X86_RESCTRL_INTERNAL_H */ diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resct= rl/core.c index 3c6946a5ff1b..283d653002a2 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -580,6 +580,10 @@ static void domain_add_cpu_mon(int cpu, struct rdt_res= ource *r) if (!hdr) l3_mon_domain_setup(cpu, id, r, add_pos); break; + case RDT_RESOURCE_PERF_PKG: + if (!hdr) + intel_aet_mon_domain_setup(cpu, id, r, add_pos); + break; default: pr_warn_once("Unknown resource rid=3D%d\n", r->rid); break; @@ -679,6 +683,19 @@ static void domain_remove_cpu_mon(int cpu, struct rdt_= resource *r) l3_mon_domain_free(hw_dom); break; } + case RDT_RESOURCE_PERF_PKG: { + struct rdt_perf_pkg_mon_domain *pkgd; + + if (!domain_header_is_valid(hdr, RESCTRL_MON_DOMAIN, RDT_RESOURCE_PERF_P= KG)) + return; + + pkgd =3D container_of(hdr, struct rdt_perf_pkg_mon_domain, hdr); + resctrl_offline_mon_domain(r, hdr); + list_del_rcu(&hdr->list); + synchronize_rcu(); + kfree(pkgd); + break; + } default: pr_warn_once("Unknown resource rid=3D%d\n", r->rid); break; diff --git a/arch/x86/kernel/cpu/resctrl/intel_aet.c b/arch/x86/kernel/cpu/= resctrl/intel_aet.c index bf3c70590d4c..46c64419ec10 100644 --- a/arch/x86/kernel/cpu/resctrl/intel_aet.c +++ b/arch/x86/kernel/cpu/resctrl/intel_aet.c @@ -17,16 +17,21 @@ #include #include #include +#include #include #include +#include #include #include #include #include #include #include +#include +#include #include #include +#include #include #include #include @@ -272,3 +277,27 @@ int intel_aet_read_event(int domid, u32 rmid, void *ar= ch_priv, u64 *val) =20 return valid ? 0 : -EINVAL; } + +void intel_aet_mon_domain_setup(int cpu, int id, struct rdt_resource *r, + struct list_head *add_pos) +{ + struct rdt_perf_pkg_mon_domain *d; + int err; + + d =3D kzalloc_node(sizeof(*d), GFP_KERNEL, cpu_to_node(cpu)); + if (!d) + return; + + d->hdr.id =3D id; + d->hdr.type =3D RESCTRL_MON_DOMAIN; + d->hdr.rid =3D RDT_RESOURCE_PERF_PKG; + cpumask_set_cpu(cpu, &d->hdr.cpu_mask); + list_add_tail_rcu(&d->hdr.list, add_pos); + + err =3D resctrl_online_mon_domain(r, &d->hdr); + if (err) { + list_del_rcu(&d->hdr.list); + synchronize_rcu(); + kfree(d); + } +} diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c index 679247c43b1a..ac3c6e44b7c5 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -4307,11 +4307,6 @@ void resctrl_offline_mon_domain(struct rdt_resource = *r, struct rdt_domain_hdr *h =20 mutex_lock(&rdtgroup_mutex); =20 - if (!domain_header_is_valid(hdr, RESCTRL_MON_DOMAIN, RDT_RESOURCE_L3)) - goto out_unlock; - - d =3D container_of(hdr, struct rdt_l3_mon_domain, hdr); - /* * If resctrl is mounted, remove all the * per domain monitor data directories. @@ -4319,6 +4314,13 @@ void resctrl_offline_mon_domain(struct rdt_resource = *r, struct rdt_domain_hdr *h if (resctrl_mounted && resctrl_arch_mon_capable()) rmdir_mondata_subdir_allrdtgrp(r, hdr); =20 + if (r->rid !=3D RDT_RESOURCE_L3) + goto out_unlock; + + if (!domain_header_is_valid(hdr, RESCTRL_MON_DOMAIN, RDT_RESOURCE_L3)) + goto out_unlock; + + d =3D container_of(hdr, struct rdt_l3_mon_domain, hdr); if (resctrl_is_mbm_enabled()) cancel_delayed_work(&d->mbm_over); if (resctrl_is_mon_event_enabled(QOS_L3_OCCUP_EVENT_ID) && has_busy_rmid(= d)) { @@ -4415,6 +4417,9 @@ int resctrl_online_mon_domain(struct rdt_resource *r,= struct rdt_domain_hdr *hdr =20 mutex_lock(&rdtgroup_mutex); =20 + if (r->rid !=3D RDT_RESOURCE_L3) + goto mkdir; + if (!domain_header_is_valid(hdr, RESCTRL_MON_DOMAIN, RDT_RESOURCE_L3)) goto out_unlock; =20 @@ -4432,6 +4437,8 @@ int resctrl_online_mon_domain(struct rdt_resource *r,= struct rdt_domain_hdr *hdr if (resctrl_is_mon_event_enabled(QOS_L3_OCCUP_EVENT_ID)) INIT_DELAYED_WORK(&d->cqm_limbo, cqm_handle_limbo); =20 +mkdir: + err =3D 0; /* * If the filesystem is not mounted then only the default resource group * exists. Creation of its directories is deferred until mount time --=20 2.51.1 From nobody Tue Dec 2 00:25:23 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B172B325724 for ; Mon, 24 Nov 2025 18:55:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764010507; cv=none; b=KpIFA5MlQTzYmkQLG/ESKAtHxI1k7fXF0ItdeMFZ6qhp0WFZBfISWIWA5TnAmfemuQl30EdBszNeSKYGYOh5blPRqvSimJWKRULy2TCV+cZzacr6Ft2yP29HapiPo7qZU5q3AgkBwTkNNP6a2O4lnoi4qE8uRb0NBYVSQVblnqE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764010507; c=relaxed/simple; bh=4XoXTDSAzjR+FuLDzRLi0xcTlYd7JBY+p4ofE6ckqr8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EI8V0bsBBCeHEjmzDUaZQXTYfEdI0tg49oWzW8tnOR+BRTnZ+UOj/Woo+1qfEpnEmuK5v18jiUnNJQI40rb2Hy+IX3QHDJK2RRplybM8Zg/pNIkrphdgUB8ntMeFIhpvs8f725snkL54rH1s9wlBC2W9itEUzzdKBaS/puLPEv4= 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=T0V1lbDj; arc=none smtp.client-ip=192.198.163.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="T0V1lbDj" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1764010506; x=1795546506; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=4XoXTDSAzjR+FuLDzRLi0xcTlYd7JBY+p4ofE6ckqr8=; b=T0V1lbDj1QfpHRcs1LEzWQakoDlfuBBq8DWdJiACyaxPLl3u+L/eFRRP E+IwkgOo22/A1V7fdYveANlswY0jNR4aWehM9IbZ1oIyf4NrbUX+RApyB qKSF1gJkUJSoHaYzUGpZI3zxRhfbcD1+91CU+zEkMcsjzK7pkbIMTmYN+ JqaJNPL4s9Mxa39CWgr8JROYeeCzk+dudk6O/NSAWr6gUit1xYK80z4WC PGzBpz+FqbBgNpP80Md9l31Pb+3p+FZlo7UHr5Eue8cBwLxpxt6gZcteE kJLZCPe6Ev5aQqUDV48kfWNRUX1Xy1QHKWlUfWfBibwQE5qs4u395FIT7 A==; X-CSE-ConnectionGUID: 0P1qywskRvOz4IBRE+NR1w== X-CSE-MsgGUID: xbmYAjtbR3KQTycp3bSJoA== X-IronPort-AV: E=McAfee;i="6800,10657,11623"; a="76636836" X-IronPort-AV: E=Sophos;i="6.20,223,1758610800"; d="scan'208";a="76636836" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Nov 2025 10:54:30 -0800 X-CSE-ConnectionGUID: SUkCbQriQZefb+gEdDRrhg== X-CSE-MsgGUID: 5Hew9XgFRt6Lpo4dcuDIJQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.20,223,1758610800"; d="scan'208";a="192225024" Received: from rfrazer-mobl3.amr.corp.intel.com (HELO agluck-desk3.home.arpa) ([10.124.222.153]) by orviesa009-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Nov 2025 10:54:30 -0800 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Maciej Wieczor-Retman , Peter Newman , James Morse , Babu Moger , Drew Fustini , Dave Martin , Chen Yu Cc: x86@kernel.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [PATCH v14 24/32] x86/resctrl: Add energy/perf choices to rdt boot option Date: Mon, 24 Nov 2025 10:54:01 -0800 Message-ID: <20251124185412.24155-25-tony.luck@intel.com> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251124185412.24155-1-tony.luck@intel.com> References: <20251124185412.24155-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" Legacy resctrl features are enumerated by X86_FEATURE_* flags. These may be overridden by quirks to disable features in the case of errata. Users can use kernel command line options to either disable a feature, or to force enable a feature that was disabled by a quirk. Provide similar functionality for hardware features that do not have an X86_FEATURE_* flag. Unlike other features that are tied to X86_FEATURE_* flags, these are defined by the feature name. Users may force a feature to be disabled. E.g. "rdt=3D!perf" will ensure th= at none of the perf telemetry events are enabled. Resctrl architecture code may disable a feature that does not provide full functionality. Users may override that decision. E.g. "rdt=3Denergy" will enable any available energy telemetry events even if they do not provide full functionality. An optional guid can be included for more granular control of features shar= ing a name. E.g. rdt=3Denergy:0x12345 will only override disabling of the energy feature with guid =3D 0x12345. Signed-off-by: Tony Luck --- .../admin-guide/kernel-parameters.txt | 6 ++- arch/x86/kernel/cpu/resctrl/internal.h | 2 + arch/x86/kernel/cpu/resctrl/core.c | 2 + arch/x86/kernel/cpu/resctrl/intel_aet.c | 37 +++++++++++++++++++ 4 files changed, 46 insertions(+), 1 deletion(-) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentatio= n/admin-guide/kernel-parameters.txt index 8c5636a120ee..e47def4a3dd8 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -6207,9 +6207,13 @@ rdt=3D [HW,X86,RDT] Turn on/off individual RDT features. List is: cmt, mbmtotal, mbmlocal, l3cat, l3cdp, l2cat, l2cdp, - mba, smba, bmec, abmc, sdciae. + mba, smba, bmec, abmc, sdciae, energy[:guid], + perf[:guid]. E.g. to turn on cmt and turn off mba use: rdt=3Dcmt,!mba + To turn off all energy features and ensure that + the 0x12345 perf feature is enabled use: + rdt=3D!energy,perf:0x12345 =20 reboot=3D [KNL] Format (x86 or x86_64): diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/r= esctrl/internal.h index 0b7f8317be14..304e6e341905 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -236,6 +236,7 @@ void __exit intel_aet_exit(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_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) { } @@ -246,6 +247,7 @@ static inline int intel_aet_read_event(int domid, u32 r= mid, void *arch_priv, u64 =20 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_aet_option(bool force_off, char *tok) { return fa= lse; } #endif =20 #endif /* _ASM_X86_RESCTRL_INTERNAL_H */ diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resct= rl/core.c index 283d653002a2..960974ffa866 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -820,6 +820,8 @@ static int __init set_rdt_options(char *str) force_off =3D *tok =3D=3D '!'; if (force_off) tok++; + if (intel_aet_option(force_off, tok)) + continue; for (o =3D rdt_options; o < &rdt_options[NUM_RDT_OPTIONS]; o++) { if (strcmp(tok, o->name) =3D=3D 0) { if (force_off) diff --git a/arch/x86/kernel/cpu/resctrl/intel_aet.c b/arch/x86/kernel/cpu/= resctrl/intel_aet.c index 46c64419ec10..50c8b4c50790 100644 --- a/arch/x86/kernel/cpu/resctrl/intel_aet.c +++ b/arch/x86/kernel/cpu/resctrl/intel_aet.c @@ -57,12 +57,16 @@ struct pmt_event { * struct event_group - Events with the same feature type ("energy" or "pe= rf") and guid. * @feature: Type of events, for example FEATURE_PER_RMID_PERF_TELEM or * FEATURE_PER_RMID_ENERGY_TELEM, in this group. + * @name: Name for this group (used by boot rdt=3D option) * @pfg: Points to the aggregated telemetry space information * returned by the intel_pmt_get_regions_by_feature() * call to the INTEL_PMT_TELEMETRY driver that contains * data for all telemetry regions type @feature. * Valid if the system supports the event group. * NULL otherwise. + * @force_off: True when "rdt" command line disables this @guid. + * @force_on: True when "rdt" command line overrides disable of + * this @guid due to insufficient @num_rmid. * @guid: Unique number per XML description file. * @mmio_size: Number of bytes of MMIO registers for this group. * @num_events: Number of events in this group. @@ -71,7 +75,9 @@ struct pmt_event { struct event_group { /* Data fields for additional structures to manage this group. */ enum pmt_feature_id feature; + char *name; struct pmt_feature_group *pfg; + bool force_off, force_on; =20 /* Remaining fields initialized from XML file. */ u32 guid; @@ -89,6 +95,7 @@ struct event_group { */ static struct event_group energy_0x26696143 =3D { .feature =3D FEATURE_PER_RMID_ENERGY_TELEM, + .name =3D "energy", .guid =3D 0x26696143, .mmio_size =3D XML_MMIO_SIZE(576, 2, 3), .num_events =3D 2, @@ -104,6 +111,7 @@ static struct event_group energy_0x26696143 =3D { */ static struct event_group perf_0x26557651 =3D { .feature =3D FEATURE_PER_RMID_PERF_TELEM, + .name =3D "perf", .guid =3D 0x26557651, .mmio_size =3D XML_MMIO_SIZE(576, 7, 3), .num_events =3D 7, @@ -128,6 +136,32 @@ static struct event_group *known_event_groups[] =3D { _peg < &known_event_groups[ARRAY_SIZE(known_event_groups)]; \ _peg++) =20 +bool intel_aet_option(bool force_off, char *tok) +{ + struct event_group **peg; + bool ret =3D false; + u32 guid =3D 0; + char *name; + + name =3D strsep(&tok, ":"); + if (tok && kstrtou32(tok, 16, &guid)) + return false; + + for_each_event_group(peg) { + if (strcmp(name, (*peg)->name)) + continue; + if (guid && (*peg)->guid !=3D guid) + continue; + if (force_off) + (*peg)->force_off =3D true; + else + (*peg)->force_on =3D true; + ret =3D true; + } + + return ret; +} + /* * Clear the address field of regions that did not pass the checks in * skip_telem_region() so they will not be used by intel_aet_read_event(). @@ -178,6 +212,9 @@ static bool enable_events(struct event_group *e, struct= pmt_feature_group *p) { int skipped_events =3D 0; =20 + if (e->force_off) + return false; + if (!group_has_usable_regions(e, p)) return false; =20 --=20 2.51.1 From nobody Tue Dec 2 00:25:23 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E342A32572B for ; Mon, 24 Nov 2025 18:55:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764010509; cv=none; b=BtZ7bleK9e5FfOa95G3tFeQblEFlhYKXTqBGB+MY0b8oy+FouM5G27/m/KvuPro3KN02VrNYTEu88E3oVWANxypVKJXD6dCmiY+cNXB+yXdwFfO0zGzHZww4CG34jS/i4Mhe46a3Q/YLkeuvjXQwx1lzCZ88GaugZk3Z+aUFua8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764010509; c=relaxed/simple; bh=h3Wi7QH7rdtDrArQ1z7cd2FkqfhhsltJzE5lLsizdB0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=W7HFvAYvUmtaeku0ok2KqpVxY25vaIpPish49/td6n5rx7TcwnTZi3kJynI8zBhtoW7OLdGuLNOrdtVhDx9jfyAxe9eHAVsjDABWEgihLSjX2OaG44Bf8Ois184SI2mq2RHSVNBB5iGTnhiX6fzsNNU5yuMatyQCdEqIrC4mxHE= 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=eRAZlz+O; arc=none smtp.client-ip=192.198.163.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="eRAZlz+O" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1764010508; x=1795546508; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=h3Wi7QH7rdtDrArQ1z7cd2FkqfhhsltJzE5lLsizdB0=; b=eRAZlz+OXBUH2rKI+3BtHdoQEhS9t6dUSqAVsXgEmD3VNosnOKvo0kHZ 3EzOXjsgEVHXCMxagf+lN7slQMkBOqGFYZm/4J1472GpRiUaWP4IRr5ld KlSfvM+6bK/glqZicp8Wc6ZX1Rwjq85MTJSYGuk4rDjxVfaKSnveIYecu OSJ6o5K3x6vPelSQ7RuqDRte9pI8YnPG1JJB/RQ8HII+DL4DIqU4hoCSM 8jHTIUSrCjniNlFEKbtD+/KAZHPUX8lPbuXtFw0RQHTiYmOvhlv2tWdGY m3z+qsO+4QcXkEaNhWvM0zPBog5fAYQ3wb7oCrQ5/KdOxQm/DrLoojnNW A==; X-CSE-ConnectionGUID: hujdeNgIRSiQP9gwAyOICQ== X-CSE-MsgGUID: etJVI/bTQ8GacQG9ExwXLg== X-IronPort-AV: E=McAfee;i="6800,10657,11623"; a="76636859" X-IronPort-AV: E=Sophos;i="6.20,223,1758610800"; d="scan'208";a="76636859" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Nov 2025 10:54:30 -0800 X-CSE-ConnectionGUID: P0uo7BHkTPKQb/QJjCtAfQ== X-CSE-MsgGUID: A2Z1u6jmSlCOvu8lMnDc3g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.20,223,1758610800"; d="scan'208";a="192225029" Received: from rfrazer-mobl3.amr.corp.intel.com (HELO agluck-desk3.home.arpa) ([10.124.222.153]) by orviesa009-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Nov 2025 10:54:30 -0800 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Maciej Wieczor-Retman , Peter Newman , James Morse , Babu Moger , Drew Fustini , Dave Martin , Chen Yu Cc: x86@kernel.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [PATCH v14 25/32] x86/resctrl: Handle number of RMIDs supported by RDT_RESOURCE_PERF_PKG Date: Mon, 24 Nov 2025 10:54:02 -0800 Message-ID: <20251124185412.24155-26-tony.luck@intel.com> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251124185412.24155-1-tony.luck@intel.com> References: <20251124185412.24155-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" There are now three meanings for "number of RMIDs": 1) The number for legacy features enumerated by CPUID leaf 0xF. This is the maximum number of distinct values that can be loaded into MSR_IA32_PQR_ASSOC. Note that systems with Sub-NUMA Cluster mode enabled will force scaling down the CPUID enumerated value by the number of SNC nodes per L3-cache. 2) The number of registers in MMIO space for each event. This is enumerated in the XML files and is the value initialized into event_group::num_rmid. 3) The number of "hardware counters" (this isn't a strictly accurate description of how things work, but serves as a useful analogy that does describe the limitations) feeding to those MMIO registers. This is enumerated in telemetry_region::num_rmids returned from the call to intel_pmt_get_regions_by_feature() Event groups with insufficient "hardware counters" to track all RMIDs are difficult for users to use, since the system may reassign "hardware counter= s" at any time. This means that users cannot reliably collect two consecutive event counts to compute the rate at which events are occurring. Limit an under-resourced event group's number of possible monitor resource groups to the lowest number of "hardware counters" if the user explicitly requests to enable it. Scan all enabled event groups and assign the RDT_RESOURCE_PERF_PKG resource "num_rmid" value to the smallest of these values as this value will be used later to compare against the number of RMIDs supported by other resources to determine how many monitoring resource groups are supported. N.B. Change type of resctrl_mon::num_rmid to u32 to match its usage and the type of event_group::num_rmid so that min(r->num_rmid, e->num_rmid) won't complain about mixing signed and unsigned types. Signed-off-by: Tony Luck --- include/linux/resctrl.h | 2 +- arch/x86/kernel/cpu/resctrl/intel_aet.c | 58 ++++++++++++++++++++++++- fs/resctrl/rdtgroup.c | 2 +- 3 files changed, 59 insertions(+), 3 deletions(-) diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index 14126d228e61..8623e450619a 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -295,7 +295,7 @@ enum resctrl_schema_fmt { * events of monitor groups created via mkdir. */ struct resctrl_mon { - int num_rmid; + u32 num_rmid; unsigned int mbm_cfg_mask; int num_mbm_cntrs; bool mbm_cntr_assignable; diff --git a/arch/x86/kernel/cpu/resctrl/intel_aet.c b/arch/x86/kernel/cpu/= resctrl/intel_aet.c index 50c8b4c50790..6eff606541ad 100644 --- a/arch/x86/kernel/cpu/resctrl/intel_aet.c +++ b/arch/x86/kernel/cpu/resctrl/intel_aet.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -68,6 +69,10 @@ struct pmt_event { * @force_on: True when "rdt" command line overrides disable of * this @guid due to insufficient @num_rmid. * @guid: Unique number per XML description file. + * @num_rmid: Number of RMIDs supported by this group. May be + * adjusted downwards if enumeration from + * intel_pmt_get_regions_by_feature() indicates fewer + * RMIDs can be tracked simultaneously. * @mmio_size: Number of bytes of MMIO registers for this group. * @num_events: Number of events in this group. * @evts: Array of event descriptors. @@ -81,6 +86,7 @@ struct event_group { =20 /* Remaining fields initialized from XML file. */ u32 guid; + u32 num_rmid; size_t mmio_size; unsigned int num_events; struct pmt_event evts[] __counted_by(num_events); @@ -97,6 +103,7 @@ static struct event_group energy_0x26696143 =3D { .feature =3D FEATURE_PER_RMID_ENERGY_TELEM, .name =3D "energy", .guid =3D 0x26696143, + .num_rmid =3D 576, .mmio_size =3D XML_MMIO_SIZE(576, 2, 3), .num_events =3D 2, .evts =3D { @@ -113,6 +120,7 @@ static struct event_group perf_0x26557651 =3D { .feature =3D FEATURE_PER_RMID_PERF_TELEM, .name =3D "perf", .guid =3D 0x26557651, + .num_rmid =3D 576, .mmio_size =3D XML_MMIO_SIZE(576, 7, 3), .num_events =3D 7, .evts =3D { @@ -208,8 +216,25 @@ static bool group_has_usable_regions(struct event_grou= p *e, struct pmt_feature_g return usable_regions; } =20 +static bool all_regions_have_sufficient_rmid(struct event_group *e, struct= pmt_feature_group *p) +{ + struct telemetry_region *tr; + bool ret =3D true; + + for (int i =3D 0; i < p->count; i++) { + if (!p->regions[i].addr) + continue; + tr =3D &p->regions[i]; + if (tr->num_rmids < e->num_rmid) + ret =3D false; + } + + return ret; +} + 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) @@ -218,13 +243,44 @@ static bool enable_events(struct event_group *e, stru= ct pmt_feature_group *p) if (!group_has_usable_regions(e, p)) return false; =20 + /* + * Only enable feature with insufficient RMIDs if the user + * requested it from the kernel command line. + */ + if (!all_regions_have_sufficient_rmid(e, p) && !e->force_on) { + pr_info("Feature %s:0x%x not enabled due to insufficient RMIDs\n", + e->name, e->guid); + return false; + } + + for (int i =3D 0; i < p->count; i++) { + if (!p->regions[i].addr) + continue; + /* + * e->num_rmid only adjusted lower if user (via rdt=3D kernel + * parameter) forces an event group with insufficient RMID + * to be enabled. + */ + e->num_rmid =3D min(e->num_rmid, p->regions[i].num_rmids); + } + for (int j =3D 0; j < e->num_events; j++) { if (!resctrl_enable_mon_event(e->evts[j].id, true, e->evts[j].bin_bits, &e->evts[j])) skipped_events++; } =20 - return skipped_events < e->num_events; + if (e->num_events =3D=3D skipped_events) { + pr_info("No events enabled in %s %s:0x%x\n", r->name, e->name, e->guid); + return false; + } + + if (r->mon.num_rmid) + r->mon.num_rmid =3D min(r->mon.num_rmid, e->num_rmid); + else + r->mon.num_rmid =3D e->num_rmid; + + return true; } =20 /* diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c index ac3c6e44b7c5..60ce2390723e 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -1157,7 +1157,7 @@ static int rdt_num_rmids_show(struct kernfs_open_file= *of, { struct rdt_resource *r =3D rdt_kn_parent_priv(of->kn); =20 - seq_printf(seq, "%d\n", r->mon.num_rmid); + seq_printf(seq, "%u\n", r->mon.num_rmid); =20 return 0; } --=20 2.51.1 From nobody Tue Dec 2 00:25:23 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 970F8327207 for ; Mon, 24 Nov 2025 18:55:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764010512; cv=none; b=c0UDpo09mdnTy9+bY5eXFVEJoaVRPKbEuEAVu58kFACmmVpSsTmyRnIWf4heXlQnKHWkw2MVgIPasda35aEDbL9kT/X5jtWkRUW0RXu29l7la95sCF1YAz/G4Rudg+LAY3YUyEM/fGsDWHU0y0Jmn6kpdfhFWM7DimUOOuTD2D0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764010512; c=relaxed/simple; bh=UHRS0TLDoO64TMYWFggzrudAr8TGRSam3ri6R+Gk2Q4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PWs51VroI2rTbFH2dGxpeF9FhMcg+YhpJlGgKQOwO68g5rInWJ7I0PkazMjRBAVSqwkSzi1oM6yhx2GMoOQn/O4WuVol9gd259rcc+NzmOh4a0GVheE7n0Nv9QqWmo9AnHPSByLjopMBg9r0XFK5z2V5UKdHCktIO0xPLSEEs7U= 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=MTCLRBLY; arc=none smtp.client-ip=192.198.163.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="MTCLRBLY" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1764010511; x=1795546511; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=UHRS0TLDoO64TMYWFggzrudAr8TGRSam3ri6R+Gk2Q4=; b=MTCLRBLYVIqyJtk74FsWY2CinF3Gyqm/3gHL440qsycgs2kvhPwjCks2 DfTpqEpE+9Dzs9GhOVoF1sTwffwtSWbvDKzqNXNfkr689UiF0Mk1afuwY 5VsUCyJCBjeeDkPjo+GfPJNNHOcfkvwBTNAKcOuLT0hqMKy5cF9wgCXIS I61mCgW1hRfSL0CH72X+KpZELDWExiiPWJHc4ozMK0o3FvWbe0TxPTzA9 bhV5zVDK8abV0XqpjlFNErRV4ghpRWACpDRGYNxQBvFGCuKCc71odwHH3 OkpPvDBEwUBdADuMIQLGriwMC/eJ7ltuLaPjkQLVeilK1uGVvbJW6RDgJ g==; X-CSE-ConnectionGUID: E/9zPcWHRbW/Gd6ltgSKvQ== X-CSE-MsgGUID: 9JIraqEDQcuaXb+7Wh8OFg== X-IronPort-AV: E=McAfee;i="6800,10657,11623"; a="76636885" X-IronPort-AV: E=Sophos;i="6.20,223,1758610800"; d="scan'208";a="76636885" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Nov 2025 10:54:31 -0800 X-CSE-ConnectionGUID: ELxfIMmDQCabBzqQO7WS8Q== X-CSE-MsgGUID: HxAshJb3SmW0jXb2RJhibg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.20,223,1758610800"; d="scan'208";a="192225032" Received: from rfrazer-mobl3.amr.corp.intel.com (HELO agluck-desk3.home.arpa) ([10.124.222.153]) by orviesa009-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Nov 2025 10:54:31 -0800 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Maciej Wieczor-Retman , Peter Newman , James Morse , Babu Moger , Drew Fustini , Dave Martin , Chen Yu Cc: x86@kernel.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [PATCH v14 26/32] fs/resctrl: Move allocation/free of closid_num_dirty_rmid[] Date: Mon, 24 Nov 2025 10:54:03 -0800 Message-ID: <20251124185412.24155-27-tony.luck@intel.com> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251124185412.24155-1-tony.luck@intel.com> References: <20251124185412.24155-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" closid_num_dirty_rmid[] and rmid_ptrs[] are allocated together during resct= rl initialization and freed together during resctrl exit. Telemetry events are enumerated on resctrl mount so only at resctrl mount will the number of RMID supported by all monitoring resources and needed as size for rmid_ptrs[] be known. Separate closid_num_dirty_rmid[] and rmid_ptrs[] allocation and free in preparation for rmid_ptrs[] to be allocated on resctrl mount. Keep the rdtgroup_mutex protection around the allocation and free of closid_num_dirty_rmid[] as ARM needs this to guarantee memory ordering. Signed-off-by: Tony Luck Reviewed-by: Reinette Chatre --- fs/resctrl/monitor.c | 79 ++++++++++++++++++++++++++++---------------- 1 file changed, 51 insertions(+), 28 deletions(-) diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c index 8c90a24ae0d0..55772aeec1a2 100644 --- a/fs/resctrl/monitor.c +++ b/fs/resctrl/monitor.c @@ -899,36 +899,14 @@ void mbm_setup_overflow_handler(struct rdt_l3_mon_dom= ain *dom, unsigned long del static int dom_data_init(struct rdt_resource *r) { u32 idx_limit =3D resctrl_arch_system_num_rmid_idx(); - u32 num_closid =3D resctrl_arch_get_num_closid(r); struct rmid_entry *entry =3D NULL; int err =3D 0, i; u32 idx; =20 mutex_lock(&rdtgroup_mutex); - if (IS_ENABLED(CONFIG_RESCTRL_RMID_DEPENDS_ON_CLOSID)) { - u32 *tmp; - - /* - * If the architecture hasn't provided a sanitised value here, - * this may result in larger arrays than necessary. Resctrl will - * use a smaller system wide value based on the resources in - * use. - */ - tmp =3D kcalloc(num_closid, sizeof(*tmp), GFP_KERNEL); - if (!tmp) { - err =3D -ENOMEM; - goto out_unlock; - } - - closid_num_dirty_rmid =3D tmp; - } =20 rmid_ptrs =3D kcalloc(idx_limit, sizeof(struct rmid_entry), GFP_KERNEL); if (!rmid_ptrs) { - if (IS_ENABLED(CONFIG_RESCTRL_RMID_DEPENDS_ON_CLOSID)) { - kfree(closid_num_dirty_rmid); - closid_num_dirty_rmid =3D NULL; - } err =3D -ENOMEM; goto out_unlock; } @@ -964,11 +942,6 @@ static void dom_data_exit(struct rdt_resource *r) if (!r->mon_capable) goto out_unlock; =20 - if (IS_ENABLED(CONFIG_RESCTRL_RMID_DEPENDS_ON_CLOSID)) { - kfree(closid_num_dirty_rmid); - closid_num_dirty_rmid =3D NULL; - } - kfree(rmid_ptrs); rmid_ptrs =3D NULL; =20 @@ -1807,6 +1780,45 @@ ssize_t mbm_L3_assignments_write(struct kernfs_open_= file *of, char *buf, return ret ?: nbytes; } =20 +static int closid_num_dirty_rmid_alloc(struct rdt_resource *r) +{ + if (IS_ENABLED(CONFIG_RESCTRL_RMID_DEPENDS_ON_CLOSID)) { + u32 num_closid =3D resctrl_arch_get_num_closid(r); + u32 *tmp; + + /* For ARM memory ordering access to closid_num_dirty_rmid */ + mutex_lock(&rdtgroup_mutex); + + /* + * If the architecture hasn't provided a sanitised value here, + * this may result in larger arrays than necessary. Resctrl will + * use a smaller system wide value based on the resources in + * use. + */ + tmp =3D kcalloc(num_closid, sizeof(*tmp), GFP_KERNEL); + if (!tmp) { + mutex_unlock(&rdtgroup_mutex); + return -ENOMEM; + } + + closid_num_dirty_rmid =3D tmp; + + mutex_unlock(&rdtgroup_mutex); + } + + return 0; +} + +static void closid_num_dirty_rmid_free(void) +{ + if (IS_ENABLED(CONFIG_RESCTRL_RMID_DEPENDS_ON_CLOSID)) { + mutex_lock(&rdtgroup_mutex); + kfree(closid_num_dirty_rmid); + closid_num_dirty_rmid =3D NULL; + mutex_unlock(&rdtgroup_mutex); + } +} + /** * resctrl_l3_mon_resource_init() - Initialise global monitoring structure= s. * @@ -1827,10 +1839,16 @@ int resctrl_l3_mon_resource_init(void) if (!r->mon_capable) return 0; =20 - ret =3D dom_data_init(r); + ret =3D closid_num_dirty_rmid_alloc(r); if (ret) return ret; =20 + ret =3D dom_data_init(r); + if (ret) { + closid_num_dirty_rmid_free(); + return ret; + } + if (resctrl_arch_is_evt_configurable(QOS_L3_MBM_TOTAL_EVENT_ID)) { mon_event_all[QOS_L3_MBM_TOTAL_EVENT_ID].configurable =3D true; resctrl_file_fflags_init("mbm_total_bytes_config", @@ -1873,5 +1891,10 @@ void resctrl_l3_mon_resource_exit(void) { struct rdt_resource *r =3D resctrl_arch_get_resource(RDT_RESOURCE_L3); =20 + if (!r->mon_capable) + return; + + closid_num_dirty_rmid_free(); + dom_data_exit(r); } --=20 2.51.1 From nobody Tue Dec 2 00:25:23 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 645D6327204 for ; Mon, 24 Nov 2025 18:55:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764010512; cv=none; b=G8VCaGeBwIjVGxfN3ye8eRLmdIe0+WKnBb1Lb2k/4qDfz0WFbv7ggcz4/OgDLEE1c4EJGEQZcIJsLC9rdBLe/7z3xW5LPy7a2EKm9cv4CpNZ6Pg8S75HsXqZPPL8LbijRb5vh+ARSnIKdxNe371jemb+N5ko+FluEI5KDTez0xo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764010512; c=relaxed/simple; bh=6P6/qdwIinWh3GhPxgZSngc0CYjUPfiSTLftQro4OAU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=n69F5+fgFCpo6oFReR0L3O91LKLqFto0/HkKce4eckc0xtatgcwLJ4Yry5DkCAF+6r/yTjgBQj4jgmzmyD7QeGIgFbXX6A6haA5fPvP0j0GYP6uhFi76LF7rZVDdeRtChTXGdAEej5UBB86k6yKPWsMSKwMyvBXX+hVygozmF8I= 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=OlpPJohM; arc=none smtp.client-ip=192.198.163.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="OlpPJohM" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1764010510; x=1795546510; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=6P6/qdwIinWh3GhPxgZSngc0CYjUPfiSTLftQro4OAU=; b=OlpPJohMT+Bco3adU8YDOc12a//erF/PqUzPCLeT0ssYgu0MOTWwO4VQ CdS4D5Qkrs+FqDWGdSUMtAaNO9Rm4LyO89JeDvIPMRwsbcuW+ggTuRsyc 4DabsZxPtVLD6Zp6RpJEJVGKlgs8jmIHf1rcFt01Cv8gvFvn0JSB7mXK0 jvwi0FdLhQingUFdZgwF/XaCl3Kyf1+CmsNPbvXA+As3ps0oFLXnqSAMI Ae9Yj38PDqsK4/cW49CC0Z1J47yOh+9ki9M3bmU75Lj1djUq9hm7Z9OPK 2Y6Hcklwp4pxCkx6xJrjhbXnWMCUlZJTTP/1YDiM4cxjXB3EZy9bR6pte A==; X-CSE-ConnectionGUID: vZYb7hhaRUG//TuBClVZlA== X-CSE-MsgGUID: RSRWk6/ZSyaMpBeqTD7cCw== X-IronPort-AV: E=McAfee;i="6800,10657,11623"; a="76636901" X-IronPort-AV: E=Sophos;i="6.20,223,1758610800"; d="scan'208";a="76636901" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Nov 2025 10:54:31 -0800 X-CSE-ConnectionGUID: EkEPN/twQ2KcrhoMM/KKJw== X-CSE-MsgGUID: 7sk5b8xGRBqoNTPZKWUE9g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.20,223,1758610800"; d="scan'208";a="192225035" Received: from rfrazer-mobl3.amr.corp.intel.com (HELO agluck-desk3.home.arpa) ([10.124.222.153]) by orviesa009-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Nov 2025 10:54:31 -0800 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Maciej Wieczor-Retman , Peter Newman , James Morse , Babu Moger , Drew Fustini , Dave Martin , Chen Yu Cc: x86@kernel.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [PATCH v14 27/32] x86,fs/resctrl: Compute number of RMIDs as minimum across resources Date: Mon, 24 Nov 2025 10:54:04 -0800 Message-ID: <20251124185412.24155-28-tony.luck@intel.com> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251124185412.24155-1-tony.luck@intel.com> References: <20251124185412.24155-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 assumes that only the L3 resource supports monitor events, so it simply takes the rdt_resource::num_rmid from RDT_RESOURCE_L3 as the system's number of RMIDs. The addition of telemetry events in a different resource breaks that assumption. Compute the number of available RMIDs as the minimum value across all mon_capable resources (analogous to how the number of CLOSIDs is computed across alloc_capable resources). Note that mount time enumeration of the telemetry resource means that this number can be reduced. If this happens, then some memory will be wasted as the allocations for rdt_l3_mon_domain::mbm_states[] and rdt_l3_mon_domain::rmid_busy_llc created during resctrl initialization will be larger than needed. Signed-off-by: Tony Luck Reviewed-by: Reinette Chatre --- arch/x86/kernel/cpu/resctrl/core.c | 15 +++++++++++++-- fs/resctrl/rdtgroup.c | 6 ++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resct= rl/core.c index 960974ffa866..bca65851d592 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -110,12 +110,23 @@ struct rdt_hw_resource rdt_resources_all[RDT_NUM_RESO= URCES] =3D { }, }; =20 +/** + * resctrl_arch_system_num_rmid_idx - Compute number of supported RMIDs + * (minimum across all mon_capable resource) + * + * Return: Number of supported RMIDs at time of call. Note that mount time + * enumeration of resources may reduce the number. + */ u32 resctrl_arch_system_num_rmid_idx(void) { - struct rdt_resource *r =3D &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl; + u32 num_rmids =3D U32_MAX; + struct rdt_resource *r; + + for_each_mon_capable_rdt_resource(r) + num_rmids =3D min(num_rmids, r->mon.num_rmid); =20 /* RMID are independent numbers for x86. num_rmid_idx =3D=3D num_rmid */ - return r->mon.num_rmid; + return num_rmids =3D=3D U32_MAX ? 0 : num_rmids; } =20 struct rdt_resource *resctrl_arch_get_resource(enum resctrl_res_level l) diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c index 60ce2390723e..e95d3d0dc515 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -4352,6 +4352,12 @@ void resctrl_offline_mon_domain(struct rdt_resource = *r, struct rdt_domain_hdr *h * During boot this may be called before global allocations have been made= by * resctrl_l3_mon_resource_init(). * + * Called during CPU online that may run as soon as CPU online callbacks + * are set up during resctrl initialization. The number of supported RMIDs + * may be reduced if additional mon_capable resources are enumerated + * at mount time. This means the rdt_l3_mon_domain::mbm_states[] and + * rdt_l3_mon_domain::rmid_busy_llc allocations may be larger than needed. + * * Return: 0 for success, or -ENOMEM. */ static int domain_setup_l3_mon_state(struct rdt_resource *r, struct rdt_l3= _mon_domain *d) --=20 2.51.1 From nobody Tue Dec 2 00:25:23 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DE0FD32779D for ; Mon, 24 Nov 2025 18:55:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764010513; cv=none; b=B1Gy3YeH8nqCSxeqGFaWFs9cAPpfXvOUEIPdunJqFiBHy5m0exIecBfMK9eGT7X2oa4pte1V0bmD2wbXjWNmbPaLJ64lwL78L09yzU0UtA6DJPpGZ4s4GKNCaQbwsGiR820/ZeBTNe5EycHM+YAz0rmOUbndeCnHtrVOiR5B/oY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764010513; c=relaxed/simple; bh=r5Ul2DM4PmLvMaeyHK+TpelMi2f91vGBiwdPwZ0mZDE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lPfiN6/NzT93h8qw68V71Rya7Qj0fqjifsTro3uqJmz330LNG6PbTdARYTb16OXLqMCEN3KvsE0ZVbCnRzX8/yo0jvt0yob4fF675PEhXA857oaGoSd5xZyRd93YM0YYH006TbUpg+Lj0earTk/MAnixHoT71HL/mis7aJ7fls4= 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=NqV4kiDo; arc=none smtp.client-ip=192.198.163.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="NqV4kiDo" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1764010512; x=1795546512; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=r5Ul2DM4PmLvMaeyHK+TpelMi2f91vGBiwdPwZ0mZDE=; b=NqV4kiDo/0/l7snG3Qw5Ry5Pa7NIVUyc00qWMWlPqcbyqw3LIlVn7y2I aTf6h6DBmnLjPpiNw608voB30vrKXBLdK8hhQZs8OY08HIhKbOOTZBuOW WBgy5DZNUoT/q5vELB9Fy+r4XalctsaMou+hPx148pvtGdO8i06qe3ALV w9RcAGvzaQUDBIl3XHFTQf6Q8r5Muu6Vy7+nEdYHQbYKTp3FD/5DWZ+hb 8y5pNd+3n5In2Qc6W4Dn2Ed+W6yGca66bS8kX4ioDtRqjUonNEuE1aPbN AC+dEIDK0lsqcvws2QbdCicoaZWNtDlNKKWVE9Q8xnn424KVFGUrg0fWM g==; X-CSE-ConnectionGUID: 618m3YqxSq+xO7r0Vah+oQ== X-CSE-MsgGUID: jtAhxh0pQ72pYUsbtAR2PQ== X-IronPort-AV: E=McAfee;i="6800,10657,11623"; a="76636917" X-IronPort-AV: E=Sophos;i="6.20,223,1758610800"; d="scan'208";a="76636917" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Nov 2025 10:54:32 -0800 X-CSE-ConnectionGUID: XDhGFgslSgSIrVDWcqmQXg== X-CSE-MsgGUID: siQbzqTSR+2cmvfziW4eNw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.20,223,1758610800"; d="scan'208";a="192225038" Received: from rfrazer-mobl3.amr.corp.intel.com (HELO agluck-desk3.home.arpa) ([10.124.222.153]) by orviesa009-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Nov 2025 10:54:31 -0800 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Maciej Wieczor-Retman , Peter Newman , James Morse , Babu Moger , Drew Fustini , Dave Martin , Chen Yu Cc: x86@kernel.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [PATCH v14 28/32] fs/resctrl: Move RMID initialization to first mount Date: Mon, 24 Nov 2025 10:54:05 -0800 Message-ID: <20251124185412.24155-29-tony.luck@intel.com> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251124185412.24155-1-tony.luck@intel.com> References: <20251124185412.24155-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" L3 monitor features are enumerated during resctrl initialization and rmid_ptrs[] that tracks all RMIDs and depends on the number of supported RMIDs is allocated during this time. Telemetry monitor features are enumerated during first resctrl mount and may support a different number of RMIDs compared to L3 monitor features. Delay allocation and initialization of rmid_ptrs[] until first mount. Since the number of RMIDs cannot change on later mounts, keep the same set = of rmid_ptrs[] until resctrl_exit(). This is required because the limbo handler keeps running after resctrl is unmounted and needs to access rmid_ptrs[] as it keeps tracking busy RMIDs after unmount. Rename routines to match what they now do: dom_data_init() -> setup_rmid_lru_list() dom_data_exit() -> free_rmid_lru_list() Signed-off-by: Tony Luck Reviewed-by: Reinette Chatre --- fs/resctrl/internal.h | 4 ++++ fs/resctrl/monitor.c | 54 ++++++++++++++++++++----------------------- fs/resctrl/rdtgroup.c | 5 ++++ 3 files changed, 34 insertions(+), 29 deletions(-) diff --git a/fs/resctrl/internal.h b/fs/resctrl/internal.h index 399f625be67d..1a9b29119f88 100644 --- a/fs/resctrl/internal.h +++ b/fs/resctrl/internal.h @@ -369,6 +369,10 @@ int closids_supported(void); =20 void closid_free(int closid); =20 +int setup_rmid_lru_list(void); + +void free_rmid_lru_list(void); + int alloc_rmid(u32 closid); =20 void free_rmid(u32 closid, u32 rmid); diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c index 55772aeec1a2..bec6a69f2aae 100644 --- a/fs/resctrl/monitor.c +++ b/fs/resctrl/monitor.c @@ -896,20 +896,29 @@ void mbm_setup_overflow_handler(struct rdt_l3_mon_dom= ain *dom, unsigned long del schedule_delayed_work_on(cpu, &dom->mbm_over, delay); } =20 -static int dom_data_init(struct rdt_resource *r) +int setup_rmid_lru_list(void) { - u32 idx_limit =3D resctrl_arch_system_num_rmid_idx(); struct rmid_entry *entry =3D NULL; - int err =3D 0, i; + u32 idx_limit; u32 idx; + int i; =20 - mutex_lock(&rdtgroup_mutex); + if (!resctrl_arch_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. + */ + if (rmid_ptrs) + return 0; + + idx_limit =3D resctrl_arch_system_num_rmid_idx(); rmid_ptrs =3D kcalloc(idx_limit, sizeof(struct rmid_entry), GFP_KERNEL); - if (!rmid_ptrs) { - err =3D -ENOMEM; - goto out_unlock; - } + if (!rmid_ptrs) + return -ENOMEM; =20 for (i =3D 0; i < idx_limit; i++) { entry =3D &rmid_ptrs[i]; @@ -922,30 +931,24 @@ static int dom_data_init(struct rdt_resource *r) /* * RESCTRL_RESERVED_CLOSID and RESCTRL_RESERVED_RMID are special and * are always allocated. These are used for the rdtgroup_default - * control group, which will be setup later in resctrl_init(). + * 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); =20 -out_unlock: - mutex_unlock(&rdtgroup_mutex); - - return err; + return 0; } =20 -static void dom_data_exit(struct rdt_resource *r) +void free_rmid_lru_list(void) { - mutex_lock(&rdtgroup_mutex); - - if (!r->mon_capable) - goto out_unlock; + if (!resctrl_arch_mon_capable()) + return; =20 + mutex_lock(&rdtgroup_mutex); kfree(rmid_ptrs); rmid_ptrs =3D NULL; - -out_unlock: mutex_unlock(&rdtgroup_mutex); } =20 @@ -1823,7 +1826,8 @@ static void closid_num_dirty_rmid_free(void) * resctrl_l3_mon_resource_init() - Initialise global monitoring structure= s. * * Allocate and initialise global monitor resources that do not belong to a - * specific domain. i.e. the rmid_ptrs[] used for the limbo and free lists. + * specific domain. i.e. the closid_num_dirty_rmid[] used to find the CLOS= ID + * with the cleanest set of RMIDs. * Called once during boot after the struct rdt_resource's have been confi= gured * but before the filesystem is mounted. * Resctrl's cpuhp callbacks may be called before this point to bring a do= main @@ -1843,12 +1847,6 @@ int resctrl_l3_mon_resource_init(void) if (ret) return ret; =20 - ret =3D dom_data_init(r); - if (ret) { - closid_num_dirty_rmid_free(); - return ret; - } - if (resctrl_arch_is_evt_configurable(QOS_L3_MBM_TOTAL_EVENT_ID)) { mon_event_all[QOS_L3_MBM_TOTAL_EVENT_ID].configurable =3D true; resctrl_file_fflags_init("mbm_total_bytes_config", @@ -1895,6 +1893,4 @@ void resctrl_l3_mon_resource_exit(void) return; =20 closid_num_dirty_rmid_free(); - - dom_data_exit(r); } diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c index e95d3d0dc515..d49ffc56ea61 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -2799,6 +2799,10 @@ static int rdt_get_tree(struct fs_context *fc) goto out; } =20 + ret =3D setup_rmid_lru_list(); + if (ret) + goto out; + ret =3D rdtgroup_setup_root(ctx); if (ret) goto out; @@ -4654,4 +4658,5 @@ void resctrl_exit(void) */ =20 resctrl_l3_mon_resource_exit(); + free_rmid_lru_list(); } --=20 2.51.1 From nobody Tue Dec 2 00:25:23 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 743FC327C0D for ; Mon, 24 Nov 2025 18:55:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764010515; cv=none; b=UDF5hjSPOoshwVi8Kbov+YOapKO2sO0gz3EQVdl7xezcBWbRPI+X01J+b4sVrhih0dp1zdirLpsDmLR4qw1TaB9Gmv6uVsQ1uP+ixFFF97FXSujIbIMSc/421UE7bmMAFC3t35Np6KKTYI6g67PeHasBNZGF2lJjuy6rS0ZhyXU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764010515; c=relaxed/simple; bh=ktuSk2wMgmJMK50ZK4GLeGxWbH7w+Yr81xrVxNRhnWs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Gku0cmLeWd6q1nARsz+P/DO+Xb9zLJgG7YOy3J7tPcJMgI8pmOJyoYsN5JtmtcyGWzoi47/V9FZvpZt4uoYLLzLV0BS/IwSnzFxZp16zsrE8l2oTp6ZtEzTaw503lGO+a9TUfSk4/7RjnfviwSC3jpFbI9dMLmwmQbHtmyYYEKU= 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=IAcnS23q; arc=none smtp.client-ip=192.198.163.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="IAcnS23q" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1764010513; x=1795546513; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ktuSk2wMgmJMK50ZK4GLeGxWbH7w+Yr81xrVxNRhnWs=; b=IAcnS23qsi1V2PXSR2d5EmTv1zBjpgFVnPAzo8axRTXWbrTYC55U2wBO ueOVY+xTZgA99ejW7HfFJt3pEifluQnaAGtlyehMbjjsRXO06vLGa7209 NdMfIcrjugfActWSkCt2I00RQdXUhPa66xcRj1+e4lGVQjopy+WgoFdv1 Y6+L7sSq4PWNsUwqG80Sq2UskGjZMa1z7+PsGznGTY5zLLI/PhqrXLmXg cZwjWZdK86crCnSxLSg5JKubKX3X1MlMMCuSUqmq7/BfLFIPHvUM7ldvL Bjn43xdWJA11yTEFvFmyNv/z5hn8AOAhoPS59e5Js/CdPwZf5sU1F9wQe Q==; X-CSE-ConnectionGUID: idfUhOb9QCaw9NBWE8EhiA== X-CSE-MsgGUID: GvIZvy2HTxuWlk+joUMItw== X-IronPort-AV: E=McAfee;i="6800,10657,11623"; a="76636939" X-IronPort-AV: E=Sophos;i="6.20,223,1758610800"; d="scan'208";a="76636939" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Nov 2025 10:54:32 -0800 X-CSE-ConnectionGUID: KQ9Pgc8XTwWqTDBrc5q1RA== X-CSE-MsgGUID: KOBCkZbVRamLT94qatBzsw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.20,223,1758610800"; d="scan'208";a="192225041" Received: from rfrazer-mobl3.amr.corp.intel.com (HELO agluck-desk3.home.arpa) ([10.124.222.153]) by orviesa009-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Nov 2025 10:54:32 -0800 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Maciej Wieczor-Retman , Peter Newman , James Morse , Babu Moger , Drew Fustini , Dave Martin , Chen Yu Cc: x86@kernel.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [PATCH v14 29/32] x86/resctrl: Enable RDT_RESOURCE_PERF_PKG Date: Mon, 24 Nov 2025 10:54:06 -0800 Message-ID: <20251124185412.24155-30-tony.luck@intel.com> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251124185412.24155-1-tony.luck@intel.com> References: <20251124185412.24155-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" Since telemetry events are enumerated on resctrl mount the RDT_RESOURCE_PER= F_PKG resource is not considered "monitoring capable" during early resctrl initia= lization. This means that the domain list for RDT_RESOURCE_PERF_PKG is not built when= the CPU hot plug notifiers are registered and run for the first time right after re= sctrl initialization. Mark the RDT_RESOURCE_PERF_PKG as "monitoring capable" upon successful tele= metry event enumeration to ensure future CPU hotplug events include this resource= and initialize its domain list for CPUs that are already online. Print to console log announcing the name of the telemetry feature detected. Signed-off-by: Tony Luck Reviewed-by: Reinette Chatre --- arch/x86/kernel/cpu/resctrl/core.c | 16 +++++++++++++++- arch/x86/kernel/cpu/resctrl/intel_aet.c | 6 ++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resct= rl/core.c index bca65851d592..829633bc54e5 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -766,14 +766,28 @@ static int resctrl_arch_offline_cpu(unsigned int cpu) =20 void resctrl_arch_pre_mount(void) { + struct rdt_resource *r =3D &rdt_resources_all[RDT_RESOURCE_PERF_PKG].r_re= sctrl; static atomic_t only_once =3D ATOMIC_INIT(0); - int old =3D 0; + int cpu, old =3D 0; =20 if (!atomic_try_cmpxchg(&only_once, &old, 1)) return; =20 if (!intel_aet_get_events()) return; + + /* + * Late discovery of telemetry events means the domains for the + * resource were not built. Do that now. + */ + 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); + cpus_read_unlock(); } =20 enum { diff --git a/arch/x86/kernel/cpu/resctrl/intel_aet.c b/arch/x86/kernel/cpu/= resctrl/intel_aet.c index 6eff606541ad..83d0bab4d6f5 100644 --- a/arch/x86/kernel/cpu/resctrl/intel_aet.c +++ b/arch/x86/kernel/cpu/resctrl/intel_aet.c @@ -280,6 +280,12 @@ static bool enable_events(struct event_group *e, struc= t pmt_feature_group *p) else r->mon.num_rmid =3D e->num_rmid; =20 + if (skipped_events) + pr_info("%s %s:0x%x monitoring detected (skipped %d events)\n", r->name, + e->name, e->guid, skipped_events); + else + pr_info("%s %s:0x%x monitoring detected\n", r->name, e->name, e->guid); + return true; } =20 --=20 2.51.1 From nobody Tue Dec 2 00:25:23 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BC35D327C16 for ; Mon, 24 Nov 2025 18:55:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764010515; cv=none; b=sZ9Ub3zNPgYKZLzPqlrF3u4SR6ICObkKQJZgcsbA7udBpoC17VWFbSAc9BSXJv6+yqurniqoFNGUIyfcDeUP5sCIUV0ufZZ4hjds2DN+uaiKcxrYsoCxC4cV2KtgwXpSrkGmSGu6ADkSDMcagjiXxFvjZCNz5CB62rI0/DdaXKc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764010515; c=relaxed/simple; bh=a6GqSiYes3g1hfurapo7TsD5x6nKUzU6tpAj8OUBXbc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gvldO2jCH3blQcKXihRzn6OuT+M9NvH5JF9VZVhpoGpOzRZFiQ1E6nNo5Vty8FI4kSrBYKfMcaBW3Su8yNkL9Y3Bnbul9CeFMmlMxFSIm8BQmDRKsaS/H5C8FPnYbojOGGMsCGaKzdETCqPfXv8YyknC5BQMYMmFDbCK70iUE+4= 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=j+pGaSnu; arc=none smtp.client-ip=192.198.163.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="j+pGaSnu" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1764010514; x=1795546514; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=a6GqSiYes3g1hfurapo7TsD5x6nKUzU6tpAj8OUBXbc=; b=j+pGaSnu3ZTup7/U1TRIfunzCt7I1ELluxCujzOKmJ6gIsL/Ho2SMRHc 0ip1FT7Eww7AOnQQ0iDgojzhcxIRQt97hwIb655ucRN19Vqu8rCVipxe/ 68JZh6YyI7G7oOb7BJmb89g0kFRwA7NLNemSm6IIINwXFA2VPKXpgpiZ3 Liy6h1pVLXX/4ORPcx73JEuhCVLcVmsZi4NbntVAkfKnKbsd9+GCCjtNf wEiaFFGOkQ4CoNvtD6F2sCiLJ2HfAcc4Du1JML8AmtAA+i7pRwNtnZdvG fMUPUZhqGXyGPysAVgP1Y7dv9GsDCjs/8vSQo2kKVWTizl5A0hP/y31eY A==; X-CSE-ConnectionGUID: PE8766vtQ4GXFBI0AZ7Ybg== X-CSE-MsgGUID: 6Ipcn10JQUaFS0CJSFqTeQ== X-IronPort-AV: E=McAfee;i="6800,10657,11623"; a="76636953" X-IronPort-AV: E=Sophos;i="6.20,223,1758610800"; d="scan'208";a="76636953" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Nov 2025 10:54:32 -0800 X-CSE-ConnectionGUID: 1Pj1nOF0S5idjYP30dN5bg== X-CSE-MsgGUID: u5re61K5SfaGAvuFIPadlQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.20,223,1758610800"; d="scan'208";a="192225045" Received: from rfrazer-mobl3.amr.corp.intel.com (HELO agluck-desk3.home.arpa) ([10.124.222.153]) by orviesa009-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Nov 2025 10:54:32 -0800 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Maciej Wieczor-Retman , Peter Newman , James Morse , Babu Moger , Drew Fustini , Dave Martin , Chen Yu Cc: x86@kernel.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [PATCH v14 30/32] fs/resctrl: Provide interface to create architecture specific debugfs area Date: Mon, 24 Nov 2025 10:54:07 -0800 Message-ID: <20251124185412.24155-31-tony.luck@intel.com> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251124185412.24155-1-tony.luck@intel.com> References: <20251124185412.24155-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 files below /sys/fs/resctrl are considered user ABI. This leaves no place for architectures to provide additional interfaces. Add resctrl_debugfs_mon_info_arch_mkdir() which creates a directory in the debugfs file system for a monitoring resource. Naming follows the layout of the main resctrl hierarchy: /sys/kernel/debug/resctrl/info/{resource}_MON/{arch} The {arch} last level directory name matches the output of the user level "uname -m" command. Architecture code may use this directory for debug information, or for minor tuning of features. It must not be used for basic feature enabling as debug= fs may not be configured/mounted on production systems. Suggested-by: Reinette Chatre Signed-off-by: Tony Luck Reviewed-by: Reinette Chatre --- include/linux/resctrl.h | 10 ++++++++++ fs/resctrl/rdtgroup.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index 8623e450619a..b862a9dd785b 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -702,6 +702,16 @@ bool resctrl_arch_get_io_alloc_enabled(struct rdt_reso= urce *r); extern unsigned int resctrl_rmid_realloc_threshold; extern unsigned int resctrl_rmid_realloc_limit; =20 +/** + * resctrl_debugfs_mon_info_arch_mkdir() - Create a debugfs info directory. + * Removed by resctrl_exit(). + * @r: Resource (must be mon_capable). + * + * Return: NULL if resource is not monitoring capable, + * dentry pointer on success, or ERR_PTR(-ERROR) on failure. + */ +struct dentry *resctrl_debugfs_mon_info_arch_mkdir(struct rdt_resource *r); + int resctrl_init(void); void resctrl_exit(void); =20 diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c index d49ffc56ea61..d13291d71adf 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -24,6 +24,7 @@ #include #include #include +#include =20 #include =20 @@ -75,6 +76,8 @@ static void rdtgroup_destroy_root(void); =20 struct dentry *debugfs_resctrl; =20 +static struct dentry *debugfs_resctrl_info; + /* * Memory bandwidth monitoring event to use for the default CTRL_MON group * and each new CTRL_MON group created by the user. Only relevant when @@ -4599,6 +4602,31 @@ int resctrl_init(void) return ret; } =20 +/* + * Create /sys/kernel/debug/resctrl/info/{r->name}_MON/{arch} directory + * by request for architecture to use for debugging or minor tuning. + * Basic functionality of features must not be controlled by files + * added to this directory as debugfs may not be configured/mounted + * on production systems. + */ +struct dentry *resctrl_debugfs_mon_info_arch_mkdir(struct rdt_resource *r) +{ + struct dentry *moninfodir; + char name[32]; + + if (!r->mon_capable) + return NULL; + + if (!debugfs_resctrl_info) + debugfs_resctrl_info =3D debugfs_create_dir("info", debugfs_resctrl); + + sprintf(name, "%s_MON", r->name); + + moninfodir =3D debugfs_create_dir(name, debugfs_resctrl_info); + + return debugfs_create_dir(utsname()->machine, moninfodir); +} + static bool resctrl_online_domains_exist(void) { struct rdt_resource *r; @@ -4650,6 +4678,7 @@ void resctrl_exit(void) =20 debugfs_remove_recursive(debugfs_resctrl); debugfs_resctrl =3D NULL; + debugfs_resctrl_info =3D NULL; unregister_filesystem(&rdt_fs_type); =20 /* --=20 2.51.1 From nobody Tue Dec 2 00:25:23 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4895A32825C for ; Mon, 24 Nov 2025 18:55:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764010517; cv=none; b=KhoFCSakXK6xeavpw5b8FfPcmXwDqHujjPMmk+33dRn+K3E7cDgxzZivoaLE3rVzNfb1eWf0UhILhlxJiyzaejmpdTsuFIXntZOR5fxHa0oWNHUgg94sMQl28Lczm5VFf1qCuQfFh1wfL0HdNCFlHiH0kTaRf5AHV2GVsUDAu+c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764010517; c=relaxed/simple; bh=uAnkQlLU3vWsmm5FFgB7ke1atYw5vOlVrS4bysI7COU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YtYlRp5y+UznPO7Rq0wibVJfotKEE0CaaSdg3vk+DyhAmfD/iJGB+uKhrtEmNksNjuNiosCioEXcwPDKsC1VLoyaCeXbJd3++DQ4TxBxJkPT+7j6gmv3xMqWw9yqfdRQfi+Uyu6U9k30z2ES/Zzq8ITAB7KdpQ1Et7pgetP2qj8= 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=YQQVufS+; arc=none smtp.client-ip=192.198.163.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="YQQVufS+" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1764010515; x=1795546515; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=uAnkQlLU3vWsmm5FFgB7ke1atYw5vOlVrS4bysI7COU=; b=YQQVufS+hnjTuGPoI6S8PlpqL1+pEekPCaR2rF8h1bU7qZny/zO06ajJ SDvWledz47xQr7Z7Cs0lQCGNqz7T2oduww/dDHZCY78hR0PBGgiEIQUDq SDcXh+22zjv2GR5VB0qXzDv5M0GhT2LLcPrTTaccs+eXGjP1eU0gvZZaT oQ+q3DPNE2JwQhp4aYjnXeEYVX5WIFADccPniBIvO2p2wYZOVYPkXvjZ4 6BqgqSdoOPde2+Dv1cqtLiezqS5g84z5UrE2L3DzcwnP6jeRwD/2XdhQu 0BUAtGxO2GyItsKPV85DfNQomXwhP+VbB4Lgzk3UVr/CapwafQOH+pUfq g==; X-CSE-ConnectionGUID: RSAv5KU7S7mDniCxkh+phw== X-CSE-MsgGUID: FNpBzmjBTXqcRKPJjYPnyw== X-IronPort-AV: E=McAfee;i="6800,10657,11623"; a="76636966" X-IronPort-AV: E=Sophos;i="6.20,223,1758610800"; d="scan'208";a="76636966" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Nov 2025 10:54:33 -0800 X-CSE-ConnectionGUID: SMQyxvLBSlqKAdfOrH0HZg== X-CSE-MsgGUID: tMVxjBm+Q36KPBpM8mRICQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.20,223,1758610800"; d="scan'208";a="192225049" Received: from rfrazer-mobl3.amr.corp.intel.com (HELO agluck-desk3.home.arpa) ([10.124.222.153]) by orviesa009-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Nov 2025 10:54:33 -0800 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Maciej Wieczor-Retman , Peter Newman , James Morse , Babu Moger , Drew Fustini , Dave Martin , Chen Yu Cc: x86@kernel.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [PATCH v14 31/32] x86/resctrl: Add debugfs files to show telemetry aggregator status Date: Mon, 24 Nov 2025 10:54:08 -0800 Message-ID: <20251124185412.24155-32-tony.luck@intel.com> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251124185412.24155-1-tony.luck@intel.com> References: <20251124185412.24155-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" Each telemetry aggregator provides three status registers at the top end of MMIO space after all the per-RMID per-event counters: data_loss_count: This counts the number of times that this aggregator failed to accumulate a counter value supplied by a CPU core. data_loss_timestamp: This is a "timestamp" from a free running 25MHz uncore timer indicating when the most recent data loss occurred. last_update_timestamp: Another 25MHz timestamp indicating when the most recent counter update was successfully applied. Create files in /sys/kernel/debug/resctrl/info/PERF_PKG_MON/x86_64/ to disp= lay the value of each of these status registers for each aggregator in each ena= bled event group. The prefix for each file name describes the type of aggregator, the guid, which package it is located on, and an opaque instance number to provide a unique file name when there are multiple aggregators on a package. The suffix is one of the three strings listed above. An example name is: energy_0x26696143_pkg0_agg2_data_loss_count These files are removed along with all other debugfs entries by the call to debugfs_remove_recursive() in resctrl_exit(). Signed-off-by: Tony Luck Reviewed-by: Reinette Chatre --- arch/x86/kernel/cpu/resctrl/internal.h | 2 + arch/x86/kernel/cpu/resctrl/core.c | 2 + arch/x86/kernel/cpu/resctrl/intel_aet.c | 60 +++++++++++++++++++++++++ 3 files changed, 64 insertions(+) diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/r= esctrl/internal.h index 304e6e341905..96ee016f2012 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -236,6 +236,7 @@ void __exit intel_aet_exit(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); +void intel_aet_add_debugfs(void); bool intel_aet_option(bool force_off, char *tok); #else static inline bool intel_aet_get_events(void) { return false; } @@ -247,6 +248,7 @@ static inline int intel_aet_read_event(int domid, u32 r= mid, void *arch_priv, u64 =20 static inline void intel_aet_mon_domain_setup(int cpu, int id, struct rdt_= resource *r, struct list_head *add_pos) { } +static inline void intel_aet_add_debugfs(void) { } static inline bool intel_aet_option(bool force_off, char *tok) { return fa= lse; } #endif =20 diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resct= rl/core.c index 829633bc54e5..62e96aad060d 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -788,6 +788,8 @@ void resctrl_arch_pre_mount(void) domain_add_cpu_mon(cpu, r); mutex_unlock(&domain_list_lock); cpus_read_unlock(); + + intel_aet_add_debugfs(); } =20 enum { diff --git a/arch/x86/kernel/cpu/resctrl/intel_aet.c b/arch/x86/kernel/cpu/= resctrl/intel_aet.c index 83d0bab4d6f5..5e0c0b1ff6a7 100644 --- a/arch/x86/kernel/cpu/resctrl/intel_aet.c +++ b/arch/x86/kernel/cpu/resctrl/intel_aet.c @@ -18,8 +18,11 @@ #include #include #include +#include +#include #include #include +#include #include #include #include @@ -33,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -232,6 +236,46 @@ static bool all_regions_have_sufficient_rmid(struct ev= ent_group *e, struct pmt_f return ret; } =20 +static int status_read(void *priv, u64 *val) +{ + void __iomem *info =3D (void __iomem *)priv; + + *val =3D readq(info); + + return 0; +} + +DEFINE_SIMPLE_ATTRIBUTE(status_fops, status_read, NULL, "%llu\n"); + +static void make_status_files(struct dentry *dir, struct event_group *e, u= 8 pkg, + int instance, void *info_end) +{ + char name[80]; + + sprintf(name, "%s_0x%x_pkg%u_agg%d_data_loss_count", e->name, e->guid, pk= g, instance); + debugfs_create_file(name, 0400, dir, info_end - 24, &status_fops); + + sprintf(name, "%s_0x%x_pkg%u_agg%d_data_loss_timestamp", e->name, e->guid= , pkg, instance); + debugfs_create_file(name, 0400, dir, info_end - 16, &status_fops); + + sprintf(name, "%s_0x%x_pkg%u_agg%d_last_update_timestamp", e->name, e->gu= id, pkg, instance); + debugfs_create_file(name, 0400, dir, info_end - 8, &status_fops); +} + +static void create_debug_event_status_files(struct dentry *dir, struct eve= nt_group *e) +{ + struct pmt_feature_group *p =3D e->pfg; + void *info_end; + + for (int i =3D 0; i < p->count; i++) { + if (!p->regions[i].addr) + continue; + info_end =3D (void __force *)p->regions[i].addr + e->mmio_size; + make_status_files(dir, e, p->regions[i].plat_info.package_id, + i, info_end); + } +} + 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; @@ -400,3 +444,19 @@ void intel_aet_mon_domain_setup(int cpu, int id, struc= t rdt_resource *r, kfree(d); } } + +void intel_aet_add_debugfs(void) +{ + struct rdt_resource *r =3D &rdt_resources_all[RDT_RESOURCE_PERF_PKG].r_re= sctrl; + struct event_group **peg; + struct dentry *infodir; + + infodir =3D resctrl_debugfs_mon_info_arch_mkdir(r); + + if (IS_ERR_OR_NULL(infodir)) + return; + + for_each_event_group(peg) + if ((*peg)->pfg) + create_debug_event_status_files(infodir, *peg); +} --=20 2.51.1 From nobody Tue Dec 2 00:25:23 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BCE10328273 for ; Mon, 24 Nov 2025 18:55:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764010518; cv=none; b=PeepPP3FJbFiLjHZ8KZ7/f5tYJFbZrq7yOzsmiJzDvcKYQkTEZGbmCMK/gHp2YABaZDVmJpwiAOK5skzsFONaYwH0+HLWrXfcIFASd7GRzjvHLpEIyi50L+Wa+xFfCSiqZ0v0uHBPZ0GlvAW6CyY5wt+iCSR9kdF8afrZEICGfY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764010518; c=relaxed/simple; bh=cE+HGYLq3Yqm4nqyvtg00Zeqbcbxe1oYuxCiT0sDMGo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PaG9jZRpcSQhg4vRasmkBIwBbhHRayyyKaj5o7dMw5/N60udBX8n7Hv2nOtDd2SqqV04ti1RKqZkw2v6j2QdS1QQvQUTahMB407jIit0bsxOVyLhDoGEtEidAMTGUXP2xoe7qL9lNJKXvkC/lZHoLrLmx0G8kGCPa10iArz6jm8= 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=QAKFIarX; arc=none smtp.client-ip=192.198.163.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="QAKFIarX" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1764010516; x=1795546516; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=cE+HGYLq3Yqm4nqyvtg00Zeqbcbxe1oYuxCiT0sDMGo=; b=QAKFIarX+Aw6ODgQkKeh2I1NrkI1AL3ie1jrKBmvrrJ0BZkCO9fL2ePS +ZCw5I82SYlvc5x0rIMRQJT/cG97S+aC9DfltQFZLVlG78I3RrjLxMuzp GQs5fOcm+nJDougCEkloNsOqfMqUg3wEO0txg8wjo3bH3txxYChz8zO4G iNMhHfIL65ruDcaU1t/zlQnazDO4AzruYSpXWtb6odiskx/2yREN5X/7c 1102a6P79hociQxwvucnBvfD0S6ZkcJTevnOoyoc1uO6k6q1J/2S80wx8 uL215k7C7nq9uKVcvZMj5jo6OsY5YIjT1N/QDPAOPUn6/UyO0YvMgycu+ w==; X-CSE-ConnectionGUID: thtSyfJ3QsizV/Hfty8IXg== X-CSE-MsgGUID: ueKCiX1ATe2xHnmQnLrXRQ== X-IronPort-AV: E=McAfee;i="6800,10657,11623"; a="76636977" X-IronPort-AV: E=Sophos;i="6.20,223,1758610800"; d="scan'208";a="76636977" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Nov 2025 10:54:33 -0800 X-CSE-ConnectionGUID: EMqgfZCIRJW5zNFBgo2pCg== X-CSE-MsgGUID: 0P5NpPN5RqyvFCv3b2InOA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.20,223,1758610800"; d="scan'208";a="192225052" Received: from rfrazer-mobl3.amr.corp.intel.com (HELO agluck-desk3.home.arpa) ([10.124.222.153]) by orviesa009-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Nov 2025 10:54:33 -0800 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Maciej Wieczor-Retman , Peter Newman , James Morse , Babu Moger , Drew Fustini , Dave Martin , Chen Yu Cc: x86@kernel.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [PATCH v14 32/32] x86,fs/resctrl: Update documentation for telemetry events Date: Mon, 24 Nov 2025 10:54:09 -0800 Message-ID: <20251124185412.24155-33-tony.luck@intel.com> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251124185412.24155-1-tony.luck@intel.com> References: <20251124185412.24155-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" Update resctrl filesystem documentation with the details about the resctrl files that support telemetry events. Signed-off-by: Tony Luck --- Documentation/filesystems/resctrl.rst | 102 +++++++++++++++++++++++--- 1 file changed, 90 insertions(+), 12 deletions(-) diff --git a/Documentation/filesystems/resctrl.rst b/Documentation/filesyst= ems/resctrl.rst index 8c8ce678148a..138d2663b03d 100644 --- a/Documentation/filesystems/resctrl.rst +++ b/Documentation/filesystems/resctrl.rst @@ -252,13 +252,12 @@ with respect to allocation: bandwidth percentages are directly applied to the threads running on the core =20 -If RDT monitoring is available there will be an "L3_MON" directory +If L3 monitoring is available there will be an "L3_MON" directory with the following files: =20 "num_rmids": - The number of RMIDs available. This is the - upper bound for how many "CTRL_MON" + "MON" - groups can be created. + The number of RMIDs supported by hardware for + L3 monitoring events. =20 "mon_features": Lists the monitoring events if @@ -484,6 +483,25 @@ with the following files: bytes) at which a previously used LLC_occupancy counter can be considered for re-use. =20 +If telemetry monitoring is available there will be a "PERF_PKG_MON" direct= ory +with the following files: + +"num_rmids": + The number of RMIDs for telemetry monitoring events. By default, + resctrl will not enable telemetry events of a particular type + ("perf" or "energy") if the number of RMIDs that can be tracked + concurrently for that type is lower than the total number of + RMIDs supported by that type. The user can force-enable each + type of telemetry events with the "rdt=3D" boot command line + option, but this may reduce the number of monitoring groups that + can be created. + +"mon_features": + Lists the telemetry monitoring events that are enabled on this system. + +The upper bound for how many "CTRL_MON" + "MON" can be created +is the smaller of the L3_MON and PERF_PKG_MON "num_rmids" values. + Finally, in the top level of the "info" directory there is a file named "last_cmd_status". This is reset with every "command" issued via the file system (making new directories or writing to any of the @@ -589,15 +607,40 @@ When control is enabled all CTRL_MON groups will also= contain: When monitoring is enabled all MON groups will also contain: =20 "mon_data": - This contains a set of files organized by L3 domain and by - RDT event. E.g. on a system with two L3 domains there will - be subdirectories "mon_L3_00" and "mon_L3_01". Each of these - directories have one file per event (e.g. "llc_occupancy", - "mbm_total_bytes", and "mbm_local_bytes"). In a MON group these - files provide a read out of the current value of the event for - all tasks in the group. In CTRL_MON groups these files provide - the sum for all tasks in the CTRL_MON group and all tasks in + This contains directories for each monitor domain. + + If L3 monitoring is enabled, there will be a "mon_L3_XX" directory for + 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"= ). + + 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.) + + The info/`*`/mon_features files provide the full list of enabled + event/file names. + + "core energy" reports a floating point number for the energy (in Joules) + consumed by cores (registers, arithmetic units, TLB and L1/L2 caches) + during execution of instructions summed across all logical CPUs on a + package for the current monitoring group. + + "activity" also reports a floating point value (in Farads). This provides + an estimate of work done independent of the frequency that the CPUs used + for execution. + + Note that "core energy" and "activity" only measure energy/activity in the + "core" of the CPU (arithmetic units, TLB, L1 and L2 caches, etc.). They + do not include L3 cache, memory, I/O devices etc. + + All other events report decimal integer values. + + In a MON group these files provide a read out of the current value of + the event for all tasks in the group. In CTRL_MON groups these files + provide the sum for all tasks in the CTRL_MON group and all tasks in MON groups. Please see example section for more details on usage. + On systems with Sub-NUMA Cluster (SNC) enabled there are extra directories for each node (located within the "mon_L3_XX" directory for the L3 cache they occupy). These are named "mon_sub_L3_YY" @@ -1590,6 +1633,41 @@ Example with C:: resctrl_release_lock(fd); } =20 +Debugfs +=3D=3D=3D=3D=3D=3D=3D +In addition to the use of debugfs for tracing of pseudo-locking performanc= e, +architecture code may create debugfs directories associated with monitoring +features for a specific resource. + +The full pathname for these is in the form: + + /sys/kernel/debug/resctrl/info/{resource_name}_MON/{arch}/ + +The presence, names, and format of these files may vary between architectu= res +even if the same resource is present. + +PERF_PKG_MON/x86_64 +------------------- +Three files are present per telemetry aggregator instance that show status. +The prefix of each file name describes the type ("energy" or "perf"), the +guid, which processor package it belongs to, and the instance number of the +aggregator. For example: "energy_0x26696143_pkg1_agg2". + +The suffix describes which data is reported in the file and is one of: + +data_loss_count: + This counts the number of times that this aggregator + failed to accumulate a counter value supplied by a CPU. + +data_loss_timestamp: + This is a "timestamp" from a free running 25MHz uncore + timer indicating when the most recent data loss occurred. + +last_update_timestamp: + Another 25MHz timestamp indicating when the + most recent counter update was successfully applied. + + Examples for RDT Monitoring along with allocation usage =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=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D Reading monitored data --=20 2.51.1