Hi, I have a couple of suggestions for improving this patch, please see
in-line text.
Thanks,
Ian
> -----Original Message-----
> From: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
> [mailto:xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx] On Behalf
> Of Xen patchbot -unstable
> Sent: 29 July 2005 11:36
> To: xen-changelog@xxxxxxxxxxxxxxxxxxx
> Subject: [Xen-changelog] This patch does 2 jobs:
>
> # HG changeset patch
> # User kaf24@xxxxxxxxxxxxxxxxxxxx
> # Node ID 2c0036a1cf4f6c7fc164c837f4c8daf58af1acba
> # Parent 52260d8c27754a54c636bc73483f51e189281ff7
> This patch does 2 jobs:
>
> - Enforce the number of CPUs dom0 will take. See the new
> variable "dom0-cpus" in xend-config.sxp (you will want to set
> this variable to
> 1 on SMP systems)
>
> - Balloon out dom0 memory when creating domU, if there is not
> enough free memory. The lowest level we will balloon out is
> configured via the new variable "dom0-min-mem" in xend-config.sxp
>
>
> I still have a doubt: where to put the code to enforce
> dom0-cpus. At the moment I put it into
> python/xen/xend/server/SrvDaemon.py, and hopefully that is
> resonable enough. Any comment?
>
> Signed-off-by: Nguyen Anh Quynh <aquynh@xxxxxxxxx>
> diff -r 52260d8c2775 -r 2c0036a1cf4f tools/python/xen/xend/XendRoot.py
> --- a/tools/python/xen/xend/XendRoot.py Fri Jul 29 10:36:11 2005
> +++ b/tools/python/xen/xend/XendRoot.py Fri Jul 29 10:36:53 2005
> @@ -75,6 +75,10 @@
>
> """Default port xend serves consoles at. """
> console_port_base_default = '9600'
> +
> + dom0_min_mem_default = '0'
> +
> + dom0_cpus_default = '0'
Let's also add something to the default xend-config.sxp such that:
dom0_min_mem = 80MB # don't let dom0 go below 80MB
dom0_cpus = 1 # give up all but 1 CPU
We should also provide an xm command for setting dom0_min_mem.
> +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
I'm not sure its ever a good idea to try taking a CPU in xend startup.
It may be offline for a reason e.g. its broken! Let's just give them
back.
> +def balloon_out(dom0_min_mem, opts):
> + """Balloon out to get memory for domU, if necessarily"""
> + SLACK = 4
> +
> + xc = xen.lowlevel.xc.new()
> + pinfo = xc.physinfo()
> + free_mem = pinfo['free_pages']/256
> + if free_mem < opts.vals.memory + SLACK:
> + need_mem = opts.vals.memory + SLACK - free_mem
> + cur_alloc = get_dom0_alloc()
> + if cur_alloc - need_mem >= dom0_min_mem:
> + server.xend_domain_mem_target_set(0, cur_alloc -
> need_mem)
> + del xc
I think this needs to be wait in a loop testing the amount of free
memory, with a timeout. It's going to take the dom0 balloon driver some
time to react. After changing the target we should sleep for 100ms, and
re-test to see how much is free, exiting the loop if there's sufficent
memory (+slack) for the new domain. If after e.g. 10s there's still not
enough memory, exit anyway and let the memory allocation fail.
I'd be grateful if you could write a follow up patch.
Thanks,
Ian
> +
> def main(argv):
> opts = gopts
> args = opts.parse(argv)
> @@ -671,6 +705,10 @@
> if opts.vals.dryrun:
> PrettyPrint.prettyprint(config)
> else:
> + dom0_min_mem = xroot.get_dom0_min_mem()
> + if dom0_min_mem != 0:
> + balloon_out(dom0_min_mem, opts)
> +
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
|