All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] linux/balloon: don't allow ballooning down a domain below a reasonable limit
@ 2008-04-04 15:07 Jan Beulich
  2008-04-05 21:39 ` Keir Fraser
  0 siblings, 1 reply; 29+ messages in thread
From: Jan Beulich @ 2008-04-04 15:07 UTC (permalink / raw)
  To: xen-devel; +Cc: Ky Srinivasan, Kurt Garloff

From: K.Y. Srinivasan <ksrinivasan@novell.com>

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.

Memory changes are logged, so making domains too small should at least
result in a trace.

As usual, written and tested on 2.6.25-rc8 and 2.6.16.60 and made apply
to the 2.6.18 tree without further testing.

Signed-off-by: Kurt Garloff <garloff@suse.de>
Signed-off-by: Jan Beulich <jbeulich@novell.com>

Index: head-2008-02-20/drivers/xen/balloon/balloon.c
===================================================================
--- head-2008-02-20.orig/drivers/xen/balloon/balloon.c	2008-02-20 10:32:43.000000000 +0100
+++ head-2008-02-20/drivers/xen/balloon/balloon.c	2008-02-20 10:40:54.000000000 +0100
@@ -194,6 +194,42 @@ static unsigned long current_target(void
 	return target;
 }
 
+static unsigned long minimum_target(void)
+{
+	unsigned long min_pages;
+	unsigned long curr_pages = current_target();
+#ifndef CONFIG_XEN
+#define max_pfn totalram_pages
+#endif
+
+#define MB2PAGES(mb) ((mb) << (20 - PAGE_SHIFT))
+	/* Simple continuous piecewiese linear function:
+	 *  max MiB -> min MiB	gradient
+	 *       0	   0
+	 *      16	  16
+	 *      32	  24
+	 *     128	  72	(1/2)
+	 *     512 	 168	(1/4)
+	 *    2048	 360	(1/8)
+	 *    8192	 552	(1/32)
+	 *   32768	1320
+	 *  131072	4392
+	 */
+	if (max_pfn < MB2PAGES(128))
+		min_pages = MB2PAGES(8) + (max_pfn >> 1);
+	else if (max_pfn < MB2PAGES(512))
+		min_pages = MB2PAGES(40) + (max_pfn >> 2);
+	else if (max_pfn < MB2PAGES(2048))
+		min_pages = MB2PAGES(104) + (max_pfn >> 3);
+	else
+		min_pages = MB2PAGES(296) + (max_pfn >> 5);
+#undef MB2PAGES
+
+	/* Don't enforce growth */
+	return min_pages < curr_pages ? min_pages : curr_pages;
+#undef max_pfn
+}
+
 static int increase_reservation(unsigned long nr_pages)
 {
 	unsigned long  pfn, i, flags;
@@ -382,6 +418,17 @@ static void balloon_process(struct work_
 /* Resets the Xen limit, sets new target, and kicks off processing. */
 void balloon_set_new_target(unsigned long target)
 {
+	/* First make sure that we are not lowering the value below the
+	 * "minimum".
+	 */
+	unsigned long min_pages = minimum_target();
+
+	if (target < min_pages)
+		target = min_pages;
+
+	printk(KERN_INFO "Setting mem allocation to %lu kiB\n",
+	       PAGES2KB(target));
+
 	/* No need for lock. Not read-modify-write updates. */
 	bs.hard_limit   = ~0UL;
 	bs.target_pages = target;

^ permalink raw reply	[flat|nested] 29+ messages in thread
* RE: [PATCH] linux/balloon:don't allow ballooningdowna domain below a reasonable limit
@ 2008-05-02 19:30 Jan Beulich
  2008-05-02 22:22 ` Dan Magenheimer
  2008-05-09 20:38 ` Dan Magenheimer
  0 siblings, 2 replies; 29+ messages in thread
From: Jan Beulich @ 2008-05-02 19:30 UTC (permalink / raw)
  To: dan.magenheimer; +Cc: Ky Srinivasan, xen-devel, keir.fraser, garloff

>>> "Dan Magenheimer" <dan.magenheimer@oracle.com> 05/01/08 2:00 AM >>>
>OK, I think I am understanding it a bit better:
>the max_pfn part is just adding in some "slop"
>which is a fraction of total main memory which
>is growing smaller (roughly logarithmically)
>as memory grows larger.  I'm still not sure about
>the magic values in MB2PAGES though... I'm guessing
>these were gathered somehow experimentally?

I have to defer to the original author here - Kurt?

>With the "divide result of your algorithm by two",
>I was able to get thirteen 512MB domains (idle
>for now) running on a 2GB system.

You mean ballooned-down domains, right? Perhaps using your
self-ballooning change? I have to admit I'm a little nervous
about attempting to overcommit memory in this way in a
production environment, but as long as this depends on a
decision of the operator it's certainly a good option to have.

Jan

^ permalink raw reply	[flat|nested] 29+ messages in thread

end of thread, other threads:[~2008-05-13 10:35 UTC | newest]

Thread overview: 29+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-04-04 15:07 [PATCH] linux/balloon: don't allow ballooning down a domain below a reasonable limit Jan Beulich
2008-04-05 21:39 ` Keir Fraser
2008-04-07  7:10   ` [PATCH] linux/balloon: don't allow ballooningdown " Jan Beulich
2008-04-29 18:35     ` Dan Magenheimer
2008-04-30  6:29       ` [PATCH] linux/balloon: don't allow ballooningdowna " Jan Beulich
2008-04-30 16:04         ` Dan Magenheimer
2008-04-30 23:49           ` Dan Magenheimer
2008-05-01  7:01             ` Keir Fraser
2008-05-01 14:44               ` Dan Magenheimer
2008-05-01 16:36               ` Alan Cox
2008-05-01 16:56                 ` Keir Fraser
2008-05-01 20:05                   ` Alan Cox
2008-05-01 16:59                 ` Dan Magenheimer
2008-05-01 21:18                   ` Keir Fraser
2008-05-01 23:03                     ` Alan Cox
2008-05-01 23:27                       ` Dan Magenheimer
2008-05-02  7:05                         ` Keir Fraser
2008-05-03 13:53                           ` Dan Magenheimer
2008-05-03 14:11                             ` Keir Fraser
2008-05-03 19:27                               ` Dan Magenheimer
2008-05-03 17:32                             ` Mark Williamson
2008-05-03 19:43                               ` Dan Magenheimer
2008-05-12 22:19                             ` [PATCH] linux/balloon: don't allowballooningdowna " Ian Pratt
2008-05-12 23:34                               ` Dan Magenheimer
2008-05-13 10:35                               ` Markus Hochholdinger
  -- strict thread matches above, loose matches on Subject: below --
2008-05-02 19:30 [PATCH] linux/balloon:don't allow ballooningdowna " Jan Beulich
2008-05-02 22:22 ` Dan Magenheimer
2008-05-03 13:24   ` Goswin von Brederlow
2008-05-09 20:38 ` Dan Magenheimer

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.