Linux Kernel Selftest development
 help / color / mirror / Atom feed
From: Peter Newman <peternewman@google.com>
To: Fenghua Yu <fenghua.yu@intel.com>,
	Reinette Chatre <reinette.chatre@intel.com>
Cc: Babu Moger <babu.moger@amd.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
	Stephane Eranian <eranian@google.com>,
	James Morse <james.morse@arm.com>,
	linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org,
	Peter Newman <peternewman@google.com>
Subject: [PATCH v1 1/9] selftests/resctrl: Verify all RMIDs count together
Date: Fri, 21 Apr 2023 16:17:15 +0200	[thread overview]
Message-ID: <20230421141723.2405942-2-peternewman@google.com> (raw)
In-Reply-To: <20230421141723.2405942-1-peternewman@google.com>

AMD CPUs in particular implement fewer monitors than RMIDs, so add a
test case to see if a large number of monitoring groups can be measured
together.

Signed-off-by: Peter Newman <peternewman@google.com>
---
 tools/testing/selftests/resctrl/test_rmids.sh | 93 +++++++++++++++++++
 1 file changed, 93 insertions(+)
 create mode 100755 tools/testing/selftests/resctrl/test_rmids.sh

diff --git a/tools/testing/selftests/resctrl/test_rmids.sh b/tools/testing/selftests/resctrl/test_rmids.sh
new file mode 100755
index 000000000000..475e69c0217e
--- /dev/null
+++ b/tools/testing/selftests/resctrl/test_rmids.sh
@@ -0,0 +1,93 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0
+
+cd /sys/fs/resctrl
+
+grep -q mbm_total_bytes info/L3_MON/mon_features || {
+	echo "MBM required"
+	exit 4
+}
+
+which perf > /dev/null || {
+	echo "perf tool required"
+	exit 4
+}
+
+num_rmids=$(cat info/L3_MON/num_rmids)
+
+count=0
+
+result=0
+
+# use as many RMIDs as possible, up to the number of RMIDs
+for i in `seq $num_rmids`; do
+	mkdir mon_groups/_test_m$((count+1)) 2> /dev/null || break
+	if [[ -d mon_groups/_test_m$((count+1))/mon_data ]]; then
+		count=$((count+1))
+	else
+		break;
+	fi
+done
+
+echo "Created $count monitoring groups."
+
+if [[ $count -eq 0 ]]; then
+	echo "need monitoring groups to continue."
+	exit 4
+fi
+
+declare -a bytes_array
+
+unavailable=0
+unavailable0=0
+
+for i in `seq $count`; do
+	bytes_array[$i]=$(cat mon_groups/_test_m${i}/mon_data/mon_L3_00/mbm_total_bytes)
+
+	if [[ "${bytes_array[$i]}" = "Unavailable" ]]; then
+		unavailable0=$((unavailable0 + 1))
+	fi
+done
+
+for i in `seq $count`; do
+	echo $$ > mon_groups/_test_m${i}/tasks
+	taskset 0x1 perf bench mem memcpy -s 100MB -f default > /dev/null
+done
+echo $$ > tasks
+
+# zero non-integer values
+declare -i bytes bytes0
+
+success_count=0
+
+for i in `seq $count`; do
+	raw_bytes=$(cat mon_groups/_test_m${i}/mon_data/mon_L3_00/mbm_total_bytes)
+	raw_bytes0=${bytes_array[$i]}
+
+	# coerce the value to an integer for math
+	bytes=$raw_bytes
+	bytes0=$raw_bytes0
+
+	echo -n "g${i}: mbm_total_bytes: $raw_bytes0 -> $raw_bytes"
+
+	if [[ "$raw_bytes" = "Unavailable" ]]; then
+		unavailable=$((unavailable + 1))
+	fi
+
+	if [[ $bytes -gt $bytes0 ]]; then
+		success_count=$((success_count+1))
+		echo ""
+	else
+		echo " (FAIL)"
+		result=1
+	fi
+done
+
+first=$((count-unavailable0))
+second=$((count-unavailable))
+echo "$count groups, $first returned counts in first pass, $second in second"
+echo "successfully measured bandwidth from ${success_count}/${count} groups"
+
+rmdir mon_groups/_test_m*
+
+exit $result
-- 
2.40.0.634.g4ca3ef3211-goog


  reply	other threads:[~2023-04-21 14:17 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-21 14:17 [PATCH v1 0/9] x86/resctrl: Use soft RMIDs for reliable MBM on AMD Peter Newman
2023-04-21 14:17 ` Peter Newman [this message]
2023-04-21 14:17 ` [PATCH v1 2/9] x86/resctrl: Hold a spinlock in __rmid_read() " Peter Newman
2023-05-11 21:35   ` Reinette Chatre
2023-05-12 13:23     ` Peter Newman
2023-05-12 15:23       ` Reinette Chatre
2023-04-21 14:17 ` [PATCH v1 3/9] x86/resctrl: Add resctrl_mbm_flush_cpu() to collect CPUs' MBM events Peter Newman
2023-05-11 21:37   ` Reinette Chatre
2023-05-12 13:25     ` Peter Newman
2023-05-12 15:26       ` Reinette Chatre
2023-05-15 14:42         ` Peter Newman
2023-05-17  0:05           ` Reinette Chatre
2023-12-01 20:56             ` Peter Newman
2023-12-05 21:57               ` Reinette Chatre
2023-12-06  0:33                 ` Peter Newman
2023-12-06  1:46                   ` Reinette Chatre
2023-12-06 18:38                     ` Peter Newman
2023-12-06 20:02                       ` Reinette Chatre
2023-05-16 14:18       ` Peter Newman
2023-05-16 14:27         ` Peter Newman
2023-06-01 14:45     ` Peter Newman
2023-06-01 17:14       ` Reinette Chatre
2023-04-21 14:17 ` [PATCH v1 4/9] x86/resctrl: Flush MBM event counts on soft RMID change Peter Newman
2023-05-11 21:37   ` Reinette Chatre
2023-04-21 14:17 ` [PATCH v1 5/9] x86/resctrl: Call mon_event_count() directly for soft RMIDs Peter Newman
2023-05-11 21:38   ` Reinette Chatre
2023-04-21 14:17 ` [PATCH v1 6/9] x86/resctrl: Create soft RMID version of __mon_event_count() Peter Newman
2023-05-11 21:38   ` Reinette Chatre
2023-04-21 14:17 ` [PATCH v1 7/9] x86/resctrl: Assign HW RMIDs to CPUs for soft RMID Peter Newman
2023-05-11 21:39   ` Reinette Chatre
2023-05-16 14:49     ` Peter Newman
2023-05-17  0:06       ` Reinette Chatre
2023-06-06 13:31         ` Peter Newman
2023-06-06 13:36   ` Peter Newman
2023-04-21 14:17 ` [PATCH v1 8/9] x86/resctrl: Use mbm_update() to push soft RMID counts Peter Newman
2023-05-11 21:40   ` Reinette Chatre
2023-06-02 12:42     ` Peter Newman
2023-06-06 13:48   ` Peter Newman
2023-04-21 14:17 ` [PATCH v1 9/9] x86/resctrl: Add mount option to enable soft RMID Peter Newman
2023-05-11 21:41   ` Reinette Chatre

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=20230421141723.2405942-2-peternewman@google.com \
    --to=peternewman@google.com \
    --cc=babu.moger@amd.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=eranian@google.com \
    --cc=fenghua.yu@intel.com \
    --cc=hpa@zytor.com \
    --cc=james.morse@arm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=reinette.chatre@intel.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /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