public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jeremy Fitzhardinge <jeremy@goop.org>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Dmitry Torokhov <dtor@vmware.com>,
	linux-kernel@vger.kernel.org, pv-drivers@vmware.com,
	Avi Kivity <avi@redhat.com>,
	Dan Magenheimer <dan.magenheimer@oracle.com>
Subject: Re: [PATCH] VMware Balloon driver
Date: Mon, 05 Apr 2010 16:28:38 -0700	[thread overview]
Message-ID: <4BBA7226.9080508@goop.org> (raw)
In-Reply-To: <20100405151720.8a6ac5e3.akpm@linux-foundation.org>

On 04/05/2010 03:17 PM, Andrew Morton wrote:
> On Mon, 05 Apr 2010 15:03:08 -0700
> Jeremy Fitzhardinge<jeremy@goop.org>  wrote:
>
>    
>> On 04/05/2010 02:24 PM, Andrew Morton wrote:
>>      
>>> I think I've forgotten what balloon drivers do.  Are they as nasty a
>>> hack as I remember believing them to be?
>>>
>>>        
>> (I haven't looked at Dmitry's patch yet, so this is from the Xen
>> perspective.)
>>
>> In the simplest form, they just look like a driver which allocates a
>> pile of pages, and the underlying memory gets returned to the
>> hypervisor.  When you want the memory back, it reattaches memory to the
>> pageframes and releases the memory back to the kernel.  This allows a
>> virtual machine to shrink with respect to its original size.
>>
>> Going the other way - expanding beyond the memory allocation - is a bit
>> trickier because you need to get some new page structures from
>> somewhere.   We don't do this in Xen yet, but I've done some experiments
>> with hotplug memory to implement this.  Or a simpler approach is to fake
>> up some reserved E820 ranges to grow into.
>>
>>      
> Lots of stuff for Dmitry to add to his changelog ;)
>
>    
>>> A summary of what this code sets out to do, and how it does it would be
>>> useful.
>>>
>>> Also please explain the applicability of this driver.  Will xen use it?
>>> kvm?  Out-of-tree code?
>>>
>>>        
>> The basic idea of the driver is to allow a guest system to give up
>> memory it isn't using so it can be reused by other virtual machines (or
>> the host itself).
>>      
> So...  does this differ in any fundamental way from what hibernation
> does, via shrink_all_memory()?
>    

Note that we're using shrink and grow in opposite senses.  
shrink_all_memory() is trying to free as much kernel memory as possible, 
which to the virtual machine's host looks like the guest is growing 
(since it has claimed more memory for its own use).  A balloon "shrink" 
appears to Linux as allocated memory (ie, locking down memory within 
Linux to make it available to the rest of system).

The fact that shrink_all_memory() has much deeper insight into the 
current state of the vm subsystem is interesting; it has much more to 
work with than a simple alloc/free page.  Does it actively try to 
reclaim cold, unlikely to be used stuff, first?  It appears it does to 
my mm/ naive eye.

I guess a way to use it in the short term is to have a loop of the form:

	while (guest_size>  target) {
		shrink_all_memory(guest_size - target);		/* force pages to be free */
		while (p = alloc_page(GFP_NORETRY))		/* vacuum up pages */
			release_page_to_hypervisor(p);
		/* twiddle thumbs */
	}

...assuming the allocation would tend to pick up the pages that 
shrink_all_memory just freed.

Or ideally, have a form of shrink_all_memory() which causes pages to 
become unused, but rather than freeing them returns them to the caller.

And is there some way to get the vm subsystem to provide backpressure: 
"I'm getting desperately short of memory!"?  Experience has shown that 
administrators often accidentally over-shrink their domains and 
effectively kill them.  Sometimes due to bad UI - entering the wrong 
units - but also because they just don't know what the actual memory 
demands are.  Or they change over time.

Thanks,
     J

  parent reply	other threads:[~2010-04-05 23:28 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-04 21:52 [PATCH] VMware Balloon driver Dmitry Torokhov
2010-04-05 21:24 ` Andrew Morton
2010-04-05 22:03   ` Jeremy Fitzhardinge
2010-04-05 22:17     ` Andrew Morton
2010-04-05 22:26       ` Avi Kivity
2010-04-05 22:40         ` Andrew Morton
2010-04-05 23:01           ` Dmitry Torokhov
2010-04-05 23:03           ` Dan Magenheimer
2010-04-05 23:11             ` Andrew Morton
2010-04-05 23:28               ` Dmitry Torokhov
2010-04-06 16:28           ` Avi Kivity
2010-04-05 23:28       ` Jeremy Fitzhardinge [this message]
2010-04-05 23:34         ` Andrew Morton
2010-04-06  0:26           ` Dan Magenheimer
2010-04-06 16:30           ` Avi Kivity
2010-04-06 17:27             ` Dan Magenheimer
2010-04-06 23:20         ` Dave Hansen
2010-04-05 22:58   ` Dmitry Torokhov
2010-04-06 16:32     ` Avi Kivity
2010-04-06 17:06       ` Dmitry Torokhov
2010-04-06 17:42         ` Avi Kivity
2010-04-06 18:25       ` Jeremy Fitzhardinge
2010-04-06 18:36         ` Avi Kivity
2010-04-06 19:18           ` Jeremy Fitzhardinge
2010-04-08  5:30             ` Pavel Machek
2010-04-08  7:18               ` Avi Kivity
2010-04-08 17:01               ` Jeremy Fitzhardinge
2010-04-15 21:00   ` [PATCH v2] " Dmitry Torokhov
2010-04-21 19:59     ` Dmitry Torokhov
2010-04-21 20:18       ` Andrew Morton
2010-04-21 20:52         ` Dmitry Torokhov
2010-04-21 21:13           ` Andrew Morton
2010-04-22  0:09             ` Dmitry Torokhov
2010-04-21 23:54     ` Andrew Morton
2010-04-22  0:00       ` Dmitry Torokhov
2010-04-22  1:02         ` [Pv-drivers] " Dmitry Torokhov

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=4BBA7226.9080508@goop.org \
    --to=jeremy@goop.org \
    --cc=akpm@linux-foundation.org \
    --cc=avi@redhat.com \
    --cc=dan.magenheimer@oracle.com \
    --cc=dtor@vmware.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pv-drivers@vmware.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox