mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Reinette Chatre <reinette.chatre@intel.com>
To: Tony Luck <tony.luck@intel.com>, Fenghua Yu <fenghuay@nvidia.com>,
	"Maciej Wieczor-Retman" <maciej.wieczor-retman@intel.com>,
	Peter Newman <peternewman@google.com>,
	James Morse <james.morse@arm.com>,
	Babu Moger <babu.moger@amd.com>,
	Drew Fustini <dfustini@baylibre.com>,
	Dave Martin <Dave.Martin@arm.com>,
	Anil Keshavamurthy <anil.s.keshavamurthy@intel.com>,
	Chen Yu <yu.c.chen@intel.com>
Cc: <x86@kernel.org>, <linux-kernel@vger.kernel.org>,
	<patches@lists.linux.dev>
Subject: Re: [PATCH v6 18/30] x86/resctrl: Count valid telemetry aggregators per package
Date: Tue, 8 Jul 2025 19:20:35 -0700	[thread overview]
Message-ID: <69f18b65-4e20-4383-a559-46fe1eda7db0@intel.com> (raw)
In-Reply-To: <20250626164941.106341-19-tony.luck@intel.com>

Hi Tony,

On 6/26/25 9:49 AM, Tony Luck wrote:
> There may be multiple telemetry aggregators per package, each enumerated
> by a telemetry region structure in the feature group.

This is the valuable connection missing from earlier patch changelog.

