qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Alex Bennée" <alex.bennee@linaro.org>
To: qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org,
	"Peter Crosthwaite" <crosthwaite.peter@gmail.com>,
	sbruno@freebsd.org, pbonzini@redhat.com,
	"Alex Bennée" <alex.bennee@linaro.org>,
	"Richard Henderson" <rth@twiddle.net>
Subject: [Qemu-devel] [PATCH v1 1/2] cpus: don't use atomic_read for vm_clock_warp_start
Date: Mon, 21 Mar 2016 16:23:05 +0000	[thread overview]
Message-ID: <1458577386-9984-2-git-send-email-alex.bennee@linaro.org> (raw)
In-Reply-To: <1458577386-9984-1-git-send-email-alex.bennee@linaro.org>

As vm_clock_warp_start is a 64 bit value this causes problems for the
compiler trying to come up with a suitable atomic operation on 32 bit
hosts. The variable documentation says this is meant to be protected by
vm_clock_seqlock so lets just move the code into that section.

All other references to vm_clock_warp_start are already protected by the
seqlock.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
 cpus.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/cpus.c b/cpus.c
index 23cf7aa..2fd5381 100644
--- a/cpus.c
+++ b/cpus.c
@@ -338,15 +338,10 @@ static int64_t qemu_icount_round(int64_t count)
 
 static void icount_warp_rt(void)
 {
-    /* The icount_warp_timer is rescheduled soon after vm_clock_warp_start
-     * changes from -1 to another value, so the race here is okay.
-     */
-    if (atomic_read(&vm_clock_warp_start) == -1) {
-        return;
-    }
+    bool check_clock = false;
 
     seqlock_write_lock(&timers_state.vm_clock_seqlock);
-    if (runstate_is_running()) {
+    if (vm_clock_warp_start != -1 && runstate_is_running()) {
         int64_t clock = REPLAY_CLOCK(REPLAY_CLOCK_VIRTUAL_RT,
                                      cpu_get_clock_locked());
         int64_t warp_delta;
@@ -362,11 +357,12 @@ static void icount_warp_rt(void)
             warp_delta = MIN(warp_delta, delta);
         }
         timers_state.qemu_icount_bias += warp_delta;
+        check_clock = true;
     }
     vm_clock_warp_start = -1;
     seqlock_write_unlock(&timers_state.vm_clock_seqlock);
 
-    if (qemu_clock_expired(QEMU_CLOCK_VIRTUAL)) {
+    if (check_clock && qemu_clock_expired(QEMU_CLOCK_VIRTUAL)) {
         qemu_clock_notify(QEMU_CLOCK_VIRTUAL);
     }
 }
-- 
2.7.3

  reply	other threads:[~2016-03-21 16:23 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-21 16:23 [Qemu-devel] [PATCH v1 0/2] Fix for FreeBSD compile on i386 Alex Bennée
2016-03-21 16:23 ` Alex Bennée [this message]
2016-03-21 16:26   ` [Qemu-devel] [PATCH v1 1/2] cpus: don't use atomic_read for vm_clock_warp_start Paolo Bonzini
2016-03-21 17:45     ` Alex Bennée
2016-03-21 16:23 ` [Qemu-devel] [PATCH v1 2/2] include/qemu/atomic: add compile time asserts Alex Bennée
2016-04-01 15:03   ` Alex Bennée
2016-04-04  8:33     ` Paolo Bonzini

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=1458577386-9984-2-git-send-email-alex.bennee@linaro.org \
    --to=alex.bennee@linaro.org \
    --cc=crosthwaite.peter@gmail.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=rth@twiddle.net \
    --cc=sbruno@freebsd.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;
as well as URLs for NNTP newsgroup(s).