summaryrefslogtreecommitdiffstats
path: root/include/qemu
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2015-12-16 12:32:22 +0100
committerTimothy Pearson <tpearson@raptorengineering.com>2019-11-29 19:28:20 -0600
commit38aad572650c9a7bc6d8c0d3cadddd72c0cbe594 (patch)
tree8571036a8b46d608eb21ed8d5fe5a16ca6d29e86 /include/qemu
parent8f59b057156e4d88e019ade92f74bdf32b11f870 (diff)
downloadhqemu-38aad572650c9a7bc6d8c0d3cadddd72c0cbe594.zip
hqemu-38aad572650c9a7bc6d8c0d3cadddd72c0cbe594.tar.gz
rcu: optimize rcu_read_lock
rcu_read_lock cannot change rcu_gp_ongoing from true to false (the previous value of p_rcu_reader->ctr is zero), hence there is no need to check p_rcu_reader->waiting and wake up a concurrent synchronize_rcu. While at it mark the wakeup as unlikely in rcu_read_unlock. Reviewed-by: Wen Congyang <wency@cn.fujitsu.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Message-Id: <1450265542-4323-1-git-send-email-pbonzini@redhat.com>
Diffstat (limited to 'include/qemu')
-rw-r--r--include/qemu/rcu.h6
1 files changed, 1 insertions, 5 deletions
diff --git a/include/qemu/rcu.h b/include/qemu/rcu.h
index 0d9f677..f596260 100644
--- a/include/qemu/rcu.h
+++ b/include/qemu/rcu.h
@@ -88,10 +88,6 @@ static inline void rcu_read_lock(void)
ctr = atomic_read(&rcu_gp_ctr);
atomic_xchg(&p_rcu_reader->ctr, ctr);
- if (atomic_read(&p_rcu_reader->waiting)) {
- atomic_set(&p_rcu_reader->waiting, false);
- qemu_event_set(&rcu_gp_event);
- }
}
static inline void rcu_read_unlock(void)
@@ -104,7 +100,7 @@ static inline void rcu_read_unlock(void)
}
atomic_xchg(&p_rcu_reader->ctr, 0);
- if (atomic_read(&p_rcu_reader->waiting)) {
+ if (unlikely(atomic_read(&p_rcu_reader->waiting))) {
atomic_set(&p_rcu_reader->waiting, false);
qemu_event_set(&rcu_gp_event);
}
OpenPOWER on IntegriCloud