qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eduardo Habkost <ehabkost@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Igor Mammedov" <imammedo@redhat.com>,
	"Andreas Färber" <afaerber@suse.de>,
	"Gleb Natapov" <gleb@redhat.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>
Subject: [Qemu-devel] [RFC 00/15] attempt to fix CPU topology info on CPU APIC IDs
Date: Tue,  7 Aug 2012 16:56:38 -0300	[thread overview]
Message-ID: <1344369413-9053-1-git-send-email-ehabkost@redhat.com> (raw)

First, the bug description:

The CPU APIC IDs generated by QEMU are broken if the number of cores-per-socket
or threads-per-core are not powers of 2, as the bits on the APIC ID do not
correspond to what's expected to reflect the CPU sockets/cores/threads
topology[1].

[1] http://software.intel.com/en-us/articles/intel-64-architecture-processor-topology-enumeration/


This is an attempt to fix it, but there were some obstacles on the way:

1) The NUMA fw_cfg interface requires the full topology information to be
available even for hotplug CPUs that don't exist yet, so we need to be able to
calculate the APIC ID solely from the CPU index.

2) CPU objects are not qdev objects (yet).

3) We don't have a "list CPUs" object (yet), so we don't have an object where
a compatibility global property could be set, and that would be responsible for
calculating the APIC IDs.

