qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Andreas Färber" <afaerber@suse.de>
To: Igor Mammedov <imammedo@redhat.com>
Cc: Chen Fan <chen.fan.fnst@cn.fujitsu.com>, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [RFC qom-cpu v2 1/8] apic: remove apic_no from apic_init_common()
Date: Tue, 10 Sep 2013 14:16:25 +0200	[thread overview]
Message-ID: <522F0D99.5050508@suse.de> (raw)
In-Reply-To: <20130910140926.091ea307@nial.usersys.redhat.com>

Am 10.09.2013 14:09, schrieb Igor Mammedov:
> On Tue, 10 Sep 2013 17:43:41 +0800
> Chen Fan <chen.fan.fnst@cn.fujitsu.com> wrote:
> 
>> the 'apic_no' is increased by one when initialize/create a vCPU each time,
>> which causes APICCommonState s->idx always is increased.
>> but if we want to re-add a vCPU after removing a vCPU, we need to re-use the
>> vacant s->idx which the corresponding vCPU had been removed. 
>> so we could use the unique cpu apic_id instead of the progressive s->idx.
>>
>> Signed-off-by: Chen Fan <chen.fan.fnst@cn.fujitsu.com>
>> ---
>>  hw/intc/apic_common.c | 4 +---
>>  target-i386/cpu.c     | 1 +
>>  2 files changed, 2 insertions(+), 3 deletions(-)
>>
>> diff --git a/hw/intc/apic_common.c b/hw/intc/apic_common.c
>> index a0beb10..5568621 100644
>> --- a/hw/intc/apic_common.c
>> +++ b/hw/intc/apic_common.c
>> @@ -289,13 +289,11 @@ static int apic_init_common(ICCDevice *dev)
>>      APICCommonState *s = APIC_COMMON(dev);
>>      APICCommonClass *info;
>>      static DeviceState *vapic;
>> -    static int apic_no;
>>      static bool mmio_registered;
>>  
>> -    if (apic_no >= MAX_APICS) {
>> +    if (s->idx >= MAX_APICS) {
>>          return -1;
>>      }
>> -    s->idx = apic_no++;
>>  
>>      info = APIC_COMMON_GET_CLASS(s);
>>      info->init(s);
>> diff --git a/target-i386/cpu.c b/target-i386/cpu.c
>> index 42c5de0..2b99683 100644
>> --- a/target-i386/cpu.c
>> +++ b/target-i386/cpu.c
>> @@ -2322,6 +2322,7 @@ static void x86_cpu_apic_create(X86CPU *cpu, Error **errp)
>>      /* TODO: convert to link<> */
>>      apic = APIC_COMMON(env->apic_state);
>>      apic->cpu = cpu;
>> +    apic->idx = env->cpuid_apic_id;
> earlier here we set:
>  qdev_prop_set_uint8(env->apic_state, "id", env->cpuid_apic_id);
> so apic->idx = env->cpuid_apic_id is redundant.
> 
> it would be better to search by apic->id and preferably replace O(MAX_APIC) scans with
> a faster approach since for TCG iqr delivery might be a hot path, dropping MAX_APIC
> altogether and using dynamic present APICs list.

Independent of that, the recent removal of X86_CPU() cast from
x86_env_get_cpu() should allow us to finally tackle the TODO above,
moving apic_state field from CPUX86State to X86CPU.

Andreas

> 
>>  }
>>  
>>  static void x86_cpu_apic_realize(X86CPU *cpu, Error **errp)
> 


-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg

  reply	other threads:[~2013-09-10 12:16 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-10  9:43 [Qemu-devel] [RFC qom-cpu v2 0/8] i386: add cpu hot remove support Chen Fan
2013-09-10  9:43 ` [Qemu-devel] [RFC qom-cpu v2 1/8] apic: remove apic_no from apic_init_common() Chen Fan
2013-09-10 12:09   ` Igor Mammedov
2013-09-10 12:16     ` Andreas Färber [this message]
2013-09-11  5:37       ` chenfan
2013-09-10  9:43 ` [Qemu-devel] [RFC qom-cpu v2 2/8] x86: add x86_cpu_unrealizefn() for cpu apic remove Chen Fan
2013-09-10 12:26   ` Andreas Färber
2013-09-10  9:43 ` [Qemu-devel] [RFC qom-cpu v2 3/8] qmp: add 'cpu-del' command support Chen Fan
2013-09-10 15:52   ` Eric Blake
2013-09-11  2:32     ` chenfan
2013-09-10  9:43 ` [Qemu-devel] [RFC qom-cpu v2 4/8] qom cpu: rename variable 'cpu_added_notifier' to 'cpu_hotplug_notifier' Chen Fan
2013-09-10  9:43 ` [Qemu-devel] [RFC qom-cpu v2 5/8] qom cpu: add UNPLUG cpu notifier support Chen Fan
2013-09-10  9:43 ` [Qemu-devel] [RFC qom-cpu v2 6/8] i386: implement pc interface pc_hot_del_cpu() Chen Fan
2013-09-10  9:43 ` [Qemu-devel] [RFC qom-cpu v2 7/8] piix4: implement function cpu_status_write() for vcpu ejection Chen Fan
2013-09-10  9:43 ` [Qemu-devel] [RFC qom-cpu v2 8/8] cpus: release allocated vCPU objects Chen Fan

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=522F0D99.5050508@suse.de \
    --to=afaerber@suse.de \
    --cc=chen.fan.fnst@cn.fujitsu.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).