All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Chen Fan <chen.fan.fnst@cn.fujitsu.com>, qemu-devel@nongnu.org
Cc: "Igor Mammedov" <imammedo@redhat.com>,
	"Andreas Färber" <afaerber@suse.de>
Subject: Re: [Qemu-devel] [RFC 2/3] target-i386: add -smp X,apics=0x option
Date: Mon, 17 Feb 2014 11:37:01 -0700	[thread overview]
Message-ID: <530256CD.20007@redhat.com> (raw)
In-Reply-To: <50f1d46e5a346a6788f8c4dd6c2bef7da34d7b6d.1389685621.git.chen.fan.fnst@cn.fujitsu.com>

[-- Attachment #1: Type: text/plain, Size: 3239 bytes --]

On 01/14/2014 02:27 AM, Chen Fan wrote:
> This option provides the infrastructure for specifying apicids when
> boot VM, For example:
> 
>  #boot with apicid 0 and 2:
>  -smp 2,apics=0xA,maxcpus=4  /* 1010 */
>  #boot with apicid 1 and 7:
>  -smp 2,apics=0x41,maxcpus=8 /* 0100 0001 */

This syntax feels a bit odd when maxcpus is not a multiple of 8, and
even harder when not a multiple of 4.  I think part of my confusion
stems from you treating the lsb as the left-most bit, but expect me to
write in hex where I'm used to the right-most bit being lsb   Wouldn't
it be easier to express:

msb .... lsb

with leading 0s implied as needed, as in:

0x5 => 0101 => id 0 (lsb) and id 2 are enabled, regardless of whether
maxcpus=4 or maxcpus=8
0x82 => 1000 0010 => id 1 and id 7 are enabled, regardless of whether
maxcpus=8 or maxcpus=256

0x100000000 => id 32 is enabled

Or even better, why not reuse existing parsers that take cpu ids
directly as numbers instead of making me compute a bitmap (as in
maxcpus=4,id=0,id=2 - although I don't quite know QemuOpts well enough
to know if you can repeat id= for forming a list of disjoint id numbers)

> @@ -92,6 +93,14 @@ of @var{threads} per cores and the total number of @var{sockets} can be
>  specified. Missing values will be computed. If any on the three values is
>  given, the total number of CPUs @var{n} can be omitted. @var{maxcpus}
>  specifies the maximum number of hotpluggable CPUs.
> +@var{apics} specifies the boot bitmap of existed apicid.

s/existed/existing/

> +
> +@example
> +#specify the boot bitmap of apicid with 0 and 2:
> +qemu-system-i386 -smp 2,apics=0xA,maxcpus=4  /* 1010 */
> +#specify the boot bitmap of apicid with 1 and 7:
> +qemu-system-i386 -smp 2,apics=0x41,maxcpus=8 /* 0100 0001 */
> +@end example

These examples would need updating to match my concerns.

> @@ -1379,6 +1382,9 @@ static QemuOptsList qemu_smp_opts = {
>          }, {
>              .name = "maxcpus",
>              .type = QEMU_OPT_NUMBER,
> +        }, {
> +            .name = "apics",
> +            .type = QEMU_OPT_STRING,

Why a string with your own ad-hoc parser?  Can't we reuse some of the
existing parsers that already know how to handle (possibly-disjoint)
lists of cpu numbers?

> +        if (apics) {
> +            if (strstart(apics, "0x", &apics)) {

Why not also allow 0X?

> +                if (*apics != '\0') {
> +                    int i, count;
> +                    int64_t max_apicid = 0;
> +                    uint32_t val;
> +                    char tmp[2];
> +
> +                    count = strlen(apics);
> +
> +                    for (i = 0; i < count; i++) {
> +                        tmp[0] = apics[i];
> +                        tmp[1] = '\0';
> +                        sscanf(tmp, "%x", &val);

sscanf is evil.  It has undefined behavior on input overflow (that is,
if I say 0x10000000000000000, there is no guarantee what sscanf will
stick into val).  All the more reason you should be using an existing
parser which gracefully handles overflow.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

  reply	other threads:[~2014-02-17 18:37 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-14  9:27 [Qemu-devel] [RFC 0/3] fix migration issues after hotplug a discontinuous cpuid Chen Fan
2014-01-14  9:27 ` [Qemu-devel] [RFC 1/3] target-i386: moving registers of vmstate from cpu_exec_init() to x86_cpu_realizefn() Chen Fan
2014-01-14 10:40   ` Igor Mammedov
2014-01-15 12:24     ` Chen Fan
2014-01-15 14:37       ` Igor Mammedov
2014-01-17 19:13         ` [Qemu-devel] Exposing and calculating CPU APIC IDs (was Re: [RFC 1/3] target-i386: moving registers of vmstate from cpu_exec_init() to x86_cpu_realizefn()) Eduardo Habkost
2014-01-20 12:29           ` Igor Mammedov
2014-01-21  7:12             ` Chen Fan
2014-01-21  9:31               ` Igor Mammedov
2014-01-21  9:51                 ` Chen Fan
2014-01-21 10:10                   ` Andreas Färber
2014-02-13  6:14                     ` Chen Fan
2014-02-13  9:44                       ` Igor Mammedov
2014-02-17 10:24                         ` Chen Fan
2014-02-17 10:43                           ` Igor Mammedov
2014-02-25  9:07                             ` [Qemu-devel] [PATCH 0/2][RFC] prebuild cpu QOM tree /machine/node/socket/core/thread/ Chen Fan
2014-02-25  9:07                               ` [Qemu-devel] [PATCH 1/2][RFC] qom: introduce cpu QOM hierarchy tree /machine/node/socket/core/thread/cpu Chen Fan
2014-02-25 13:35                                 ` Eric Blake
2014-02-26  1:05                                   ` Chen Fan
2014-02-26 18:52                                 ` Eduardo Habkost
2014-02-28  2:01                                   ` Chen Fan
2014-03-04 10:50                                     ` [Qemu-devel] [RFC v2 0/2] prebuild cpu QOM tree /machine/node/socket/core/thread/ Chen Fan
2014-03-04 10:50                                       ` [Qemu-devel] [RFC v2 1/2] i386: introduce "struct X86TopoInfo" for saving cpu topology information Chen Fan
2014-03-04 19:35                                         ` Eduardo Habkost
2014-03-05  1:33                                           ` Chen Fan
2014-03-11 10:58                                             ` [Qemu-devel] [RFC v3 0/3] prebuild cpu QOM tree /machine/node/socket/core ->link-cpu chen.fan.fnst
2014-03-11 10:58                                               ` [Qemu-devel] [RFC v3 1/3] cpu: introduce CpuTopoInfo structure for argument simplification chen.fan.fnst
2014-03-11 17:10                                                 ` Eduardo Habkost
2014-03-11 10:58                                               ` [Qemu-devel] [RFC v3 2/3] i386: use CpuTopoInfo instead apic_id as argument for pc_new_cpu() chen.fan.fnst
2014-03-11 18:00                                                 ` Eduardo Habkost
2014-03-12  5:53                                                   ` Chen Fan
2014-03-12  7:51                                                   ` [Qemu-devel] [RFC v4 0/3] prebuild cpu QOM tree /machine/node/socket/core ->link-cpu Chen Fan
2014-03-12  7:51                                                     ` [Qemu-devel] [RFC v4 1/3] cpu: introduce CpuTopoInfo structure for argument simplification Chen Fan
2014-03-12 15:36                                                       ` Eduardo Habkost
2014-03-19  8:53                                                         ` [Qemu-devel] [PATCH v1 0/4] prebuild cpu QOM tree /machine/node/socket/core ->link-cpu Chen Fan
2014-03-19  8:53                                                           ` [Qemu-devel] [PATCH v1 1/4] cpu: introduce CpuTopoInfo structure for argument simplification Chen Fan
2014-03-19  8:53                                                           ` [Qemu-devel] [PATCH v1 2/4] i386: use CpuTopoInfo instead apic_id as argument for pc_new_cpu() Chen Fan
2014-03-19 19:27                                                             ` Eduardo Habkost
2014-03-20  6:25                                                               ` Chen Fan
2014-03-19  8:53                                                           ` [Qemu-devel] [PATCH v1 3/4] topo unit-test: update Unit tests to test-x86-cpuid.c Chen Fan
2014-03-19  8:53                                                           ` [Qemu-devel] [PATCH v1 4/4] i386: introduce cpu QOM hierarchy tree Chen Fan
2014-03-19 12:00                                                           ` [Qemu-devel] [PATCH v1 0/4] prebuild cpu QOM tree /machine/node/socket/core ->link-cpu Eric Blake
2014-03-20  0:55                                                             ` Chen Fan
2014-03-12  7:51                                                     ` [Qemu-devel] [RFC v4 2/3] i386: use CpuTopoInfo instead apic_id as argument for pc_new_cpu() Chen Fan
2014-03-12 15:39                                                       ` Eduardo Habkost
2014-03-12  7:51                                                     ` [Qemu-devel] [RFC v4 3/3] i386: introduce cpu QOM hierarchy tree Chen Fan
2014-03-11 10:58                                               ` [Qemu-devel] [RFC v3 " chen.fan.fnst
2014-03-04 10:50                                       ` [Qemu-devel] [RFC v2 2/2] " Chen Fan
2014-02-25  9:07                               ` [Qemu-devel] [PATCH 2/2][RFC] cpu: link each new cpu to QOM tree /machine/node/socket/core/thread/cpu respectively Chen Fan
2014-02-26 19:11                                 ` Eduardo Habkost
2014-02-13 10:00                     ` [Qemu-devel] Exposing and calculating CPU APIC IDs (was Re: [RFC 1/3] target-i386: moving registers of vmstate from cpu_exec_init() to x86_cpu_realizefn()) Igor Mammedov
2014-01-14  9:27 ` [Qemu-devel] [RFC 2/3] target-i386: add -smp X,apics=0x option Chen Fan
2014-02-17 18:37   ` Eric Blake [this message]
2014-02-18  1:49     ` Chen Fan
2014-01-14  9:27 ` [Qemu-devel] [RFC 3/3] target-i386: add qmp command 'query-cpus' to display apic_id Chen Fan
2014-02-17 18:37   ` Eric Blake

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=530256CD.20007@redhat.com \
    --to=eblake@redhat.com \
    --cc=afaerber@suse.de \
    --cc=chen.fan.fnst@cn.fujitsu.com \
    --cc=imammedo@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 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.