> 
> Scan the array of telemetry region structures and count how many are
> in each package in preparation to allocate structures to save the MMIO
> addresses for each in a convenient format for use when reading event
> counters.
> 
> Sanity check that the telemetry region structures have a valid
> package_id and that the size they report for the MMIO space is as
> large as expected from the XML description of the registers in
> the region.
> 
> Signed-off-by: Tony Luck <tony.luck@intel.com>
> ---
>  arch/x86/kernel/cpu/resctrl/intel_aet.c | 55 ++++++++++++++++++++++++-
>  1 file changed, 53 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/x86/kernel/cpu/resctrl/intel_aet.c b/arch/x86/kernel/cpu/resctrl/intel_aet.c
> index b09044b093dd..8d67ed709a74 100644
> --- a/arch/x86/kernel/cpu/resctrl/intel_aet.c
> +++ b/arch/x86/kernel/cpu/resctrl/intel_aet.c
> @@ -15,6 +15,7 @@
>  #include <linux/cpu.h>
>  #include <linux/intel_vsec.h>
>  #include <linux/resctrl.h>
> +#include <linux/slab.h>
>  
>  #include "internal.h"
>  
> @@ -24,6 +25,7 @@
>   *			within the OOBMSM driver that contains data for all
>   *			telemetry regions.
>   * @guid:		Unique number per XML description file.
> + * @mmio_size:		Number of bytes of MMIO registers for this group.
>   */
>  struct event_group {
>  	/* Data fields for additional structures to manage this group. */
> @@ -31,14 +33,19 @@ struct event_group {
>  
>  	/* Remaining fields initialized from XML file. */
>  	u32				guid;
> +	size_t				mmio_size;
>  };
>  
> +#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 = {
>  	.guid		= 0x26696143,
> +	.mmio_size	= XML_MMIO_SIZE(576, 2, 3),
>  };
>  
>  /*
> @@ -47,6 +54,7 @@ static struct event_group energy_0x26696143 = {
>   */
>  static struct event_group perf_0x26557651 = {
>  	.guid		= 0x26557651,
> +	.mmio_size	= XML_MMIO_SIZE(576, 7, 3),
>  };
>  
>  static struct event_group *known_event_groups[] = {
> @@ -56,10 +64,53 @@ static struct event_group *known_event_groups[] = {
>  
>  #define NUM_KNOWN_GROUPS ARRAY_SIZE(known_event_groups)
>  
> -/* Stub for now */
> +static bool skip_this_region(struct telemetry_region *tr, struct event_group *e)
> +{
> +	if (tr->guid != e->guid)
> +		return true;
> +	if (tr->plat_info.package_id >= topology_max_packages()) {
> +		pr_warn_once("Bad package %d in guid 0x%x\n", tr->plat_info.package_id,

If struct event_group includes the RMID telemetry feature ID (see below) then it
would be helpful to print that here.

> +			     tr->guid);
> +		return true;
> +	}
> +	if (tr->size < e->mmio_size) {

Why not "tr->size != e->mmio_size"?

Patch #25 explains how tr->num_rmids may be smaller than the number of RMIDs in XML file
but from that description I got the impression that telemetry regions should always
support all registers documented in the XML file. Similarly, in the earlier "fake OOBMSM"
code the MMIO size of the "energy" MMIO size could still accommodate the 576 RMIDs while
the regions were configured to only support 64 RMIDs. 

> +		pr_warn_once("MMIO space %zu too small for guid 0x%x\n", tr->size, e->guid);
> +		return true;
> +	}
> +
> +	return false;
> +}
> +
> +/*
> + * Configure events from one pmt_feature_group.

"Configure events" -> "Discover events"?

> + * 1) Count how many per package.

It is not clear what is counted here ... first sentence is "Configure events" followed
by this unspecific "Count how many per package" that can be interpreted that it
counts events here ... but it is actually counting telemetry regions?

> + * 2...) To be continued.

This comment implies that as capabilities are added to this function the comments
will be amended to document these new capabilities ... but at the end of this series
this function comment still reads as "2...) To be continued".

> + */
>  static int configure_events(struct event_group *e, struct pmt_feature_group *p)
>  {
> -	return -EINVAL;
> +	int *pkgcounts __free(kfree) = NULL;
> +	struct telemetry_region *tr;
> +	int num_pkgs;
> +
> +	num_pkgs = topology_max_packages();
> +
> +	/* Get per-package counts of telemetry_regions for this event group */

"telemetry_regions" -> "telemetry regions"? Or is it referring to the actual struct
here?

> +	for (int i = 0; i < p->count; i++) {
> +		tr = &p->regions[i];
> +		if (skip_this_region(tr, e))
> +			continue;

The function calling configure_event() does:

	struct event_group **peg;

	for (peg = &known_event_groups[0]; peg < &known_event_groups[NUM_KNOWN_GROUPS]; peg++)  {
		ret = configure_events(*peg, p);
		...
	}

As I understand there is 1:1 relationship between struct event_group and struct pmt_feature_group.
It thus seems unnecessary to loop through all the telemetry regions of a struct pmt_feature_group
if it is known to not be associated with the "event group"?
Could it be helpful to add a new (hardcoded) event_group::id that is of type enum pmt_feature_id
that can be used to ensure that only relevant struct pmt_feature_group is used to discover events
for a particular struct event_group?

Another consideration is that this implementation seems to require that guids are unique across
all telemetry regions of all RMID telemetry features, is this guaranteed?

> +		if (!pkgcounts) {
> +			pkgcounts = kcalloc(num_pkgs, sizeof(*pkgcounts), GFP_KERNEL);
> +			if (!pkgcounts)
> +				return -ENOMEM;
> +		}
> +		pkgcounts[tr->plat_info.package_id]++;
> +	}
> +
> +	if (!pkgcounts)
> +		return -ENODEV;
> +
> +	return 0;
>  }
>  
>  DEFINE_FREE(intel_pmt_put_feature_group, struct pmt_feature_group *,

Reinette

  reply	other threads:[~2025-07-09  2:20 UTC|newest]

Thread overview: 89+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-26 16:49 [PATCH v6 00/30] x86,fs/resctrl telemetry monitoring Tony Luck
2025-06-26 16:49 ` [PATCH v6 01/30] x86,fs/resctrl: Consolidate monitor event descriptions Tony Luck
2025-06-27 21:55   ` Fenghua Yu
2025-07-08 20:52   ` Reinette Chatre
2025-06-26 16:49 ` [PATCH v6 02/30] x86,fs/resctrl: Replace architecture event enabled checks Tony Luck
2025-06-27 22:15   ` Fenghua Yu
2025-07-08 20:52   ` Reinette Chatre
2025-06-26 16:49 ` [PATCH v6 03/30] x86/resctrl: Remove 'rdt_mon_features' global variable Tony Luck
2025-07-08 20:53   ` Reinette Chatre
2025-06-26 16:49 ` [PATCH v6 04/30] x86,fs/resctrl: Prepare for more monitor events Tony Luck
2025-07-08 20:55   ` Reinette Chatre
2025-06-26 16:49 ` [PATCH v6 05/30] x86,fs/resctrl: Improve domain type checking Tony Luck
2025-07-08 21:01   ` Reinette Chatre
2025-06-26 16:49 ` [PATCH v6 06/30] x86/resctrl: Move L3 initialization out of domain_add_cpu_mon() Tony Luck
2025-07-08 20:56   ` Reinette Chatre
2025-06-26 16:49 ` [PATCH v6 07/30] x86,fs/resctrl: Refactor domain_remove_cpu_mon() ready for new domain types Tony Luck
2025-07-08 20:57   ` Reinette Chatre
2025-06-26 16:49 ` [PATCH v6 08/30] x86/resctrl: Clean up domain_remove_cpu_ctrl() Tony Luck
2025-06-26 16:49 ` [PATCH v6 09/30] x86,fs/resctrl: Use struct rdt_domain_hdr instead of struct rdt_mon_domain Tony Luck
2025-07-08 21:04   ` Reinette Chatre
2025-06-26 16:49 ` [PATCH v6 10/30] x86,fs/resctrl: Rename struct rdt_mon_domain and rdt_hw_mon_domain Tony Luck
2025-07-08 21:06   ` Reinette Chatre
2025-06-26 16:49 ` [PATCH v6 11/30] x86,fs/resctrl: Rename some L3 specific functions Tony Luck
2025-07-08 21:08   ` Reinette Chatre
2025-06-26 16:49 ` [PATCH v6 12/30] fs/resctrl: Make event details accessible to functions when reading events Tony Luck
2025-07-09 22:12   ` Reinette Chatre
2025-06-26 16:49 ` [PATCH v6 13/30] x86,fs/resctrl: Handle events that can be read from any CPU Tony Luck
2025-07-08 21:15   ` Reinette Chatre
2025-06-26 16:49 ` [PATCH v6 14/30] x86,fs/resctrl: Support binary fixed point event counters Tony Luck
2025-06-27 21:22   ` Fenghua Yu
2025-06-27 22:28     ` Luck, Tony
2025-06-27 21:49   ` Fenghua Yu
2025-07-08 21:46   ` Reinette Chatre
2025-07-09 16:52     ` Luck, Tony
2025-06-26 16:49 ` [PATCH v6 15/30] x86,fs/resctrl: Add an architectural hook called for each mount Tony Luck
2025-06-26 16:49 ` [PATCH v6 16/30] x86,fs/resctrl: Add and initialize rdt_resource for package scope core monitor Tony Luck
2025-07-08 22:05   ` Reinette Chatre
2025-06-26 16:49 ` [PATCH v6 17/30] x86/resctrl: Discover hardware telemetry events Tony Luck
2025-06-27 18:06   ` Luck, Tony
2025-07-03 18:27     ` Reinette Chatre
2025-07-03 20:17       ` Luck, Tony
2025-07-03 20:31         ` Reinette Chatre
2025-07-03 21:11           ` Luck, Tony
2025-07-03 22:00             ` Reinette Chatre
2025-07-03 23:29               ` Luck, Tony
2025-07-08 23:51   ` Reinette Chatre
2025-06-26 16:49 ` [PATCH v6 18/30] x86/resctrl: Count valid telemetry aggregators per package Tony Luck
2025-07-09  2:20   ` Reinette Chatre [this message]
2025-07-09 18:12     ` Luck, Tony
2025-07-09 22:13       ` Reinette Chatre
2025-07-09 22:48         ` Luck, Tony
2025-07-09 22:59           ` Reinette Chatre
2025-06-26 16:49 ` [PATCH v6 19/30] x86/resctrl: Complete telemetry event enumeration Tony Luck
2025-07-09  2:38   ` Reinette Chatre
2025-06-26 16:49 ` [PATCH v6 20/30] x86,fs/resctrl: Fill in details of Clearwater Forest events Tony Luck
2025-07-09  3:00   ` Reinette Chatre
2025-06-26 16:49 ` [PATCH v6 21/30] x86,fs/resctrl: Add architectural event pointer Tony Luck
2025-07-09  3:21   ` Reinette Chatre
2025-07-09 21:16     ` Reinette Chatre
2025-06-26 16:49 ` [PATCH v6 22/30] x86/resctrl: Read core telemetry events Tony Luck
2025-07-09 15:48   ` Reinette Chatre
2025-07-09 21:57     ` Luck, Tony
2025-07-09 22:13       ` Reinette Chatre
2025-06-26 16:49 ` [PATCH v6 23/30] x86/resctrl: Handle domain creation/deletion for RDT_RESOURCE_PERF_PKG Tony Luck
2025-07-09 22:13   ` Reinette Chatre
2025-06-26 16:49 ` [PATCH v6 24/30] x86/resctrl: Add energy/perf choices to rdt boot option Tony Luck
2025-07-09 22:14   ` Reinette Chatre
2025-06-26 16:49 ` [PATCH v6 25/30] x86/resctrl: Handle number of RMIDs supported by telemetry resources Tony Luck
2025-07-09 22:17   ` Reinette Chatre
2025-06-26 16:49 ` [PATCH v6 26/30] x86,fs/resctrl: Move RMID initialization to first mount Tony Luck
2025-07-09 22:18   ` Reinette Chatre
2025-06-26 16:49 ` [PATCH v6 27/30] x86/resctrl: Enable RDT_RESOURCE_PERF_PKG Tony Luck
2025-06-26 16:49 ` [PATCH v6 28/30] fs/resctrl: Provide interface to create a debugfs info directory Tony Luck
2025-07-09 22:19   ` Reinette Chatre
2025-06-26 16:49 ` [PATCH v6 29/30] x86/resctrl: Add debug info/PERF_PKG_MON/status files Tony Luck
2025-07-09 22:22   ` Reinette Chatre
2025-06-26 16:49 ` [PATCH v6 30/30] x86,fs/resctrl: Update Documentation for package events Tony Luck
2025-07-09 22:24   ` Reinette Chatre
2025-06-27  0:26 ` [PATCH v6 00/30] x86,fs/resctrl telemetry monitoring Luck, Tony
2025-06-27 18:09   ` Luck, Tony
2025-06-30 17:51 ` Reinette Chatre
2025-06-30 22:46   ` Luck, Tony
2025-07-08 20:50     ` Reinette Chatre
2025-07-03 16:45 ` Reinette Chatre
2025-07-03 17:22   ` Luck, Tony
2025-07-08 19:08     ` Luck, Tony
2025-07-08 20:49       ` Reinette Chatre
2025-07-08 22:43         ` Luck, Tony
2025-07-08 23:26           ` Reinette Chatre

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=69f18b65-4e20-4383-a559-46fe1eda7db0@intel.com \
    --to=reinette.chatre@intel.com \
    --cc=Dave.Martin@arm.com \
    --cc=anil.s.keshavamurthy@intel.com \
    --cc=babu.moger@amd.com \
    --cc=dfustini@baylibre.com \
    --cc=fenghuay@nvidia.com \
    --cc=james.morse@arm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maciej.wieczor-retman@intel.com \
    --cc=patches@lists.linux.dev \
    --cc=peternewman@google.com \
    --cc=tony.luck@intel.com \
    --cc=x86@kernel.org \
    --cc=yu.c.chen@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®