[PATCH v1 5/9] x86/resctrl: Call mon_event_count() directly for soft RMIDs

From: Peter Newman
Date: Fri Apr 21 2023 - 10:18:27 EST


There is no point in using IPIs to call mon_event_count() when it is
only reading software counters from memory.

When RMIDs are soft, mon_event_read() just calls mon_event_count()
directly.

Signed-off-by: Peter Newman <peternewman@xxxxxxxxxx>
---
arch/x86/kernel/cpu/resctrl/ctrlmondata.c | 9 ++++++++-
arch/x86/kernel/cpu/resctrl/internal.h | 1 +
arch/x86/kernel/cpu/resctrl/monitor.c | 5 +++++
3 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kernel/cpu/resctrl/ctrlmondata.c b/arch/x86/kernel/cpu/resctrl/ctrlmondata.c
index b44c487727d4..b2ed25a08f6f 100644
--- a/arch/x86/kernel/cpu/resctrl/ctrlmondata.c
+++ b/arch/x86/kernel/cpu/resctrl/ctrlmondata.c
@@ -534,7 +534,14 @@ void mon_event_read(struct rmid_read *rr, struct rdt_resource *r,
rr->val = 0;
rr->first = first;

- smp_call_function_any(&d->cpu_mask, mon_event_count, rr, 1);
+ if (rdt_mon_soft_rmid)
+ /*
+ * Soft RMID counters reside in memory, so they can be read from
+ * anywhere.
+ */
+ mon_event_count(rr);
+ else
+ smp_call_function_any(&d->cpu_mask, mon_event_count, rr, 1);
}

int rdtgroup_mondata_show(struct seq_file *m, void *arg)
diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/resctrl/internal.h
index 256eee05d447..e6ff31a4dbc4 100644
--- a/arch/x86/kernel/cpu/resctrl/internal.h
+++ b/arch/x86/kernel/cpu/resctrl/internal.h
@@ -115,6 +115,7 @@ struct rmid_read {

extern bool rdt_alloc_capable;
extern bool rdt_mon_capable;
+extern bool rdt_mon_soft_rmid;
extern unsigned int rdt_mon_features;
extern struct list_head resctrl_schema_all;

diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/resctrl/monitor.c
index 3671100d3cc7..bb857eefa3b0 100644
--- a/arch/x86/kernel/cpu/resctrl/monitor.c
+++ b/arch/x86/kernel/cpu/resctrl/monitor.c
@@ -57,6 +57,11 @@ static struct rmid_entry *rmid_ptrs;
*/
bool rdt_mon_capable;

+/*
+ * Global boolean to indicate when RMIDs are implemented in software.
+ */
+bool rdt_mon_soft_rmid;
+
/*
* Global to indicate which monitoring events are enabled.
*/
--
2.40.0.634.g4ca3ef3211-goog