[RFC PATCH 09/17] x86/resctrl: Add Intel PMT domain specific code
From: Tony Luck
Date: Mon Mar 03 2025 - 18:36:21 EST
Domain specific initialization and tear down. Very simple as
there are no domain specific elements that need to be allocated
or initiailazed. Just the domain itself.
This does need the mkdir_mondata_subdir_allrdtgrp() and
rmdir_mondata_subdir_allrdtgrp() functions. So change them
from static to global so they can be called from other source
files.
Signed-off-by: Tony Luck <tony.luck@xxxxxxxxx>
---
arch/x86/kernel/cpu/resctrl/internal.h | 7 +++++++
arch/x86/kernel/cpu/resctrl/core.c | 12 ++++++++++++
arch/x86/kernel/cpu/resctrl/intel_pmt.c | 16 ++++++++++++++++
arch/x86/kernel/cpu/resctrl/rdtgroup.c | 6 ++----
4 files changed, 37 insertions(+), 4 deletions(-)
diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/resctrl/internal.h
index f530382d8871..65bbe223f8a1 100644
--- a/arch/x86/kernel/cpu/resctrl/internal.h
+++ b/arch/x86/kernel/cpu/resctrl/internal.h
@@ -640,9 +640,12 @@ int rdt_get_mon_l3_config(struct rdt_resource *r);
#ifdef CONFIG_INTEL_PMT_RESCTRL
int rdt_get_intel_pmt_mon_config(void);
void rdt_get_intel_pmt_mount(void);
+void setup_intel_pmt_mon_domain(int cpu, int id, struct rdt_resource *r, struct list_head *add_pos);
#else
static inline int rdt_get_intel_pmt_mon_config(void) { return 0; }
static inline void rdt_get_intel_pmt_mount(void) { }
+static inline void setup_intel_pmt_mon_domain(int cpu, int id, struct rdt_resource *r,
+ struct list_head *add_pos) { }
#endif
void __exit rdt_put_mon_l3_config(void);
bool __init rdt_cpu_has(int flag);
@@ -667,4 +670,8 @@ void resctrl_file_fflags_init(const char *config, unsigned long fflags);
void rdt_staged_configs_clear(void);
bool closid_allocated(unsigned int closid);
int resctrl_find_cleanest_closid(void);
+void mkdir_mondata_subdir_allrdtgrp(struct rdt_resource *r,
+ struct rdt_domain_hdr *hdr);
+void rmdir_mondata_subdir_allrdtgrp(struct rdt_resource *r,
+ struct rdt_domain_hdr *hdr);
#endif /* _ASM_X86_RESCTRL_INTERNAL_H */
diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resctrl/core.c
index c18d79e470d2..b6e6a25520f7 100644
--- a/arch/x86/kernel/cpu/resctrl/core.c
+++ b/arch/x86/kernel/cpu/resctrl/core.c
@@ -657,6 +657,9 @@ static void domain_add_cpu_mon(int cpu, struct rdt_resource *r)
case RDT_RESOURCE_L3:
setup_l3_mon_domain(cpu, id, r, add_pos);
break;
+ case RDT_RESOURCE_INTEL_PMT:
+ setup_intel_pmt_mon_domain(cpu, id, r, add_pos);
+ break;
default:
WARN_ON_ONCE(1);
}
@@ -752,6 +755,15 @@ static void domain_remove_cpu_mon(int cpu, struct rdt_resource *r)
synchronize_rcu();
mon_domain_free(hw_dom);
break;
+ case RDT_RESOURCE_INTEL_PMT:
+ mutex_lock(&rdtgroup_mutex);
+ if (resctrl_mounted && resctrl_arch_mon_capable())
+ rmdir_mondata_subdir_allrdtgrp(r, hdr);
+ mutex_unlock(&rdtgroup_mutex);
+ list_del_rcu(&hdr->list);
+ synchronize_rcu();
+ kfree(container_of(hdr, struct rdt_core_mon_domain, hdr));
+ break;
}
}
diff --git a/arch/x86/kernel/cpu/resctrl/intel_pmt.c b/arch/x86/kernel/cpu/resctrl/intel_pmt.c
index 44373052ca49..76ec42a67c48 100644
--- a/arch/x86/kernel/cpu/resctrl/intel_pmt.c
+++ b/arch/x86/kernel/cpu/resctrl/intel_pmt.c
@@ -167,3 +167,19 @@ void rdt_get_intel_pmt_mount(void)
r->mon_capable = false;
}
}
+
+void setup_intel_pmt_mon_domain(int cpu, int id, struct rdt_resource *r, struct list_head *add_pos)
+{
+ struct rdt_core_mon_domain *hw_dom;
+
+ hw_dom = kzalloc_node(sizeof(*hw_dom), GFP_KERNEL, cpu_to_node(cpu));
+ if (!hw_dom)
+ return;
+
+ hw_dom->hdr.id = id;
+ hw_dom->hdr.type = RESCTRL_MON_DOMAIN;
+ cpumask_set_cpu(cpu, &hw_dom->hdr.cpu_mask);
+ list_add_tail_rcu(&hw_dom->hdr.list, add_pos);
+ if (resctrl_mounted && resctrl_arch_mon_capable())
+ mkdir_mondata_subdir_allrdtgrp(r, &hw_dom->hdr);
+}
diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
index 4259bded5b7b..93da2e4f7fec 100644
--- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c
+++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
@@ -3041,8 +3041,7 @@ static void mon_rmdir_one_subdir(struct kernfs_node *pkn, char *name, char *subn
* Remove files and directories containing "sum" of domain data
* when last domain being summed is removed.
*/
-static void rmdir_mondata_subdir_allrdtgrp(struct rdt_resource *r,
- struct rdt_domain_hdr *hdr)
+void rmdir_mondata_subdir_allrdtgrp(struct rdt_resource *r, struct rdt_domain_hdr *hdr)
{
struct rdtgroup *prgrp, *crgrp;
char subname[32];
@@ -3170,8 +3169,7 @@ static int mkdir_mondata_subdir(struct kernfs_node *parent_kn,
* Add all subdirectories of mon_data for "ctrl_mon" groups
* and "monitor" groups with given domain id.
*/
-static void mkdir_mondata_subdir_allrdtgrp(struct rdt_resource *r,
- struct rdt_domain_hdr *hdr)
+void mkdir_mondata_subdir_allrdtgrp(struct rdt_resource *r, struct rdt_domain_hdr *hdr)
{
struct kernfs_node *parent_kn;
struct rdtgroup *prgrp, *crgrp;
--
2.48.1