That said, the patches are organized as follows:

 - Patches 1 to 3 are just code movements or smaller fixes to prepare for the
   actual fix. They should be safe to be applied right now.
 - Patches 4 to 6 addresses issue #1 above.
 - Patches 7 to 12 change the global property handling code to make it at least
   possible to use a global property without requiring QOM or qdev (due to
   issues #2 and #3 above). I expect it to be controversial and I would like to
   get some feedback.
 - Patches 13 and 14 are the actual fix, that changes the APIC ID calculation to
   match the requested CPU topology, and use a "SMP.contiguous_apic_ids" global
   property to keep compatibility on pc-1.1 and older machine-types.

The fix depends on commit 008c1fc5bd4f1c545c38e07242ad676830ea7785 of SeaBIOS,
that allows CPU APIC IDs to be non-contiguous. However, older SeaBIOS verions
should still work, as long as cores/threads are powers of 2 or you use the
"pc-1.1" machine-type (or older).

I am aware of the coding style warnings from checkpatch.pl (mainly "line over 80
characters" warnings), and I plan to fix them in the final version of the fix.


Eduardo Habkost (15):
  cpus.h: include cpu-common.h
  hw/apic.c: rename bit functions to not conflict with bitops.h (v2)
  kvm: set vcpu_id to APIC ID instead of CPU index
  i386: create apic_id_for_cpu() function (v2)
  remove FW_CFG_MAX_CPUS from fw_cfg_init()
  pc: set FW_CFG data based on APIC ID calculation
  qdev: allow qdev_prop_parse() to report errors
  move global properties code to global-properties.c
  isolate qdev-independent parts of qdev_prop_set_globals()
  create object_prop_set_globals()
  rename qdev_prop_register_global_list to qemu_globals_register_list
  create qemu_global_get() function
  tests: support target-specific unit tests
  i386: topology & APIC ID utility functions (v2)
  generate APIC IDs according to CPU topology (v2)

 Makefile.objs          |   1 +
 cpus.h                 |   2 +
 global-properties.c    |  88 ++++++++++++++++++++++++++++++
 hw/apic.c              |  35 ++++++------
 hw/fw_cfg.c            |   1 -
 hw/pc.c                |  23 +++++---
 hw/pc_piix.c           |   4 ++
 hw/ppc_newworld.c      |   1 +
 hw/ppc_oldworld.c      |   1 +
 hw/qdev-monitor.c      |   6 ++-
 hw/qdev-properties.c   |  67 ++---------------------
 hw/qdev.h              |  18 +++++--
 hw/sun4m.c             |   3 ++
 hw/sun4u.c             |   1 +
 kvm-all.c              |   2 +-
 target-i386/cpu.c      |  40 +++++++++++++-
 target-i386/cpu.h      |  17 ++++++
 target-i386/topology.h | 144 +++++++++++++++++++++++++++++++++++++++++++++++++
 tests/.gitignore       |   1 +
 tests/Makefile         |  19 +++++--
 tests/test-x86-cpuid.c | 108 +++++++++++++++++++++++++++++++++++++
 vl.c                   |   6 +--
 22 files changed, 488 insertions(+), 100 deletions(-)
 create mode 100644 global-properties.c
 create mode 100644 target-i386/topology.h
 create mode 100644 tests/test-x86-cpuid.c

-- 
1.7.11.2

             reply	other threads:[~2012-08-07 19:56 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-07 19:56 Eduardo Habkost [this message]
2012-08-07 19:56 ` [Qemu-devel] [RFC 01/15] cpus.h: include cpu-common.h Eduardo Habkost
2012-08-13 19:06   ` Igor Mammedov
2012-08-07 19:56 ` [Qemu-devel] [RFC 02/15] hw/apic.c: rename bit functions to not conflict with bitops.h (v2) Eduardo Habkost
2012-08-13 19:08   ` Igor Mammedov
2012-08-07 19:56 ` [Qemu-devel] [RFC 03/15] kvm: set vcpu_id to APIC ID instead of CPU index Eduardo Habkost
2012-08-13 19:16   ` Igor Mammedov
2012-08-13 19:59     ` Eduardo Habkost
2012-08-07 19:56 ` [Qemu-devel] [RFC 04/15] i386: create apic_id_for_cpu() function (v2) Eduardo Habkost
2012-08-07 19:56 ` [Qemu-devel] [RFC 05/15] remove FW_CFG_MAX_CPUS from fw_cfg_init() Eduardo Habkost
2012-08-07 19:56 ` [Qemu-devel] [RFC 06/15] pc: set FW_CFG data based on APIC ID calculation Eduardo Habkost
2012-08-13 19:52   ` Igor Mammedov
2012-08-13 20:01     ` Eduardo Habkost
2012-08-07 19:56 ` [Qemu-devel] [RFC 07/15] qdev: allow qdev_prop_parse() to report errors Eduardo Habkost
2012-08-07 19:56 ` [Qemu-devel] [RFC 08/15] move global properties code to global-properties.c Eduardo Habkost
2012-08-07 19:56 ` [Qemu-devel] [RFC 09/15] isolate qdev-independent parts of qdev_prop_set_globals() Eduardo Habkost
2012-08-07 19:56 ` [Qemu-devel] [RFC 10/15] create object_prop_set_globals() Eduardo Habkost
2012-08-07 19:56 ` [Qemu-devel] [RFC 11/15] rename qdev_prop_register_global_list to qemu_globals_register_list Eduardo Habkost
2012-08-07 19:56 ` [Qemu-devel] [RFC 12/15] create qemu_global_get() function Eduardo Habkost
2012-08-07 19:56 ` [Qemu-devel] [RFC 13/15] tests: support target-specific unit tests Eduardo Habkost
2012-08-07 19:56 ` [Qemu-devel] [RFC 14/15] i386: topology & APIC ID utility functions (v2) Eduardo Habkost
2012-08-08 18:57   ` Blue Swirl
2012-08-08 19:06     ` Eduardo Habkost
2012-08-14 17:03   ` Igor Mammedov
2012-08-07 19:56 ` [Qemu-devel] [RFC 15/15] generate APIC IDs according to CPU topology (v2) 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=1344369413-9053-1-git-send-email-ehabkost@redhat.com \
    --to=ehabkost@redhat.com \
    --cc=afaerber@suse.de \
    --cc=gleb@redhat.com \
    --cc=imammedo@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).