[PATCH v10 03/28] x86,fs/resctrl: Refactor domain_remove_cpu_mon() ready for new domain types

Tony Luck posted 28 patches 2 weeks ago
There is a newer version of this series
[PATCH v10 03/28] x86,fs/resctrl: Refactor domain_remove_cpu_mon() ready for new domain types
Posted by Tony Luck 2 weeks ago
All monitoring events are associated with the L3 resource.

The RDT_RESOURCE_L3 resource carries a lot of state in the domain
structures which needs to be dealt with when a domain is taken offline
by removing the last CPU in the domain.

New telemetry events will be associated with a new package scoped
resource with new domain structures.

Refactor domain_remove_cpu_mon() so all the L3 processing is separate
from general actions of clearing the CPU bit in the mask and removing
sub-directories from the mon_data directory.

Signed-off-by: Tony Luck <tony.luck@intel.com>
---
 arch/x86/kernel/cpu/resctrl/core.c | 21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resctrl/core.c
index 055df4d406d0..b874cbe0218b 100644
--- a/arch/x86/kernel/cpu/resctrl/core.c
+++ b/arch/x86/kernel/cpu/resctrl/core.c
@@ -648,20 +648,25 @@ static void domain_remove_cpu_mon(int cpu, struct rdt_resource *r)
 		return;
 	}
 
-	if (!domain_header_is_valid(hdr, RESCTRL_MON_DOMAIN, r->rid))
+	cpumask_clear_cpu(cpu, &hdr->cpu_mask);
+	if (!cpumask_empty(&hdr->cpu_mask))
 		return;
 
-	d = container_of(hdr, struct rdt_mon_domain, hdr);
-	hw_dom = resctrl_to_arch_mon_dom(d);
+	switch (r->rid) {
+	case RDT_RESOURCE_L3:
+		if (!domain_header_is_valid(hdr, RESCTRL_MON_DOMAIN, RDT_RESOURCE_L3))
+			return;
 
-	cpumask_clear_cpu(cpu, &d->hdr.cpu_mask);
-	if (cpumask_empty(&d->hdr.cpu_mask)) {
+		d = container_of(hdr, struct rdt_mon_domain, hdr);
+		hw_dom = resctrl_to_arch_mon_dom(d);
 		resctrl_offline_mon_domain(r, d);
-		list_del_rcu(&d->hdr.list);
+		list_del_rcu(&hdr->list);
 		synchronize_rcu();
 		mon_domain_free(hw_dom);
-
-		return;
+		break;
+	default:
+		pr_warn_once("Unknown resource rid=%d\n", r->rid);
+		break;
 	}
 }
 
-- 
2.51.0
Re: [PATCH v10 03/28] x86,fs/resctrl: Refactor domain_remove_cpu_mon() ready for new domain types
Posted by Reinette Chatre 1 week, 1 day ago
Hi Tony,

On 9/12/25 3:10 PM, Tony Luck wrote:
> All monitoring events are associated with the L3 resource.

Above sentence can be dropped.

> 
> The RDT_RESOURCE_L3 resource carries a lot of state in the domain
> structures which needs to be dealt with when a domain is taken offline
> by removing the last CPU in the domain.
> 
> New telemetry events will be associated with a new package scoped
> resource with new domain structures.

Above is intended to be problem statement but the problem is unclear without
connection how the solution below solves it.

> 
> Refactor domain_remove_cpu_mon() so all the L3 processing is separate
> from general actions of clearing the CPU bit in the mask and removing
> sub-directories from the mon_data directory.

Can "and removing sub-directories from the mon_data directory" now be dropped
to match the change made to this patch?

> 
> Signed-off-by: Tony Luck <tony.luck@intel.com>
> ---

Reinette