From: Marcelo Tosatti <mtosatti@redhat.com>
To: Gleb Natapov <gleb@redhat.com>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH 1/2] Complete cpu initialization before signaling main thread.
Date: Tue, 13 Oct 2009 15:19:08 -0300 [thread overview]
Message-ID: <20091013181908.GA14313@amt.cnet> (raw)
In-Reply-To: <1255436240-994-1-git-send-email-gleb@redhat.com>
On Tue, Oct 13, 2009 at 02:17:19PM +0200, Gleb Natapov wrote:
> Otherwise some cpus may start executing code before others
> are fully initialized.
>
> Signed-off-by: Gleb Natapov <gleb@redhat.com>
> ---
> qemu-kvm.c | 26 ++++++++++++--------------
> 1 files changed, 12 insertions(+), 14 deletions(-)
>
> diff --git a/qemu-kvm.c b/qemu-kvm.c
> index 62ca050..3765818 100644
> --- a/qemu-kvm.c
> +++ b/qemu-kvm.c
> @@ -1954,18 +1954,6 @@ static void process_irqchip_events(CPUState *env)
>
> static int kvm_main_loop_cpu(CPUState *env)
> {
> - setup_kernel_sigmask(env);
> -
> - pthread_mutex_lock(&qemu_mutex);
> -
> - kvm_arch_init_vcpu(env);
> -#ifdef TARGET_I386
> - kvm_tpr_vcpu_start(env);
> -#endif
> -
> - cpu_single_env = env;
> - kvm_arch_load_regs(env);
> -
> while (1) {
> int run_cpu = !is_cpu_stopped(env);
> if (run_cpu && !kvm_irqchip_in_kernel(kvm_context)) {
> @@ -2003,15 +1991,25 @@ static void *ap_main_loop(void *_env)
> on_vcpu(env, kvm_arch_do_ioperm, data);
> #endif
>
> - /* signal VCPU creation */
> + setup_kernel_sigmask(env);
> +
> pthread_mutex_lock(&qemu_mutex);
> + cpu_single_env = env;
> +
> + kvm_arch_init_vcpu(env);
> +#ifdef TARGET_I386
> + kvm_tpr_vcpu_start(env);
> +#endif
> +
> + kvm_arch_load_regs(env);
> +
> + /* signal VCPU creation */
> current_env->created = 1;
> pthread_cond_signal(&qemu_vcpu_cond);
>
> /* and wait for machine initialization */
> while (!qemu_system_ready)
> qemu_cond_wait(&qemu_system_cond);
> - pthread_mutex_unlock(&qemu_mutex);
You don't set cpu_single_env after reacquiring
qemu_mutex here (via qemu_cond_wait).
next prev parent reply other threads:[~2009-10-13 18:19 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-13 12:17 [PATCH 1/2] Complete cpu initialization before signaling main thread Gleb Natapov
2009-10-13 12:17 ` [PATCH 2/2] Don't sync mpstate to/from kernel when unneeded Gleb Natapov
2009-10-13 18:36 ` Marcelo Tosatti
2009-10-13 18:40 ` Gleb Natapov
2009-10-13 18:19 ` Marcelo Tosatti [this message]
2009-10-13 18:23 ` [PATCH 1/2] Complete cpu initialization before signaling main thread Marcelo Tosatti
2009-10-13 18:34 ` Gleb Natapov
2009-10-13 18:24 ` Gleb Natapov
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=20091013181908.GA14313@amt.cnet \
--to=mtosatti@redhat.com \
--cc=gleb@redhat.com \
--cc=kvm@vger.kernel.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).