qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Peter Maydell <peter.maydell@linaro.org>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: QEMU Developers <qemu-devel@nongnu.org>,
	"Dr. David Alan Gilbert" <dgilbert@redhat.com>
Subject: Re: [Qemu-devel] [PATCH] rcu: do not create thread in pthread_atfork callback
Date: Tue, 31 Mar 2015 12:41:12 +0100	[thread overview]
Message-ID: <CAFEAcA8aXC65=7L56p1SAsOE5ixyNaJ9DzcmU++TRP41B-XFbA@mail.gmail.com> (raw)
In-Reply-To: <1427799701-31563-1-git-send-email-pbonzini@redhat.com>

On 31 March 2015 at 12:01, Paolo Bonzini <pbonzini@redhat.com> wrote:
> If QEMU forks after the CPU threads have been created, qemu_mutex_lock_iothread
> will not be able to do qemu_cpu_kick_thread.  There is no solution other than
> assuming that forks after the CPU threads have been created will end up in an
> exec.

This assumption is false for linux-user mode...
(though in that case we don't have an iothread).

> diff --git a/include/qemu/rcu.h b/include/qemu/rcu.h
> index 506ab58..7df1e86 100644
> --- a/include/qemu/rcu.h
> +++ b/include/qemu/rcu.h
> @@ -117,6 +117,7 @@ extern void synchronize_rcu(void);
>   */
>  extern void rcu_register_thread(void);
>  extern void rcu_unregister_thread(void);
> +extern void rcu_after_fork(void);
>
>  struct rcu_head;
>  typedef void RCUCBFunc(struct rcu_head *head);
> diff --git a/os-posix.c b/os-posix.c
> index ba091f1..e4da406 100644
> --- a/os-posix.c
> +++ b/os-posix.c
> @@ -39,6 +39,7 @@
>  #include "sysemu/sysemu.h"
>  #include "net/slirp.h"
>  #include "qemu-options.h"
> +#include "qemu/rcu.h"
>
>  #ifdef CONFIG_LINUX
>  #include <sys/prctl.h>
> @@ -247,6 +248,7 @@ void os_daemonize(void)
>          signal(SIGTSTP, SIG_IGN);
>          signal(SIGTTOU, SIG_IGN);
>          signal(SIGTTIN, SIG_IGN);
> +        rcu_after_fork();
>      }
>  }
>
> diff --git a/util/rcu.c b/util/rcu.c
> index 27802a4..7270151 100644
> --- a/util/rcu.c
> +++ b/util/rcu.c
> @@ -311,19 +311,18 @@ static void rcu_init_unlock(void)
>  {
>      qemu_mutex_unlock(&rcu_gp_lock);
>  }
> +#endif
>
> -static void rcu_init_child(void)
> +void rcu_after_fork(void)
>  {
> -    qemu_mutex_unlock(&rcu_gp_lock);
>      memset(&registry, 0, sizeof(registry));
>      rcu_init_complete();
>  }
> -#endif
>
>  static void __attribute__((__constructor__)) rcu_init(void)
>  {
>  #ifdef CONFIG_POSIX
> -    pthread_atfork(rcu_init_lock, rcu_init_unlock, rcu_init_child);
> +    pthread_atfork(rcu_init_lock, rcu_init_unlock, rcu_init_unlock);
>  #endif
>      rcu_init_complete();
>  }

So this is changing the linux-user behaviour so we no
longer do any init after fork; is that a problem?

-- PMM

  reply	other threads:[~2015-03-31 11:41 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-31 11:01 [Qemu-devel] [PATCH] rcu: do not create thread in pthread_atfork callback Paolo Bonzini
2015-03-31 11:41 ` Peter Maydell [this message]
2015-03-31 12:55   ` Paolo Bonzini
2015-03-31 12:59     ` Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAFEAcA8aXC65=7L56p1SAsOE5ixyNaJ9DzcmU++TRP41B-XFbA@mail.gmail.com' \
    --to=peter.maydell@linaro.org \
    --cc=dgilbert@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).