rcu: actually register threads that have RCU read-side critical sections
Otherwise, grace periods are detected too early! Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
c170aad8b0
commit
ab28bd2312
6
cpus.c
6
cpus.c
@ -954,6 +954,8 @@ static void *qemu_kvm_cpu_thread_fn(void *arg)
|
|||||||
CPUState *cpu = arg;
|
CPUState *cpu = arg;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
|
rcu_register_thread();
|
||||||
|
|
||||||
qemu_mutex_lock_iothread();
|
qemu_mutex_lock_iothread();
|
||||||
qemu_thread_get_self(cpu->thread);
|
qemu_thread_get_self(cpu->thread);
|
||||||
cpu->thread_id = qemu_get_thread_id();
|
cpu->thread_id = qemu_get_thread_id();
|
||||||
@ -995,6 +997,8 @@ static void *qemu_dummy_cpu_thread_fn(void *arg)
|
|||||||
sigset_t waitset;
|
sigset_t waitset;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
|
rcu_register_thread();
|
||||||
|
|
||||||
qemu_mutex_lock_iothread();
|
qemu_mutex_lock_iothread();
|
||||||
qemu_thread_get_self(cpu->thread);
|
qemu_thread_get_self(cpu->thread);
|
||||||
cpu->thread_id = qemu_get_thread_id();
|
cpu->thread_id = qemu_get_thread_id();
|
||||||
@ -1034,6 +1038,8 @@ static void *qemu_tcg_cpu_thread_fn(void *arg)
|
|||||||
{
|
{
|
||||||
CPUState *cpu = arg;
|
CPUState *cpu = arg;
|
||||||
|
|
||||||
|
rcu_register_thread();
|
||||||
|
|
||||||
qemu_mutex_lock_iothread();
|
qemu_mutex_lock_iothread();
|
||||||
qemu_tcg_init_cpu_signals();
|
qemu_tcg_init_cpu_signals();
|
||||||
qemu_thread_get_self(cpu->thread);
|
qemu_thread_get_self(cpu->thread);
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
#include "sysemu/iothread.h"
|
#include "sysemu/iothread.h"
|
||||||
#include "qmp-commands.h"
|
#include "qmp-commands.h"
|
||||||
#include "qemu/error-report.h"
|
#include "qemu/error-report.h"
|
||||||
|
#include "qemu/rcu.h"
|
||||||
|
|
||||||
typedef ObjectClass IOThreadClass;
|
typedef ObjectClass IOThreadClass;
|
||||||
|
|
||||||
@ -31,6 +32,8 @@ static void *iothread_run(void *opaque)
|
|||||||
IOThread *iothread = opaque;
|
IOThread *iothread = opaque;
|
||||||
bool blocking;
|
bool blocking;
|
||||||
|
|
||||||
|
rcu_register_thread();
|
||||||
|
|
||||||
qemu_mutex_lock(&iothread->init_done_lock);
|
qemu_mutex_lock(&iothread->init_done_lock);
|
||||||
iothread->thread_id = qemu_get_thread_id();
|
iothread->thread_id = qemu_get_thread_id();
|
||||||
qemu_cond_signal(&iothread->init_done_cond);
|
qemu_cond_signal(&iothread->init_done_cond);
|
||||||
@ -45,6 +48,8 @@ static void *iothread_run(void *opaque)
|
|||||||
}
|
}
|
||||||
aio_context_release(iothread->ctx);
|
aio_context_release(iothread->ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rcu_unregister_thread();
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
#include "block/block.h"
|
#include "block/block.h"
|
||||||
#include "qapi/qmp/qerror.h"
|
#include "qapi/qmp/qerror.h"
|
||||||
#include "qemu/sockets.h"
|
#include "qemu/sockets.h"
|
||||||
|
#include "qemu/rcu.h"
|
||||||
#include "migration/block.h"
|
#include "migration/block.h"
|
||||||
#include "qemu/thread.h"
|
#include "qemu/thread.h"
|
||||||
#include "qmp-commands.h"
|
#include "qmp-commands.h"
|
||||||
@ -917,6 +918,8 @@ static void *migration_thread(void *opaque)
|
|||||||
int64_t start_time = initial_time;
|
int64_t start_time = initial_time;
|
||||||
bool old_vm_running = false;
|
bool old_vm_running = false;
|
||||||
|
|
||||||
|
rcu_register_thread();
|
||||||
|
|
||||||
qemu_savevm_state_header(s->file);
|
qemu_savevm_state_header(s->file);
|
||||||
qemu_savevm_state_begin(s->file, &s->params);
|
qemu_savevm_state_begin(s->file, &s->params);
|
||||||
|
|
||||||
@ -1016,6 +1019,7 @@ static void *migration_thread(void *opaque)
|
|||||||
qemu_bh_schedule(s->cleanup_bh);
|
qemu_bh_schedule(s->cleanup_bh);
|
||||||
qemu_mutex_unlock_iothread();
|
qemu_mutex_unlock_iothread();
|
||||||
|
|
||||||
|
rcu_unregister_thread();
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,6 +108,8 @@ static void *rcu_q_reader(void *arg)
|
|||||||
long long n_reads_local = 0;
|
long long n_reads_local = 0;
|
||||||
struct list_element *el;
|
struct list_element *el;
|
||||||
|
|
||||||
|
rcu_register_thread();
|
||||||
|
|
||||||
*(struct rcu_reader_data **)arg = &rcu_reader;
|
*(struct rcu_reader_data **)arg = &rcu_reader;
|
||||||
atomic_inc(&nthreadsrunning);
|
atomic_inc(&nthreadsrunning);
|
||||||
while (goflag == GOFLAG_INIT) {
|
while (goflag == GOFLAG_INIT) {
|
||||||
@ -129,6 +131,8 @@ static void *rcu_q_reader(void *arg)
|
|||||||
qemu_mutex_lock(&counts_mutex);
|
qemu_mutex_lock(&counts_mutex);
|
||||||
n_reads += n_reads_local;
|
n_reads += n_reads_local;
|
||||||
qemu_mutex_unlock(&counts_mutex);
|
qemu_mutex_unlock(&counts_mutex);
|
||||||
|
|
||||||
|
rcu_unregister_thread();
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -216,6 +216,8 @@ static void *call_rcu_thread(void *opaque)
|
|||||||
{
|
{
|
||||||
struct rcu_head *node;
|
struct rcu_head *node;
|
||||||
|
|
||||||
|
rcu_register_thread();
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
int tries = 0;
|
int tries = 0;
|
||||||
int n = atomic_read(&rcu_call_count);
|
int n = atomic_read(&rcu_call_count);
|
||||||
|
Loading…
Reference in New Issue
Block a user