ia64/linux-2.6.18-xen.hg

changeset 515:b61443b1bf76

linux/balloon: don't allow ballooning down a domain below a reasonable limit

Reasonable is hard to judge; we don't want to disallow small domains.
But the system needs a reasonable amount of memory to perform its
duties, set up tables, etc. If on the other hand, the admin is able
to set up and boot up correctly a very small domain, there's no point
in forcing it to be larger. We end up with some kind of logarithmic
function, approximated.

Signed-off-by: Kurt Garloff <garloff@suse.de>
Signed-off-by: Jan Beulich <jbeulich@novell.com>
author Keir Fraser <keir.fraser@citrix.com>
date Sat Apr 05 22:36:49 2008 +0100 (2008-04-05)
parents 0d6c9c975eae
children 10b69cd7ac53
files drivers/xen/balloon/balloon.c
line diff
     1.1 --- a/drivers/xen/balloon/balloon.c	Fri Apr 04 13:27:48 2008 +0100
     1.2 +++ b/drivers/xen/balloon/balloon.c	Sat Apr 05 22:36:49 2008 +0100
     1.3 @@ -194,6 +194,41 @@ static unsigned long current_target(void
     1.4  	return target;
     1.5  }
     1.6  
     1.7 +static unsigned long minimum_target(void)
     1.8 +{
     1.9 +#ifndef CONFIG_XEN
    1.10 +	return 0;
    1.11 +#else
    1.12 +	unsigned long min_pages, curr_pages = current_target();
    1.13 +
    1.14 +#define MB2PAGES(mb) ((mb) << (20 - PAGE_SHIFT))
    1.15 +	/* Simple continuous piecewiese linear function:
    1.16 +	 *  max MiB -> min MiB	gradient
    1.17 +	 *       0	   0
    1.18 +	 *      16	  16
    1.19 +	 *      32	  24
    1.20 +	 *     128	  72	(1/2)
    1.21 +	 *     512 	 168	(1/4)
    1.22 +	 *    2048	 360	(1/8)
    1.23 +	 *    8192	 552	(1/32)
    1.24 +	 *   32768	1320
    1.25 +	 *  131072	4392
    1.26 +	 */
    1.27 +	if (max_pfn < MB2PAGES(128))
    1.28 +		min_pages = MB2PAGES(8) + (max_pfn >> 1);
    1.29 +	else if (max_pfn < MB2PAGES(512))
    1.30 +		min_pages = MB2PAGES(40) + (max_pfn >> 2);
    1.31 +	else if (max_pfn < MB2PAGES(2048))
    1.32 +		min_pages = MB2PAGES(104) + (max_pfn >> 3);
    1.33 +	else
    1.34 +		min_pages = MB2PAGES(296) + (max_pfn >> 5);
    1.35 +#undef MB2PAGES
    1.36 +
    1.37 +	/* Don't enforce growth */
    1.38 +	return min(min_pages, curr_pages);
    1.39 +#endif
    1.40 +}
    1.41 +
    1.42  static int increase_reservation(unsigned long nr_pages)
    1.43  {
    1.44  	unsigned long  pfn, i, flags;
    1.45 @@ -384,7 +419,7 @@ void balloon_set_new_target(unsigned lon
    1.46  {
    1.47  	/* No need for lock. Not read-modify-write updates. */
    1.48  	bs.hard_limit   = ~0UL;
    1.49 -	bs.target_pages = target;
    1.50 +	bs.target_pages = max(target, minimum_target());
    1.51  	schedule_work(&balloon_worker);
    1.52  }
    1.53