From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37829) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZMn7-0005SH-NV for qemu-devel@nongnu.org; Tue, 08 Sep 2015 13:34:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZMn3-0003of-Nv for qemu-devel@nongnu.org; Tue, 08 Sep 2015 13:34:45 -0400 Received: from mail-wi0-f174.google.com ([209.85.212.174]:37393) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZMn3-0003oQ-It for qemu-devel@nongnu.org; Tue, 08 Sep 2015 13:34:41 -0400 Received: by wicfx3 with SMTP id fx3so123462040wic.0 for ; Tue, 08 Sep 2015 10:34:40 -0700 (PDT) References: <1440375847-17603-1-git-send-email-cota@braap.org> <1440375847-17603-9-git-send-email-cota@braap.org> From: Alex =?utf-8?Q?Benn=C3=A9e?= In-reply-to: <1440375847-17603-9-git-send-email-cota@braap.org> Date: Tue, 08 Sep 2015 18:34:38 +0100 Message-ID: <877fo0ak7l.fsf@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [RFC 08/38] rcu: init rcu_registry_lock after fork List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Emilio G. Cota" Cc: mttcg@listserver.greensocs.com, mark.burton@greensocs.com, a.rigo@virtualopensystems.com, qemu-devel@nongnu.org, guillaume.delbergue@greensocs.com, pbonzini@redhat.com, Frederic Konrad Emilio G. Cota writes: > We were unlocking this lock after fork, which is wrong since > only the thread that holds a mutex is allowed to unlock it. > > Signed-off-by: Emilio G. Cota > --- > util/rcu.c | 7 ++++++- > 1 file changed, 6 insertions(+), 1 deletion(-) > > diff --git a/util/rcu.c b/util/rcu.c > index 8ba304d..47c2bce 100644 > --- a/util/rcu.c > +++ b/util/rcu.c > @@ -335,6 +335,11 @@ static void rcu_init_unlock(void) > qemu_mutex_unlock(&rcu_registry_lock); > qemu_mutex_unlock(&rcu_sync_lock); > } > + > +static void rcu_init_child(void) > +{ > + qemu_mutex_init(&rcu_registry_lock); > +} > #endif > > void rcu_after_fork(void) > @@ -346,7 +351,7 @@ void rcu_after_fork(void) > static void __attribute__((__constructor__)) rcu_init(void) > { > #ifdef CONFIG_POSIX > - pthread_atfork(rcu_init_lock, rcu_init_unlock, rcu_init_unlock); > + pthread_atfork(rcu_init_lock, rcu_init_unlock, rcu_init_child); > #endif Hmm previously we unlocked both rcu_sync_lock and rcu_registry_lock, is it somehow different in it's locking rules? If I'm reading the pthread_atfork man page right couldn't we just do: pthread_atfork(rcu_init_lock, rcu_init_unlock, rcu_init_lock); > rcu_init_complete(); > } -- Alex Bennée