qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Chen Fan <chen.fan.fnst@cn.fujitsu.com>
To: Eduardo Habkost <ehabkost@redhat.com>
Cc: "Igor Mammedov" <imammedo@redhat.com>,
	qemu-devel@nongnu.org, "Andreas Färber" <afaerber@suse.de>
Subject: Re: [Qemu-devel] [RFC v3 2/3] i386: use CpuTopoInfo instead apic_id as argument for pc_new_cpu()
Date: Wed, 12 Mar 2014 13:53:05 +0800	[thread overview]
Message-ID: <1394603585.28706.7.camel@G08FNSTD131468> (raw)
In-Reply-To: <20140311180044.GC29227@otherpad.lan.raisama.net>

On Tue, 2014-03-11 at 15:00 -0300, Eduardo Habkost wrote:
> On Tue, Mar 11, 2014 at 06:58:53PM +0800, chen.fan.fnst wrote:
> > From: "chen.fan.fnst" <chen.fan.fnst@cn.fujitsu.com>
> > 
> > Signed-off-by: Chen Fan <chen.fan.fnst@cn.fujitsu.com>
> > ---
> >  hw/i386/pc.c      | 12 ++++++++----
> >  target-i386/cpu.c |  2 --
> >  target-i386/cpu.h |  3 +++
> >  3 files changed, 11 insertions(+), 6 deletions(-)
> > 
> > diff --git a/hw/i386/pc.c b/hw/i386/pc.c
> > index e715a33..c754042 100644
> > --- a/hw/i386/pc.c
> > +++ b/hw/i386/pc.c
> > @@ -927,11 +927,12 @@ void pc_acpi_smi_interrupt(void *opaque, int irq, int level)
> >      }
> >  }
> >  
> > -static X86CPU *pc_new_cpu(const char *cpu_model, int64_t apic_id,
> > +static X86CPU *pc_new_cpu(const char *cpu_model, CpuTopoInfo *topo,
> >                            DeviceState *icc_bridge, Error **errp)
> >  {
> >      X86CPU *cpu;
> >      Error *local_err = NULL;
> > +    uint32_t apic_id = apicid_from_topo_ids(smp_cores, smp_threads, topo);
> >  
> >      cpu = cpu_x86_create(cpu_model, icc_bridge, &local_err);
> >      if (local_err != NULL) {
> > @@ -956,6 +957,7 @@ void pc_hot_add_cpu(const int64_t id, Error **errp)
> >  {
> >      DeviceState *icc_bridge;
> >      int64_t apic_id = x86_cpu_apic_id_from_index(id);
> 
> With this patch, pc_new_cpu() is CPUTopoInfo-based, but cpu_exists() is
> apic_id-based. This requires apic_id to be calculated here, but
> pc_new_cpu() doesn't require it anymore.
> 
> We could make this more consistent, and avoid calculating the APIC ID in
> two different places. We are eveng using two different methods: here we
> use x86_cpu_apic_id_from_index() and pc_new_cpu() is using
> apicid_from_topo_ids().
> 
> Maybe we could simply move the cpu_exists() check inside pc_new_cpu()?
> 
> 
> > +    CpuTopoInfo topo;
> >  
> >      if (id < 0) {
> >          error_setg(errp, "Invalid CPU id: %" PRIi64, id);
> > @@ -976,7 +978,8 @@ void pc_hot_add_cpu(const int64_t id, Error **errp)
> >  
> >      icc_bridge = DEVICE(object_resolve_path_type("icc-bridge",
> >                                                   TYPE_ICC_BRIDGE, NULL));
> > -    pc_new_cpu(current_cpu_model, apic_id, icc_bridge, errp);
> > +    x86_topo_ids_from_idx(smp_cores, smp_threads, id, &topo);
> > +    pc_new_cpu(current_cpu_model, &topo, icc_bridge, errp);
> >  }
> >  
> >  void pc_cpus_init(const char *cpu_model, DeviceState *icc_bridge)
> > @@ -996,8 +999,9 @@ void pc_cpus_init(const char *cpu_model, DeviceState *icc_bridge)
> >      current_cpu_model = cpu_model;
> >  
> >      for (i = 0; i < smp_cpus; i++) {
> > -        cpu = pc_new_cpu(cpu_model, x86_cpu_apic_id_from_index(i),
> > -                         icc_bridge, &error);
> 
> x86_cpu_apic_id_from_index() has compat code to keep compatibility on
> older machine-types, and you are removing the compat behavior.
> 
> To keep the compat code isolated on pc_cpus_init() and keep pc_new_cpu()
> interface saner, we could do something like this, on pc_cpus_init()
> only:
> 
>     CPUTopoInfo topo;
>     x86_topo_ids_from_idx(cpu_index, &topo);
>     if (apic_id_compat) {
>         correct_apic_id = apicid_from_topo_ids(&topo);
>         apic_id = cpu_index;
>         if (apic_id != correct_apic_id) {
>             error_report("APIC IDs set in compatibility mode, "
>                          "CPU topology won't match the configuration");
>         }
>         // get_topo_from_apic_id() needs to be written:
>         get_topo_from_apic_id(apic_id, &topo);
>         // just in case:
>         assert(apicid_from_topo_ids(&topo) == apic_id);
>     }
I think we can write new x86_cpu_topo_ids_from_index() to do this
 compat work. I think I can make it soon.

> 
> And on pc_hot_add_cpu():
> 
>     if (apic_id_compat) {
>         error_setg(errp, "CPU hotplug is not supported on this machine");
>         return;
>     }
cpu hotplug supported since pc 1.5, and apic_id_compat is below pc 1.3,
so I think this must be unnecessary.

Thanks,
Chen


> 
> 
> 
> > +        CpuTopoInfo topo;
> > +        x86_topo_ids_from_idx(smp_cores, smp_threads, i, &topo);
> > +        cpu = pc_new_cpu(cpu_model, &topo, icc_bridge, &error);
> >          if (error) {
> >              error_report("%s", error_get_pretty(error));
> >              error_free(error);
> > diff --git a/target-i386/cpu.c b/target-i386/cpu.c
> > index 0e8812a..3a5df33 100644
> > --- a/target-i386/cpu.c
> > +++ b/target-i386/cpu.c
> > @@ -23,8 +23,6 @@
> >  
> >  #include "cpu.h"
> >  #include "sysemu/kvm.h"
> > -#include "sysemu/cpus.h"
> > -#include "topology.h"
> >  
> >  #include "qemu/option.h"
> >  #include "qemu/config-file.h"
> > diff --git a/target-i386/cpu.h b/target-i386/cpu.h
> > index 0014acc..8bc7b45 100644
> > --- a/target-i386/cpu.h
> > +++ b/target-i386/cpu.h
> > @@ -22,6 +22,9 @@
> >  #include "config.h"
> >  #include "qemu-common.h"
> >  
> > +#include "sysemu/cpus.h"
> > +#include "topology.h"
> > +
> >  #ifdef TARGET_X86_64
> >  #define TARGET_LONG_BITS 64
> >  #else
> > -- 
> > 1.8.1.4
> > 
> 

  reply	other threads:[~2014-03-12  6:22 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-14  9:27 [Qemu-devel] [RFC 0/3] fix migration issues after hotplug a discontinuous cpuid Chen Fan
2014-01-14  9:27 ` [Qemu-devel] [RFC 1/3] target-i386: moving registers of vmstate from cpu_exec_init() to x86_cpu_realizefn() Chen Fan
2014-01-14 10:40   ` Igor Mammedov
2014-01-15 12:24     ` Chen Fan
2014-01-15 14:37       ` Igor Mammedov
2014-01-17 19:13         ` [Qemu-devel] Exposing and calculating CPU APIC IDs (was Re: [RFC 1/3] target-i386: moving registers of vmstate from cpu_exec_init() to x86_cpu_realizefn()) Eduardo Habkost
2014-01-20 12:29           ` Igor Mammedov
2014-01-21  7:12             ` Chen Fan
2014-01-21  9:31               ` Igor Mammedov
2014-01-21  9:51                 ` Chen Fan
2014-01-21 10:10                   ` Andreas Färber
2014-02-13  6:14                     ` Chen Fan
2014-02-13  9:44                       ` Igor Mammedov
2014-02-17 10:24                         ` Chen Fan
2014-02-17 10:43                           ` Igor Mammedov
2014-02-25  9:07                             ` [Qemu-devel] [PATCH 0/2][RFC] prebuild cpu QOM tree /machine/node/socket/core/thread/ Chen Fan
2014-02-25  9:07                               ` [Qemu-devel] [PATCH 1/2][RFC] qom: introduce cpu QOM hierarchy tree /machine/node/socket/core/thread/cpu Chen Fan
2014-02-25 13:35                                 ` Eric Blake
2014-02-26  1:05                                   ` Chen Fan
2014-02-26 18:52                                 ` Eduardo Habkost
2014-02-28  2:01                                   ` Chen Fan
2014-03-04 10:50                                     ` [Qemu-devel] [RFC v2 0/2] prebuild cpu QOM tree /machine/node/socket/core/thread/ Chen Fan
2014-03-04 10:50                                       ` [Qemu-devel] [RFC v2 1/2] i386: introduce "struct X86TopoInfo" for saving cpu topology information Chen Fan
2014-03-04 19:35                                         ` Eduardo Habkost
2014-03-05  1:33                                           ` Chen Fan
2014-03-11 10:58                                             ` [Qemu-devel] [RFC v3 0/3] prebuild cpu QOM tree /machine/node/socket/core ->link-cpu chen.fan.fnst
2014-03-11 10:58                                               ` [Qemu-devel] [RFC v3 1/3] cpu: introduce CpuTopoInfo structure for argument simplification chen.fan.fnst
2014-03-11 17:10                                                 ` Eduardo Habkost
2014-03-11 10:58                                               ` [Qemu-devel] [RFC v3 2/3] i386: use CpuTopoInfo instead apic_id as argument for pc_new_cpu() chen.fan.fnst
2014-03-11 18:00                                                 ` Eduardo Habkost
2014-03-12  5:53                                                   ` Chen Fan [this message]
2014-03-12  7:51                                                   ` [Qemu-devel] [RFC v4 0/3] prebuild cpu QOM tree /machine/node/socket/core ->link-cpu Chen Fan
2014-03-12  7:51                                                     ` [Qemu-devel] [RFC v4 1/3] cpu: introduce CpuTopoInfo structure for argument simplification Chen Fan
2014-03-12 15:36                                                       ` Eduardo Habkost
2014-03-19  8:53                                                         ` [Qemu-devel] [PATCH v1 0/4] prebuild cpu QOM tree /machine/node/socket/core ->link-cpu Chen Fan
2014-03-19  8:53                                                           ` [Qemu-devel] [PATCH v1 1/4] cpu: introduce CpuTopoInfo structure for argument simplification Chen Fan
2014-03-19  8:53                                                           ` [Qemu-devel] [PATCH v1 2/4] i386: use CpuTopoInfo instead apic_id as argument for pc_new_cpu() Chen Fan
2014-03-19 19:27                                                             ` Eduardo Habkost
2014-03-20  6:25                                                               ` Chen Fan
2014-03-19  8:53                                                           ` [Qemu-devel] [PATCH v1 3/4] topo unit-test: update Unit tests to test-x86-cpuid.c Chen Fan
2014-03-19  8:53                                                           ` [Qemu-devel] [PATCH v1 4/4] i386: introduce cpu QOM hierarchy tree Chen Fan
2014-03-19 12:00                                                           ` [Qemu-devel] [PATCH v1 0/4] prebuild cpu QOM tree /machine/node/socket/core ->link-cpu Eric Blake
2014-03-20  0:55                                                             ` Chen Fan
2014-03-12  7:51                                                     ` [Qemu-devel] [RFC v4 2/3] i386: use CpuTopoInfo instead apic_id as argument for pc_new_cpu() Chen Fan
2014-03-12 15:39                                                       ` Eduardo Habkost
2014-03-12  7:51                                                     ` [Qemu-devel] [RFC v4 3/3] i386: introduce cpu QOM hierarchy tree Chen Fan
2014-03-11 10:58                                               ` [Qemu-devel] [RFC v3 " chen.fan.fnst
2014-03-04 10:50                                       ` [Qemu-devel] [RFC v2 2/2] " Chen Fan
2014-02-25  9:07                               ` [Qemu-devel] [PATCH 2/2][RFC] cpu: link each new cpu to QOM tree /machine/node/socket/core/thread/cpu respectively Chen Fan
2014-02-26 19:11                                 ` Eduardo Habkost
2014-02-13 10:00                     ` [Qemu-devel] Exposing and calculating CPU APIC IDs (was Re: [RFC 1/3] target-i386: moving registers of vmstate from cpu_exec_init() to x86_cpu_realizefn()) Igor Mammedov
2014-01-14  9:27 ` [Qemu-devel] [RFC 2/3] target-i386: add -smp X,apics=0x option Chen Fan
2014-02-17 18:37   ` Eric Blake
2014-02-18  1:49     ` Chen Fan
2014-01-14  9:27 ` [Qemu-devel] [RFC 3/3] target-i386: add qmp command 'query-cpus' to display apic_id Chen Fan
2014-02-17 18:37   ` Eric Blake

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=1394603585.28706.7.camel@G08FNSTD131468 \
    --to=chen.fan.fnst@cn.fujitsu.com \
    --cc=afaerber@suse.de \
    --cc=ehabkost@redhat.com \
    --cc=imammedo@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).