qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eduardo Habkost <ehabkost@redhat.com>
To: David Gibson <david@gibson.dropbear.id.au>
Cc: Cornelia Huck <cohuck@redhat.com>,
	Igor Mammedov <imammedo@redhat.com>,
	qemu-devel@nongnu.org, peter.maydell@linaro.org,
	pkrempa@redhat.com, pbonzini@redhat.com, drjones@redhat.com
Subject: Re: [Qemu-devel] [RFC v2 3/6] possible_cpus: add CPUArchId::type field
Date: Thu, 9 Nov 2017 18:02:35 -0200	[thread overview]
Message-ID: <20171109200235.GG3111@localhost.localdomain> (raw)
In-Reply-To: <20171109065803.GG7732@umbus.fritz.box>

On Thu, Nov 09, 2017 at 05:58:03PM +1100, David Gibson wrote:
> On Tue, Nov 07, 2017 at 04:04:04PM +0100, Cornelia Huck wrote:
> > On Mon, 6 Nov 2017 16:02:16 -0200
> > Eduardo Habkost <ehabkost@redhat.com> wrote:
> > 
> > > On Tue, Oct 31, 2017 at 03:01:14PM +0100, Igor Mammedov wrote:
> > > > On Thu, 19 Oct 2017 17:31:51 +1100
> > > > David Gibson <david@gibson.dropbear.id.au> wrote:
> > > >   
> > > > > On Wed, Oct 18, 2017 at 01:12:12PM +0200, Igor Mammedov wrote:  
> > > > > > For enabling early cpu to numa node configuration at runtime
> > > > > > qmp_query_hotpluggable_cpus() should provide a list of available
> > > > > > cpu slots at early stage, before machine_init() is called and
> > > > > > the 1st cpu is created, so that mgmt might be able to call it
> > > > > > and use output to set numa mapping.
> > > > > > Use MachineClass::possible_cpu_arch_ids() callback to set
> > > > > > cpu type info, along with the rest of possible cpu properties,
> > > > > > to let machine define which cpu type* will be used.
> > > > > > 
> > > > > > * for SPAPR it will be a spapr core type and for ARM/s390x/x86
> > > > > >   a respective descendant of CPUClass.
> > > > > > 
> > > > > > Move parse_numa_opts() in vl.c after cpu_model is parsed into
> > > > > > cpu_type so that possible_cpu_arch_ids() would know which
> > > > > > cpu_type to use during layout initialization.
> > > > > > 
> > > > > > Signed-off-by: Igor Mammedov <imammedo@redhat.com>    
> > > > > 
> > > > > Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
> > > > >   
> > > > > > ---
> > > > > >   v2:
> > > > > >      - fix NULL dereference caused by not initialized
> > > > > >        MachineState::cpu_type at the time parse_numa_opts()
> > > > > >        were called
> > > > > > ---
> > > > > >  include/hw/boards.h        |  2 ++
> > > > > >  hw/arm/virt.c              |  3 ++-
> > > > > >  hw/core/machine.c          | 12 ++++++------
> > > > > >  hw/i386/pc.c               |  4 +++-
> > > > > >  hw/ppc/spapr.c             | 13 ++++++++-----
> > > > > >  hw/s390x/s390-virtio-ccw.c |  1 +
> > > > > >  vl.c                       |  3 +--
> > > > > >  7 files changed, 23 insertions(+), 15 deletions(-)
> > > > > > 
> > > > > > diff --git a/include/hw/boards.h b/include/hw/boards.h
> > > > > > index 191a5b3..fa21758 100644
> > > > > > --- a/include/hw/boards.h
> > > > > > +++ b/include/hw/boards.h
> > > > > > @@ -80,6 +80,7 @@ void machine_set_cpu_numa_node(MachineState *machine,
> > > > > >   * CPUArchId:
> > > > > >   * @arch_id - architecture-dependent CPU ID of present or possible CPU    
> > > > > 
> > > > > I know this isn't really in scope for this patch, but is @arch_id here
> > > > > supposed to have meaning defined by the target, or by the machine?
> > > > > 
> > > > > If it's the machime, it could do with a rename - "arch" means target
> > > > > to most people (thanks to Linux).
> > > > > 
> > > > > If it's the target, it's kind of bogus, because it doesn't necessarily
> > > > > have a clear meaning per target - get_arch_id in CPUClass has the same
> > > > > problem, which is probably one reason it's basically only used by the
> > > > > x86 code at present.
> > > > > 
> > > > > e.g. for target/ppc, what do we use?  There's the PIR, which is in the
> > > > > CPU.. but only on some cpu models, not all.  There will generally be
> > > > > some kind of master PIC id, but there are different PIC models on
> > > > > different boards.  What goes in the devicetree?  Well only some
> > > > > machines use devicetree, and they might define the cpu reg 
> > > > > differently.
> > > > > 
> > > > > Board designs will generally try to make some if not all of those
> > > > > possible values equal for simplicity, but there's still no real way of
> > > > > defining a sensible arch_id independent of machine / board.  
> > > > I'd say arch_id is machine specific so far, it was introduced when we
> > > > didn't have CpuInstanceProperties and at that time we considered only
> > > > vcpus (threads) and doesn't really apply to spapr cores.
> > > > 
> > > > In general we could do away with arch_id and use CpuInstanceProperties
> > > > instead, but arch_id also serves aux purpose, it allows machine to
> > > > pre-calculate(cache) apic-id/mpidr values in one place and then they
> > > > are/(could be) used by arch in-depended code to build acpi tables.
> > > > So if we drop arch_id we would need to introduce a machine hook,
> > > > which would translate CpuInstanceProperties into current arch_id.  
> > > 
> > > I think we need to do a better to job documenting where exactly
> > > we expect arch_id to be used and how, so people know what it's
> > > supposed to return.
> > > 
> > > If the only place where it's useful now is ACPI code (is it?),
> > > should we rename it to something like get_acpi_id()?
> > 
> > It is also used in hw/s390x/sclp.c to fill out a control block, so acpi
> > isn't the only user.
> 
> Yeah.. this is kind of bogus.  The s390 use is in machine specific
> code, so it's basically just re-using the field for an unrelated usage
> to the x86/arm one (ACPI).
> 
> If we can't assign a universal meaning to the field (even if the
> actual values are per-machine) - and I don't think we can - then I
> really don't think it belongs in CPUState.  A machine hook which
> translates an ArchId to an acpi_id is the correct solution I believe.
> Or even an ACPIMachine interface (to be implemented by machines which
> do ACPI) which has a method to do this.
> 
> Since both the assignment and use are in machine type specific code
> for s390, it can have its own field in the s390 specific cpu subclass.
> 

