From: David Gibson <david@gibson.dropbear.id.au>
To: Andrew Jones <drjones@redhat.com>
Cc: peter.maydell@linaro.org, ehabkost@redhat.com,
qemu-devel@nongnu.org, agraf@suse.de, qemu-arm@nongnu.org,
qemu-ppc@nongnu.org, pbonzini@redhat.com, imammedo@redhat.com,
dgibson@redhat.com
Subject: Re: [Qemu-arm] [PATCH RFC 02/16] vl: smp: add checks for maxcpus based topologies
Date: Tue, 14 Jun 2016 11:28:52 +1000 [thread overview]
Message-ID: <20160614012852.GF4882@voom.fritz.box> (raw)
In-Reply-To: <1465580427-13596-3-git-send-email-drjones@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 3002 bytes --]
On Fri, Jun 10, 2016 at 07:40:13PM +0200, Andrew Jones wrote:
> smp_parse computes missing smp options. Unfortunately cores and
> threads are computed by dividing smp_cpus, instead of max_cpus.
> This is incorrect because the topology doesn't leave room for
> hotplug. More unfortunately, we can't change it easily, as doing
> so would impact existing command lines. This patch adds a warning
> when the topology doesn't add up, and then checks that the topology
> at least computes when sockets are recalculated. If not, then it
> does fail.
>
> Adding the new failure is justified by the fact that we don't
> store the number of input sockets, and thus all consumers of
> cpu topology information recalculate it. If they choose to
> (correctly) calculate it based on maxcpus, then we need to
> guard them against building topologies which provide more cpu
> slots than are the maximum allowed cpus.
>
> Signed-off-by: Andrew Jones <drjones@redhat.com>
Hmm.. this makes sense to me. Except that I've never been clear if
sockets= was supposed to match initial cpus or maxcpus.
> ---
> vl.c | 19 +++++++++++++++++++
> 1 file changed, 19 insertions(+)
>
> diff --git a/vl.c b/vl.c
> index 7b96e787922f9..8d482cb1bf020 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -1227,6 +1227,7 @@ static void smp_parse(QemuOpts *opts)
> unsigned sockets = qemu_opt_get_number(opts, "sockets", 0);
> unsigned cores = qemu_opt_get_number(opts, "cores", 0);
> unsigned threads = qemu_opt_get_number(opts, "threads", 0);
> + bool sockets_input = sockets > 0;
>
> /* compute missing values, prefer sockets over cores over threads */
> if (cpus == 0 || sockets == 0) {
> @@ -1269,6 +1270,24 @@ static void smp_parse(QemuOpts *opts)
> exit(1);
> }
>
> + if (sockets_input && sockets * cores * threads != max_cpus) {
> + unsigned sockets_rounded = DIV_ROUND_UP(max_cpus, cores * threads);
> +
> + error_report("warning: cpu topology: "
> + "sockets (%u) * cores (%u) * threads (%u) != "
> + "maxcpus (%u). Trying sockets=%u.",
> + sockets, cores, threads, max_cpus, sockets_rounded);
> + sockets = sockets_rounded;
> +
> + if (sockets * cores * threads > max_cpus) {
> + error_report("cpu topology: "
> + "sockets (%u) * cores (%u) * threads (%u) > "
> + "maxcpus (%u)",
> + sockets, cores, threads, max_cpus);
> + exit(1);
> + }
> + }
> +
> smp_cpus = cpus;
> smp_cores = cores;
> smp_threads = threads;
--
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 --]
WARNING: multiple messages have this Message-ID (diff)
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 02/16] vl: smp: add checks for maxcpus based topologies
Date: Tue, 14 Jun 2016 11:28:52 +1000 [thread overview]
Message-ID: <20160614012852.GF4882@voom.fritz.box> (raw)
In-Reply-To: <1465580427-13596-3-git-send-email-drjones@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 3002 bytes --]
On Fri, Jun 10, 2016 at 07:40:13PM +0200, Andrew Jones wrote:
> smp_parse computes missing smp options. Unfortunately cores and
> threads are computed by dividing smp_cpus, instead of max_cpus.
> This is incorrect because the topology doesn't leave room for
> hotplug. More unfortunately, we can't change it easily, as doing
> so would impact existing command lines. This patch adds a warning
> when the topology doesn't add up, and then checks that the topology
> at least computes when sockets are recalculated. If not, then it
> does fail.
>
> Adding the new failure is justified by the fact that we don't
> store the number of input sockets, and thus all consumers of
> cpu topology information recalculate it. If they choose to
> (correctly) calculate it based on maxcpus, then we need to
> guard them against building topologies which provide more cpu
> slots than are the maximum allowed cpus.
>
> Signed-off-by: Andrew Jones <drjones@redhat.com>
Hmm.. this makes sense to me. Except that I've never been clear if
sockets= was supposed to match initial cpus or maxcpus.
> ---
> vl.c | 19 +++++++++++++++++++
> 1 file changed, 19 insertions(+)
>
> diff --git a/vl.c b/vl.c
> index 7b96e787922f9..8d482cb1bf020 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -1227,6 +1227,7 @@ static void smp_parse(QemuOpts *opts)
> unsigned sockets = qemu_opt_get_number(opts, "sockets", 0);
> unsigned cores = qemu_opt_get_number(opts, "cores", 0);
> unsigned threads = qemu_opt_get_number(opts, "threads", 0);
> + bool sockets_input = sockets > 0;
>
> /* compute missing values, prefer sockets over cores over threads */
> if (cpus == 0 || sockets == 0) {
> @@ -1269,6 +1270,24 @@ static void smp_parse(QemuOpts *opts)
> exit(1);
> }
>
> + if (sockets_input && sockets * cores * threads != max_cpus) {
> + unsigned sockets_rounded = DIV_ROUND_UP(max_cpus, cores * threads);
> +
> + error_report("warning: cpu topology: "
> + "sockets (%u) * cores (%u) * threads (%u) != "
> + "maxcpus (%u). Trying sockets=%u.",
> + sockets, cores, threads, max_cpus, sockets_rounded);
> + sockets = sockets_rounded;
> +
> + if (sockets * cores * threads > max_cpus) {
> + error_report("cpu topology: "
> + "sockets (%u) * cores (%u) * threads (%u) > "
> + "maxcpus (%u)",
> + sockets, cores, threads, max_cpus);
> + exit(1);
> + }
> + }
> +
> smp_cpus = cpus;
> smp_cores = cores;
> smp_threads = threads;
--
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 1:36 UTC|newest]
Thread overview: 151+ 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-devel] " Andrew Jones
2016-06-10 17:40 ` [Qemu-arm] [PATCH RFC 01/16] vl: smp_parse: cleanups Andrew Jones
2016-06-10 17:40 ` [Qemu-devel] " Andrew Jones
2016-06-14 1:15 ` [Qemu-arm] " David Gibson
2016-06-14 1:15 ` [Qemu-devel] " 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-10 17:40 ` [Qemu-devel] " Andrew Jones
2016-06-14 1:28 ` David Gibson [this message]
2016-06-14 1:28 ` David Gibson
2016-06-14 6:43 ` [Qemu-arm] " Andrew Jones
2016-06-14 6:43 ` Andrew Jones
2016-06-10 17:40 ` [Qemu-arm] [PATCH RFC 03/16] hw/smbios/smbios: fix number of sockets calculation Andrew Jones
2016-06-10 17:40 ` [Qemu-devel] " Andrew Jones
2016-07-11 14:23 ` [Qemu-arm] " Igor Mammedov
2016-07-11 14:23 ` [Qemu-devel] " Igor Mammedov
2016-06-10 17:40 ` [Qemu-arm] [PATCH RFC 04/16] hw/core/machine: Introduce pre_init Andrew Jones
2016-06-10 17:40 ` [Qemu-devel] " Andrew Jones
2016-06-14 1:30 ` [Qemu-arm] " David Gibson
2016-06-14 1:30 ` [Qemu-devel] " David Gibson
2016-06-14 5:58 ` [Qemu-arm] " Andrew Jones
2016-06-14 5:58 ` Andrew Jones
2016-07-14 20:10 ` [Qemu-arm] " Eduardo Habkost
2016-07-14 20:10 ` Eduardo Habkost
2016-07-15 6:26 ` [Qemu-arm] " Andrew Jones
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-10 17:40 ` [Qemu-devel] " Andrew Jones
2016-06-14 2:00 ` [Qemu-arm] " David Gibson
2016-06-14 2:00 ` [Qemu-devel] " David Gibson
2016-06-14 6:08 ` [Qemu-arm] " Andrew Jones
2016-06-14 6:08 ` Andrew Jones
2016-06-15 0:37 ` [Qemu-arm] " David Gibson
2016-06-15 0:37 ` David Gibson
2016-06-15 7:11 ` [Qemu-arm] " Andrew Jones
2016-06-15 7:11 ` Andrew Jones
2016-07-14 20:18 ` [Qemu-arm] " Eduardo Habkost
2016-07-14 20:18 ` Eduardo Habkost
2016-07-15 6:29 ` [Qemu-arm] " Andrew Jones
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-10 17:40 ` [Qemu-devel] " Andrew Jones
2016-06-13 17:04 ` [Qemu-arm] " Paolo Bonzini
2016-06-13 17:04 ` [Qemu-devel] " Paolo Bonzini
2016-06-13 20:35 ` [Qemu-arm] " Andrew Jones
2016-06-13 20:35 ` Andrew Jones
2016-06-14 8:17 ` Paolo Bonzini
2016-06-14 8:17 ` Paolo Bonzini
2016-06-14 11:39 ` [Qemu-arm] " Andrew Jones
2016-06-14 11:39 ` Andrew Jones
2016-06-14 11:53 ` [Qemu-arm] " Paolo Bonzini
2016-06-14 11:53 ` [Qemu-devel] " Paolo Bonzini
2016-06-14 14:03 ` Andrew Jones
2016-06-14 14:03 ` Andrew Jones
2016-06-14 14:05 ` [Qemu-arm] " Paolo Bonzini
2016-06-14 14:05 ` Paolo Bonzini
2016-06-15 0:51 ` [Qemu-arm] " David Gibson
2016-06-15 0:51 ` David Gibson
2016-06-15 7:19 ` [Qemu-arm] " Andrew Jones
2016-06-15 7:19 ` Andrew Jones
2016-06-15 0:43 ` [Qemu-arm] " David Gibson
2016-06-15 0:43 ` [Qemu-devel] " 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-10 17:40 ` Andrew Jones
2016-06-11 6:54 ` [Qemu-arm] " Thomas Huth
2016-06-11 6:54 ` Thomas Huth
2016-06-12 13:48 ` [Qemu-arm] " Andrew Jones
2016-06-12 13:48 ` Andrew Jones
2016-06-14 2:12 ` [Qemu-arm] " David Gibson
2016-06-14 2:12 ` David Gibson
2016-06-14 6:19 ` [Qemu-arm] " Andrew Jones
2016-06-14 6:19 ` Andrew Jones
2016-06-15 0:56 ` [Qemu-arm] " David Gibson
2016-06-15 0:56 ` David Gibson
2016-07-14 20:07 ` [Qemu-arm] " Eduardo Habkost
2016-07-14 20:07 ` Eduardo Habkost
2016-07-15 6:35 ` [Qemu-arm] " Andrew Jones
2016-07-15 6:35 ` Andrew Jones
2016-07-15 9:11 ` [Qemu-arm] " Igor Mammedov
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 ` 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 ` 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 ` 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 18:38 ` Igor Mammedov
2016-07-15 21:33 ` [Qemu-arm] " Eduardo Habkost
2016-07-15 21:33 ` Eduardo Habkost
2016-07-16 15:30 ` [Qemu-arm] " Andrew Jones
2016-07-16 15:30 ` Andrew Jones
2016-07-19 11:54 ` [Qemu-arm] " Eduardo Habkost
2016-07-19 11:54 ` Eduardo Habkost
2016-07-18 7:23 ` [Qemu-arm] " Igor Mammedov
2016-07-18 7:23 ` Igor Mammedov
2016-07-19 11:59 ` [Qemu-arm] " Eduardo Habkost
2016-07-19 11:59 ` Eduardo Habkost
2016-07-19 12:21 ` [Qemu-arm] " Paolo Bonzini
2016-07-19 12:21 ` Paolo Bonzini
2016-07-19 13:29 ` [Qemu-arm] " Igor Mammedov
2016-07-19 13:29 ` Igor Mammedov
2016-07-19 13:39 ` [Qemu-arm] " Paolo Bonzini
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 ` 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-06-10 17:40 ` [Qemu-devel] " Andrew Jones
2016-07-14 20:33 ` Eduardo Habkost
2016-07-14 20:33 ` Eduardo Habkost
2016-06-10 17:40 ` [Qemu-arm] [PATCH RFC 10/16] hw/ppc/spapr: " Andrew Jones
2016-06-10 17:40 ` [Qemu-devel] " Andrew Jones
2016-06-14 3:03 ` [Qemu-arm] " David Gibson
2016-06-14 3:03 ` [Qemu-devel] " David Gibson
2016-06-14 6:23 ` [Qemu-arm] " Andrew Jones
2016-06-14 6:23 ` Andrew Jones
2016-06-15 0:59 ` [Qemu-arm] " David Gibson
2016-06-15 0:59 ` David Gibson
2016-06-15 7:34 ` [Qemu-arm] " Andrew Jones
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] " 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 ` 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-devel] " 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-06-10 17:40 ` [Qemu-devel] " Andrew Jones
2016-07-14 20:43 ` [Qemu-arm] " Eduardo Habkost
2016-07-14 20:43 ` Eduardo Habkost
2016-07-15 6:40 ` [Qemu-arm] " Andrew Jones
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-06-10 17:40 ` Andrew Jones
2016-07-14 20:51 ` [Qemu-arm] " Eduardo Habkost
2016-07-14 20:51 ` Eduardo Habkost
2016-07-15 6:45 ` [Qemu-arm] " Andrew Jones
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-10 17:40 ` [Qemu-devel] " Andrew Jones
2016-06-11 6:42 ` [Qemu-arm] [Qemu-devel] [PATCH RFC 00/16] Rework SMP parameters Thomas Huth
2016-06-11 6:42 ` Thomas Huth
2016-06-12 13:58 ` [Qemu-arm] " Andrew Jones
2016-06-12 13:58 ` Andrew Jones
2016-06-12 14:03 ` [Qemu-arm] " Andrew Jones
2016-06-12 14:03 ` Andrew Jones
2016-07-14 9:16 ` [Qemu-arm] " 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=20160614012852.GF4882@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.