From: Gleb Natapov <gleb@redhat.com>
To: Marcelo Tosatti <mtosatti@redhat.com>
Cc: avi@redhat.com, kvm@vger.kernel.org
Subject: Re: [PATCH RFC 3/3] Break dependency between vcpu index in vcpus array and vcpu's apic id.
Date: Fri, 22 May 2009 14:41:20 +0300 [thread overview]
Message-ID: <20090522114120.GD6052@redhat.com> (raw)
In-Reply-To: <20090521202957.GA12943@amt.cnet>
On Thu, May 21, 2009 at 05:29:57PM -0300, Marcelo Tosatti wrote:
> On Thu, May 21, 2009 at 11:06:42PM +0300, Gleb Natapov wrote:
> > > Why don't make a convention that vcpu_id 0 is the BSP, by default,
> > > instead of the first vcpu created? This way if userspace creates vcpu 3
> > > first, there are no problems.
> > >
> > Because userspace no longer control vcpu_id allocation. I also want to
> > get rid of "first vcpu is bsp" restriction, but this fill require new
> > ioctl I guess.
>
> Or hardcode "apic_id == 0 is BSP" for now, and later add an ioctl to set
> the BSP?
>
We should not assume anything about apic_ids. For instance if the number
of ioapics+cpu cores are greater than 15 it is recommended to assign ids
0-(N-1) to ioapic (N is the number of ioapics). This is because ioapic
id is only 4 bits long, but it occupies the same id space as apic ids.
> > > That brings the question, why is the apic_id passed as the argument to
> > > vcpu_create? It seems that the argument to vcpu_create should be the
> > > kVM's internal vcpu_id, and the apic_id should come from somewhere else,
> > > apic_mmio_write maybe?
> > I think exactly opposite :) Why userspace should care what index vcpu
> > occupies in internal kernel data structure? This information is never
> > ever used by userspace again.
>
> At the moment its used to implicitly set the BSP (BSP is vcpu_id == 0).
>
Correct. This is the only use of vcpu_id and the patch change it to be
"first cpu created is BSP" and that works with all knows userspace users
of the API. We should add another vcpu_create ioctl that will get
additional flags as a parameter, or have bsp_cpu_id ioctl that should
be issued before first vcpu is even created.
> > > is determined by hardware and BIOS), but in KVM's BIOS case the BSP is
> > > conventioned to be vcpu with vcpu_id == 0, no?
> > Yes (except not vcpu_id == 0, but apic_id == 0), we will have to fix this
> > bug too. Bios should get acpi_ids of active cpus from qemu, not assume
> > anything.
> >
> > > Another thing, it would be better if the linking of the vcpu in the
> > > array could be in arch independent code as it is today?
> > Possible, I will have to define kvm_arch_vcpu_find(id) function to
> > search for duplicates in generic code, but it will not be prettier.
> > I did it this way initially, but decided to hide everything in arch
> > code.
>
> Building on what you said, how KVM stores vcpu structures is no business
> of arch vcpu initialization code (or that should be the goal), IMO.
This is definitely the goal. I can remove vcpu_id/vcpus[] uses from x86
in a couple of key strokes, but other arches uses vcpu_id in a ways I
don't fully understand.
--
Gleb.
next prev parent reply other threads:[~2009-05-22 11:41 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-21 12:56 [PATCH RFC 0/3] decouple vcpu index from apic id Gleb Natapov
2009-05-21 12:56 ` [PATCH RFC 1/3] Introduce kvm_vcpu_is_bsp() function Gleb Natapov
2009-05-21 12:56 ` [PATCH RFC 2/3] Use pointer to vcpu instead of vcpu_id in timer code Gleb Natapov
2009-05-21 12:56 ` [PATCH RFC 3/3] Break dependency between vcpu index in vcpus array and vcpu's apic id Gleb Natapov
2009-05-21 18:21 ` Marcelo Tosatti
2009-05-21 20:06 ` Gleb Natapov
2009-05-21 20:29 ` Marcelo Tosatti
2009-05-22 11:41 ` Gleb Natapov [this message]
2009-05-28 3:47 ` Marcelo Tosatti
2009-05-28 5:11 ` 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=20090522114120.GD6052@redhat.com \
--to=gleb@redhat.com \
--cc=avi@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=mtosatti@redhat.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.