qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eduardo Habkost <ehabkost@redhat.com>
To: Igor Mammedov <imammedo@redhat.com>
Cc: pbonzini@redhat.com, qemu-devel@nongnu.org, mst@redhat.com
Subject: Re: [Qemu-devel] [PATCH 2/9] machine: introduce MachineClass.possible_cpu_arch_ids() hook
Date: Fri, 5 Feb 2016 13:50:05 -0200	[thread overview]
Message-ID: <20160205155005.GU26314@thinpad.lan.raisama.net> (raw)
In-Reply-To: <20160205163946.0422a7c3@nial.brq.redhat.com>

On Fri, Feb 05, 2016 at 04:39:46PM +0100, Igor Mammedov wrote:
> On Fri, 5 Feb 2016 13:04:26 -0200
> Eduardo Habkost <ehabkost@redhat.com> wrote:
> 
> > On Thu, Feb 04, 2016 at 12:47:28PM +0100, Igor Mammedov wrote:
> > > on x86 currently range 0..max_cpus is used to generate
> > > architecture-dependent CPU ID (APIC Id) for each present
> > > and possible CPUs. However architecture-dependent CPU IDs
> > > list could be sparse and code that needs to enumerate
> > > all IDs (ACPI) ended up doing guess work enumerating all
> > > possible and impossible IDs up to
> > >   apic_id_limit = x86_cpu_apic_id_from_index(max_cpus).
> > > 
> > > That leads to creation of MADT entries and Processor
> > > objects in ACPI tables for not possible CPUs.
> > > Fix it by allowing board specify a concrete list of
> > > CPU IDs accourding its own rules (which for x86 depends
> > > on topology). So that code that needs this list could
> > > request it from board instead of trying to figure out
> > > what IDs are correct on its own.
> > > 
> > > Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> > > ---
> > >  hw/i386/pc.c        | 16 ++++++++++++++++
> > >  include/hw/boards.h | 18 ++++++++++++++++++
> > >  2 files changed, 34 insertions(+)
> > > 
> > > diff --git a/hw/i386/pc.c b/hw/i386/pc.c
> > > index d72246d..2fd8fc8 100644
> > > --- a/hw/i386/pc.c
> > > +++ b/hw/i386/pc.c
> > > @@ -1946,6 +1946,21 @@ static unsigned pc_cpu_index_to_socket_id(unsigned cpu_index)
> > >      return topo.pkg_id;
> > >  }
> > >  
> > > +static GArray *pc_possible_cpu_arch_ids(void)
> > > +{
> > > +    int i;
> > > +    GArray *list = g_array_new (FALSE, FALSE, sizeof (CPUArchId));
> > > +
> > > +    for (i = 0; i < max_cpus; i++) {
> > > +        CPUArchId val;
> > > +
> > > +        val.arch_id = x86_cpu_apic_id_from_index(i);
> > > +        val.cpu = qemu_get_cpu_by_arch_id(val.arch_id);
> > > +        g_array_append_val(list, val);  
> > 
> > What about letting callers call qemu_get_cpu_by_arch_id() only if
> > they really need it?
> > 
> > If you do that, you just need to return an uint64_t array, and
> > there's no need for struct CPUArchId.
> So far all callers that would use it would need to call
> qemu_get_cpu_by_arch_id() so doing it in one place (here)
> seems better than to duplicating that call over the code.

I see only one place using CPUArchId.cpu. All other callers don't
use the field.

Simply replacing "id.cpu" with "qemu_get_cpu_by_arch_id(id)" in
one line seems worth it, if it's going to save us the trouble of
defining another struct and avoid lots of unnecessary calls to
qemu_get_cpu_by_arch_id() (that loops through all CPUs every time
it's called).

-- 
Eduardo

  reply	other threads:[~2016-02-05 15:50 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-04 11:47 [Qemu-devel] [PATCH 0/9] pc: do not create invalid MADT.LAPIC/Processor entries Igor Mammedov
2016-02-04 11:47 ` [Qemu-devel] [PATCH 2/9] machine: introduce MachineClass.possible_cpu_arch_ids() hook Igor Mammedov
2016-02-04 12:18   ` Marcel Apfelbaum
2016-02-04 13:36     ` Igor Mammedov
2016-02-05 14:13       ` Eduardo Habkost
2016-02-05 14:49         ` Igor Mammedov
2016-02-05 15:04   ` Eduardo Habkost
2016-02-05 15:39     ` Igor Mammedov
2016-02-05 15:50       ` Eduardo Habkost [this message]
2016-02-05 16:29         ` Igor Mammedov
2016-02-04 11:47 ` [Qemu-devel] [PATCH 3/9] pc: acpi: cleanup qdev_get_machine() calls Igor Mammedov
2016-02-04 12:21   ` Marcel Apfelbaum
2016-02-04 11:47 ` [Qemu-devel] [PATCH 4/9] pc: acpi: SRAT: create only valid processor lapic entries Igor Mammedov
2016-02-05 15:07   ` Eduardo Habkost
2016-02-04 11:47 ` [Qemu-devel] [PATCH 5/9] pc: acpi: create Processor and Notify objects only for valid lapics Igor Mammedov
2016-02-05 15:17   ` Eduardo Habkost
2016-02-05 15:43     ` Igor Mammedov
2016-02-04 11:47 ` [Qemu-devel] [PATCH 6/9] pc: acpi: create MADT.lapic entries " Igor Mammedov
2016-02-05 15:28   ` Eduardo Habkost
2016-02-05 16:14     ` Igor Mammedov
2016-02-11 16:11       ` Eduardo Habkost
2016-02-12 10:04         ` Igor Mammedov
2016-02-04 11:47 ` [Qemu-devel] [PATCH 7/9] pc: acpi: drop not needed intermediate bitmap cpu->found_cpus Igor Mammedov
2016-02-05 15:39   ` Eduardo Habkost
2016-02-05 16:19     ` Igor Mammedov
2016-02-05 16:44       ` Igor Mammedov
2016-02-11 15:59         ` Eduardo Habkost
2016-02-12 10:05           ` Igor Mammedov
2016-02-04 11:47 ` [Qemu-devel] [PATCH 8/9] pc: move apic_id_limit to PCMachineState Igor Mammedov
     [not found]   ` <56B348BA.40502@gmail.com>
2016-02-04 17:08     ` Igor Mammedov
2016-02-04 18:18       ` Michael S. Tsirkin
2016-02-04 18:24         ` Igor Mammedov
2016-02-04 11:47 ` [Qemu-devel] [PATCH 9/9] pc: acpi: clarify why possible LAPIC entries must be present in MADT Igor Mammedov
2016-02-05 15:39   ` Eduardo Habkost
2016-02-04 11:49 ` [Qemu-devel] [PATCH 1/9] cpu: rename cpu_exists() to qemu_get_cpu_by_arch_id() Igor Mammedov
2016-02-05 14:20   ` 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=20160205155005.GU26314@thinpad.lan.raisama.net \
    --to=ehabkost@redhat.com \
    --cc=imammedo@redhat.com \
    --cc=mst@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).