WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

RE: [Xen-devel] [PATCH 2/3] xend: Add multiple cpumasks support

To: "Ryan Harper" <ryanh@xxxxxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: RE: [Xen-devel] [PATCH 2/3] xend: Add multiple cpumasks support
From: "Ian Pratt" <m+Ian.Pratt@xxxxxxxxxxxx>
Date: Mon, 14 Aug 2006 19:10:15 +0100
Delivery-date: Mon, 14 Aug 2006 11:11:16 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
Thread-index: Aca/wwpPDI3S2WrIS0SWjBrKuZgTbQAAnMZQ
Thread-topic: [Xen-devel] [PATCH 2/3] xend: Add multiple cpumasks support
> This patch modifies xend to accept and parse multiple cpumask strings
> from the cpus parameter.  The cpus string stays the same, but it now
> can parse either a python list of strings:

According to the example config file, we currently take a string
containing the list of CPUs that the *domain* can run on. We should be
putting this CPU mask into all of the VCPUs for the domain (rather than
one bit in each as we currently do).

Adding support to enable separate masks for each VCPU isn't a bad idea,
but we certainly don't want to break the behaviour of being able to set
the mask for a domain.

Allowing a list of masks to be passed in (as well as a single string)
isn't a bad idea.

Surely the comma separated list of vcpus isn't compatible with the
current parsing? Or are you using the quotes to try and separate the
different vcpu masks? That's horrid.

BTW: As syntactic sugar, if the string starts with an exclusion, should
it implicitly mean that mask starts off containing all 1's rather than
all 0's? [avoiding the need to do "0-255,^0"]

Ian   
 
