From: Igor Mammedov <imammedo@redhat.com>
To: Eduardo Habkost <ehabkost@redhat.com>
Cc: "Paolo Bonzini" <pbonzini@redhat.com>,
qemu-devel@nongnu.org, "Andreas Färber" <afaerber@suse.de>
Subject: Re: [Qemu-devel] [PATCH 27/27] pc: generate APIC IDs according to CPU topology
Date: Thu, 1 Nov 2012 15:46:08 +0100 [thread overview]
Message-ID: <20121101154608.19b38695@nial.usersys.redhat.com> (raw)
In-Reply-To: <1351101001-14589-28-git-send-email-ehabkost@redhat.com>
On Wed, 24 Oct 2012 15:50:01 -0200
Eduardo Habkost <ehabkost@redhat.com> wrote:
> This keeps compatibility on machine-types pc-1.2 and older, and prints a
> warning in case the requested configuration won't get the correct
> topology.
>
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> ---
> Changes v1 -> v2:
> - Move code to cpu.c
> - keep using cpu_index on *-user
> - Use SMP.contiguous_apic_ids global property
> - Prints warning in case the compatibility mode will expose incorrect
> topology
>
> Changes v2 -> v3:
> - Now all code is inside hw/pc.c
> - Use a real "PC" class and a "contiguous_apic_ids" property
>
> Changes v3 -> v4:
> - Instead of using a global property, use a separate machine init
> function and a PCInitArgs field, to implement compatibility mode
> - Use error_report() instead of fprintf(stderr) for the warning
> - Use a field on PCInitArgs instead of a static variable to check
> if warning was already printed
> ---
> hw/pc.c | 19 +++++++++++++++----
> hw/pc.h | 6 ++++++
> hw/pc_piix.c | 1 +
> 3 files changed, 22 insertions(+), 4 deletions(-)
>
> diff --git a/hw/pc.c b/hw/pc.c
> index 8895087..3d08271 100644
> --- a/hw/pc.c
> +++ b/hw/pc.c
> @@ -51,6 +51,8 @@
> #include "exec-memory.h"
> #include "arch_init.h"
> #include "bitmap.h"
> +#include "topology.h"
> +#include "cpus.h"
>
> /* debug PC/ISA interrupts */
> //#define DEBUG_IRQ
> @@ -562,10 +564,19 @@ static void bochs_bios_write(void *opaque, uint32_t
> addr, uint32_t val) */
> static uint32_t apic_id_for_cpu(PCInitArgs *args, int cpu_index)
> {
> - /* right now APIC ID == CPU index. this will eventually change to use
> - * the CPU topology configuration properly
> - */
> - return cpu_index;
> + uint32_t correct_id;
> +
> + correct_id = topo_apicid_for_cpu(smp_cores, smp_threads, cpu_index);
> + if (args->compat_contiguous_apic_ids) {
> + if (cpu_index != correct_id && !args->apic_id_warned) {
> + error_report("APIC IDs set in compatibility mode, "
> + "CPU topology won't match the configuration");
> + args->apic_id_warned = true;
> + }
> + return cpu_index;
> + } else {
> + return correct_id;
> + }
> }
>
> int e820_add_entry(uint64_t address, uint64_t length, uint32_t type)
> diff --git a/hw/pc.h b/hw/pc.h
> index 53883f5..a14944a 100644
> --- a/hw/pc.h
> +++ b/hw/pc.h
> @@ -81,6 +81,12 @@ typedef struct PCInitArgs {
> QEMUMachineInitArgs *qemu_args;
> bool pci_enabled;
> bool kvmclock_enabled;
> + /* Enable compatibility (buggy) APIC ID generation, that keep APIC IDs
> + * contiguous
> + */
> + bool compat_contiguous_apic_ids;
> + /* Warning message about incorrect APIC ID was shown */
> + bool apic_id_warned;
>
> /* Memory regions & sizes: */
> MemoryRegion *system_memory;
> diff --git a/hw/pc_piix.c b/hw/pc_piix.c
> index 57a3228..79a54e6 100644
> --- a/hw/pc_piix.c
> +++ b/hw/pc_piix.c
> @@ -298,6 +298,7 @@ static void pc_init_pci_v1_2(QEMUMachineInitArgs *args)
> .qemu_args = args,
> .pci_enabled = true,
> .kvmclock_enabled = true,
> + .compat_contiguous_apic_ids = true,
I suppose libvirt/whatever would know that it's starting v1_2 machine, so it
would be able to provide valid APIC ID at hotplug time. But it looks fragile.
As Anthony once suggested, perhaps we could model sockets as links.
/machine/cpu[apic_id..]
So machine at level we would have a pre-defined topology with apic_id in link
name serving as initial apic_id selector pins in socket.
Pre-allocate them (sockets) in pc_cpus_init() for all possible CPUs and when
creating CPUs, apic_id property setter could accept link path and get
appropriate apic_id from link name and assign itself to a specified link.
It would be friendly with hot-plug and
-device X86CPU,id='/machine/cpu[apic_id]' cmdline if we ever decide in future
to create CPUs this way.
> };
> pc_init1(&pc_args);
> }
next prev parent reply other threads:[~2012-11-01 14:54 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-24 17:49 [Qemu-devel] Subject: [PATCH 00/27] Fix APIC-ID-based CPU topology, take 3 Eduardo Habkost
2012-10-24 17:49 ` [Qemu-devel] [PATCH 01/27] move I/O-related definitions from qemu-common.h to a new header (qemu-stdio.h) Eduardo Habkost
2012-10-24 17:49 ` [Qemu-devel] [PATCH 02/27] cpus.h: include qemu-stdio.h Eduardo Habkost
2012-10-24 17:49 ` [Qemu-devel] [PATCH 03/27] hw/apic.c: rename bit functions to not conflict with bitops.h Eduardo Habkost
2012-10-24 17:49 ` [Qemu-devel] [PATCH 04/27] target-i386: initialize APIC at CPU level Eduardo Habkost
2012-10-24 17:49 ` [Qemu-devel] [PATCH 05/27] kvm: create kvm_arch_vcpu_id() function Eduardo Habkost
2012-10-24 17:49 ` [Qemu-devel] [PATCH 06/27] target-i386: kvm: set vcpu_id to APIC ID instead of CPU index Eduardo Habkost
2012-10-24 17:49 ` [Qemu-devel] [PATCH 07/27] pc: pc_init1(): always use rom_memory on pc_memory_init() call Eduardo Habkost
2012-10-24 17:49 ` [Qemu-devel] [PATCH 08/27] pc: pc_init1(): remove MemoryRegion arguments Eduardo Habkost
2012-10-24 17:49 ` [Qemu-devel] [PATCH 09/27] pc: pc_init1(): get QEMUMachineInitArgs argument Eduardo Habkost
2012-10-24 17:49 ` [Qemu-devel] [PATCH 10/27] pc: create PCInitArgs struct Eduardo Habkost
2012-10-24 17:49 ` [Qemu-devel] [PATCH 11/27] pc: add PC_DEFAULT_CPU_MODEL #define Eduardo Habkost
2012-10-24 17:49 ` [Qemu-devel] [PATCH 12/27] pc: add PCInitArgs parameter to pc_cpus_init() Eduardo Habkost
2012-10-24 17:49 ` [Qemu-devel] [PATCH 13/27] pc: pass PCInitArgs struct to pc_memory_init() Eduardo Habkost
2012-10-24 17:49 ` [Qemu-devel] [PATCH 14/27] pc: use FWCfgState* instead of void* for fw_cfg data Eduardo Habkost
2012-10-24 17:49 ` [Qemu-devel] [PATCH 15/27] pc: rename bochs_bios_init() to pc_bios_init() Eduardo Habkost
2012-10-24 17:49 ` [Qemu-devel] [PATCH 16/27] pc: pass PCInitArgs struct " Eduardo Habkost
2012-10-24 17:49 ` [Qemu-devel] [PATCH 17/27] xen_machine_pv: use cpu_init() instead of cpu_x86_init() Eduardo Habkost
2012-10-24 17:49 ` [Qemu-devel] [PATCH 18/27] pc: isolate the code that create CPUs Eduardo Habkost
2012-10-24 17:49 ` [Qemu-devel] [PATCH 19/27] cpu_x86_init: check for x86_cpu_realize() errors Eduardo Habkost
2012-10-24 17:49 ` [Qemu-devel] [PATCH 20/27] target-i386: do not call x86_cpu_realize() on cpu_x86_init() Eduardo Habkost
2012-10-31 16:32 ` Igor Mammedov
2012-10-31 16:43 ` Andreas Färber
2012-10-31 17:10 ` Eduardo Habkost
2012-11-01 12:53 ` Igor Mammedov
2012-10-31 17:01 ` Eduardo Habkost
2012-10-24 17:49 ` [Qemu-devel] [PATCH 21/27] fw_cfg: remove FW_CFG_MAX_CPUS from fw_cfg_init() Eduardo Habkost
2012-10-24 17:49 ` [Qemu-devel] [PATCH 22/27] pc: set CPU APIC ID explicitly Eduardo Habkost
2012-11-01 14:04 ` Igor Mammedov
2012-11-01 14:30 ` Eduardo Habkost
2012-11-01 14:50 ` Igor Mammedov
2012-10-24 17:49 ` [Qemu-devel] [PATCH 23/27] pc: set fw_cfg data based on APIC ID calculation Eduardo Habkost
2012-10-24 17:49 ` [Qemu-devel] [PATCH 24/27] tests: support target-specific unit tests Eduardo Habkost
2012-10-24 17:49 ` [Qemu-devel] [PATCH 25/27] target-i386: topology & APIC ID utility functions Eduardo Habkost
2012-10-24 17:50 ` [Qemu-devel] [PATCH 26/27] pc: create separate init function for pc-1.3 Eduardo Habkost
2012-10-24 18:12 ` Michael S. Tsirkin
2012-10-25 13:23 ` Eduardo Habkost
2012-10-24 17:50 ` [Qemu-devel] [PATCH 27/27] pc: generate APIC IDs according to CPU topology Eduardo Habkost
2012-11-01 14:46 ` Igor Mammedov [this message]
2012-11-01 15:16 ` Eduardo Habkost
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=20121101154608.19b38695@nial.usersys.redhat.com \
--to=imammedo@redhat.com \
--cc=afaerber@suse.de \
--cc=ehabkost@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.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).