Blob Blame History Raw
From 4790e570ce0e41bde4e1866ed6e3cba723b5f4d8 Mon Sep 17 00:00:00 2001
From: Marcelo Tosatti <mtosatti@redhat.com>
Date: Wed, 4 Jul 2018 17:30:37 -0300
Subject: [PATCH] realtime-virtual-host: pin only the vcpu thread to isolated
 pCPU (v2)

As noted in the bugzilla ticket

https://bugzilla.redhat.com/show_bug.cgi?id=1554851

The QEMU I/O thread can interrupt the time measurement
of the timer. To avoid this problem, only
pin the vCPU thread.

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Reviewed-and-Tested-by: Luiz Capitulino <lcapitulino@redhat.com>

v2:
   - Use unix sockets (Luiz)
   - Proper numeric output (Luiz)
---
 profiles/realtime-virtual-host/script.sh | 31 ++++++++++++++++--------
 1 file changed, 21 insertions(+), 10 deletions(-)

diff --git a/profiles/realtime-virtual-host/script.sh b/profiles/realtime-virtual-host/script.sh
index 515d2547..32e962db 100755
--- a/profiles/realtime-virtual-host/script.sh
+++ b/profiles/realtime-virtual-host/script.sh
@@ -17,20 +17,31 @@ run_tsc_deadline_latency()
 
     for i in `seq 1000 500 7000`; do
         echo $i > $KVM_LAPIC_FILE
-        chrt -f 1 taskset -c $1 $QEMU -enable-kvm -device pc-testdev \
+
+        unixpath=`mktemp`
+
+        chrt -f 1 $QEMU -S -enable-kvm -device pc-testdev \
             -device isa-debug-exit,iobase=0xf4,iosize=0x4 \
             -display none -serial stdio -device pci-testdev \
             -kernel "$TSCDEADLINE_LATENCY"  \
-            -cpu host | grep latency | cut -f 2 -d ":" > $dir/out
-
-	if [ ! -f $dir/out ]; then
-	    die running $TSCDEADLINE_LATENCY failed
-	fi
+            -cpu host \
+            -mon chardev=char0,mode=readline \
+            -chardev socket,id=char0,nowait,path=$unixpath,server | grep latency | cut -f 2 -d ":" > $dir/out &
+
+        sleep 1s
+        pidofvcpu=`echo "info cpus" | nc -U $unixpath | grep thread_id | cut -f 3 -d "=" | tr -d "\r"`
+        taskset -p -c $1 $pidofvcpu >/dev/null
+        echo "cont" | nc -U $unixpath >/dev/null
+        wait
+
+        if [ ! -f $dir/out ]; then
+             die running $TSCDEADLINE_LATENCY failed
+        fi
 
-	tmp=$(wc -l $dir/out | awk '{ print $1 }')
-	if [ $tmp -eq 0 ]; then
-	    die running $TSCDEADLINE_LATENCY failed
-	fi
+        tmp=$(wc -l $dir/out | awk '{ print $1 }')
+        if [ $tmp -eq 0 ]; then
+            die running $TSCDEADLINE_LATENCY failed
+        fi
 
         A=0
         while read l; do