From: Tony Luck <tony.luck@intel.com>
To: Fenghua Yu <fenghuay@nvidia.com>,
Reinette Chatre <reinette.chatre@intel.com>,
Maciej Wieczor-Retman <maciej.wieczor-retman@intel.com>,
Peter Newman <peternewman@google.com>,
James Morse <james.morse@arm.com>,
Babu Moger <babu.moger@amd.com>,
Drew Fustini <dfustini@baylibre.com>,
Dave Martin <Dave.Martin@arm.com>
Cc: linux-kernel@vger.kernel.org, patches@lists.linux.dev,
Tony Luck <tony.luck@intel.com>
Subject: [RFC PATCH 09/17] x86/resctrl: Add Intel PMT domain specific code
Date: Mon, 3 Mar 2025 15:33:29 -0800 [thread overview]
Message-ID: <20250303233340.333743-10-tony.luck@intel.com> (raw)
In-Reply-To: <20250303233340.333743-1-tony.luck@intel.com>
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@intel.com>
---
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
next prev parent reply other threads:[~2025-03-03 23:34 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-03 23:33 [RFC PATCH 00/17] x86/resctrl telemetry monitoring Tony Luck
2025-03-03 23:33 ` [RFC PATCH 01/17] x86/rectrl: Fake OOBMSM interface Tony Luck
2025-03-03 23:33 ` [RFC PATCH 02/17] x86/resctrl: Move L3 initialization out of domain_add_cpu_mon() Tony Luck
2025-03-03 23:33 ` [RFC PATCH 03/17] x86/resctrl: Refactor domain_remove_cpu_mon() ready for new domain types Tony Luck
2025-03-03 23:33 ` [RFC PATCH 04/17] x86/resctrl: Split L3 specific code out of rdtgroup_mondata_show() Tony Luck
2025-03-03 23:33 ` [RFC PATCH 05/17] x86/resctrl: Change generic monitor functions to use struct rdt_domain_hdr Tony Luck
2025-03-03 23:33 ` [RFC PATCH 06/17] x86/resctrl: Add and initialize rdt_resource for package scope core monitor Tony Luck
2025-03-03 23:33 ` [RFC PATCH 07/17] x86/resctrl: Prepare for resource specific event ids Tony Luck
2025-03-03 23:33 ` [RFC PATCH 08/17] x86/resctrl: Add initialization hook for Intel PMT events Tony Luck
2025-03-03 23:33 ` Tony Luck [this message]
2025-03-03 23:33 ` [RFC PATCH 10/17] x86/resctrl: Add detailed descriptions for Clearwater Forest events Tony Luck
2025-03-03 23:33 ` [RFC PATCH 11/17] x86/resctrl: Allocate per-package structures for known events Tony Luck
2025-03-03 23:33 ` [RFC PATCH 12/17] x86/resctrl: Add list of known events to RDT_RESOURCE_INTEL_PMT Tony Luck
2025-03-03 23:33 ` [RFC PATCH 13/17] x86/resctrl: Build lookup table for package events Tony Luck
2025-03-03 23:33 ` [RFC PATCH 14/17] x86/resctrl: Add code in rdtgroup_mondata_show() for core monitor events Tony Luck
2025-03-03 23:33 ` [RFC PATCH 15/17] x86/resctrl: Add status files to info/PKG_MON Tony Luck
2025-03-03 23:33 ` [RFC PATCH 16/17] x86/resctrl: Enable package event monitoring Tony Luck
2025-03-03 23:33 ` [RFC PATCH 17/17] x86/resctrl: Update Documentation for package events Tony Luck
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250303233340.333743-10-tony.luck@intel.com \
--to=tony.luck@intel.com \
--cc=Dave.Martin@arm.com \
--cc=babu.moger@amd.com \
--cc=dfustini@baylibre.com \
--cc=fenghuay@nvidia.com \
--cc=james.morse@arm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=maciej.wieczor-retman@intel.com \
--cc=patches@lists.linux.dev \
--cc=peternewman@google.com \
--cc=reinette.chatre@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®