From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36255) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZIDm2-00029s-RI for qemu-devel@nongnu.org; Thu, 23 Jul 2015 06:30:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZIDlw-00018X-UZ for qemu-devel@nongnu.org; Thu, 23 Jul 2015 06:30:46 -0400 Received: from e06smtp15.uk.ibm.com ([195.75.94.111]:55501) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZIDlw-000186-Gn for qemu-devel@nongnu.org; Thu, 23 Jul 2015 06:30:40 -0400 Received: from /spool/local by e06smtp15.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 23 Jul 2015 11:30:39 +0100 Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by d06dlp02.portsmouth.uk.ibm.com (Postfix) with ESMTP id 4D30B2190061 for ; Thu, 23 Jul 2015 11:30:13 +0100 (BST) Received: from d06av06.portsmouth.uk.ibm.com (d06av06.portsmouth.uk.ibm.com [9.149.37.217]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t6NAUaxT37552192 for ; Thu, 23 Jul 2015 10:30:36 GMT Received: from d06av06.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av06.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t6N5NFC3013125 for ; Thu, 23 Jul 2015 01:23:15 -0400 Message-ID: <55B0C24C.7020401@de.ibm.com> Date: Thu, 23 Jul 2015 12:30:36 +0200 From: Christian Borntraeger MIME-Version: 1.0 References: <1437574681-18362-2-git-send-email-pbonzini@redhat.com> In-Reply-To: <1437574681-18362-2-git-send-email-pbonzini@redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] rcu: actually register threads that have RCU read-side critical sections List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini , qemu-devel@nongnu.org Am 22.07.2015 um 16:18 schrieb Paolo Bonzini: > Otherwise, grace periods are detected too early! I guess this or Wens proposal is still necessary for 2.4? > > Signed-off-by: Paolo Bonzini > --- > cpus.c | 6 ++++++ > iothread.c | 5 +++++ > migration/migration.c | 4 ++++ > tests/test-rcu-list.c | 4 ++++ > util/rcu.c | 2 ++ > 5 files changed, 21 insertions(+) > > diff --git a/cpus.c b/cpus.c > index b00a423..a822ce3 100644 > --- a/cpus.c > +++ b/cpus.c > @@ -954,6 +954,8 @@ static void *qemu_kvm_cpu_thread_fn(void *arg) > CPUState *cpu = arg; > int r; > > + rcu_register_thread(); > + > qemu_mutex_lock_iothread(); > qemu_thread_get_self(cpu->thread); > cpu->thread_id = qemu_get_thread_id(); > @@ -995,6 +997,8 @@ static void *qemu_dummy_cpu_thread_fn(void *arg) > sigset_t waitset; > int r; > > + rcu_register_thread(); > + > qemu_mutex_lock_iothread(); > qemu_thread_get_self(cpu->thread); > cpu->thread_id = qemu_get_thread_id(); > @@ -1034,6 +1038,8 @@ static void *qemu_tcg_cpu_thread_fn(void *arg) > { > CPUState *cpu = arg; > > + rcu_register_thread(); > + > qemu_mutex_lock_iothread(); > qemu_tcg_init_cpu_signals(); > qemu_thread_get_self(cpu->thread); > diff --git a/iothread.c b/iothread.c > index 6d2a33f..da6ce7b 100644 > --- a/iothread.c > +++ b/iothread.c > @@ -18,6 +18,7 @@ > #include "sysemu/iothread.h" > #include "qmp-commands.h" > #include "qemu/error-report.h" > +#include "qemu/rcu.h" > > typedef ObjectClass IOThreadClass; > > @@ -31,6 +32,8 @@ static void *iothread_run(void *opaque) > IOThread *iothread = opaque; > bool blocking; > > + rcu_register_thread(); > + > qemu_mutex_lock(&iothread->init_done_lock); > iothread->thread_id = qemu_get_thread_id(); > qemu_cond_signal(&iothread->init_done_cond); > @@ -45,6 +48,8 @@ static void *iothread_run(void *opaque) > } > aio_context_release(iothread->ctx); > } > + > + rcu_unregister_thread(); > return NULL; > } > > diff --git a/migration/migration.c b/migration/migration.c > index 86ca099..fd4f99b 100644 > --- a/migration/migration.c > +++ b/migration/migration.c > @@ -22,6 +22,7 @@ > #include "block/block.h" > #include "qapi/qmp/qerror.h" > #include "qemu/sockets.h" > +#include "qemu/rcu.h" > #include "migration/block.h" > #include "qemu/thread.h" > #include "qmp-commands.h" > @@ -917,6 +918,8 @@ static void *migration_thread(void *opaque) > int64_t start_time = initial_time; > bool old_vm_running = false; > > + rcu_register_thread(); > + > qemu_savevm_state_header(s->file); > 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_mutex_unlock_iothread(); > > + rcu_unregister_thread(); > return NULL; > } > > diff --git a/tests/test-rcu-list.c b/tests/test-rcu-list.c > index 4c5f62e..daa8bf4 100644 > --- a/tests/test-rcu-list.c > +++ b/tests/test-rcu-list.c > @@ -108,6 +108,8 @@ static void *rcu_q_reader(void *arg) > long long n_reads_local = 0; > struct list_element *el; > > + rcu_register_thread(); > + > *(struct rcu_reader_data **)arg = &rcu_reader; > atomic_inc(&nthreadsrunning); > while (goflag == GOFLAG_INIT) { > @@ -129,6 +131,8 @@ static void *rcu_q_reader(void *arg) > qemu_mutex_lock(&counts_mutex); > n_reads += n_reads_local; > qemu_mutex_unlock(&counts_mutex); > + > + rcu_unregister_thread(); > return NULL; > } > > diff --git a/util/rcu.c b/util/rcu.c > index 7270151..cdcad67 100644 > --- a/util/rcu.c > +++ b/util/rcu.c > @@ -216,6 +216,8 @@ static void *call_rcu_thread(void *opaque) > { > struct rcu_head *node; > > + rcu_register_thread(); > + > for (;;) { > int tries = 0; > int n = atomic_read(&rcu_call_count); >