From: Glauber Costa <glommer@redhat.com>
To: Avi Kivity <avi@redhat.com>
Cc: kvm@vger.kernel.org, ehabkost@redhat.com
Subject: Re: [PATCH 1/2] don't start cpu main loop while there is still init work to do.
Date: Mon, 4 May 2009 11:26:27 -0300 [thread overview]
Message-ID: <20090504142627.GG12844@poweredge.glommer> (raw)
In-Reply-To: <49FEA7C2.7050908@redhat.com>
On Mon, May 04, 2009 at 11:30:58AM +0300, Avi Kivity wrote:
> Glauber Costa wrote:
>> As soon as we call kvm_init_vcpu(), we start the vcpu thread.
>> However, there is still things that has to be done, as soon
>> as the new CPUState is created. Examples include initializing the
>> apic, halting the cpu, etc.
>>
>> Without this patch, it is possible that the cpu may want to start
>> using those things, before initializing them, leading to segfaults.
>> We introduce another state variable, "initialized", meaning that
>> the cpu is already created, but not totally initialized,
>> to serialize it.
>>
>> Before this patch:
>> (qemu) cpu_set X online => segfaults ~ 80 % of the time
>> After this patch:
>> (qemu) cpu_set X online => works.
>>
>>
>
> Is it possible to move all those things to the vcpu thread, so it
> serializes naturally?
Everything is possible. moving everything to inside cpu_x86_init would be best,
IMHO. We have to remember qemu will have the same problem when kvm gets in there.
However, we might as well remember that cpu_x86_init creates a x86 cpu. It does not
have to be a pc cpu. So initializing apic and the like inside cpu_x86_init could break
this separability. Of course, right now we don't do anything other than pc, so we might
not care. But theorectically...
>
> I'd like to avoid vcpu ioctls from more than one thread, in case we ever
> move to a syscall implementation.
Although I don't see exactly what's your point in here.
We're just adding a serialization points through pthreads function, not doing any ioctl from
the outside.
next prev parent reply other threads:[~2009-05-04 14:21 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-29 20:31 [PATCH 0/2] Fix cpu hotplug in upstream kvm Glauber Costa
2009-04-29 20:31 ` [PATCH 1/2] don't start cpu main loop while there is still init work to do Glauber Costa
2009-04-29 20:31 ` [PATCH 2/2] Present kvm with corret apic phys id Glauber Costa
2009-05-04 8:32 ` Avi Kivity
2009-05-04 8:30 ` [PATCH 1/2] don't start cpu main loop while there is still init work to do Avi Kivity
2009-05-04 14:26 ` Glauber Costa [this message]
2009-05-04 14:33 ` Avi Kivity
2009-05-04 14:44 ` Glauber Costa
2009-05-04 14:48 ` Avi Kivity
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=20090504142627.GG12844@poweredge.glommer \
--to=glommer@redhat.com \
--cc=avi@redhat.com \
--cc=ehabkost@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