[PATCH 02/10] x86/resctrl: Add new rdt_resource for sub-node monitoring

From: Tony Luck
Date: Wed Mar 27 2024 - 16:05:46 EST


When a system enables Sub-NUMA Cluster (SNC) mode each CPU socket is
divided into 2 or more NUMA nodes. CPU cores and memory are divided
between these nodes. L3 cache monitoring functions are independently
implemented on each SNC node.

Add a new rdt_resource as a foundation for the structures to track
monitor resources in each of the L3 sub-nodes.

Add new scope option RESCTRL_NODE to build domains scoped at the
NUMA node level.

Signed-off-by: Tony Luck <tony.luck@xxxxxxxxx>
---
include/linux/resctrl.h | 1 +
arch/x86/kernel/cpu/resctrl/internal.h | 1 +
arch/x86/kernel/cpu/resctrl/core.c | 12 ++++++++++++
3 files changed, 14 insertions(+)

diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h
index ed693bfe474d..f39a07b27a98 100644
--- a/include/linux/resctrl.h
+++ b/include/linux/resctrl.h
@@ -153,6 +153,7 @@ struct resctrl_schema;
enum resctrl_scope {
RESCTRL_L2_CACHE = 2,
RESCTRL_L3_CACHE = 3,
+ RESCTRL_NODE,
};

/**
diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/resctrl/internal.h
index 8f40fb35db78..24fad5ecc158 100644
--- a/arch/x86/kernel/cpu/resctrl/internal.h
+++ b/arch/x86/kernel/cpu/resctrl/internal.h
@@ -472,6 +472,7 @@ enum resctrl_res_level {
RDT_RESOURCE_L2,
RDT_RESOURCE_MBA,
RDT_RESOURCE_SMBA,
+ RDT_RESOURCE_SUBL3,

/* Must be the last */
RDT_NUM_RESOURCES,
diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resctrl/core.c
index 4c5e985e1388..395bcb3199f8 100644
--- a/arch/x86/kernel/cpu/resctrl/core.c
+++ b/arch/x86/kernel/cpu/resctrl/core.c
@@ -115,6 +115,16 @@ struct rdt_hw_resource rdt_resources_all[] = {
.fflags = RFTYPE_RES_MB,
},
},
+ [RDT_RESOURCE_SUBL3] =
+ {
+ .r_resctrl = {
+ .rid = RDT_RESOURCE_SUBL3,
+ .name = "SUBL3",
+ .scope = RESCTRL_NODE,
+ .domains = domain_init(RDT_RESOURCE_SUBL3),
+ .fflags = RFTYPE_RES_CACHE,
+ },
+ },
};

/*
@@ -487,6 +497,8 @@ static int get_domain_id_from_scope(int cpu, enum resctrl_scope scope)
case RESCTRL_L2_CACHE:
case RESCTRL_L3_CACHE:
return get_cpu_cacheinfo_id(cpu, scope);
+ case RESCTRL_NODE:
+ return cpu_to_node(cpu);
default:
break;
}
--
2.44.0