From: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
To: Matt Wilson <msw@amazon.com>
Cc: "Roger Pau Monné" <roger.pau@citrix.com>,
"Keir Fraser" <keir@xen.org>,
"Ian Campbell" <Ian.Campbell@citrix.com>,
xen-devel <xen-devel@lists.xen.org>
Subject: Re: HVM CPU enumeration, mapping to VCPU ID (Was: Re: [Xen-users] FreeBSD PVHVM call for testing)
Date: Mon, 3 Jun 2013 10:44:43 -0400 [thread overview]
Message-ID: <20130603144443.GA2816@phenom.dumpdata.com> (raw)
In-Reply-To: <20130531185320.GA6133@u109add4315675089e695.ant.amazon.com>
On Fri, May 31, 2013 at 11:53:22AM -0700, Matt Wilson wrote:
> On Fri, May 31, 2013 at 09:21:50AM +0100, Ian Campbell wrote:
> > On Thu, 2013-05-30 at 10:16 -0700, Matt Wilson wrote:
> > >
> > > On bare metal x86 Linux, the kernel enumerates CPUs based on an order
> > > defined by the BIOS.
> > > Typically this means that all the cores are
> > > enumerated first, followed by logical processors (HT/SMT). For Linux,
> > > maxcpus=N/2 should disable HT on systems that enumerate processors in
> > > the recommended order. Some history:
> > > https://bugzilla.kernel.org/show_bug.cgi?id=2317
> >
> > How the guest chooses to enumerate the CPUs is not terribly relevant so
> > long as the Xen specific code for that OS knows how to invert that
> > mapping to get at the underlying ABI which determines Xen's VCPUID for a
> > CPU.
>
> Indeed.
>
> > I think I was wrong to focus on the guest enumeration scheme before,
> > what actually matters is where in our ABI we expose the VCPUID, which
> > isn't at all clear to me.
>
> Agreed.
>
> > > The virtual BIOS provides both ACPI tables and a legacy MP-table that
> > > gives the LAPIC id mapping. The guest could infer the Xen vCPU ID from
> > > a processor's position in these tables.
> >
> > Do we consider the ordering given in any of those tables to be an HVM
> > guest ABI? What about the lapic_id == 2*vcpuid -- is that multiplication
> > factor part of the ABI (i.e. is the guest expected to pass lapic_id/2 to
> > vcpuop)?
>
> I strongly prefer the order in the BIOS tables, *not* the
> lapic_id = 2*vcpuid formula. Once I've done some libxl work, I'll be
> proposing a patch that makes the LAPIC / x2APIC IDs configurable,
> and that will break this assumption.
>
> > > Or we could add a VCPUOP that an enlightened guest could use to get
> > > the information more directly.
> >
> > I'm hoping that there is some existing interface which I simply don't
> > know about, but yes this could be the answer if such a thing doesn't
> > exist.
>
> I don't know of one that provide the information explicitly. It might
> be easiest to provide this as a hypervisor CPUID leaf so it can be
> used in early boot.
>
> > > One question: why does a hypercall take a parameter that only has one
> > > valid value? That value can be determined by looking at the current
> > > running vCPU.
> >
> > The generic prototype is:
> > vcpu_op(int cmd, int vcpuid, void *extra_args)
> > Some cmds can act on any vcpuid and others can only act on the current
> > vcpu. In an ideal world we would have had VCPUID_SELF or something but
> > its a bit late for that.
>
> Yea, that makes sense.
>
> > > The *2 is just for assigning the LAPIC ID, and I'm pretty sure that
> > > Linux is assigning processor IDs sequentially at ACPI parse time.
> >
> > That probably doesn't matter, what matters is the Xen specific parts of
> > the kernel's ability to reverse that assignment to get at the underlying
> > APIC ID, assuming that is actually an ABI from which we can infer the
> > VCPU ID...
>
> Indeed. This seems to be loosely defined so far, and easy to get wrong
> as happened with this FreeBSD work.
>
> Konrad, Keir - any thoughts here?
I am a bit confused by 'I strongly prefer the order in the BIOS tables'.
The way I understand it - Linux setup up the vCPUs based on the LAPIC
which are created by the hvmloader. There are no hypercalls or any
lapic_id =2*vcpuid formule in the Linux kernel. I presume what you meant
by the lapic_id = 2 * vcpuid is more of this:
144 for ( i = 0; i < nr_processor_objects; i++ )
145 {
146 memset(lapic, 0, sizeof(*lapic));
147 lapic->type = ACPI_PROCESSOR_LOCAL_APIC;
148 lapic->length = sizeof(*lapic);
149 /* Processor ID must match processor-object IDs in the DSDT. */
150 lapic->acpi_processor_id = i;
151 lapic->apic_id = LAPIC_ID(i);
Which sets this up.
So .. assuming this was thought out, why are we starting on vCPUs
that don't match to this? That seems like a bug? (Note, this is
with maxvcpus=32, vcpus=1 and the starting of a VCPU1 actually
ended up starting at VCPU4?!).
I think all of this can be sorted out if the hvmloader sets the
LAPIC CPU == VCPU ID properly. So perhaps a better question is - why
is it not setup properly nowadays? If the formal is baked in for
the PVHVM guests, somewhere the formula is not being evaluated properly?
The new hypercall to figure this out could be used, but that wouldn't
explain why we are failing to start on the correct VCPU?
>
> --msw
next prev parent reply other threads:[~2013-06-03 14:44 UTC|newest]
Thread overview: 102+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <519131D8.9010307@citrix.com>
2013-05-13 18:52 ` FreeBSD PVHVM call for testing Michael Sierchio
[not found] ` <CAHu1Y73xuFqAQL99rTJL0_LGFNsdafcDd0sTpyg9DYjAgmf_jQ@mail.gmail.com>
2013-05-13 18:59 ` Colin Percival
[not found] ` <51913821.4040104@freebsd.org>
2013-05-13 19:08 ` Michael Sierchio
[not found] ` <CAHu1Y727R0KW-MfrfNf1_jjuZhCTq+8=dJidNmRZ29i2iKPQ+w@mail.gmail.com>
2013-05-13 19:13 ` Colin Percival
2013-05-14 9:19 ` George Dunlap
[not found] ` <CAFLBxZZ1eNf2UoHf1NvWd_cfomSChr0LDYyfFcXpYROg8RNC8Q@mail.gmail.com>
2013-05-14 15:56 ` Dario Faggioli
2013-05-16 18:55 ` Colin Percival
[not found] ` <51952BAE.6010609@freebsd.org>
2013-05-17 0:43 ` Roger Pau Monné
[not found] ` <51957D42.9060801@citrix.com>
2013-05-17 3:07 ` Colin Percival
[not found] ` <51959ED9.6040405@freebsd.org>
2013-05-18 9:50 ` Roger Pau Monné
[not found] ` <51974EC9.9030204@citrix.com>
2013-05-18 15:44 ` Colin Percival
[not found] ` <5197A1EA.2040404@freebsd.org>
2013-05-22 11:45 ` Roger Pau Monné
[not found] ` <519CAFC7.1070908@citrix.com>
2013-05-22 20:03 ` Colin Percival
[not found] ` <519D24A9.3050407@freebsd.org>
2013-05-23 9:06 ` Roger Pau Monné
[not found] ` <519DDC0A.9000201@citrix.com>
2013-05-23 19:09 ` Colin Percival
[not found] ` <519E6958.6020606@freebsd.org>
2013-05-24 10:11 ` Roger Pau Monné
[not found] ` <519F3CD0.5090405@citrix.com>
2013-05-28 16:15 ` Roger Pau Monné
[not found] ` <51A4D804.9050208@citrix.com>
2013-05-28 19:18 ` Matt Wilson
[not found] ` <20130528191855.GA13736@u109add4315675089e695.ant.amazon.com>
2013-05-28 21:33 ` Colin Percival
[not found] ` <51A5229F.80205@freebsd.org>
2013-05-29 17:03 ` Roger Pau Monné
[not found] ` <51A634EC.7050805@citrix.com>
2013-05-29 17:22 ` Matt Wilson
2013-05-29 17:25 ` [Xen-users] " Ian Campbell
2013-05-29 18:24 ` Konrad Rzeszutek Wilk
2013-05-30 9:26 ` Ian Campbell
2013-05-29 22:10 ` Matt Wilson
2013-05-30 9:31 ` Ian Campbell
2013-05-30 17:16 ` Matt Wilson
2013-05-31 8:21 ` HVM CPU enumeration, mapping to VCPU ID (Was: Re: [Xen-users] FreeBSD PVHVM call for testing) Ian Campbell
2013-05-31 18:53 ` Matt Wilson
2013-06-03 14:44 ` Konrad Rzeszutek Wilk [this message]
2013-06-03 15:57 ` Matt Wilson
2013-06-03 17:33 ` Konrad Rzeszutek Wilk
2013-06-03 18:23 ` Matt Wilson
2013-06-04 14:22 ` Konrad Rzeszutek Wilk
2013-06-05 16:15 ` Matt Wilson
2013-06-05 19:10 ` Konrad Rzeszutek Wilk
2013-08-09 13:54 ` Konrad Rzeszutek Wilk
[not found] ` <20130529172201.GA20973@u109add4315675089e695.ant.amazon.com>
2013-05-29 17:45 ` FreeBSD PVHVM call for testing Roger Pau Monné
[not found] ` <51A63EB3.5090007@citrix.com>
2013-05-29 20:58 ` Colin Percival
[not found] ` <51A66C13.7060203@freebsd.org>
2013-05-29 22:19 ` Matt Wilson
[not found] ` <20130529221920.GC20973@u109add4315675089e695.ant.amazon.com>
2013-05-30 1:10 ` Colin Percival
2013-05-21 17:40 ` Konrad Rzeszutek Wilk
2013-05-22 11:41 ` Roger Pau Monné
[not found] ` <519CAECE.9040706@citrix.com>
2013-05-22 12:21 ` Konrad Rzeszutek Wilk
2013-05-22 15:27 ` Yuriy Kohut
2013-05-23 12:57 ` Jeroen van der Ham
2013-05-23 13:20 ` Jeroen van der Ham
[not found] ` <647F6650-AEED-4784-8A45-98324860EE0A@dckd.nl>
2013-05-23 13:30 ` Roger Pau Monné
[not found] ` <519E1A0C.3070609@citrix.com>
2013-05-24 22:27 ` Craig Rodrigues
[not found] ` <CAG=rPVeWnTdhXucg-KRjgSRLfTCz5bRNdkTGQX7ug2Bu2qJkiQ@mail.gmail.com>
2013-05-28 15:21 ` Outback Dingo
[not found] ` <CAKYr3zyu-zppwsy9RDOGXj+cc1Xt76hzwB0S1LnfZnhCLpxL=g@mail.gmail.com>
2013-05-28 22:05 ` Craig Rodrigues
2013-05-28 22:43 ` Outback Dingo
[not found] ` <CAKYr3zwbdtw4s+jUMNQJCc1P3S=T_b1k2M_QK8=FQKieDa7Uhg@mail.gmail.com>
2013-05-28 23:09 ` Craig Rodrigues
[not found] ` <CAG=rPVeZKSbWRd0egjZpvJghUsK6rXVr+wwL-u7LAoeKMNpozQ@mail.gmail.com>
2013-05-28 23:20 ` Outback Dingo
[not found] ` <CAKYr3zzqgii5G8xw2yQtgxEXaa38Ww4hibxMcCCVCtJZ7PGgew@mail.gmail.com>
2013-05-29 17:07 ` Justin T. Gibbs
[not found] ` <616EE8A8-78BA-46E6-90AA-4A22160289DF@dckd.nl>
2013-05-23 13:02 ` Outback Dingo
2013-05-23 13:33 ` Roger Pau Monné
[not found] ` <519E1AA6.2060808@citrix.com>
2013-05-23 15:02 ` Outback Dingo
2013-05-23 16:30 ` Outback Dingo
[not found] ` <CAKYr3zyB-9FOUwAgbq19rMNoxb5XEzHP5Wa0RiiGYJ_XcG7VbA@mail.gmail.com>
2013-05-23 16:48 ` Sergey Kandaurov
2013-05-23 16:48 ` Roger Pau Monné
[not found] ` <519E4850.1090305@citrix.com>
2013-05-23 17:02 ` Outback Dingo
[not found] ` <CAKYr3zxJMdhMCu-A0epLekLw+sLAWjSUR7UB7jHo0zfG_QfaRQ@mail.gmail.com>
2013-05-23 17:22 ` Jeroen van der Ham
[not found] ` <0BBCBA0B-F4A6-4775-A172-D051D9363665@dckd.nl>
2013-05-23 17:29 ` Outback Dingo
2013-05-23 17:41 ` Roger Pau Monné
2013-05-23 23:24 ` Outback Dingo
[not found] ` <7C420745-BAC0-4BD0-AB60-E3BC7F8BA2A7@onapp.com>
2013-05-24 8:34 ` Yuriy Kohut
[not found] ` <519E54DE.5090304@citrix.com>
2013-05-24 14:14 ` Konrad Rzeszutek Wilk
[not found] ` <20130524141400.GB3900@phenom.dumpdata.com>
2013-05-24 14:16 ` Outback Dingo
2013-05-24 14:21 ` Roger Pau Monné
2013-05-24 22:21 ` Craig Rodrigues
[not found] ` <CAG=rPVfoyHOzN5qZPn9YAfR2QPnLxBMVJBLv2abg7CMtdPWHJA@mail.gmail.com>
2013-05-28 13:42 ` Konrad Rzeszutek Wilk
2013-05-30 8:50 ` Jeroen van der Ham
[not found] ` <6B8B9354-AF52-4081-B67B-04565D1BCE99@dckd.nl>
2013-05-30 9:04 ` Roger Pau Monné
[not found] ` <51A71616.4060508@citrix.com>
2013-05-30 9:15 ` Jeroen van der Ham
[not found] ` <ED94B614-A210-4D0B-A60B-8022C30BB0F1@dckd.nl>
2013-05-30 14:56 ` Outback Dingo
[not found] ` <CAKYr3zxo0-BOBQuJk_qY2=kbxnMyMR7gffEzoVL+YuTmj-Trdg@mail.gmail.com>
2013-05-30 15:10 ` Jeroen van der Ham
2013-06-10 14:48 ` Roger Pau Monné
[not found] ` <51B5E730.6070007@citrix.com>
2013-06-10 15:09 ` Outback Dingo
[not found] ` <CAKYr3zxhqvpaL-G0L9220zbRY7D_ZQ+9DZ4MKKGiKtsWvPw3RA@mail.gmail.com>
2013-06-10 15:16 ` Roger Pau Monné
2013-06-13 17:20 ` Roger Pau Monné
[not found] ` <51B9FF53.2020901@citrix.com>
2013-06-19 11:13 ` Jeroen van der Ham
[not found] ` <2C70BC9B-5964-498F-AAE2-E5024160E3E5@dckd.nl>
2013-06-19 11:34 ` Roger Pau Monné
[not found] ` <51C1972B.50703@citrix.com>
2013-06-19 12:16 ` Jeroen van der Ham
[not found] ` <C4BE5FBE-DF19-404F-B478-0F33D716454F@dckd.nl>
2013-06-19 12:20 ` Roger Pau Monné
[not found] ` <51C1A223.6030305@citrix.com>
2013-06-19 12:33 ` Jeroen van der Ham
[not found] ` <6E99C9B2-E28D-4793-81C2-97440AC5AD0E@dckd.nl>
2013-06-19 12:44 ` Roger Pau Monné
[not found] ` <51C1A7AA.2010307@citrix.com>
2013-06-19 16:07 ` Jeroen van der Ham
[not found] ` <B6D2239B-86D0-4B1B-A357-63F6E5A18284@dckd.nl>
2013-06-19 16:15 ` Justin T. Gibbs
[not found] ` <BB38EA9B-54E4-43CD-AF49-7B480DC50BFF@freebsd.org>
2013-06-19 16:50 ` Jeroen van der Ham
[not found] ` <546D0358-4F92-4E8C-AED0-94FC5D36086F@dckd.nl>
2013-06-19 16:52 ` Justin T. Gibbs
[not found] ` <E8150505-ECA0-4CB6-B777-A41334B8B903@FreeBSD.org>
2013-06-19 20:03 ` Jeroen van der Ham
2013-06-20 9:20 ` Jeroen van der Ham
[not found] ` <54560214-F170-426E-BDF9-2295D8B8E982@dckd.nl>
2013-06-20 9:33 ` Roger Pau Monné
[not found] ` <51C2CC63.9070505@citrix.com>
2013-06-20 9:37 ` Jeroen van der Ham
2013-07-22 7:18 ` Jeroen van der Ham
[not found] ` <4A595D02-7B79-4C6C-9356-55FA9E45EDDC@dckd.nl>
2013-07-22 8:29 ` Roger Pau Monné
[not found] ` <51ECED83.9020905@citrix.com>
2013-07-22 8:40 ` Jeroen van der Ham
[not found] ` <A1FE7DDA-7C0D-4456-A754-65CBCA81232D@dckd.nl>
2013-07-22 10:40 ` Roger Pau Monné
2013-07-22 16:23 ` Jeroen van der Ham
2013-10-11 9:42 ` Eggert, Lars
[not found] ` <7BE1E0BE-C4E8-4706-8751-23A30D733A94@netapp.com>
2013-10-11 13:56 ` Roger Pau Monné
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=20130603144443.GA2816@phenom.dumpdata.com \
--to=konrad.wilk@oracle.com \
--cc=Ian.Campbell@citrix.com \
--cc=keir@xen.org \
--cc=msw@amazon.com \
--cc=roger.pau@citrix.com \
--cc=xen-devel@lists.xen.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).