> [ '2-5, '2-5', '2-5' ]
> 
> A regular string with ", " as the separator:
> 
> "2-5, 2-5, 2-5, 2-5"
> 
> or a mixture of both:
> 
> [ 2-5, '2-5', 2-5, '2-5' ]
> 
> all result in the same list of integers which is used to create the
> cpumask for each vcpu in the domain.
> 
> Without this patch the cpus parameter only enables one bit of the
> cpumask preventing the credit scheduler from balancing.
> 
> --
> Ryan Harper
> Software Engineer; Linux Technology Center
> IBM Corp., Austin, Tx
> (512) 838-9253   T/L: 678-9253
> ryanh@xxxxxxxxxx
> 
> 
> diffstat output:
>  examples/xmexample.hvm            |    3 +
>  examples/xmexample.vti            |    1
>  examples/xmexample1               |    3 +
>  examples/xmexample2               |    3 +
>  examples/xmexample3               |    3 +
>  python/xen/xend/XendDomainInfo.py |   66
+++++++++++++++++++++++++--------
> -----
>  6 files changed, 53 insertions(+), 26 deletions(-)
> 
> Signed-off-by: Ryan Harper <ryanh@xxxxxxxxxx>
> ---
> diff -r e6de470f9287 tools/python/xen/xend/XendDomainInfo.py
> --- a/tools/python/xen/xend/XendDomainInfo.py Sat Aug 12 08:22:45 2006
-
> 0500
> +++ b/tools/python/xen/xend/XendDomainInfo.py Sat Aug 12 08:22:47 2006
-
> 0500
> @@ -328,27 +328,49 @@ def parseConfig(config):
>             else:
>                 result['cpus'] = str(result['cpu'])
> 
> -        # convert 'cpus' string to list of ints
> -        # 'cpus' supports a list of ranges (0-3), seperated by
> -        # commas, and negation, (^1).
> -        # Precedence is settled by  order of the string:
> -        #     "0-3,^1"   -> [0,2,3]
> -        #     "0-3,^1,1" -> [0,1,2,3]
> -        if result['cpus']:
> -            cpus = []
> -            for c in result['cpus'].split(','):
> -                if c.find('-') != -1:
> -                    (x,y) = c.split('-')
> -                    for i in range(int(x),int(y)+1):
> -                        cpus.append(int(i))
> -                else:
> -                    # remove this element from the list
> -                    if c[0] == '^':
> -                        cpus = [x for x in cpus if x != int(c[1:])]
> +        if result['cpus'] is not None:
> +            # see if cpus string specifies multiple cpumasks, or just
one
> +            # e.g: "[ '2-5', '0-1', '0-3,^1', '5' ]" vs. "0-3,5"
> +            if result['cpus'].startswith("["):
> +                # the below was tested with the following sample
string
> +                # "[4, '2-5','2-5', '1-3,6,^2', '2-6','1' 1-7,^2 ]"
and
> resulted in
> +                # ['4', '2-5', '2-5', '1-3,6,^2', '2-6', '1']
> +                result['cpus'] = filter(lambda x: len(x), map(lambda
x:
> x.strip(", "),
> +
> result['cpus'].replace('[',"").replace(']',"").split("'")))
> +
> +            # if user didn't use list bracket, convert to to list of
> strings
> +            # cpus = "4, 2-5,^4, 1-3,5,^2, 1, ^2" ->
> +            # ['4', '2-5,^4', '1-3,5,^2', '1', '^2']
> +            # also takes care of cpus = "4"
> +            else:
> +                result['cpus'] = map(lambda x: x.strip(", "),
> result['cpus'].split())
> +
> +            # convert 'cpus' list of strings into a list of list of
ints
> +            # 'cpus' supports a list of ranges (0-3), seperated by
> +            # commas, and negation, (^1).
> +            # Precedence is settled by  order of the string:
> +            #     "0-3,^1"   -> [0,2,3]
> +            #     "0-3,^1,1" -> [0,1,2,3]
> +
> +            new_cpus = []
> +            for x in result['cpus']:
> +                cpus = []
> +                for c in x.split(','):
> +                    if c.find('-') != -1:
> +                        (x,y) = c.split('-')
> +                        for i in range(int(x),int(y)+1):
> +                            cpus.append(int(i))
>                      else:
> -                        cpus.append(int(c))
> -
> -            result['cpus'] = cpus
> +                        # remove this element from the list
> +                        if c[0] == '^':
> +                            cpus = [x for x in cpus if x !=
int(c[1:])]
> +                        else:
> +                            cpus.append(int(c))
> +
> +                new_cpus.append(cpus)
> +
> +
> +            result['cpus'] = new_cpus
> 
>      except ValueError, exn:
>          raise VmError(
> @@ -1275,8 +1297,8 @@ class XendDomainInfo:
>              cpus = self.info['cpus']
>              if cpus is not None and len(cpus) > 0:
>                  for v in range(0, self.info['max_vcpu_id']+1):
> -                    # pincpu takes a list of ints
> -                    cpu = [ int( cpus[v % len(cpus)] ) ]
> +                    # pincpu takes a list of ints,
> +                    cpu = map(lambda x: int(x), cpus[v % len(cpus)])
>                      xc.vcpu_setaffinity(self.domid, v, cpu)
> 
>              # set domain maxmem in KiB
> diff -r e6de470f9287 tools/examples/xmexample.hvm
> --- a/tools/examples/xmexample.hvm    Sat Aug 12 08:22:45 2006 -0500
> +++ b/tools/examples/xmexample.hvm    Sat Aug 12 08:34:13 2006 -0500
> @@ -47,10 +47,11 @@ name = "ExampleHVMDomain"
>  # enable/disable HVM guest APIC, default=0 (disabled)
>  #apic=0
> 
> -# List of which CPUS this domain is allowed to use, default Xen picks
> +# List of which CPUS vcpus are allowed to use, default Xen picks
>  #cpus = ""         # leave to Xen to pick
>  #cpus = "0"        # all vcpus run on CPU0
>  #cpus = "0-3,5,^1" # run on cpus 0,2,3,5
> +#cpus = "0-1, 2-3" # run VCPU0 on CPU0-1, VCPU1 on CPU2-3
> 
>  # Optionally define mac and/or bridge for the network interfaces.
>  # Random MACs are assigned if not given.
> diff -r e6de470f9287 tools/examples/xmexample.vti
> --- a/tools/examples/xmexample.vti    Sat Aug 12 08:22:45 2006 -0500
> +++ b/tools/examples/xmexample.vti    Sat Aug 12 08:39:42 2006 -0500
> @@ -34,6 +34,7 @@ name = "ExampleVTIDomain"
>  #cpus = ""         # leave to Xen to pick
>  #cpus = "0"        # all vcpus run on CPU0
>  #cpus = "0-3,5,^1" # run on cpus 0,2,3,5
> +#cpus = "0-1, 2-3" # run VCPU0 on CPU0-1, VCPU1 on CPU2-3
> 
>  # Optionally define mac and/or bridge for the network interfaces.
>  # Random MACs are assigned if not given.
> diff -r e6de470f9287 tools/examples/xmexample1
> --- a/tools/examples/xmexample1       Sat Aug 12 08:22:45 2006 -0500
> +++ b/tools/examples/xmexample1       Sat Aug 12 08:27:02 2006 -0500
> @@ -30,10 +30,11 @@ name = "ExampleDomain"
>  # on each call to 'xm create'.
>  #uuid = "06ed00fe-1162-4fc4-b5d8-11993ee4a8b9"
> 
> -# List of which CPUS this domain is allowed to use, default Xen picks
> +# List of which CPUS vcpus are allowed to use, default Xen picks
>  #cpus = ""         # leave to Xen to pick
>  #cpus = "0"        # all vcpus run on CPU0
>  #cpus = "0-3,5,^1" # run on cpus 0,2,3,5
> +#cpus = "0-1, 2-3" # run VCPU0 on CPU0-1, VCPU1 on CPU2-3
> 
>  # Number of Virtual CPUS to use, default is 1
>  #vcpus = 1
> diff -r e6de470f9287 tools/examples/xmexample2
> --- a/tools/examples/xmexample2       Sat Aug 12 08:22:45 2006 -0500
> +++ b/tools/examples/xmexample2       Sat Aug 12 08:27:47 2006 -0500
> @@ -59,10 +59,11 @@ name = "VM%d" % vmid
>  # on each call to 'xm create'.
>  #uuid = "06ed00fe-1162-4fc4-b5d8-11993ee4a8b9"
> 
> -# List of which CPUS this domain is allowed to use, default Xen picks
> +# List of which CPUS vcpus are allowed to use, default Xen picks
>  #cpus = ""         # leave to Xen to pick
>  #cpus = "0"        # all vcpus run on CPU0
>  #cpus = "0-3,5,^1" # run on cpus 0,2,3,5
> +#cpus = "0-1, 2-3" # run VCPU0 on CPU0-1, VCPU1 on CPU2-3
>  #cpus = "%s" % vmid # set based on vmid (mod number of CPUs)
> 
>  # Number of Virtual CPUS to use, default is 1
> diff -r e6de470f9287 tools/examples/xmexample3
> --- a/tools/examples/xmexample3       Sat Aug 12 08:22:45 2006 -0500
> +++ b/tools/examples/xmexample3       Sat Aug 12 08:33:35 2006 -0500
> @@ -59,10 +59,11 @@ name = "VM%d" % vmid
>  # on each call to 'xm create'.
>  #uuid = "06ed00fe-1162-4fc4-b5d8-11993ee4a8b9"
> 
> -# List of which CPUS this domain is allowed to use, default Xen picks
> +# List of which CPUS vcpus are allowed to use, default Xen picks
>  #cpus = ""         # leave to Xen to pick
>  #cpus = "0"        # all vcpus run on CPU0
>  #cpus = "0-3,5,^1" # run on cpus 0,2,3,5
> +#cpus = "0-1, 2-3" # run VCPU0 on CPU0-1, VCPU1 on CPU2-3
>  cpus = "%s" % vmid # set based on vmid (mod number of CPUs)
> 
>
#-----------------------------------------------------------------------
--
> ---
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@xxxxxxxxxxxxxxxxxxx
> http://lists.xensource.com/xen-devel

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel