Xen-Devel Archive mirror
 help / color / mirror / Atom feed
From: Alejandro Vallejo <alejandro.vallejo@cloud.com>
To: Xen-devel <xen-devel@lists.xenproject.org>
Cc: "Alejandro Vallejo" <alejandro.vallejo@cloud.com>,
	"Jan Beulich" <jbeulich@suse.com>,
	"Andrew Cooper" <andrew.cooper3@citrix.com>,
	"Roger Pau Monné" <roger.pau@citrix.com>, "Wei Liu" <wl@xen.org>,
	"Anthony PERARD" <anthony.perard@citrix.com>,
	"Juergen Gross" <jgross@suse.com>
Subject: [PATCH 0/6] x86: Expose consistent topology to guests
Date: Tue,  9 Jan 2024 15:38:28 +0000	[thread overview]
Message-ID: <20240109153834.4192-1-alejandro.vallejo@cloud.com> (raw)

Current topology handling is close to non-existent. As things stand, APIC
IDs are allocated through the apic_id=vcpu_id*2 relation without giving any
hints to the OS on how to parse the x2APIC ID of a given CPU and assuming
the guest will assume 2 threads per core.

This series involves bringing x2APIC IDs into the migration stream, so
older guests keep operating as they used to and enhancing Xen+toolstack so
new guests get topology information consistent with their x2APIC IDs. As a
side effect of this, x2APIC IDs are now packed and don't have (unless under
a pathological case) gaps.

Further work ought to allow combining this topology configurations with
gang-scheduling of guest hyperthreads into affine physical hyperthreads.
For the time being it purposefully keeps the configuration of "1 socket" +
"1 thread per core" + "1 core per vCPU".

Patch 1: Includes x2APIC IDs in the migration stream. This allows Xen to
         reconstruct the right x2APIC IDs on migrated-in guests, and
         future-proofs itself in the face of x2APIC ID derivation changes.
Patch 2: Minor refactor to expose xc_cpu_policy in libxl
Patch 3: Refactors xen/lib/x86 to work on non-Xen freestanding environments
         (e.g: hvmloader)
Patch 4: Remove old assumptions about vcpu_id<->apic_id relationship in hvmloader
Patch 5: Add logic to derive x2APIC IDs given a CPU policy and vCPU IDs
Patch 6: Includes a simple topology generator for toolstack so new guests
         have topologically consistent information in CPUID

Alejandro Vallejo (6):
  xen/x86: Add initial x2APIC ID to the per-vLAPIC save area
  tools/xc: Add xc_cpu_policy to the public xenctrl.h header
  xen/x86: Refactor xen/lib/x86 so it can be linked in hvmloader
  tools/hvmloader: Use cpu_policy to determine APIC IDs
  xen/x86: Derive topologically correct x2APIC IDs from the policy
  xen/x86: Add topology generator

 tools/firmware/hvmloader/Makefile        |   7 ++
 tools/firmware/hvmloader/config.h        |   5 +-
 tools/firmware/hvmloader/hvmloader.c     |   6 +
 tools/firmware/hvmloader/util.c          |   3 +-
 tools/include/xenguest.h                 |  23 +++-
 tools/libacpi/build.c                    |  27 ++++-
 tools/libacpi/libacpi.h                  |   5 +-
 tools/libs/guest/xg_cpuid_x86.c          | 144 ++++++++++++++---------
 tools/libs/guest/xg_private.h            |  10 --
 tools/libs/light/libxl_x86_acpi.c        |  21 +++-
 tools/tests/cpu-policy/test-cpu-policy.c | 128 ++++++++++++++++++++
 xen/arch/x86/cpu-policy.c                |   6 +-
 xen/arch/x86/cpuid.c                     |  20 +---
 xen/arch/x86/domain.c                    |   3 +
 xen/arch/x86/hvm/vlapic.c                |  27 ++++-
 xen/arch/x86/include/asm/hvm/vlapic.h    |   2 +
 xen/include/public/arch-x86/hvm/save.h   |   2 +
 xen/include/xen/lib/x86/cpu-policy.h     |  16 +++
 xen/lib/x86/cpuid.c                      |  12 +-
 xen/lib/x86/policy.c                     |  74 ++++++++++++
 xen/lib/x86/private.h                    |   8 +-
 21 files changed, 442 insertions(+), 107 deletions(-)

-- 
2.34.1



             reply	other threads:[~2024-01-09 15:38 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-09 15:38 Alejandro Vallejo [this message]
2024-01-09 15:38 ` [PATCH 1/6] xen/x86: Add initial x2APIC ID to the per-vLAPIC save area Alejandro Vallejo
2024-03-19 16:20   ` Roger Pau Monné
2024-03-20  9:33     ` Roger Pau Monné
2024-03-25 16:56       ` Alejandro Vallejo
2024-03-25 15:44     ` Alejandro Vallejo
2024-03-25 16:45   ` Jan Beulich
2024-03-25 18:00     ` Alejandro Vallejo
2024-03-26  7:16       ` Jan Beulich
2024-01-09 15:38 ` [PATCH 2/6] tools/xc: Add xc_cpu_policy to the public xenctrl.h header Alejandro Vallejo
2024-03-19 17:55   ` Roger Pau Monné
2024-03-25 18:19     ` Alejandro Vallejo
2024-01-09 15:38 ` [PATCH 3/6] xen/x86: Refactor xen/lib/x86 so it can be linked in hvmloader Alejandro Vallejo
2024-03-25 16:55   ` Jan Beulich
2024-01-09 15:38 ` [PATCH 4/6] tools/hvmloader: Use cpu_policy to determine APIC IDs Alejandro Vallejo
2024-03-20  8:52   ` Roger Pau Monné
2024-03-25 17:00     ` Jan Beulich
2024-01-09 15:38 ` [PATCH 5/6] xen/x86: Derive topologically correct x2APIC IDs from the policy Alejandro Vallejo
2024-03-20 10:15   ` Roger Pau Monné
2024-05-01 16:05     ` Alejandro Vallejo
2024-03-26 16:41   ` Jan Beulich
2024-05-01 16:35     ` Alejandro Vallejo
2024-05-02  6:55       ` Jan Beulich
2024-05-02  6:57         ` Jan Beulich
2024-05-02 14:44           ` Alejandro Vallejo
2024-01-09 15:38 ` [PATCH 6/6] xen/x86: Add topology generator Alejandro Vallejo
2024-01-10 14:16   ` Alejandro Vallejo
2024-01-10 14:28     ` Jan Beulich
2024-03-20 10:29   ` Roger Pau Monné
2024-03-26 17:02   ` Jan Beulich
2024-05-01 17:06     ` Alejandro Vallejo
2024-05-02  7:13       ` Jan Beulich

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=20240109153834.4192-1-alejandro.vallejo@cloud.com \
    --to=alejandro.vallejo@cloud.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=anthony.perard@citrix.com \
    --cc=jbeulich@suse.com \
    --cc=jgross@suse.com \
    --cc=roger.pau@citrix.com \
    --cc=wl@xen.org \
    --cc=xen-devel@lists.xenproject.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 read-only IMAP folder(s) and NNTP newsgroup(s).