I agree.  This might require duplicating cpu_by_arch_id() and
cpu_exists() into machine-specific code, but this doesn't sound
too bad: there's only one user of cpu_by_arch_id() (that's
x86-specific code living inside monitor.c), and one user of
cpu_exists() (that's s390-specific code).

(Maybe those users could be rewritten to use
MachineState::possible_cpus, like pc_find_cpu_slot()).

-- 
Eduardo

  reply	other threads:[~2017-11-09 20:02 UTC|newest]

Thread overview: 93+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-16 16:22 [Qemu-devel] [RFC 0/6] enable numa configuration before machine_init() from HMP/QMP Igor Mammedov
2017-10-16 16:22 ` [Qemu-devel] [RFC 1/6] numa: postpone options post-processing till machine_run_board_init() Igor Mammedov
2017-10-17  5:49   ` David Gibson
2017-10-16 16:22 ` [Qemu-devel] [RFC 2/6] numa: split out NumaOptions parsing into parse_NumaOptions() Igor Mammedov
2017-10-18  3:27   ` David Gibson
2017-10-18 14:53     ` Eric Blake
2017-10-16 16:22 ` [Qemu-devel] [RFC 3/6] possible_cpus: add CPUArchId::type field Igor Mammedov
2017-10-18 11:12   ` [Qemu-devel] [RFC v2 " Igor Mammedov
2017-10-19  6:31     ` David Gibson
2017-10-31 14:01       ` Igor Mammedov
2017-11-06 18:02         ` Eduardo Habkost
2017-11-07 15:04           ` Cornelia Huck
2017-11-09  6:58             ` David Gibson
2017-11-09 20:02               ` Eduardo Habkost [this message]
2017-11-10 10:14                 ` Cornelia Huck
2017-11-10 12:34                   ` David Hildenbrand
2017-11-10 12:58                     ` Eduardo Habkost
2017-11-10 13:07                       ` David Hildenbrand
2017-11-21 14:02                 ` Igor Mammedov
2017-11-09  6:53           ` David Gibson
2017-10-16 16:22 ` [Qemu-devel] [RFC 4/6] CLI: add -paused option Igor Mammedov
2017-10-16 16:35   ` Daniel P. Berrange
2017-10-17  8:17     ` Igor Mammedov
2017-10-17 10:56       ` Laszlo Ersek
2017-10-17 11:11         ` Peter Krempa
2017-10-20 15:38     ` Eduardo Habkost
2017-10-16 16:59   ` Eduardo Habkost
2017-10-16 17:01     ` Paolo Bonzini
2017-10-16 17:17       ` Eduardo Habkost
2017-10-17  8:47         ` Paolo Bonzini
2017-10-17  9:25           ` Igor Mammedov
2017-10-17 14:48       ` Daniel P. Berrange
2017-10-17 15:21         ` Laszlo Ersek
2017-10-17 15:35           ` Daniel P. Berrange
2017-10-17 15:42             ` Laszlo Ersek
2017-10-17 15:47               ` Daniel P. Berrange
2017-10-17 15:47             ` Igor Mammedov
2017-10-17 15:52               ` Daniel P. Berrange
2017-10-17  9:10     ` Igor Mammedov
2017-10-19 10:42     ` David Gibson
2017-10-20  0:15       ` Eduardo Habkost
2017-10-20  1:19         ` David Gibson
2017-10-20 14:21           ` Eduardo Habkost
2017-10-23  9:49             ` Igor Mammedov
2017-10-23  9:53               ` Daniel P. Berrange
2017-10-23 10:36                 ` Igor Mammedov
2017-10-23 10:49                   ` Daniel P. Berrange
2017-10-23 11:18                     ` Igor Mammedov
2017-10-25 10:52                       ` Eduardo Habkost
2017-10-25 10:35               ` Eduardo Habkost
2017-10-23  9:30         ` Alex Bennée
2017-10-16 16:22 ` [Qemu-devel] [RFC 5/6] HMP: add set-numa-node command Igor Mammedov
2017-10-16 16:22 ` [Qemu-devel] [RFC 6/6] QMP: " Igor Mammedov
2017-10-16 16:36 ` [Qemu-devel] [RFC 0/6] enable numa configuration before machine_init() from HMP/QMP Daniel P. Berrange
2017-10-16 17:05   ` Eduardo Habkost
2017-10-17  7:27   ` Igor Mammedov
2017-10-17 15:07     ` Daniel P. Berrange
2017-10-17 15:24       ` Laszlo Ersek
2017-10-17 16:06       ` Igor Mammedov
2017-10-17 16:09         ` Daniel P. Berrange
2017-10-17 16:18           ` Igor Mammedov
2017-10-18 12:59             ` Eduardo Habkost
2017-10-18 14:44               ` Igor Mammedov
2017-10-18 14:49                 ` Daniel P. Berrange
2017-10-18 15:24                   ` Igor Mammedov
2017-10-18 15:27                     ` Daniel P. Berrange
2017-10-18 20:11                       ` Eduardo Habkost
2017-10-18 15:30         ` Daniel P. Berrange
2017-10-18 20:22           ` Eduardo Habkost
2017-10-19 11:49             ` David Gibson
2017-10-19 12:23               ` Paolo Bonzini
2017-10-20  1:21                 ` David Gibson
2017-10-20 19:53                   ` Eduardo Habkost
2017-10-23  8:17                     ` Igor Mammedov
2017-10-23  8:45                     ` Igor Mammedov
2017-10-25  6:57                       ` Eduardo Habkost
2017-10-25  7:02                         ` Daniel P. Berrange
2017-10-25 13:37                           ` Eduardo Habkost
2017-10-19 15:21           ` Igor Mammedov
2017-10-19 15:28             ` Daniel P. Berrange
2017-10-19 19:56               ` Eduardo Habkost
2017-10-20  9:07                 ` Daniel P. Berrange
2017-10-20 20:07                   ` Eduardo Habkost
2017-10-23  8:53                     ` Igor Mammedov
2017-10-23 10:04                   ` Igor Mammedov
2017-10-23 10:19                     ` Daniel P. Berrange
2017-10-18 12:19       ` Paolo Bonzini
2017-10-18 12:27         ` Daniel P. Berrange
2017-10-18 12:33           ` Paolo Bonzini
2017-10-18 14:26             ` Igor Mammedov
2017-10-18 14:29               ` Paolo Bonzini
2017-10-18 14:54                 ` Igor Mammedov
2017-10-18 14:21           ` Igor Mammedov

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=20171109200235.GG3111@localhost.localdomain \
    --to=ehabkost@redhat.com \
    --cc=cohuck@redhat.com \
    --cc=david@gibson.dropbear.id.au \
    --cc=drjones@redhat.com \
    --cc=imammedo@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=pkrempa@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).