[PATCH v9 28/31] x86/resctrl: Enable RDT_RESOURCE_PERF_PKG

Tony Luck posted 31 patches 1 month ago
There is a newer version of this series
[PATCH v9 28/31] x86/resctrl: Enable RDT_RESOURCE_PERF_PKG
Posted by Tony Luck 1 month ago
The RDT_RESOURCE_PERF_PKG resource is not marked as "mon_capable" during
early resctrl initialization. This means that the domain lists for the
resource are not built when the CPU hot plug notifiers are registered.

Set the global rdt_mon_capable (to cover the case when none of the L3
monitor events are enabled).

Mark the resource as mon_capable and call domain_add_cpu_mon() for
each online CPU to build the domain lists in the first call to the
resctrl_arch_pre_mount() hook.

Signed-off-by: Tony Luck <tony.luck@intel.com>
---
 arch/x86/kernel/cpu/resctrl/core.c      | 17 ++++++++++++++++-
 arch/x86/kernel/cpu/resctrl/intel_aet.c |  5 +++++
 2 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resctrl/core.c
index 8aa7d9105971..c221c68507da 100644
--- a/arch/x86/kernel/cpu/resctrl/core.c
+++ b/arch/x86/kernel/cpu/resctrl/core.c
@@ -753,14 +753,29 @@ static int resctrl_arch_offline_cpu(unsigned int cpu)
 
 void resctrl_arch_pre_mount(void)
 {
+	struct rdt_resource *r = &rdt_resources_all[RDT_RESOURCE_PERF_PKG].r_resctrl;
 	static atomic_t only_once = ATOMIC_INIT(0);
-	int old = 0;
+	int cpu, old = 0;
 
 	if (!atomic_try_cmpxchg(&only_once, &old, 1))
 		return;
 
 	if (!intel_aet_get_events())
 		return;
+
+	if (!r->mon_capable)
+		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);
+	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 f06f71c06029..35670ef07478 100644
--- a/arch/x86/kernel/cpu/resctrl/intel_aet.c
+++ b/arch/x86/kernel/cpu/resctrl/intel_aet.c
@@ -182,6 +182,9 @@ static bool enable_events(struct event_group *e, struct pmt_feature_group *p)
 	if (!usable_events)
 		return false;
 
+	r->mon_capable = true;
+	rdt_mon_capable = true;
+
 	if (r->num_rmid)
 		r->num_rmid = min(r->num_rmid, e->num_rmids);
 	else
@@ -191,6 +194,8 @@ static bool enable_events(struct event_group *e, struct pmt_feature_group *p)
 		resctrl_enable_mon_event(e->evts[j].id, true,
 					 e->evts[j].bin_bits, &e->evts[j]);
 
+	pr_info("%s %s monitoring detected\n", r->name, e->name);
+
 	return true;
 }
 
-- 
2.50.1
Re: [PATCH v9 28/31] x86/resctrl: Enable RDT_RESOURCE_PERF_PKG
Posted by Reinette Chatre 3 weeks, 1 day ago
Hi Tony,

On 8/29/25 12:33 PM, Tony Luck wrote:
> The RDT_RESOURCE_PERF_PKG resource is not marked as "mon_capable" during
> early resctrl initialization. This means that the domain lists for the
> resource are not built when the CPU hot plug notifiers are registered.
> 
> Set the global rdt_mon_capable (to cover the case when none of the L3
> monitor events are enabled).
> 
> Mark the resource as mon_capable and call domain_add_cpu_mon() for
> each online CPU to build the domain lists in the first call to the
> resctrl_arch_pre_mount() hook.

This just describes what can be seen in patch.

Reinette