lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230421141723.2405942-7-peternewman@google.com>
Date:   Fri, 21 Apr 2023 16:17:20 +0200
From:   Peter Newman <peternewman@...gle.com>
To:     Fenghua Yu <fenghua.yu@...el.com>,
        Reinette Chatre <reinette.chatre@...el.com>
Cc:     Babu Moger <babu.moger@....com>,
        Thomas Gleixner <tglx@...utronix.de>,
        Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
        Dave Hansen <dave.hansen@...ux.intel.com>, x86@...nel.org,
        "H. Peter Anvin" <hpa@...or.com>,
        Stephane Eranian <eranian@...gle.com>,
        James Morse <james.morse@....com>,
        linux-kernel@...r.kernel.org, linux-kselftest@...r.kernel.org,
        Peter Newman <peternewman@...gle.com>
Subject: [PATCH v1 6/9] x86/resctrl: Create soft RMID version of __mon_event_count()

When RMIDs are soft, __mon_event_count() only needs to report the
current byte count in memory and should not touch the hardware RMIDs.

Create a parallel version for the soft RMID configuration and update
__mon_event_count() to choose between it and the original depending on
whether the soft RMID static key is enabled.

Signed-off-by: Peter Newman <peternewman@...gle.com>
---
 arch/x86/kernel/cpu/resctrl/monitor.c | 33 ++++++++++++++++++++++++++-
 1 file changed, 32 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/resctrl/monitor.c
index bb857eefa3b0..3d54a634471a 100644
--- a/arch/x86/kernel/cpu/resctrl/monitor.c
+++ b/arch/x86/kernel/cpu/resctrl/monitor.c
@@ -487,7 +487,30 @@ void resctrl_mbm_flush_cpu(void)
 		__mbm_flush(QOS_L3_MBM_TOTAL_EVENT_ID, r, d);
 }
 
-static int __mon_event_count(u32 rmid, struct rmid_read *rr)
+static int __mon_event_count_soft_rmid(u32 rmid, struct rmid_read *rr)
+{
+	struct mbm_state *m;
+
+	WARN_ON(!is_mbm_event(rr->evtid));
+	m = get_mbm_state(rr->d, rmid, rr->evtid);
+	if (!m)
+		/* implies !is_mbm_event(...) */
+		return -1;
+
+	rr->val += atomic64_read(&m->soft_rmid_bytes);
+
+	if (rr->first) {
+		/*
+		 * Discard any bandwidth resulting from the initial HW counter
+		 * reads.
+		 */
+		atomic64_set(&m->soft_rmid_bytes, 0);
+	}
+
+	return 0;
+}
+
+static int __mon_event_count_default(u32 rmid, struct rmid_read *rr)
 {
 	struct mbm_state *m;
 	u64 tval = 0;
@@ -509,6 +532,14 @@ static int __mon_event_count(u32 rmid, struct rmid_read *rr)
 	return 0;
 }
 
+static int __mon_event_count(u32 rmid, struct rmid_read *rr)
+{
+	if (rdt_mon_soft_rmid)
+		return __mon_event_count_soft_rmid(rmid, rr);
+	else
+		return __mon_event_count_default(rmid, rr);
+}
+
 /*
  * mbm_bw_count() - Update bw count from values previously read by
  *		    __mon_event_count().
-- 
2.40.0.634.g4ca3ef3211-goog

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