]> xenbits.xensource.com Git - qemu-xen.git/commitdiff
cpus: re-factor out handle_icount_deadline
authorAlex Bennée <alex.bennee@linaro.org>
Thu, 27 Oct 2016 15:10:14 +0000 (16:10 +0100)
committerPaolo Bonzini <pbonzini@redhat.com>
Mon, 31 Oct 2016 09:51:17 +0000 (10:51 +0100)
In preparation for adding a MTTCG thread we re-factor out a bit of what
will be common code to handle the QEMU_CLOCK_VIRTUAL expiration.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Richard Henderson <rth@twiddle.net>
Message-Id: <20161027151030.20863-18-alex.bennee@linaro.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
cpus.c

diff --git a/cpus.c b/cpus.c
index cc49902b0f86dc8be1da3e38b2b4a6312f4a8449..6f0dc1a12197e13dceb78aff94e697a1f99df0ff 100644 (file)
--- a/cpus.c
+++ b/cpus.c
@@ -1076,6 +1076,18 @@ static int64_t tcg_get_icount_limit(void)
     }
 }
 
+static void handle_icount_deadline(void)
+{
+    if (use_icount) {
+        int64_t deadline =
+            qemu_clock_deadline_ns_all(QEMU_CLOCK_VIRTUAL);
+
+        if (deadline == 0) {
+            qemu_clock_notify(QEMU_CLOCK_VIRTUAL);
+        }
+    }
+}
+
 static int tcg_cpu_exec(CPUState *cpu)
 {
     int ret;
@@ -1198,13 +1210,8 @@ static void *qemu_tcg_cpu_thread_fn(void *arg)
         /* Pairs with smp_wmb in qemu_cpu_kick.  */
         atomic_mb_set(&exit_request, 0);
 
-        if (use_icount) {
-            int64_t deadline = qemu_clock_deadline_ns_all(QEMU_CLOCK_VIRTUAL);
+        handle_icount_deadline();
 
-            if (deadline == 0) {
-                qemu_clock_notify(QEMU_CLOCK_VIRTUAL);
-            }
-        }
         qemu_tcg_wait_io_event(QTAILQ_FIRST(&cpus));
         deal_with_unplugged_cpus();
     }