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

Message ID 20230421141723.2405942-6-peternewman@google.com
State New
Headers
Series x86/resctrl: Use soft RMIDs for reliable MBM on AMD |

Commit Message

Peter Newman April 21, 2023, 2:17 p.m. UTC
  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@google.com>
---
 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(-)
  

Comments

Reinette Chatre May 11, 2023, 9:38 p.m. UTC | #1
Hi Peter,

On 4/21/2023 7:17 AM, Peter Newman wrote:
> 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.

From this patch forward the patch ordering is a bit confusing.
At this time mon_event_count() does not read software counters
from memory so I think this change should move to later.

Also, note that rdt_mon_soft_rmid is introduced here but 
the reader is left wondering how it is set until the final patch
in this series.

Reinette
  

Patch

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.
  */