Skip to contentSkip to conversation

virtio-ringtest: more enablement

PATCH New Cornelia Huck 1 participant 4 messages Sep 19, 2016 virtio core

lore
Share & tools
lore
#0 lore raw

cover virtio-ringtest: more enablement

Hi Michael,

here are two patches by Halil so that we can get ringtest going on our platform as well.

Question: Do you have an idea on how realistic the timings are supposed to be? The s390 path is, well, 'tweak me'...

Halil Pasic (2):
tools/virtio/ringtest: fix run-on-all.sh for offline cpus tools/virtio/ringtest: tweaks for s390

 tools/virtio/ringtest/main.h        | 12 ++++++++++++
 tools/virtio/ringtest/run-on-all.sh |  5 +++--
 2 files changed, 15 insertions(+), 2 deletions(-)
Signature · 1 line
2.8.4
#1 lore raw

PATCH 1/2 tools/virtio/ringtest: fix run-on-all.sh for offline cpus

From: Halil Pasic <[email protected]>

Since ef1b144d ("tools/virtio/ringtest: fix run-on-all.sh to work without /dev/cpu") run-on-all.sh uses seq 0 $HOST_AFFINITY as the list of ids of the CPUs to run the command on (assuming ids of online CPUs are consecutive and start from 0), where $HOST_AFFINITY is the highest CPU id in the system previously determined using lscpu. This can fail on systems with offline CPUs.

Instead let's use lscpu to determine the list of online CPUs.

Fixes ef1b144d ("tools/virtio/ringtest: fix run-on-all.sh to work without

/dev/cpu")

---
 tools/virtio/ringtest/run-on-all.sh | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
tools/virtio/ringtest/run-on-all.sh +3 -2
index 2e69ca8..29b0d39 100755
@@ -1,12 +1,13 @@
 #!/bin/sh
 
+CPUS_ONLINE=$(lscpu --online -p=cpu|grep -v -e '#')
 #use last CPU for host. Why not the first?
 #many devices tend to use cpu0 by default so
 #it tends to be busier
-HOST_AFFINITY=$(lscpu -p=cpu | tail -1)
+HOST_AFFINITY=$(echo "${CPUS_ONLINE}"|tail -n 1)
 
 #run command on all cpus
-for cpu in $(seq 0 $HOST_AFFINITY)
+for cpu in $CPUS_ONLINE
 do
 	#Don't run guest and host on same CPU
 	#It actually works ok if using signalling
Signature · 1 line
2.8.4
#2 lore raw

PATCH 1/2 tools/virtio/ringtest: fix run-on-all.sh for offline cpus

In reply to Cornelia Huck

From: Halil Pasic <[email protected]>

Since ef1b144d ("tools/virtio/ringtest: fix run-on-all.sh to work without /dev/cpu") run-on-all.sh uses seq 0 $HOST_AFFINITY as the list of ids of the CPUs to run the command on (assuming ids of online CPUs are consecutive and start from 0), where $HOST_AFFINITY is the highest CPU id in the system previously determined using lscpu. This can fail on systems with offline CPUs.

Instead let's use lscpu to determine the list of online CPUs.

Fixes ef1b144d ("tools/virtio/ringtest: fix run-on-all.sh to work without

/dev/cpu")

---
 tools/virtio/ringtest/run-on-all.sh | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
tools/virtio/ringtest/run-on-all.sh +3 -2
index 2e69ca8..29b0d39 100755
@@ -1,12 +1,13 @@
 #!/bin/sh
 
+CPUS_ONLINE=$(lscpu --online -p=cpu|grep -v -e '#')
 #use last CPU for host. Why not the first?
 #many devices tend to use cpu0 by default so
 #it tends to be busier
-HOST_AFFINITY=$(lscpu -p=cpu | tail -1)
+HOST_AFFINITY=$(echo "${CPUS_ONLINE}"|tail -n 1)
 
 #run command on all cpus
-for cpu in $(seq 0 $HOST_AFFINITY)
+for cpu in $CPUS_ONLINE
 do
 	#Don't run guest and host on same CPU
 	#It actually works ok if using signalling
Signature · 1 line
2.8.4
#3 lore raw

PATCH 2/2 tools/virtio/ringtest: tweaks for s390

In reply to Cornelia Huck

From: Halil Pasic <[email protected]>

Make ringtest work on s390 too.

---
 tools/virtio/ringtest/main.h | 12 ++++++++++++
 1 file changed, 12 insertions(+)
tools/virtio/ringtest/main.h +12 -0
index 16917ac..7806b7b 100644
@@ -26,6 +26,16 @@ static inline void wait_cycles(unsigned long long cycles)
 #define VMEXIT_CYCLES 500
 #define VMENTRY_CYCLES 500
 
+#elif defined(__s390x__)
+static inline void wait_cycles(unsigned long long cycles)
+{
+	asm volatile("0: brctg %0,0b" : : "d" (cycles));
+}
+
+/* tweak me */
+#define VMEXIT_CYCLES 200
+#define VMENTRY_CYCLES 200
+
 #else
 static inline void wait_cycles(unsigned long long cycles)
 {
@@ -81,6 +91,8 @@ extern unsigned ring_size;
 /* Is there a portable way to do this? */
 #if defined(__x86_64__) || defined(__i386__)
 #define cpu_relax() asm ("rep; nop" ::: "memory")
+#elif defined(__s390x__)
+#define cpu_relax() barrier()
 #else
 #define cpu_relax() assert(0)
 #endif
Signature · 1 line
2.8.4