From: David Gibson <david@gibson.dropbear.id.au>
To: Andrew Jones <drjones@redhat.com>
Cc: qemu-devel@nongnu.org, qemu-ppc@nongnu.org, qemu-arm@nongnu.org,
imammedo@redhat.com, ehabkost@redhat.com, pbonzini@redhat.com,
peter.maydell@linaro.org, dgibson@redhat.com, agraf@suse.de
Subject: Re: [Qemu-devel] [PATCH RFC 05/16] hw/core/machine: add smp properites
Date: Tue, 14 Jun 2016 12:00:26 +1000 [thread overview]
Message-ID: <20160614020026.GH4882@voom.fritz.box> (raw)
In-Reply-To: <1465580427-13596-6-git-send-email-drjones@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 6088 bytes --]
On Fri, Jun 10, 2016 at 07:40:16PM +0200, Andrew Jones wrote:
> Signed-off-by: Andrew Jones <drjones@redhat.com>
> ---
> hw/core/machine.c | 81 +++++++++++++++++++++++++++++++++++++++++++++++++++++
> include/hw/boards.h | 6 ++++
> 2 files changed, 87 insertions(+)
>
> diff --git a/hw/core/machine.c b/hw/core/machine.c
> index 3dce9020e510a..2625044002e57 100644
> --- a/hw/core/machine.c
> +++ b/hw/core/machine.c
> @@ -172,6 +172,53 @@ static void machine_set_dumpdtb(Object *obj, const char *value, Error **errp)
> ms->dumpdtb = g_strdup(value);
> }
>
> +static void machine_get_smp(Object *obj, Visitor *v, const char *name,
> + void *opaque, Error **errp)
> +{
> + MachineState *ms = MACHINE(obj);
> + int64_t value;
> +
> + if (strncmp(name, "sockets", 7) == 0) {
> + value = ms->sockets;
> + } else if (strncmp(name, "cores", 5) == 0) {
> + value = ms->cores;
> + } else if (strncmp(name, "threads", 7) == 0) {
> + value = ms->threads;
> + } else if (strncmp(name, "maxcpus", 7) == 0) {
> + value = ms->maxcpus;
> + } else if (strncmp(name, "cpus", 4) == 0) {
> + value = ms->cpus;
> + }
> +
> + visit_type_int(v, name, &value, errp);
> +}
Any particular for multiplexing all the set / get, rather than having
separate callbacks for each property?
> +
> +static void machine_set_smp(Object *obj, Visitor *v, const char *name,
> + void *opaque, Error **errp)
> +{
> + MachineState *ms = MACHINE(obj);
> + Error *error = NULL;
> + int64_t value;
> +
> + visit_type_int(v, name, &value, &error);
> + if (error) {
> + error_propagate(errp, error);
> + return;
> + }
> +
> + if (strncmp(name, "sockets", 7) == 0) {
> + ms->sockets = value;
> + } else if (strncmp(name, "cores", 5) == 0) {
> + ms->cores = value;;
> + } else if (strncmp(name, "threads", 7) == 0) {
> + ms->threads = value;
> + } else if (strncmp(name, "maxcpus", 7) == 0) {
> + ms->maxcpus = value;
> + } else if (strncmp(name, "cpus", 4) == 0) {
> + ms->cpus = value;
> + }
> +}
> +
> static void machine_get_phandle_start(Object *obj, Visitor *v,
> const char *name, void *opaque,
> Error **errp)
> @@ -368,8 +415,18 @@ static void machine_init_notify(Notifier *notifier, void *data)
> foreach_dynamic_sysbus_device(error_on_sysbus_device, NULL);
> }
>
> +static void machine_set_smp_parameters(MachineState *ms)
> +{
> + if (ms->sockets != -1 || ms->cores != -1 || ms->threads != -1 ||
> + ms->maxcpus != -1 || ms->cpus != -1) {
> + error_report("warning: cpu topology: "
> + "machine properties currently ignored");
> + }
> +}
> +
> static void machine_pre_init(MachineState *ms)
> {
> + machine_set_smp_parameters(ms);
> }
>
> static void machine_class_init(ObjectClass *oc, void *data)
> @@ -403,6 +460,11 @@ static void machine_initfn(Object *obj)
> ms->dump_guest_core = true;
> ms->mem_merge = true;
> ms->enable_graphics = true;
> + ms->sockets = -1;
> + ms->cores = -1;
> + ms->threads = -1;
> + ms->maxcpus = -1;
> + ms->cpus = -1;
>
> object_property_add_str(obj, "accel",
> machine_get_accel, machine_set_accel, NULL);
> @@ -462,6 +524,25 @@ static void machine_initfn(Object *obj)
> object_property_set_description(obj, "dt-compatible",
> "Overrides the \"compatible\" property of the dt root node",
> NULL);
> + object_property_add(obj, "sockets", "int", machine_get_smp,
> + machine_set_smp, NULL, NULL, NULL);
> + object_property_set_description(obj, "sockets", "Number of sockets", NULL);
> + object_property_add(obj, "cores", "int", machine_get_smp,
> + machine_set_smp, NULL, NULL, NULL);
> + object_property_set_description(obj, "cores",
> + "Number of cores per socket", NULL);
> + object_property_add(obj, "threads", "int", machine_get_smp,
> + machine_set_smp, NULL, NULL, NULL);
> + object_property_set_description(obj, "threads",
> + "Number of threads per core", NULL);
> + object_property_add(obj, "maxcpus", "int", machine_get_smp,
> + machine_set_smp, NULL, NULL, NULL);
> + object_property_set_description(obj, "maxcpus", "Maximum number of cpus",
> + NULL);
> + object_property_add(obj, "cpus", "int", machine_get_smp,
> + machine_set_smp, NULL, NULL, NULL);
> + object_property_set_description(obj, "cpus", "Number of online cpus",
> + NULL);
> object_property_add_bool(obj, "dump-guest-core",
> machine_get_dump_guest_core,
> machine_set_dump_guest_core,
> diff --git a/include/hw/boards.h b/include/hw/boards.h
> index 4e8dc68b07a24..53adbfe2a3099 100644
> --- a/include/hw/boards.h
> +++ b/include/hw/boards.h
> @@ -166,6 +166,12 @@ struct MachineState {
> char *initrd_filename;
> const char *cpu_model;
> AccelState *accelerator;
> +
> + int sockets;
> + int cores;
> + int threads;
> + int maxcpus;
> + int cpus;
Hrm.. as the tests added in earlier patches highlight, essentially one
of these properties is redundant. Is there a reason to include them
all, rather than to pick one to drop?
> };
>
> #define DEFINE_MACHINE(namestr, machine_initfn) \
--
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-14 3:02 UTC|newest]
Thread overview: 74+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-10 17:40 [Qemu-devel] [PATCH RFC 00/16] Rework SMP parameters Andrew Jones
2016-06-10 17:40 ` [Qemu-devel] [PATCH RFC 01/16] vl: smp_parse: cleanups Andrew Jones
2016-06-14 1:15 ` David Gibson
2016-06-10 17:40 ` [Qemu-devel] [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 ` Andrew Jones
2016-06-10 17:40 ` [Qemu-devel] [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-devel] [PATCH RFC 04/16] hw/core/machine: Introduce pre_init Andrew Jones
2016-06-14 1:30 ` David Gibson
2016-06-14 5:58 ` Andrew Jones
2016-07-14 20:10 ` Eduardo Habkost
2016-07-15 6:26 ` Andrew Jones
2016-06-10 17:40 ` [Qemu-devel] [PATCH RFC 05/16] hw/core/machine: add smp properites Andrew Jones
2016-06-14 2:00 ` David Gibson [this message]
2016-06-14 6:08 ` 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-devel] [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 ` Andrew Jones
2016-06-14 8:17 ` Paolo Bonzini
2016-06-14 11:39 ` Andrew Jones
2016-06-14 11:53 ` Paolo Bonzini
2016-06-14 14:03 ` Andrew Jones
2016-06-14 14:05 ` Paolo Bonzini
2016-06-15 0:51 ` David Gibson
2016-06-15 7:19 ` Andrew Jones
2016-06-15 0:43 ` 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 ` 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:30 ` Andreas Färber
2016-07-15 17:43 ` Eduardo Habkost
2016-07-15 18:38 ` 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-devel] [PATCH RFC 09/16] hw/i386/pc: don't use smp_cores, smp_threads Andrew Jones
2016-07-14 20:33 ` Eduardo Habkost
2016-06-10 17:40 ` [Qemu-devel] [PATCH RFC 10/16] hw/ppc/spapr: " Andrew Jones
2016-06-14 3:03 ` David Gibson
2016-06-14 6:23 ` Andrew Jones
2016-06-15 0:59 ` David Gibson
2016-06-15 7:34 ` Andrew Jones
2016-06-10 17:40 ` [Qemu-devel] [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-devel] [PATCH RFC 13/16] hw/arm/virt: don't use smp_cpus, max_cpus Andrew Jones
2016-06-10 17:40 ` [Qemu-devel] [PATCH RFC 14/16] hw/arm/virt: stash cpu topo info in VirtGuestInfo Andrew Jones
2016-07-14 20:43 ` 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 ` Eduardo Habkost
2016-07-15 6:45 ` Andrew Jones
2016-06-10 17:40 ` [Qemu-devel] [PATCH RFC 16/16] sysemu/cpus: bye, bye " Andrew Jones
2016-06-11 6:42 ` [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=20160614020026.GH4882@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).