qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] qemu, numa: non-contiguous cpusets
@ 2013-09-29 15:10 Borislav Petkov
  2013-09-30  8:15 ` Daniel P. Berrange
  2013-09-30  9:05 ` Paolo Bonzini
  0 siblings, 2 replies; 5+ messages in thread
From: Borislav Petkov @ 2013-09-29 15:10 UTC (permalink / raw)
  To: Eduardo Habkost
  Cc: KVM, Gleb Natapov, libvir-list, Joerg Roedel, X86 ML, LKML,
	qemu-devel, Andre Przywara, H. Peter Anvin, Paolo Bonzini,
	Jiri Denemark, Borislav Petkov

Btw,

while I got your attention, on a not-really related topic: how do we
feel about adding support for specifying a non-contiguous set of cpus
for a numa node in qemu with the -numa option? I.e., like this, for
example:

x86_64-softmmu/qemu-system-x86_64 -smp 8 -numa node,nodeid=0,cpus=0\;2\;4-5 -numa node,nodeid=1,cpus=1\;3\;6-7

The ';' needs to be escaped from the shell but I'm open for better
suggestions.

Here's a diff:

---
diff --git a/vl.c b/vl.c
index 4e709d5c1c20..82a6c8451fb0 100644
--- a/vl.c
+++ b/vl.c
@@ -1261,9 +1261,27 @@ char *get_boot_devices_list(size_t *size)
     return list;
 }
 
