[PATCH v3 23/26] fs/resctrl: Add new telemetry event id and structures

Tony Luck
2025-04-07T23:41:02Z

Nine new events for energy and perf monitoring per-RMID.

Signed-off-by: Tony Luck <tony.luck@intel.com>
---
include/linux/resctrl_types.h | 19 ++++++++++++---
fs/resctrl/monitor.c | 45 +++++++++++++++++++++++++++++++++++
2 files changed, 61 insertions(+), 3 deletions(-)

diff --git a/include/linux/resctrl_types.h b/include/linux/resctrl_types.h
index 3354f21e82ad..2c959e7233dd 100644
--- a/include/linux/resctrl_types.h
+++ b/include/linux/resctrl_types.h
@@ -46,16 +46,29 @@ enum resctrl_res_level {
};

/*
- * Event IDs, the values match those used to program IA32_QM_EVTSEL before
- * reading IA32_QM_CTR on RDT systems.
+ * Event IDs
*/
enum resctrl_event_id {
+ /* Legacy events. Values must match X86 IA32_QM_EVTSEL usage */
QOS_L3_OCCUP_EVENT_ID = 0x01,
QOS_L3_MBM_TOTAL_EVENT_ID = 0x02,
QOS_L3_MBM_LOCAL_EVENT_ID = 0x03,
+
+ /* 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
};

-#define QOS_NUM_EVENTS (QOS_L3_MBM_LOCAL_EVENT_ID + 1)
#define QOS_NUM_MBM_EVENTS (QOS_L3_MBM_LOCAL_EVENT_ID - QOS_L3_MBM_TOTAL_EVENT_ID + 1)
#define MBM_EVENT_IDX(evt) ((evt) - QOS_L3_MBM_TOTAL_EVENT_ID)

diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c
index 5846a13c631a..0207c9ed2d47 100644
--- a/fs/resctrl/monitor.c
+++ b/fs/resctrl/monitor.c
@@ -861,6 +861,51 @@ static struct mon_evt all_events[QOS_NUM_EVENTS] = {
.rid = RDT_RESOURCE_L3,
.type = EVT_TYPE_U64,
},
+ [PMT_EVENT_ENERGY] = {
+ .name = "core_energy",
+ .evtid = PMT_EVENT_ENERGY,
+ .rid = RDT_RESOURCE_PERF_PKG,
+ },
+ [PMT_EVENT_ACTIVITY] = {
+ .name = "activity",
+ .evtid = PMT_EVENT_ACTIVITY,
+ .rid = RDT_RESOURCE_PERF_PKG,
+ },
+ [PMT_EVENT_STALLS_LLC_HIT] = {
+ .name = "stalls_llc_hit",
+ .evtid = PMT_EVENT_STALLS_LLC_HIT,
+ .rid = RDT_RESOURCE_PERF_PKG,
+ },
+ [PMT_EVENT_C1_RES] = {
+ .name = "c1_res",
+ .evtid = PMT_EVENT_C1_RES,
+ .rid = RDT_RESOURCE_PERF_PKG,
+ },
+ [PMT_EVENT_UNHALTED_CORE_CYCLES] = {
+ .name = "unhalted_core_cycles",
+ .evtid = PMT_EVENT_UNHALTED_CORE_CYCLES,
+ .rid = RDT_RESOURCE_PERF_PKG,
+ },
+ [PMT_EVENT_STALLS_LLC_MISS] = {
+ .name = "stalls_llc_miss",
+ .evtid = PMT_EVENT_STALLS_LLC_MISS,
+ .rid = RDT_RESOURCE_PERF_PKG,
+ },
+ [PMT_EVENT_AUTO_C6_RES] = {
+ .name = "c6_res",
+ .evtid = PMT_EVENT_AUTO_C6_RES,
+ .rid = RDT_RESOURCE_PERF_PKG,
+ },
+ [PMT_EVENT_UNHALTED_REF_CYCLES] = {
+ .name = "unhalted_ref_cycles",
+ .evtid = PMT_EVENT_UNHALTED_REF_CYCLES,
+ .rid = RDT_RESOURCE_PERF_PKG,
+ },
+ [PMT_EVENT_UOPS_RETIRED] = {
+ .name = "uops_retired",
+ .evtid = PMT_EVENT_UOPS_RETIRED,
+ .rid = RDT_RESOURCE_PERF_PKG,
+ },
};

int resctrl_set_event_attributes(enum resctrl_event_id evt,
--
2.48.1