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 04/17] x86/resctrl: Split L3 specific code out of rdtgroup_mondata_show()
Date: Mon, 3 Mar 2025 15:33:24 -0800 [thread overview]
Message-ID: <20250303233340.333743-5-tony.luck@intel.com> (raw)
In-Reply-To: <20250303233340.333743-1-tony.luck@intel.com>
New monitor resources require different operations to read counters.
Move the L3 specific code to a helper function.
Signed-off-by: Tony Luck <tony.luck@intel.com>
---
arch/x86/kernel/cpu/resctrl/ctrlmondata.c | 79 +++++++++++++----------
1 file changed, 46 insertions(+), 33 deletions(-)
diff --git a/arch/x86/kernel/cpu/resctrl/ctrlmondata.c b/arch/x86/kernel/cpu/resctrl/ctrlmondata.c
index 536351159cc2..515a9bec05cd 100644
--- a/arch/x86/kernel/cpu/resctrl/ctrlmondata.c
+++ b/arch/x86/kernel/cpu/resctrl/ctrlmondata.c
@@ -627,31 +627,14 @@ void mon_event_read(struct rmid_read *rr, struct rdt_resource *r,
resctrl_arch_mon_ctx_free(r, evtid, rr->arch_mon_ctx);
}
-int rdtgroup_mondata_show(struct seq_file *m, void *arg)
+static int rdtgroup_l3_data_show(struct seq_file *m, struct rdt_resource *r,
+ int domid, struct rdtgroup *rdtgrp, u32 evtid,
+ bool sum, struct rmid_read *rr)
{
- struct kernfs_open_file *of = m->private;
struct rdt_domain_hdr *hdr;
- struct rmid_read rr = {0};
struct rdt_mon_domain *d;
- u32 resid, evtid, domid;
- struct rdtgroup *rdtgrp;
- struct rdt_resource *r;
- union mon_data_bits md;
- int ret = 0;
-
- rdtgrp = rdtgroup_kn_lock_live(of->kn);
- if (!rdtgrp) {
- ret = -ENOENT;
- goto out;
- }
- md.priv = of->kn->priv;
- resid = md.u.rid;
- domid = md.u.domid;
- evtid = md.u.evtid;
- r = &rdt_resources_all[resid].r_resctrl;
-
- if (md.u.sum) {
+ if (sum) {
/*
* This file requires summing across all domains that share
* the L3 cache id that was provided in the "domid" field of the
@@ -660,37 +643,67 @@ int rdtgroup_mondata_show(struct seq_file *m, void *arg)
*/
list_for_each_entry(d, &r->mon_domains, hdr.list) {
if (d->ci->id == domid) {
- rr.ci = d->ci;
- mon_event_read(&rr, r, NULL, rdtgrp,
+ rr->ci = d->ci;
+ mon_event_read(rr, r, NULL, rdtgrp,
&d->ci->shared_cpu_map, evtid, false);
goto checkresult;
}
}
- ret = -ENOENT;
- goto out;
+ return -ENOENT;
} else {
/*
* This file provides data from a single domain. Search
* the resource to find the domain with "domid".
*/
hdr = rdt_find_domain(&r->mon_domains, domid, NULL);
- if (!hdr || WARN_ON_ONCE(hdr->type != RESCTRL_MON_DOMAIN)) {
- ret = -ENOENT;
- goto out;
- }
+ if (!hdr || WARN_ON_ONCE(hdr->type != RESCTRL_MON_DOMAIN))
+ return -ENOENT;
d = container_of(hdr, struct rdt_mon_domain, hdr);
- mon_event_read(&rr, r, d, rdtgrp, &d->hdr.cpu_mask, evtid, false);
+ mon_event_read(rr, r, d, rdtgrp, &d->hdr.cpu_mask, evtid, false);
}
checkresult:
- if (rr.err == -EIO)
+ if (rr->err == -EIO)
seq_puts(m, "Error\n");
- else if (rr.err == -EINVAL)
+ else if (rr->err == -EINVAL)
seq_puts(m, "Unavailable\n");
else
- seq_printf(m, "%llu\n", rr.val);
+ seq_printf(m, "%llu\n", rr->val);
+ return 0;
+}
+
+int rdtgroup_mondata_show(struct seq_file *m, void *arg)
+{
+ struct kernfs_open_file *of = m->private;
+ struct rmid_read rr = {0};
+ u32 resid, evtid, domid;
+ struct rdtgroup *rdtgrp;
+ struct rdt_resource *r;
+ union mon_data_bits md;
+ int ret = 0;
+
+ rdtgrp = rdtgroup_kn_lock_live(of->kn);
+ if (!rdtgrp) {
+ ret = -ENOENT;
+ goto out;
+ }
+
+ md.priv = of->kn->priv;
+ resid = md.u.rid;
+ domid = md.u.domid;
+ evtid = md.u.evtid;
+ r = &rdt_resources_all[resid].r_resctrl;
+
+ switch (r->rid) {
+ case RDT_RESOURCE_L3:
+ ret = rdtgroup_l3_data_show(m, r, domid, rdtgrp, evtid, md.u.sum, &rr);
+ break;
+ default:
+ ret = -EINVAL;
+ break;
+ }
out:
rdtgroup_kn_unlock(of->kn);
return ret;
--
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 ` Tony Luck [this message]
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 ` [RFC PATCH 09/17] x86/resctrl: Add Intel PMT domain specific code Tony Luck
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-5-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®