[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 03/43] seqlock: read sequence number atomically
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PULL 03/43] seqlock: read sequence number atomically |
Date: |
Wed, 9 Sep 2015 15:49:33 +0200 |
From: "Emilio G. Cota" <address@hidden>
With this change we make sure that the compiler will not
optimise the read of the sequence number in any way.
Signed-off-by: Emilio G. Cota <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
---
include/qemu/seqlock.h | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/include/qemu/seqlock.h b/include/qemu/seqlock.h
index f1256f5..70b01fd 100644
--- a/include/qemu/seqlock.h
+++ b/include/qemu/seqlock.h
@@ -55,18 +55,18 @@ static inline void seqlock_write_unlock(QemuSeqLock *sl)
static inline unsigned seqlock_read_begin(QemuSeqLock *sl)
{
/* Always fail if a write is in progress. */
- unsigned ret = sl->sequence & ~1;
+ unsigned ret = atomic_read(&sl->sequence);
/* Read sequence before reading other fields. */
smp_rmb();
- return ret;
+ return ret & ~1;
}
static inline int seqlock_read_retry(const QemuSeqLock *sl, unsigned start)
{
/* Read other fields before reading final sequence. */
smp_rmb();
- return unlikely(sl->sequence != start);
+ return unlikely(atomic_read(&sl->sequence) != start);
}
#endif
--
2.4.3
- [Qemu-devel] [PULL 00/43] First batch of misc changes for 2.5 (2015-09-09), Paolo Bonzini, 2015/09/09
- [Qemu-devel] [PULL 02/43] seqlock: add missing 'inline' to seqlock_read_retry, Paolo Bonzini, 2015/09/09
- [Qemu-devel] [PULL 01/43] qemu-thread: handle spurious futex_wait wakeups, Paolo Bonzini, 2015/09/09
- [Qemu-devel] [PULL 03/43] seqlock: read sequence number atomically,
Paolo Bonzini <=
- [Qemu-devel] [PULL 04/43] cpus.c: qemu_mutex_lock_iothread fix race condition at cpu thread init, Paolo Bonzini, 2015/09/09
- [Qemu-devel] [PULL 05/43] iohandler: Use aio API, Paolo Bonzini, 2015/09/09
- [Qemu-devel] [PULL 08/43] i8257: rewrite DMA_schedule to avoid hooking into the CPU loop, Paolo Bonzini, 2015/09/09
- [Qemu-devel] [PULL 06/43] block/iscsi: validate block size returned from target, Paolo Bonzini, 2015/09/09
- [Qemu-devel] [PULL 10/43] tcg: introduce tcg_current_cpu, Paolo Bonzini, 2015/09/09
- [Qemu-devel] [PULL 07/43] Added generic panic handler qemu_system_guest_panicked(), Paolo Bonzini, 2015/09/09
- [Qemu-devel] [PULL 09/43] i8257: remove cpu_request_exit irq, Paolo Bonzini, 2015/09/09
- [Qemu-devel] [PULL 14/43] tcg: synchronize exit_request and tcg_current_cpu accesses, Paolo Bonzini, 2015/09/09
- [Qemu-devel] [PULL 15/43] use qemu_cpu_kick instead of cpu_exit or qemu_cpu_kick_thread, Paolo Bonzini, 2015/09/09
- [Qemu-devel] [PULL 11/43] remove qemu/tls.h, Paolo Bonzini, 2015/09/09