All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wanlong Gao <gaowanlong@cn.fujitsu.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: andre.przywara@amd.com, aliguori@us.ibm.com, ehabkost@redhat.com,
	qemu-devel@nongnu.org, y-goto@jp.fujitsu.com, afaerber@suse.de,
	Wanlong Gao <gaowanlong@cn.fujitsu.com>
Subject: Re: [Qemu-devel] [PATCH 3/7] NUMA: parse guest numa nodes memory policy
Date: Tue, 18 Jun 2013 17:54:24 +0800	[thread overview]
Message-ID: <51C02E50.9070200@cn.fujitsu.com> (raw)
In-Reply-To: <51C02665.1060205@redhat.com>

On 06/18/2013 05:20 PM, Paolo Bonzini wrote:
> Il 18/06/2013 10:09, Wanlong Gao ha scritto:
>> +static unsigned int numa_node_parse_mpol(const char *str, unsigned long *bm)
>> +{
>> +    unsigned long long value, endvalue;
>> +    char *endptr;
>> +    unsigned int flags = 0;
>> +
>> +    if (str[0] == '!') {
>> +        flags |= 2;
> 
> clear = true;
> 
>> +        bitmap_fill(bm, MAX_CPUMASK_BITS);
>> +        str++;
>> +    }
>> +    if (str[0] == '+') {
>> +        flags |= 1;
> 
> flags = NODE_HOST_RELATIVE
> 
>> +        str++;
>> +    }
>> +
>> +    if (!strcmp(str, "all")) {
>> +        bitmap_fill(bm, MAX_CPUMASK_BITS);
>> +        return flags;
>> +    }
>> +
>> +    if (parse_uint(str, &value, &endptr, 10) < 0)
>> +        goto error;
>> +    if (*endptr == '-') {
>> +        if (parse_uint_full(endptr + 1, &endvalue, 10) < 0) {
>> +            goto error;
>> +        }
>> +    } else if (*endptr == '\0') {
>> +        endvalue = value;
>> +    } else {
>> +        goto error;
>> +    }
>> +
>> +    if (endvalue >= MAX_CPUMASK_BITS) {
>> +        endvalue = MAX_CPUMASK_BITS - 1;
>> +        fprintf(stderr,
>> +            "qemu: NUMA: A max of %d host nodes are supported\n",
>> +             MAX_CPUMASK_BITS);
>> +    }
>> +
>> +    if (endvalue < value) {
>> +        goto error;
>> +    }
>> +
>> +    if (flags & 2)
> 
> if (clear)
> 
>> +        bitmap_clear(bm, value, endvalue - value + 1);
>> +    else
>> +        bitmap_set(bm, value, endvalue - value + 1);
>> +
>> +    return flags;
>> +
>> +error:
>> +    fprintf(stderr, "qemu: Invalid host NUMA nodes range: %s\n", str);
> 
> Please change the functions (numa_add and numa_node_parse_mpol) to
> accept an Error *.  This will make it much easier to reuse them for e.g.
> memory hotplug in the future.

Got it, I'll try. Thank you.

> 
>> +    return 4;
> 
> return -EINVAL;
> 
>> +}
> 
>> +        if (get_param_value(option, 128, "interleave", optarg) != 0)
>> +            numa_info[nodenr].flags |= NODE_HOST_INTERLEAVE;
>> +        else if (get_param_value(option, 128, "preferred", optarg) != 0)
>> +            numa_info[nodenr].flags |= NODE_HOST_PREFERRED;
>> +        else if (get_param_value(option, 128, "membind", optarg) != 0)
>> +            numa_info[nodenr].flags |= NODE_HOST_BIND;
> 
> You're not handling the case where someone specifies more than one option.
> 
> What about:
> 
>    policy={interleave,preferred,bind},mem-hostnode=0
> 
> ?

OK, will follow this, thank you.

> 
> Also, please use QemuOpts instead of yet another homegrown parser.
> Eduardo, I think you had the most recent attempt to convert -numa to
> QemuOpts?

So, any patches I can based on or change it myself?  Eduardo?


Thanks,
Wanlong Gao

> 
>> +        if (option[0] != 0) {
>> +            ret = numa_node_parse_mpol(option, numa_info[nodenr].host_mem);
>> +            if (ret == 4) {
> 
> if (ret < 0)
> 
>> +                exit(1);
>> +            } else if (ret & 1) {
>> +                numa_info[nodenr].flags |= NODE_HOST_RELATIVE;
> 
> else {
>     numa_info[nodenr].flags |= ret;
> }
> 
>> +            }
>> +        }
>> +
> 
> Paolo
> 

  reply	other threads:[~2013-06-18  9:56 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-18  8:09 [Qemu-devel] [PATCH 0/7] Add support for binding guest numa nodes to host numa nodes Wanlong Gao
2013-06-18  8:09 ` [Qemu-devel] [PATCH 1/7] Add numa_info structure to contain numa nodes info Wanlong Gao
2013-06-18  8:09 ` [Qemu-devel] [PATCH 2/7] Add Linux libnuma detection Wanlong Gao
2013-06-18  8:09 ` [Qemu-devel] [PATCH 3/7] NUMA: parse guest numa nodes memory policy Wanlong Gao
2013-06-18  9:20   ` Paolo Bonzini
2013-06-18  9:54     ` Wanlong Gao [this message]
2013-06-18 19:00     ` Eduardo Habkost
2013-06-18 20:19       ` Bandan Das
2013-06-19  8:01         ` Wanlong Gao
2013-06-19 17:39           ` Paolo Bonzini
2013-06-20  0:01             ` Wanlong Gao
2013-06-18  8:09 ` [Qemu-devel] [PATCH 4/7] NUMA: set " Wanlong Gao
2013-06-18  8:09 ` [Qemu-devel] [PATCH 5/7] NUMA: add qmp command set-mpol to set memory policy for NUMA node Wanlong Gao
2013-06-18  9:21   ` Paolo Bonzini
2013-06-18  9:44     ` Wanlong Gao
2013-06-18  9:57       ` Paolo Bonzini
2013-06-18  8:09 ` [Qemu-devel] [PATCH 6/7] NUMA: add hmp command set-mpol Wanlong Gao
2013-06-18  9:23   ` Paolo Bonzini
2013-06-18  9:49     ` Wanlong Gao
2013-06-18  8:09 ` [Qemu-devel] [PATCH 7/7] NUMA: show host memory policy info in info numa command Wanlong Gao

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=51C02E50.9070200@cn.fujitsu.com \
    --to=gaowanlong@cn.fujitsu.com \
    --cc=afaerber@suse.de \
    --cc=aliguori@us.ibm.com \
    --cc=andre.przywara@amd.com \
    --cc=ehabkost@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=y-goto@jp.fujitsu.com \
    /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.