mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-03 15:53:54 -06:00
lockable: replaced locks with lock guard macros where appropriate
- ran regexp "qemu_mutex_lock\(.*\).*\n.*if" to find targets - replaced result with QEMU_LOCK_GUARD if all unlocks at function end - replaced result with WITH_QEMU_LOCK_GUARD if unlock not at end Signed-off-by: Daniel Brodsky <dnbrdsky@gmail.com> Reviewed-by: Juan Quintela <quintela@redhat.com> Message-id: 20200404042108.389635-3-dnbrdsky@gmail.com Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
parent
56f21718b8
commit
6e8a355de6
15 changed files with 83 additions and 106 deletions
|
@ -31,6 +31,7 @@
|
|||
#include "qemu/atomic.h"
|
||||
#include "qemu/thread.h"
|
||||
#include "qemu/main-loop.h"
|
||||
#include "qemu/lockable.h"
|
||||
#if defined(CONFIG_MALLOC_TRIM)
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
|
@ -141,14 +142,14 @@ static void wait_for_readers(void)
|
|||
|
||||
void synchronize_rcu(void)
|
||||
{
|
||||
qemu_mutex_lock(&rcu_sync_lock);
|
||||
QEMU_LOCK_GUARD(&rcu_sync_lock);
|
||||
|
||||
/* Write RCU-protected pointers before reading p_rcu_reader->ctr.
|
||||
* Pairs with smp_mb_placeholder() in rcu_read_lock().
|
||||
*/
|
||||
smp_mb_global();
|
||||
|
||||
qemu_mutex_lock(&rcu_registry_lock);
|
||||
QEMU_LOCK_GUARD(&rcu_registry_lock);
|
||||
if (!QLIST_EMPTY(®istry)) {
|
||||
/* In either case, the atomic_mb_set below blocks stores that free
|
||||
* old RCU-protected pointers.
|
||||
|
@ -169,9 +170,6 @@ void synchronize_rcu(void)
|
|||
|
||||
wait_for_readers();
|
||||
}
|
||||
|
||||
qemu_mutex_unlock(&rcu_registry_lock);
|
||||
qemu_mutex_unlock(&rcu_sync_lock);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue