[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250321231609.57418-15-tony.luck@intel.com>
Date: Fri, 21 Mar 2025 16:16:04 -0700
From: Tony Luck <tony.luck@...el.com>
To: Fenghua Yu <fenghuay@...dia.com>,
Reinette Chatre <reinette.chatre@...el.com>,
Maciej Wieczor-Retman <maciej.wieczor-retman@...el.com>,
Peter Newman <peternewman@...gle.com>,
James Morse <james.morse@....com>,
Babu Moger <babu.moger@....com>,
Drew Fustini <dfustini@...libre.com>,
Dave Martin <Dave.Martin@....com>
Cc: linux-kernel@...r.kernel.org,
patches@...ts.linux.dev,
Tony Luck <tony.luck@...el.com>
Subject: [PATCH v2 14/16] x86/resctrl: Add status files to info/PKG_MON
Each of the package event groups includes status about the number
of missed events and timestamps (from a 25 MHz clock) on last time
an update was missed and last time an update was processed.
Add a three info files to report per-aggregator values of these
status values.
Signed-off-by: Tony Luck <tony.luck@...el.com>
---
include/linux/resctrl.h | 12 ++++
fs/resctrl/internal.h | 2 +
arch/x86/kernel/cpu/resctrl/intel_aet.c | 90 ++++++++++++++++++++++---
fs/resctrl/rdtgroup.c | 21 ++++++
4 files changed, 117 insertions(+), 8 deletions(-)
diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h
index e900764393f4..9f6a0b26eec3 100644
--- a/include/linux/resctrl.h
+++ b/include/linux/resctrl.h
@@ -533,10 +533,22 @@ void resctrl_exit(void);
#ifdef CONFIG_INTEL_AET_RESCTRL
void rdt_get_intel_aet_mount(void);
bool intel_aet_read_event(int domid, int rmid, int evtid, u64 *val, bool *fptype);
+int rdtgroup_last_update_show(struct kernfs_open_file *of,
+ struct seq_file *seq, void *v);
+int rdtgroup_overflows_show(struct kernfs_open_file *of,
+ struct seq_file *seq, void *v);
+int rdtgroup_overflow_timestamp_show(struct kernfs_open_file *of,
+ struct seq_file *seq, void *v);
#else
static inline void rdt_get_intel_aet_mount(void) { }
static inline bool intel_aet_read_event(int domid, int rmid, int evtid, u64 *val,
bool *fptype) { return false; }
+static inline int rdtgroup_last_update_show(struct kernfs_open_file *of,
+ struct seq_file *seq, void *v) { return 0; };
+static inline int rdtgroup_overflows_show(struct kernfs_open_file *of,
+ struct seq_file *seq, void *v) { return 0; };
+static inline int rdtgroup_overflow_timestamp_show(struct kernfs_open_file *of,
+ struct seq_file *seq, void *v) { return 0; };
#endif
#endif /* _RESCTRL_H */
diff --git a/fs/resctrl/internal.h b/fs/resctrl/internal.h
index 4d65a781034e..53590b1fa8c3 100644
--- a/fs/resctrl/internal.h
+++ b/fs/resctrl/internal.h
@@ -236,6 +236,8 @@ struct rdtgroup {
#define RFTYPE_TOP_INFO (RFTYPE_INFO | RFTYPE_TOP)
+#define RFTYPE_PKG_INFO (RFTYPE_INFO | RFTYPE_RES_PKG)
+
#define RFTYPE_CTRL_BASE (RFTYPE_BASE | RFTYPE_CTRL)
#define RFTYPE_MON_BASE (RFTYPE_BASE | RFTYPE_MON)
diff --git a/arch/x86/kernel/cpu/resctrl/intel_aet.c b/arch/x86/kernel/cpu/resctrl/intel_aet.c
index 41ebb2ee9b41..28692c6ec425 100644
--- a/arch/x86/kernel/cpu/resctrl/intel_aet.c
+++ b/arch/x86/kernel/cpu/resctrl/intel_aet.c
@@ -358,6 +358,11 @@ void rdt_get_intel_aet_mount(void)
}
}
+enum ops {
+ DO_SUM_EVENT,
+ DO_PRINTVALS
+};
+
#define VALID_BIT BIT_ULL(63)
#define DATA_BITS GENMASK_ULL(62, 0)
@@ -367,22 +372,29 @@ void rdt_get_intel_aet_mount(void)
* guid and offset).
* Return failure (~0x0ull) if any counter isn't valid.
*/
-static u64 scan_pmt_devs(int package, int guid, int offset)
+static u64 scan_pmt_devs(struct seq_file *m, int package, int guid, int offset, enum ops op)
{
- u64 rval, val;
+ u64 rval = 0, val;
+ char *sep = "";
int ndev = 0;
- rval = 0;
-
for (int i = 0; i < pkg_info[package].count; i++) {
if (pkg_info[package].regions[i].guid != guid)
continue;
ndev++;
val = readq(pkg_info[package].regions[i].addr + offset);
- if (!(val & VALID_BIT))
- return ~0ull;
- rval += val & DATA_BITS;
+ switch (op) {
+ case DO_SUM_EVENT:
+ if (!(val & VALID_BIT))
+ return ~0ull;
+ rval += val & DATA_BITS;
+ break;
+ case DO_PRINTVALS:
+ seq_printf(m, "%s0x%llx", sep, val);
+ sep = ",";
+ break;
+ }
}
return ndev ? rval : ~0ull;
@@ -402,7 +414,7 @@ bool intel_aet_read_event(int domid, int rmid, int evtid, u64 *val, bool *fptype
offset = rmid * EVT_STRIDE(evtid);
offset += EVT_OFFSET(evtid);
- evtcount = scan_pmt_devs(domid, EVT_GUID(evtid), offset);
+ evtcount = scan_pmt_devs(NULL, domid, EVT_GUID(evtid), offset, DO_SUM_EVENT);
*fptype = evtid == PMT_EVENT_ENERGY || evtid == PMT_EVENT_ACTIVITY;
if (evtcount != ~0ull || *val == 0)
@@ -410,3 +422,65 @@ bool intel_aet_read_event(int domid, int rmid, int evtid, u64 *val, bool *fptype
return evtcount != ~0ull;
}
+
+static void status_show(struct seq_file *seq, char *name, int guid, int offset)
+{
+ struct rdt_resource *r = &rdt_resources_all[RDT_RESOURCE_INTEL_AET].r_resctrl;
+ struct rdt_mon_domain *d;
+ char *sep = "";
+
+ seq_printf(seq, "%s: ", name);
+
+ cpus_read_lock();
+ list_for_each_entry(d, &r->mon_domains, hdr.list) {
+ seq_printf(seq, "%s%d=[", sep, d->hdr.id);
+ scan_pmt_devs(seq, d->hdr.id, guid, offset, DO_PRINTVALS);
+ seq_puts(seq, "]");
+ sep = ";";
+ }
+ cpus_read_unlock();
+
+ seq_puts(seq, "\n");
+}
+
+int rdtgroup_last_update_show(struct kernfs_open_file *of,
+ struct seq_file *seq, void *v)
+{
+ struct telem_entry **t;
+
+ for (t = telem_entry; *t; t++) {
+ if (!(*t)->active)
+ continue;
+ status_show(seq, (*t)->name, (*t)->guid, (*t)->last_update_tstamp_off);
+ }
+
+ return 0;
+}
+
+int rdtgroup_overflows_show(struct kernfs_open_file *of,
+ struct seq_file *seq, void *v)
+{
+ struct telem_entry **t;
+
+ for (t = telem_entry; *t; t++) {
+ if (!(*t)->active)
+ continue;
+ status_show(seq, (*t)->name, (*t)->guid, (*t)->overflow_counter_off);
+ }
+
+ return 0;
+}
+
+int rdtgroup_overflow_timestamp_show(struct kernfs_open_file *of,
+ struct seq_file *seq, void *v)
+{
+ struct telem_entry **t;
+
+ for (t = telem_entry; *t; t++) {
+ if (!(*t)->active)
+ continue;
+ status_show(seq, (*t)->name, (*t)->guid, (*t)->last_overflow_tstamp_off);
+ }
+
+ return 0;
+}
diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c
index d3919642aa9b..9021c60fd05b 100644
--- a/fs/resctrl/rdtgroup.c
+++ b/fs/resctrl/rdtgroup.c
@@ -1971,6 +1971,27 @@ static struct rftype res_common_files[] = {
.seq_show = rdtgroup_closid_show,
.fflags = RFTYPE_CTRL_BASE | RFTYPE_DEBUG,
},
+ {
+ .name = "last_update",
+ .mode = 0444,
+ .kf_ops = &rdtgroup_kf_single_ops,
+ .seq_show = rdtgroup_last_update_show,
+ .fflags = RFTYPE_PKG_INFO,
+ },
+ {
+ .name = "overflows",
+ .mode = 0444,
+ .kf_ops = &rdtgroup_kf_single_ops,
+ .seq_show = rdtgroup_overflows_show,
+ .fflags = RFTYPE_PKG_INFO,
+ },
+ {
+ .name = "overflow_timestamp",
+ .mode = 0444,
+ .kf_ops = &rdtgroup_kf_single_ops,
+ .seq_show = rdtgroup_overflow_timestamp_show,
+ .fflags = RFTYPE_PKG_INFO,
+ },
};
static int rdtgroup_add_files(struct kernfs_node *kn, unsigned long fflags)
--
2.48.1
Powered by blists - more mailing lists