All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christian Limpach <christian.limpach@gmail.com>
To: Ryan Harper <ryanh@us.ibm.com>
Cc: xen-devel@lists.xensource.com
Subject: Re: [PATCH] [BUG#222] fix enforce_dom0_cpus to use vcpu_hotplug
Date: Fri, 16 Sep 2005 20:12:02 +0100	[thread overview]
Message-ID: <3d8eece205091612126985235b@mail.gmail.com> (raw)
In-Reply-To: <20050915221834.GB8699@us.ibm.com>

Thanks!

On 9/15/05, Ryan Harper <ryanh@us.ibm.com> wrote:
> This patch has enforce_dom0_cpus() use vcpu_hotplug rather than directly
> modifying the sysfs entries which would cause the xenstore state of
> a cpu's availability to be incorrect.  I've also modified slightly the
> dom0-cpus description in the xend-config.  Rather than specifying which
> dom0 vcpus are to be used, it is now a target of how many vcpus to used
> as pinvcpu ops are the preferred method for setting which physical cpu a
> vcpu uses.  In fixing this bug, I also uncovered another [1]bug related
> to hotplug in dom0.
> 
> 1. http://bugzilla.xensource.com/bugzilla/show_bug.cgi?id=228
> 
> --
> Ryan Harper
> Software Engineer; Linux Technology Center
> IBM Corp., Austin, Tx
> (512) 838-9253   T/L: 678-9253
> ryanh@us.ibm.com
> 
> 
> diffstat output:
>  examples/xend-config.sxp            |    2 +-
>  python/xen/xend/XendDomain.py       |    1 +
>  python/xen/xend/XendDomainInfo.py   |   20 ++++++++++++++++++++
>  python/xen/xend/server/SrvDaemon.py |   27 ---------------------------
>  4 files changed, 22 insertions(+), 28 deletions(-)
> 
> Signed-off-by: Ryan Harper <ryanh@us.ibm.com>
> ---
> diff -r c21f47a03225 tools/examples/xend-config.sxp
> --- a/tools/examples/xend-config.sxp    Thu Sep 15 17:09:50 2005
> +++ b/tools/examples/xend-config.sxp    Thu Sep 15 17:08:03 2005
> @@ -49,6 +49,6 @@
>  # If dom0-min-mem=0, dom0 will never balloon out.
>  (dom0-min-mem 0)
> 
> -# In SMP system, dom0 will use only CPUs in range [1,dom0-cpus]
> +# In SMP system, dom0 will use dom0-cpus # of CPUS
>  # If dom0-cpus = 0, dom0 will take all cpus available
>  (dom0-cpus 0)
> diff -r c21f47a03225 tools/python/xen/xend/XendDomain.py
> --- a/tools/python/xen/xend/XendDomain.py       Thu Sep 15 17:09:50 2005
> +++ b/tools/python/xen/xend/XendDomain.py       Thu Sep 15 17:08:03 2005
> @@ -155,6 +155,7 @@
>         if not dom0:
>             dom0 = self.domain_unknown(0)
>         dom0.dom0_init_store()
> +        dom0.enforce_dom0_cpus()
> 
>     def close(self):
>         pass
> diff -r c21f47a03225 tools/python/xen/xend/XendDomainInfo.py
> --- a/tools/python/xen/xend/XendDomainInfo.py   Thu Sep 15 17:09:50 2005
> +++ b/tools/python/xen/xend/XendDomainInfo.py   Thu Sep 15 17:08:03 2005
> @@ -1111,6 +1111,26 @@
>             # get run-time value of vcpus and update store
>             self.configure_vcpus(dom_get(self.domid)['vcpus'])
> 
> +    def enforce_dom0_cpus(self):
> +        dom = 0
> +        # get max number of cpus to use for dom0 from config
> +        from xen.xend import XendRoot
> +        xroot = XendRoot.instance()
> +        target = int(xroot.get_dom0_cpus())
> +        log.debug("number of cpus to use is %d"%(target))
> +
> +        # target = 0 means use all processors
> +        if target > 0:
> +            # count the number of online vcpus (cpu values in v2c map >= 0)
> +            vcpu_to_cpu  = dom_get(dom)['vcpu_to_cpu']
> +            vcpus_online = len(filter(lambda x: x>=0, vcpu_to_cpu))
> +            log.debug("found %d vcpus online"%(vcpus_online))
> +
> +            # disable any extra vcpus that are online over the requested target
> +            for vcpu in range(target,vcpus_online):
> +                log.info("enforcement is disabling DOM%d VCPU%d"%(dom,vcpu))
> +                self.vcpu_hotplug(vcpu, 0)
> +
> 
>  def vm_field_ignore(_, _1, _2, _3):
>     """Dummy config field handler used for fields with built-in handling.
> diff -r c21f47a03225 tools/python/xen/xend/server/SrvDaemon.py
> --- a/tools/python/xen/xend/server/SrvDaemon.py Thu Sep 15 17:09:50 2005
> +++ b/tools/python/xen/xend/server/SrvDaemon.py Thu Sep 15 17:08:03 2005
> @@ -298,7 +298,6 @@
>         return self.cleanup(kill=True)
> 
>     def run(self, status):
> -        _enforce_dom0_cpus()
>         try:
>             log.info("Xend Daemon started")
>             event.listenEvent(self)
> @@ -323,32 +322,6 @@
>         #sys.exit(rc)
>         os._exit(rc)
> 
> -def _enforce_dom0_cpus():
> -    dn = xroot.get_dom0_cpus()
> -
> -    for d in glob.glob("/sys/devices/system/cpu/cpu*"):
> -        cpu = int(os.path.basename(d)[3:])
> -        if (dn == 0) or (cpu < dn):
> -            v = "1"
> -        else:
> -            v = "0"
> -        try:
> -            f = open("%s/online" %d, "r+")
> -            c = f.read(1)
> -            if (c != v):
> -                if v == "0":
> -                    log.info("dom0 is trying to give back cpu %d", cpu)
> -                else:
> -                    log.info("dom0 is trying to take cpu %d", cpu)
> -                f.seek(0)
> -                f.write(v)
> -                f.close()
> -                log.info("dom0 successfully enforced cpu %d", cpu)
> -            else:
> -                f.close()
> -        except:
> -            pass
> -
>  def instance():
>     global inst
>     try:
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xensource.com
> http://lists.xensource.com/xen-devel
>

      reply	other threads:[~2005-09-16 19:12 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-09-15 22:18 [PATCH] [BUG#222] fix enforce_dom0_cpus to use vcpu_hotplug Ryan Harper
2005-09-16 19:12 ` Christian Limpach [this message]

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=3d8eece205091612126985235b@mail.gmail.com \
    --to=christian.limpach@gmail.com \
    --cc=Christian.Limpach@cl.cam.ac.uk \
    --cc=ryanh@us.ibm.com \
    --cc=xen-devel@lists.xensource.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.