From: David Gibson <david@gibson.dropbear.id.au>
To: Andrew Jones <drjones@redhat.com>
Cc: peter.maydell@linaro.org, ehabkost@redhat.com, agraf@suse.de,
qemu-devel@nongnu.org, qemu-arm@nongnu.org, qemu-ppc@nongnu.org,
imammedo@redhat.com, pbonzini@redhat.com, dgibson@redhat.com
Subject: Re: [Qemu-arm] [Qemu-devel] [PATCH RFC 10/16] hw/ppc/spapr: don't use smp_cores, smp_threads
Date: Wed, 15 Jun 2016 10:59:01 +1000 [thread overview]
Message-ID: <20160615005901.GV4882@voom.fritz.box> (raw)
In-Reply-To: <20160614062308.r6nafsv56yy7rjf5@hawk.localdomain>
[-- Attachment #1: Type: text/plain, Size: 4253 bytes --]
On Tue, Jun 14, 2016 at 08:23:08AM +0200, Andrew Jones wrote:
> On Tue, Jun 14, 2016 at 01:03:41PM +1000, David Gibson wrote:
> > On Fri, Jun 10, 2016 at 07:40:21PM +0200, Andrew Jones wrote:
> > > Use CPUState nr_cores,nr_threads and MachineState
> > > cores,threads instead.
> > >
> > > Signed-off-by: Andrew Jones <drjones@redhat.com>
> > > ---
> > > hw/ppc/spapr.c | 9 +++++----
> > > hw/ppc/spapr_rtas.c | 2 +-
> > > 2 files changed, 6 insertions(+), 5 deletions(-)
> > >
> > > diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
> > > index 063664234106e..f78276bb4b164 100644
> > > --- a/hw/ppc/spapr.c
> > > +++ b/hw/ppc/spapr.c
> > > @@ -35,7 +35,6 @@
> > > #include "net/net.h"
> > > #include "sysemu/device_tree.h"
> > > #include "sysemu/block-backend.h"
> > > -#include "sysemu/cpus.h"
> > > #include "sysemu/kvm.h"
> > > #include "sysemu/device_tree.h"
> > > #include "kvm_ppc.h"
> > > @@ -603,7 +602,7 @@ static void spapr_populate_cpu_dt(CPUState *cs, void *fdt, int offset,
> > > uint32_t cpufreq = kvm_enabled() ? kvmppc_get_clockfreq() : 1000000000;
> > > uint32_t page_sizes_prop[64];
> > > size_t page_sizes_prop_size;
> > > - uint32_t vcpus_per_socket = smp_threads * smp_cores;
> > > + uint32_t vcpus_per_socket = cs->nr_cores * cs->nr_threads;
This function has an 'spapr' parameter which is a subcloss of
MachineState, so you can get to the machine value from there.
> > > uint32_t pft_size_prop[] = {0, cpu_to_be32(spapr->htab_shift)};
> > >
> > > /* Note: we keep CI large pages off for now because a 64K capable guest
> > > @@ -1774,7 +1773,7 @@ static void ppc_spapr_init(MachineState *machine)
> > > /* Set up Interrupt Controller before we create the VCPUs */
> > > spapr->icp = xics_system_init(machine,
> > > DIV_ROUND_UP(max_cpus * kvmppc_smt_threads(),
> > > - smp_threads),
> > > + machine->threads),
> > > XICS_IRQS, &error_fatal);
> > >
> > > if (smc->dr_lmb_enabled) {
> > > @@ -2268,9 +2267,11 @@ static HotplugHandler *spapr_get_hotpug_handler(MachineState *machine,
> > >
> > > static unsigned spapr_cpu_index_to_socket_id(unsigned cpu_index)
> > > {
> > > + CPUState *cs = first_cpu;
> > > +
> > > /* Allocate to NUMA nodes on a "socket" basis (not that concept of
> > > * socket means much for the paravirtualized PAPR platform) */
> > > - return cpu_index / smp_threads / smp_cores;
> > > + return cpu_index / cs->nr_cores / cs->nr_threads;
Here you can use qdev_get_machine(). That's no more an ugly use of a
global than using first_cpu.
> > > }
> > >
> > > static void spapr_machine_class_init(ObjectClass *oc, void *data)
> > > diff --git a/hw/ppc/spapr_rtas.c b/hw/ppc/spapr_rtas.c
> > > index 43e2c684fda8d..3fdfbb01a20dd 100644
> > > --- a/hw/ppc/spapr_rtas.c
> > > +++ b/hw/ppc/spapr_rtas.c
> > > @@ -742,7 +742,7 @@ int spapr_rtas_device_tree_setup(void *fdt, hwaddr rtas_addr,
> > > lrdr_capacity[1] = cpu_to_be32(max_hotplug_addr & 0xffffffff);
> > > lrdr_capacity[2] = 0;
> > > lrdr_capacity[3] = cpu_to_be32(SPAPR_MEMORY_BLOCK_SIZE);
> > > - lrdr_capacity[4] = cpu_to_be32(max_cpus/smp_threads);
> > > + lrdr_capacity[4] = cpu_to_be32(max_cpus / machine->threads);
> > > ret = qemu_fdt_setprop(fdt, "/rtas", "ibm,lrdr-capacity", lrdr_capacity,
> > > sizeof(lrdr_capacity));
> > > if (ret < 0) {
> >
> > I think all the places that use cs->nr_* here it actually makes more
> > sense to use the value in the machine state.
>
> I think I used machine state whenever I (easily) could. How do I get to
> machine state from a CPU method? I will if I can, for all machines,
> and then gladly kill the CPUState->nr_cores/nr_threads.
I can't speak to all machines, but notes above on how it can be done
for spapr.
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
next prev parent reply other threads:[~2016-06-15 0:59 UTC|newest]
Thread overview: 77+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-10 17:40 [Qemu-arm] [PATCH RFC 00/16] Rework SMP parameters Andrew Jones
2016-06-10 17:40 ` [Qemu-arm] [PATCH RFC 01/16] vl: smp_parse: cleanups Andrew Jones
2016-06-14 1:15 ` David Gibson
2016-06-10 17:40 ` [Qemu-arm] [PATCH RFC 02/16] vl: smp: add checks for maxcpus based topologies Andrew Jones
2016-06-14 1:28 ` David Gibson
2016-06-14 6:43 ` [Qemu-arm] [Qemu-devel] " Andrew Jones
2016-06-10 17:40 ` [Qemu-arm] [PATCH RFC 03/16] hw/smbios/smbios: fix number of sockets calculation Andrew Jones
2016-07-11 14:23 ` Igor Mammedov
2016-06-10 17:40 ` [Qemu-arm] [PATCH RFC 04/16] hw/core/machine: Introduce pre_init Andrew Jones
2016-06-14 1:30 ` David Gibson
2016-06-14 5:58 ` [Qemu-arm] [Qemu-devel] " Andrew Jones
2016-07-14 20:10 ` Eduardo Habkost
2016-07-15 6:26 ` Andrew Jones
2016-06-10 17:40 ` [Qemu-arm] [PATCH RFC 05/16] hw/core/machine: add smp properites Andrew Jones
2016-06-14 2:00 ` David Gibson
2016-06-14 6:08 ` [Qemu-arm] [Qemu-devel] " Andrew Jones
2016-06-15 0:37 ` David Gibson
2016-06-15 7:11 ` Andrew Jones
2016-07-14 20:18 ` Eduardo Habkost
2016-07-15 6:29 ` Andrew Jones
2016-06-10 17:40 ` [Qemu-arm] [PATCH RFC 06/16] vl: move smp parsing to machine pre_init Andrew Jones
2016-06-13 17:04 ` Paolo Bonzini
2016-06-13 20:35 ` [Qemu-arm] [Qemu-devel] " Andrew Jones
2016-06-14 8:17 ` Paolo Bonzini
2016-06-14 11:39 ` [Qemu-arm] " Andrew Jones
2016-06-14 11:53 ` [Qemu-arm] " Paolo Bonzini
2016-06-14 14:03 ` [Qemu-devel] " Andrew Jones
2016-06-14 14:05 ` [Qemu-arm] " Paolo Bonzini
2016-06-15 0:51 ` David Gibson
2016-06-15 7:19 ` Andrew Jones
2016-06-15 0:43 ` [Qemu-arm] " David Gibson
2016-06-10 17:40 ` [Qemu-devel] [PATCH RFC 07/16] qom/cpu: make nr-cores, nr-threads real properties Andrew Jones
2016-06-11 6:54 ` [Qemu-arm] " Thomas Huth
2016-06-12 13:48 ` Andrew Jones
2016-06-14 2:12 ` David Gibson
2016-06-14 6:19 ` Andrew Jones
2016-06-15 0:56 ` David Gibson
2016-07-14 20:07 ` Eduardo Habkost
2016-07-15 6:35 ` Andrew Jones
2016-07-15 9:11 ` Igor Mammedov
2016-07-15 16:10 ` [Qemu-devel] QOM: best way for parents to pass information to children? (was Re: [PATCH RFC 07/16] qom/cpu: make nr-cores, nr-threads real properties) Eduardo Habkost
2016-07-15 16:10 ` [Qemu-arm] QOM: best way for parents to pass information to children? (was Re: [Qemu-devel] " Eduardo Habkost
2016-07-15 16:30 ` [Qemu-devel] QOM: best way for parents to pass information to children? (was " Andreas Färber
2016-07-15 16:30 ` [Qemu-arm] QOM: best way for parents to pass information to children? (was Re: [Qemu-devel] " Andreas Färber
2016-07-15 17:43 ` [Qemu-devel] QOM: best way for parents to pass information to children? (was " Eduardo Habkost
2016-07-15 17:43 ` [Qemu-arm] QOM: best way for parents to pass information to children? (was Re: [Qemu-devel] " Eduardo Habkost
2016-07-15 18:38 ` [Qemu-arm] [Qemu-devel] QOM: best way for parents to pass information to children? (was " Igor Mammedov
2016-07-15 21:33 ` Eduardo Habkost
2016-07-16 15:30 ` Andrew Jones
2016-07-19 11:54 ` Eduardo Habkost
2016-07-18 7:23 ` Igor Mammedov
2016-07-19 11:59 ` Eduardo Habkost
2016-07-19 12:21 ` Paolo Bonzini
2016-07-19 13:29 ` Igor Mammedov
2016-07-19 13:39 ` Paolo Bonzini
2016-06-10 17:40 ` [Qemu-devel] [PATCH RFC 08/16] hw/core/machine: set cpu global nr_cores, nr_threads in pre_init Andrew Jones
2016-06-10 17:40 ` [Qemu-arm] [PATCH RFC 09/16] hw/i386/pc: don't use smp_cores, smp_threads Andrew Jones
2016-07-14 20:33 ` [Qemu-devel] " Eduardo Habkost
2016-06-10 17:40 ` [Qemu-arm] [PATCH RFC 10/16] hw/ppc/spapr: " Andrew Jones
2016-06-14 3:03 ` David Gibson
2016-06-14 6:23 ` [Qemu-arm] [Qemu-devel] " Andrew Jones
2016-06-15 0:59 ` David Gibson [this message]
2016-06-15 7:34 ` Andrew Jones
2016-06-10 17:40 ` [Qemu-arm] [PATCH RFC 11/16] target-ppc: don't use smp_threads Andrew Jones
2016-06-10 17:40 ` [Qemu-devel] [PATCH RFC 12/16] hw/arm/virt: rename *.smp_cpus to *.cpus Andrew Jones
2016-06-10 17:40 ` [Qemu-arm] [PATCH RFC 13/16] hw/arm/virt: don't use smp_cpus, max_cpus Andrew Jones
2016-06-10 17:40 ` [Qemu-arm] [PATCH RFC 14/16] hw/arm/virt: stash cpu topo info in VirtGuestInfo Andrew Jones
2016-07-14 20:43 ` [Qemu-arm] [Qemu-devel] " Eduardo Habkost
2016-07-15 6:40 ` Andrew Jones
2016-06-10 17:40 ` [Qemu-devel] [PATCH RFC 15/16] smbios: don't use smp_cores, smp_threads Andrew Jones
2016-07-14 20:51 ` [Qemu-arm] " Eduardo Habkost
2016-07-15 6:45 ` Andrew Jones
2016-06-10 17:40 ` [Qemu-arm] [PATCH RFC 16/16] sysemu/cpus: bye, bye " Andrew Jones
2016-06-11 6:42 ` [Qemu-arm] [Qemu-devel] [PATCH RFC 00/16] Rework SMP parameters Thomas Huth
2016-06-12 13:58 ` Andrew Jones
2016-06-12 14:03 ` Andrew Jones
2016-07-14 9:16 ` Andrew Jones
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=20160615005901.GV4882@voom.fritz.box \
--to=david@gibson.dropbear.id.au \
--cc=agraf@suse.de \
--cc=dgibson@redhat.com \
--cc=drjones@redhat.com \
--cc=ehabkost@redhat.com \
--cc=imammedo@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@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).