From: Tony Luck <tony.luck@intel.com>
To: reinette.chatre@intel.com
Cc: Dave.Martin@arm.com, anil.s.keshavamurthy@intel.com,
babu.moger@amd.com, dfustini@baylibre.com, fenghuay@nvidia.com,
james.morse@arm.com, linux-kernel@vger.kernel.org,
maciej.wieczor-retman@intel.com, patches@lists.linux.dev,
peternewman@google.com, tony.luck@intel.com, x86@kernel.org,
yu.c.chen@intel.com
Subject: [PATCH v5 05/29 UPDATED] x86/resctrl: Fake OOBMSM interface
Date: Tue, 27 May 2025 13:25:50 -0700 [thread overview]
Message-ID: <20250527202550.162147-1-tony.luck@intel.com> (raw)
In-Reply-To: <33aff696-21ce-4e84-b7cb-6f05cdef0402@intel.com>
=== Changes since original v5 version of this patch ===
1) Fix typo in Subject s/rectrl/resctrl/
2) Explain all constants used for fake pmt_feature_group structures
3) Explain difference between the number of RMIDs described by the
XML files, and the number provided in telemetry_region::num_rmids.
4) Provide separate u64 arrays for each of the fake MMIO space regions
and initialize so that event registers beyond the limit of number
of hardware counters read as zero (i.e. without the DATA_VALID bit
set).
===
Real version is coming soon[1]. This is here so the remaining parts
will build (and run: assuming a 2 socket system that supports RDT
monitoring).
Missing parts:
1) The event counters just report fixed values.
2) No emulation of most-recently-used for aggregators that have fewer
hardware counters than RMID registers in MMIO space.
Faked values are provided to exercise some special conditions:
1) Multiple counter aggregators for an event per-socket.
2) Different number of hardware counters backing the RMIDs for each group.
Just for ease of testing and RFC discussion.
[1]
Link: https://lore.kernel.org/all/20250430212106.369208-1-david.e.box@linux.intel.com/
Signed-off-by: Tony Luck <tony.luck@intel.com>
---
.../cpu/resctrl/fake_intel_aet_features.h | 73 ++++++++
.../cpu/resctrl/fake_intel_aet_features.c | 158 ++++++++++++++++++
arch/x86/kernel/cpu/resctrl/Makefile | 1 +
3 files changed, 232 insertions(+)
create mode 100644 arch/x86/kernel/cpu/resctrl/fake_intel_aet_features.h
create mode 100644 arch/x86/kernel/cpu/resctrl/fake_intel_aet_features.c
diff --git a/arch/x86/kernel/cpu/resctrl/fake_intel_aet_features.h b/arch/x86/kernel/cpu/resctrl/fake_intel_aet_features.h
new file mode 100644
index 000000000000..c835c4108abc
--- /dev/null
+++ b/arch/x86/kernel/cpu/resctrl/fake_intel_aet_features.h
@@ -0,0 +1,73 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+
+/* Bits stolen from OOBMSM VSEC discovery code */
+
+enum pmt_feature_id {
+ FEATURE_INVALID = 0x0,
+ FEATURE_PER_CORE_PERF_TELEM = 0x1,
+ FEATURE_PER_CORE_ENV_TELEM = 0x2,
+ FEATURE_PER_RMID_PERF_TELEM = 0x3,
+ FEATURE_ACCEL_TELEM = 0x4,
+ FEATURE_UNCORE_TELEM = 0x5,
+ FEATURE_CRASH_LOG = 0x6,
+ FEATURE_PETE_LOG = 0x7,
+ FEATURE_TPMI_CTRL = 0x8,
+ FEATURE_RESERVED = 0x9,
+ FEATURE_TRACING = 0xA,
+ FEATURE_PER_RMID_ENERGY_TELEM = 0xB,
+ FEATURE_MAX = 0xB,
+};
+
+/**
+ * struct oobmsm_plat_info - Platform information for a device instance
+ * @cdie_mask: Mask of all compute dies in the partition
+ * @package_id: CPU Package id
+ * @partition: Package partition id when multiple VSEC PCI devices per package
+ * @segment: PCI segment ID
+ * @bus_number: PCI bus number
+ * @device_number: PCI device number
+ * @function_number: PCI function number
+ *
+ * Structure to store platform data for a OOBMSM device instance.
+ */
+struct oobmsm_plat_info {
+ u16 cdie_mask;
+ u8 package_id;
+ u8 partition;
+ u8 segment;
+ u8 bus_number;
+ u8 device_number;
+ u8 function_number;
+};
+
+enum oobmsm_supplier_type {
+ OOBMSM_SUP_PLAT_INFO,
+ OOBMSM_SUP_DISC_INFO,
+ OOBMSM_SUP_S3M_SIMICS,
+ OOBMSM_SUP_TYPE_MAX
+};
+
+struct oobmsm_mapping_supplier {
+ struct device *supplier_dev[OOBMSM_SUP_TYPE_MAX];
+ struct oobmsm_plat_info plat_info;
+ unsigned long features;
+};
+
+struct telemetry_region {
+ struct oobmsm_plat_info plat_info;
+ void __iomem *addr;
+ size_t size;
+ u32 guid;
+ u32 num_rmids;
+};
+
+struct pmt_feature_group {
+ enum pmt_feature_id id;
+ int count;
+ struct kref kref;
+ struct telemetry_region regions[];
+};
+
+struct pmt_feature_group *intel_pmt_get_regions_by_feature(enum pmt_feature_id id);
+
+void intel_pmt_put_feature_group(struct pmt_feature_group *feature_group);
diff --git a/arch/x86/kernel/cpu/resctrl/fake_intel_aet_features.c b/arch/x86/kernel/cpu/resctrl/fake_intel_aet_features.c
new file mode 100644
index 000000000000..b2f1afee063d
--- /dev/null
+++ b/arch/x86/kernel/cpu/resctrl/fake_intel_aet_features.c
@@ -0,0 +1,158 @@
+// SPDX-License-Identifier: GPL-2.0-only
+#include <linux/cleanup.h>
+#include <linux/minmax.h>
+#include <linux/slab.h>
+#include "fake_intel_aet_features.h"
+#include <linux/intel_vsec.h>
+#include <linux/resctrl.h>
+
+#include "internal.h"
+
+/*
+ * The following constants taken from Intel-PMT github repository at
+ * Link: https://github.com/intel/Intel-PMT
+ */
+
+/*
+ * XML file at xml/CWF/OOBMSM/RMID-ENERGY/cwf_aggregator.xml
+ */
+#define ENERGY_GUID 0x26696143 /* Listed as "<TELI:uniqueid>" in XML */
+#define ENERGY_RMIDS 576 /* Register definitions run from 0 to 575 */
+#define ENERGY_NUM_EVENTS 2 /* CORE_ENERGY .. ACTIVITY */
+#define ENERGY_STATUS_REGS 3 /* Number of status registers at end of MMIO */
+
+/*
+ * XML file at xml/CWF/OOBMSM/RMID-PERF/cwf_aggregator.xml
+ */
+#define PERF_GUID 0x26557651 /* Listed as "<TELI:uniqueid>" in XML */
+#define PERF_RMIDS 576 /* Register definitions run from 0 to 575 */
+#define PERF_NUM_EVENTS 7 /* STALLS_LLC_HIT .. UOPS_RETIRED_VALID */
+#define PERF_STATUS_REGS 3 /* Number of status registers at end of MMIO */
+
+/*
+ * Size of MMIO space in each telemetry aggregator for energy events.
+ */
+#define ENERGY_QWORDS ((ENERGY_RMIDS * ENERGY_NUM_EVENTS) + ENERGY_STATUS_REGS)
+#define ENERGY_SIZE (ENERGY_QWORDS * sizeof(u64))
+
+/*
+ * Size of MMIO space in each telemetry aggregator for perf events.
+ */
+#define PERF_QWORDS ((PERF_RMIDS * PERF_NUM_EVENTS) + PERF_STATUS_REGS)
+#define PERF_SIZE (PERF_QWORDS * sizeof(u64))
+
+/*
+ * These next numbers are made up out of thin air. Chosen to exercise
+ * various configurations (some present in the first implementation
+ * of telemetry events, others will appear in later implementations).
+ */
+#define ENERGY_TELEM_AGGREGATORS_PER_SOCKET 2
+#define PERF_TELEM_AGGREGATORS_PER_SOCKET 1
+#define NUM_SOCKETS 2
+
+/*
+ * The number of implemented hardware counters for a telemetry
+ * aggregator may be smaller than the number of MMIO registers
+ * allocated. When this happens the hardware uses a most recently
+ * used algorithm to attach counters to MMIO registers.
+ * MMIO registers that are not backed by counters read with
+ * BIT(63) as zero. This fake code does not attempt to
+ * fully emulate the MRU algorithm. But it does provide return
+ * from intel_pmt_get_regions_by_feature() that indicates
+ * fewer hardware counters.
+ */
+#define ENERGY_NUM_HARDWARE_COUNTERS 64
+#define PERF_NUM_HARDWARE_COUNTERS 576
+
+
+/* Fake MMIO space of each fake energy aggregator */
+static u64 fake_energy_0[ENERGY_QWORDS];
+static u64 fake_energy_1[ENERGY_QWORDS];
+static u64 fake_energy_2[ENERGY_QWORDS];
+static u64 fake_energy_3[ENERGY_QWORDS];
+
+/* Fake MMIO space of each fake perf aggregator */
+static u64 fake_perf_0[PERF_QWORDS];
+static u64 fake_perf_1[PERF_QWORDS];
+
+/*
+ * Fill the each fake MMIO space with all different values,
+ * all with BIT(63) set to indicate valid entries.
+ */
+static int __init fill(void)
+{
+ u64 val = 0;
+ int i;
+
+ for (i = 0; i < ENERGY_NUM_HARDWARE_COUNTERS * ENERGY_NUM_EVENTS; i++)
+ fake_energy_0[i] = BIT_ULL(63) + val++;
+ for (i = 0; i < ENERGY_NUM_HARDWARE_COUNTERS * ENERGY_NUM_EVENTS; i++)
+ fake_energy_1[i] = BIT_ULL(63) + val++;
+ for (i = 0; i < ENERGY_NUM_HARDWARE_COUNTERS * ENERGY_NUM_EVENTS; i++)
+ fake_energy_2[i] = BIT_ULL(63) + val++;
+ for (i = 0; i < ENERGY_NUM_HARDWARE_COUNTERS * ENERGY_NUM_EVENTS; i++)
+ fake_energy_3[i] = BIT_ULL(63) + val++;
+
+ for (i = 0; i < PERF_QWORDS; i++)
+ fake_perf_0[i] = BIT_ULL(63) + val++;
+ for (i = 0; i < PERF_QWORDS; i++)
+ fake_perf_1[i] = BIT_ULL(63) + val++;
+
+ return 0;
+}
+device_initcall(fill);
+
+#define PKG_REGION(_entry, _guid, _addr, _size, _pkg, _num_rmids) \
+ [_entry] = { .guid = _guid, .addr = (void __iomem *)_addr, \
+ .num_rmids = _num_rmids, \
+ .size = _size, .plat_info = { .package_id = _pkg }}
+
+/*
+ * Set up a fake return for call to:
+ * intel_pmt_get_regions_by_feature(FEATURE_PER_RMID_ENERGY_TELEM);
+ * Pretend there are two aggregators on each of the sockets to test
+ * the code that sums over multiple aggregators.
+ * Pretend this group only supports 64 RMIDs to exercise the code
+ * that reconciles support for different RMID counts.
+ */
+static struct pmt_feature_group fake_energy = {
+ .count = NUM_SOCKETS * ENERGY_TELEM_AGGREGATORS_PER_SOCKET,
+ .regions = {
+ PKG_REGION(0, ENERGY_GUID, fake_energy_0, ENERGY_SIZE, 0, ENERGY_NUM_HARDWARE_COUNTERS),
+ PKG_REGION(1, ENERGY_GUID, fake_energy_1, ENERGY_SIZE, 0, ENERGY_NUM_HARDWARE_COUNTERS),
+ PKG_REGION(2, ENERGY_GUID, fake_energy_2, ENERGY_SIZE, 1, ENERGY_NUM_HARDWARE_COUNTERS),
+ PKG_REGION(3, ENERGY_GUID, fake_energy_3, ENERGY_SIZE, 1, ENERGY_NUM_HARDWARE_COUNTERS)
+ }
+};
+
+/*
+ * Fake return for:
+ * intel_pmt_get_regions_by_feature(FEATURE_PER_RMID_PERF_TELEM);
+ */
+static struct pmt_feature_group fake_perf = {
+ .count = NUM_SOCKETS * PERF_TELEM_AGGREGATORS_PER_SOCKET,
+ .regions = {
+ PKG_REGION(0, PERF_GUID, fake_perf_0, PERF_SIZE, 0, PERF_NUM_HARDWARE_COUNTERS),
+ PKG_REGION(1, PERF_GUID, fake_perf_1, PERF_SIZE, 1, PERF_NUM_HARDWARE_COUNTERS)
+ }
+};
+
+struct pmt_feature_group *
+intel_pmt_get_regions_by_feature(enum pmt_feature_id id)
+{
+ switch (id) {
+ case FEATURE_PER_RMID_ENERGY_TELEM:
+ return &fake_energy;
+ case FEATURE_PER_RMID_PERF_TELEM:
+ return &fake_perf;
+ default:
+ return ERR_PTR(-ENOENT);
+ }
+}
+
+/*
+ * Nothing needed for the "put" function.
+ */
+void intel_pmt_put_feature_group(struct pmt_feature_group *feature_group)
+{
+}
diff --git a/arch/x86/kernel/cpu/resctrl/Makefile b/arch/x86/kernel/cpu/resctrl/Makefile
index d8a04b195da2..cf4fac58d068 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) += core.o rdtgroup.o monitor.o
obj-$(CONFIG_X86_CPU_RESCTRL) += ctrlmondata.o
+obj-$(CONFIG_X86_CPU_RESCTRL) += fake_intel_aet_features.o
obj-$(CONFIG_RESCTRL_FS_PSEUDO_LOCK) += pseudo_lock.o
# To allow define_trace.h's recursive include:
--
2.49.0
next prev parent reply other threads:[~2025-05-27 20:25 UTC|newest]
Thread overview: 90+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-21 22:50 [PATCH v5 00/29] x86/resctrl telemetry monitoring Tony Luck
2025-05-21 22:50 ` [PATCH v5 01/29] x86,fs/resctrl: Consolidate monitor event descriptions Tony Luck
2025-06-04 3:25 ` Reinette Chatre
2025-06-04 16:33 ` Luck, Tony
2025-06-04 18:24 ` Reinette Chatre
2025-05-21 22:50 ` [PATCH v5 02/29] x86,fs/resctrl: Replace architecture event enabled checks Tony Luck
2025-06-04 3:26 ` Reinette Chatre
2025-05-21 22:50 ` [PATCH v5 03/29] x86/resctrl: Remove 'rdt_mon_features' global variable Tony Luck
2025-06-04 3:27 ` Reinette Chatre
2025-05-21 22:50 ` [PATCH v5 04/29] x86,fs/resctrl: Prepare for more monitor events Tony Luck
2025-05-23 9:00 ` Peter Newman
2025-05-23 15:57 ` Luck, Tony
2025-06-04 3:29 ` Reinette Chatre
2025-06-07 0:45 ` Fenghua Yu
2025-06-08 21:59 ` Luck, Tony
2025-05-21 22:50 ` [PATCH v5 05/29] x86/rectrl: Fake OOBMSM interface Tony Luck
2025-05-23 23:38 ` Reinette Chatre
2025-05-27 20:25 ` Tony Luck [this message]
2025-05-21 22:50 ` [PATCH v5 06/29] x86,fs/resctrl: Improve domain type checking Tony Luck
2025-06-04 3:31 ` Reinette Chatre
2025-06-04 22:58 ` Luck, Tony
2025-06-04 23:40 ` Reinette Chatre
2025-05-21 22:50 ` [PATCH v5 07/29] x86,fs/resctrl: Rename some L3 specific functions Tony Luck
2025-06-04 3:32 ` Reinette Chatre
2025-05-21 22:50 ` [PATCH v5 08/29] x86/resctrl: Move L3 initialization out of domain_add_cpu_mon() Tony Luck
2025-05-21 22:50 ` [PATCH v5 09/29] x86,fs/resctrl: Refactor domain_remove_cpu_mon() ready for new domain types Tony Luck
2025-06-04 3:32 ` Reinette Chatre
2025-05-21 22:50 ` [PATCH v5 10/29] x86/resctrl: Change generic domain functions to use struct rdt_domain_hdr Tony Luck
2025-05-22 0:01 ` Keshavamurthy, Anil S
2025-05-22 0:15 ` Luck, Tony
2025-06-04 3:37 ` Reinette Chatre
2025-06-07 0:52 ` Fenghua Yu
2025-06-08 22:02 ` Luck, Tony
2025-05-21 22:50 ` [PATCH v5 11/29] x86,fs/resctrl: Rename struct rdt_mon_domain and rdt_hw_mon_domain Tony Luck
2025-06-04 3:40 ` Reinette Chatre
2025-05-21 22:50 ` [PATCH v5 12/29] fs/resctrl: Make event details accessible to functions when reading events Tony Luck
2025-05-21 22:50 ` [PATCH v5 13/29] x86,fs/resctrl: Handle events that can be read from any CPU Tony Luck
2025-06-04 3:42 ` Reinette Chatre
2025-05-21 22:50 ` [PATCH v5 14/29] x86,fs/resctrl: Support binary fixed point event counters Tony Luck
2025-06-04 3:49 ` Reinette Chatre
2025-06-06 16:25 ` Luck, Tony
2025-06-06 16:56 ` Reinette Chatre
2025-06-10 15:16 ` Dave Martin
2025-06-10 15:54 ` Luck, Tony
2025-06-12 16:19 ` Dave Martin
2025-05-21 22:50 ` [PATCH v5 15/29] fs/resctrl: Add an architectural hook called for each mount Tony Luck
2025-06-04 3:49 ` Reinette Chatre
2025-05-21 22:50 ` [PATCH v5 16/29] x86/resctrl: Add and initialize rdt_resource for package scope core monitor Tony Luck
2025-05-21 22:50 ` [PATCH v5 17/29] x86/resctrl: Discover hardware telemetry events Tony Luck
2025-06-04 3:53 ` Reinette Chatre
2025-05-21 22:50 ` [PATCH v5 18/29] x86/resctrl: Count valid telemetry aggregators per package Tony Luck
2025-06-04 3:54 ` Reinette Chatre
2025-05-21 22:50 ` [PATCH v5 19/29] x86/resctrl: Complete telemetry event enumeration Tony Luck
2025-06-04 4:05 ` Reinette Chatre
2025-05-21 22:50 ` [PATCH v5 20/29] x86,fs/resctrl: Fill in details of Clearwater Forest events Tony Luck
2025-06-04 3:57 ` Reinette Chatre
2025-06-07 0:57 ` Fenghua Yu
2025-06-08 22:05 ` Luck, Tony
2025-05-21 22:50 ` [PATCH v5 21/29] x86/resctrl: x86/resctrl: Read core telemetry events Tony Luck
2025-06-04 4:02 ` Reinette Chatre
2025-05-21 22:50 ` [PATCH v5 22/29] x86,fs/resctrl: Handle domain creation/deletion for RDT_RESOURCE_PERF_PKG Tony Luck
2025-06-04 4:06 ` Reinette Chatre
2025-06-07 0:54 ` Fenghua Yu
2025-06-08 22:03 ` Luck, Tony
2025-05-21 22:50 ` [PATCH v5 23/29] x86/resctrl: Enable RDT_RESOURCE_PERF_PKG Tony Luck
2025-05-21 22:50 ` [PATCH v5 24/29] x86/resctrl: Add energy/perf choices to rdt boot option Tony Luck
2025-06-04 4:10 ` Reinette Chatre
2025-06-06 23:55 ` Fenghua Yu
2025-06-08 21:52 ` Luck, Tony
2025-05-21 22:50 ` [PATCH v5 25/29] x86/resctrl: Handle number of RMIDs supported by telemetry resources Tony Luck
2025-06-04 4:13 ` Reinette Chatre
2025-05-21 22:50 ` [PATCH v5 26/29] x86,fs/resctrl: Move RMID initialization to first mount Tony Luck
2025-05-21 22:50 ` [PATCH v5 27/29] fs/resctrl: Add file system mechanism for architecture info file Tony Luck
2025-06-04 4:15 ` Reinette Chatre
2025-06-06 0:09 ` Luck, Tony
2025-06-06 16:26 ` Reinette Chatre
2025-06-06 17:30 ` Luck, Tony
2025-06-06 21:14 ` Reinette Chatre
2025-06-09 18:49 ` Luck, Tony
2025-06-09 22:39 ` Reinette Chatre
2025-06-09 23:34 ` Luck, Tony
2025-06-10 0:30 ` Reinette Chatre
2025-06-10 18:48 ` Luck, Tony
2025-05-21 22:50 ` [PATCH v5 28/29] x86/resctrl: Add info/PERF_PKG_MON/status file Tony Luck
2025-05-21 22:50 ` [PATCH v5 29/29] x86/resctrl: Update Documentation for package events Tony Luck
2025-05-28 17:21 ` [PATCH v5 00/29] x86/resctrl telemetry monitoring Reinette Chatre
2025-05-28 21:38 ` Luck, Tony
2025-05-28 22:21 ` Reinette Chatre
2025-06-13 16:57 ` James Morse
2025-06-13 18:50 ` Luck, Tony
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=20250527202550.162147-1-tony.luck@intel.com \
--to=tony.luck@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=reinette.chatre@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®