+static int __numa_set_cpus(unsigned long *map, int start, int end)
+{
+    if (end >= MAX_CPUMASK_BITS) {
+        end = MAX_CPUMASK_BITS - 1;
+        fprintf(stderr,
+            "qemu: NUMA: A max of %d VCPUs are supported\n",
+             MAX_CPUMASK_BITS);
+        return -EINVAL;
+    }
+
+    if (end < start) {
+        return -EINVAL;
+    }
+
+    bitmap_set(map, start, end-start+1);
+    return 0;
+}
+
 static void numa_node_parse_cpus(int nodenr, const char *cpus)
 {
-    char *endptr;
+    char *endptr, *ptr = (char *)cpus;
     unsigned long long value, endvalue;
 
     /* Empty CPU range strings will be considered valid, they will simply
@@ -1273,7 +1291,8 @@ static void numa_node_parse_cpus(int nodenr, const char *cpus)
         return;
     }
 
-    if (parse_uint(cpus, &value, &endptr, 10) < 0) {
+fromthetop:
+    if (parse_uint(ptr, &value, &endptr, 10) < 0) {
         goto error;
     }
     if (*endptr == '-') {
@@ -1282,22 +1301,22 @@ static void numa_node_parse_cpus(int nodenr, const char *cpus)
         }
     } else if (*endptr == '\0') {
         endvalue = value;
-    } else {
-        goto error;
-    }
+    } else if (*endptr == ';') {
+	if (__numa_set_cpus(node_cpumask[nodenr], value, value) < 0) {
+		goto error;
+	}
+	endptr++;
+        if (*endptr == '\0')
+	    return;
 
-    if (endvalue >= MAX_CPUMASK_BITS) {
-        endvalue = MAX_CPUMASK_BITS - 1;
-        fprintf(stderr,
-            "qemu: NUMA: A max of %d VCPUs are supported\n",
-             MAX_CPUMASK_BITS);
-    }
+	ptr = endptr;
 
-    if (endvalue < value) {
+	goto fromthetop;
+    } else {
         goto error;
     }
 
-    bitmap_set(node_cpumask[nodenr], value, endvalue-value+1);
+    __numa_set_cpus(node_cpumask[nodenr], value, endvalue);
     return;
 
 error:
--

Thanks.

-- 
Regards/Gruss,
    Boris.

Sent from a fat crate under my desk. Formatting is fine.
--

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] qemu, numa: non-contiguous cpusets
  2013-09-29 15:10 [Qemu-devel] qemu, numa: non-contiguous cpusets Borislav Petkov
@ 2013-09-30  8:15 ` Daniel P. Berrange
  2013-09-30  9:05 ` Paolo Bonzini
  1 sibling, 0 replies; 5+ messages in thread
From: Daniel P. Berrange @ 2013-09-30  8:15 UTC (permalink / raw)
  To: Borislav Petkov
  Cc: Eduardo Habkost, Gleb Natapov, libvir-list, Joerg Roedel, X86 ML,
	LKML, qemu-devel, Andre Przywara, KVM, H. Peter Anvin,
	Paolo Bonzini, Jiri Denemark, Borislav Petkov

On Sun, Sep 29, 2013 at 05:10:44PM +0200, Borislav Petkov wrote:
> Btw,
> 
> while I got your attention, on a not-really related topic: how do we
> feel about adding support for specifying a non-contiguous set of cpus
> for a numa node in qemu with the -numa option? I.e., like this, for
> example:
> 
> x86_64-softmmu/qemu-system-x86_64 -smp 8 -numa node,nodeid=0,cpus=0\;2\;4-5 -numa node,nodeid=1,cpus=1\;3\;6-7
> 
> The ';' needs to be escaped from the shell but I'm open for better
> suggestions.

Use a ':' instead.

Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] qemu, numa: non-contiguous cpusets
  2013-09-29 15:10 [Qemu-devel] qemu, numa: non-contiguous cpusets Borislav Petkov
  2013-09-30  8:15 ` Daniel P. Berrange
@ 2013-09-30  9:05 ` Paolo Bonzini
  2013-09-30  9:49   ` Borislav Petkov
  1 sibling, 1 reply; 5+ messages in thread
From: Paolo Bonzini @ 2013-09-30  9:05 UTC (permalink / raw)
  To: Borislav Petkov
  Cc: Eduardo Habkost, Gleb Natapov, libvir-list, Joerg Roedel, X86 ML,
	LKML, qemu-devel, Andre Przywara, KVM, H. Peter Anvin,
	Igor Mammedov, Jiri Denemark, Borislav Petkov

Il 29/09/2013 17:10, Borislav Petkov ha scritto:
> Btw,
> 
> while I got your attention, on a not-really related topic: how do we
> feel about adding support for specifying a non-contiguous set of cpus
> for a numa node in qemu with the -numa option? I.e., like this, for
> example:
> 
> x86_64-softmmu/qemu-system-x86_64 -smp 8 -numa node,nodeid=0,cpus=0\;2\;4-5 -numa node,nodeid=1,cpus=1\;3\;6-7

I think there are already patches on the list to do that, as part of the
NUMA memory binding series from Wanlong Gao.

Paolo

> The ';' needs to be escaped from the shell but I'm open for better
> suggestions.
> 
> Here's a diff:
> 
> ---
> diff --git a/vl.c b/vl.c
> index 4e709d5c1c20..82a6c8451fb0 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -1261,9 +1261,27 @@ char *get_boot_devices_list(size_t *size)
>      return list;
>  }
>  
> +static int __numa_set_cpus(unsigned long *map, int start, int end)
> +{
> +    if (end >= MAX_CPUMASK_BITS) {
> +        end = MAX_CPUMASK_BITS - 1;
> +        fprintf(stderr,
> +            "qemu: NUMA: A max of %d VCPUs are supported\n",
> +             MAX_CPUMASK_BITS);
> +        return -EINVAL;
> +    }
> +
> +    if (end < start) {
> +        return -EINVAL;
> +    }
> +
> +    bitmap_set(map, start, end-start+1);
> +    return 0;
> +}
> +
>  static void numa_node_parse_cpus(int nodenr, const char *cpus)
>  {
> -    char *endptr;
> +    char *endptr, *ptr = (char *)cpus;
>      unsigned long long value, endvalue;
>  
>      /* Empty CPU range strings will be considered valid, they will simply
> @@ -1273,7 +1291,8 @@ static void numa_node_parse_cpus(int nodenr, const char *cpus)
>          return;
>      }
>  
> -    if (parse_uint(cpus, &value, &endptr, 10) < 0) {
> +fromthetop:
> +    if (parse_uint(ptr, &value, &endptr, 10) < 0) {
>          goto error;
>      }
>      if (*endptr == '-') {
> @@ -1282,22 +1301,22 @@ static void numa_node_parse_cpus(int nodenr, const char *cpus)
>          }
>      } else if (*endptr == '\0') {
>          endvalue = value;
> -    } else {
> -        goto error;
> -    }
> +    } else if (*endptr == ';') {
> +	if (__numa_set_cpus(node_cpumask[nodenr], value, value) < 0) {
> +		goto error;
> +	}
> +	endptr++;
> +        if (*endptr == '\0')
> +	    return;
>  
> -    if (endvalue >= MAX_CPUMASK_BITS) {
> -        endvalue = MAX_CPUMASK_BITS - 1;
> -        fprintf(stderr,
> -            "qemu: NUMA: A max of %d VCPUs are supported\n",
> -             MAX_CPUMASK_BITS);
> -    }
> +	ptr = endptr;
>  
> -    if (endvalue < value) {
> +	goto fromthetop;
> +    } else {
>          goto error;
>      }
>  
> -    bitmap_set(node_cpumask[nodenr], value, endvalue-value+1);
> +    __numa_set_cpus(node_cpumask[nodenr], value, endvalue);
>      return;
>  
>  error:
> --
> 
> Thanks.
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] qemu, numa: non-contiguous cpusets
  2013-09-30  9:05 ` Paolo Bonzini
@ 2013-09-30  9:49   ` Borislav Petkov
  2013-09-30 12:18     ` Paolo Bonzini
  0 siblings, 1 reply; 5+ messages in thread
From: Borislav Petkov @ 2013-09-30  9:49 UTC (permalink / raw)
  To: Paolo Bonzini
  Cc: Eduardo Habkost, Gleb Natapov, libvir-list, Joerg Roedel, X86 ML,
	LKML, qemu-devel, Andre Przywara, KVM, H. Peter Anvin,
	Igor Mammedov, Jiri Denemark, Borislav Petkov

On Mon, Sep 30, 2013 at 11:05:10AM +0200, Paolo Bonzini wrote:
> I think there are already patches on the list to do that, as part of
> the NUMA memory binding series from Wanlong Gao.

Yeah: https://lists.gnu.org/archive/html/qemu-devel/2013-09/msg02833.html

Although I don't see from it how the syntax for -cpus will look like
from that QAPI magic except that it is an

+   '*cpus':   ['uint16'],

:-)

Thanks.

-- 
Regards/Gruss,
    Boris.

Sent from a fat crate under my desk. Formatting is fine.
--

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] qemu, numa: non-contiguous cpusets
  2013-09-30  9:49   ` Borislav Petkov
@ 2013-09-30 12:18     ` Paolo Bonzini
  0 siblings, 0 replies; 5+ messages in thread
From: Paolo Bonzini @ 2013-09-30 12:18 UTC (permalink / raw)
  To: Borislav Petkov
  Cc: Eduardo Habkost, Gleb Natapov, libvir-list, Joerg Roedel, X86 ML,
	LKML, qemu-devel, Andre Przywara, KVM, H. Peter Anvin,
	Igor Mammedov, Jiri Denemark, Borislav Petkov

Il 30/09/2013 11:49, Borislav Petkov ha scritto:
> Yeah: https://lists.gnu.org/archive/html/qemu-devel/2013-09/msg02833.html
> 
> Although I don't see from it how the syntax for -cpus will look like
> from that QAPI magic except that it is an
> 
> +   '*cpus':   ['uint16'],

It's "-numa node,cpus=0-1,cpus=4-5".

Paolo

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-09-30 12:18 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-29 15:10 [Qemu-devel] qemu, numa: non-contiguous cpusets Borislav Petkov
2013-09-30  8:15 ` Daniel P. Berrange
2013-09-30  9:05 ` Paolo Bonzini
2013-09-30  9:49   ` Borislav Petkov
2013-09-30 12:18     ` Paolo Bonzini

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).