[PATCH v3 24/26] x86/resctrl: Final steps to enable RDT_RESOURCE_PERF_PKG

From: Tony Luck
Date: Mon Apr 07 2025 - 19:45:45 EST


For each of the discovered telemetry events:
Mark as enabled in the rdt_mon_features bitmap.
Set the value display type.
Mark that the event can be read from any CPU.

Because the resource was not marked as enabled during early
initialization no domain discovery and allocation was done.
Do that in the architecture first mount hook.

Signed-off-by: Tony Luck <tony.luck@xxxxxxxxx>
---
arch/x86/kernel/cpu/resctrl/core.c | 14 ++++++++++++++
arch/x86/kernel/cpu/resctrl/intel_aet.c | 5 +++++
2 files changed, 19 insertions(+)

diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resctrl/core.c
index 6f5d52a8219b..83da63b24f45 100644
--- a/arch/x86/kernel/cpu/resctrl/core.c
+++ b/arch/x86/kernel/cpu/resctrl/core.c
@@ -756,7 +756,9 @@ static int resctrl_arch_offline_cpu(unsigned int cpu)

void resctrl_arch_mount(void)
{
+ struct rdt_resource *r = &rdt_resources_all[RDT_RESOURCE_PERF_PKG].r_resctrl;
static bool only_once;
+ int cpu;

if (only_once)
return;
@@ -764,6 +766,18 @@ void resctrl_arch_mount(void)

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 = true;
+ for_each_online_cpu(cpu)
+ domain_add_cpu_mon(cpu, r);
+ mutex_unlock(&domain_list_lock);
+ cpus_read_unlock();
}

enum {
diff --git a/arch/x86/kernel/cpu/resctrl/intel_aet.c b/arch/x86/kernel/cpu/resctrl/intel_aet.c
index 0bcbac326bee..529f6d49e3a3 100644
--- a/arch/x86/kernel/cpu/resctrl/intel_aet.c
+++ b/arch/x86/kernel/cpu/resctrl/intel_aet.c
@@ -233,9 +233,14 @@ bool intel_aet_get_events(void)
continue;
for (int i = 0; i < (*tentry)->num_events; i++) {
enum resctrl_event_id evtid = (*tentry)->evts[i].evtid;
+ enum resctrl_event_type type;

evtinfo[evtid].telem_entry = *tentry;
evtinfo[evtid].pmt_event = &(*tentry)->evts[i];
+
+ __set_bit(evtid, rdt_mon_features);
+ type = (*tentry)->evts[i].type;
+ resctrl_set_event_attributes(evtid, type, true);
}
}

--
2.48.1