From mboxrd@z Thu Jan 1 00:00:00 1970 From: Christian Limpach Subject: Re: [PATCH] [BUG#222] fix enforce_dom0_cpus to use vcpu_hotplug Date: Fri, 16 Sep 2005 20:12:02 +0100 Message-ID: <3d8eece205091612126985235b@mail.gmail.com> References: <20050915221834.GB8699@us.ibm.com> Reply-To: Christian.Limpach@cl.cam.ac.uk Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Return-path: In-Reply-To: <20050915221834.GB8699@us.ibm.com> Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Ryan Harper Cc: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org Thanks! On 9/15/05, Ryan Harper 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. >=20 > 1. http://bugzilla.xensource.com/bugzilla/show_bug.cgi?id=3D228 >=20 > -- > Ryan Harper > Software Engineer; Linux Technology Center > IBM Corp., Austin, Tx > (512) 838-9253 T/L: 678-9253 > ryanh@us.ibm.com >=20 >=20 > 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(-) >=20 > Signed-off-by: Ryan Harper > --- > 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=3D0, dom0 will never balloon out. > (dom0-min-mem 0) >=20 > -# 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 =3D 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 =3D self.domain_unknown(0) > dom0.dom0_init_store() > + dom0.enforce_dom0_cpus() >=20 > 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']) >=20 > + def enforce_dom0_cpus(self): > + dom =3D 0 > + # get max number of cpus to use for dom0 from config > + from xen.xend import XendRoot > + xroot =3D XendRoot.instance() > + target =3D int(xroot.get_dom0_cpus()) > + log.debug("number of cpus to use is %d"%(target)) > + > + # target =3D 0 means use all processors > + if target > 0: > + # count the number of online vcpus (cpu values in v2c map >= =3D 0) > + vcpu_to_cpu =3D dom_get(dom)['vcpu_to_cpu'] > + vcpus_online =3D len(filter(lambda x: x>=3D0, 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,vc= pu)) > + self.vcpu_hotplug(vcpu, 0) > + >=20 > 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=3DTrue) >=20 > 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) >=20 > -def _enforce_dom0_cpus(): > - dn =3D xroot.get_dom0_cpus() > - > - for d in glob.glob("/sys/devices/system/cpu/cpu*"): > - cpu =3D int(os.path.basename(d)[3:]) > - if (dn =3D=3D 0) or (cpu < dn): > - v =3D "1" > - else: > - v =3D "0" > - try: > - f =3D open("%s/online" %d, "r+") > - c =3D f.read(1) > - if (c !=3D v): > - if v =3D=3D "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: >=20 > _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.xensource.com > http://lists.xensource.com/xen-devel >