public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* file-backed guest memory
@ 2007-04-12 15:34 Michael Riepe
       [not found] ` <461E5181.6010504-0QoEqw4nQxo@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Michael Riepe @ 2007-04-12 15:34 UTC (permalink / raw)
  To: kvm-devel

Hi!

This is just a (probably silly) idea I had the other day. Currently, the
guest's memory is allocated inside the kernel and exported to userspace
via mmap(). But wouldn't it also be possible to create a file in
userspace and pass its descriptor to kvm? If we also pass file offset
and length parameters for each memslot, all segments can (but need not)
reside in the same file. There would be a persistent snapshot of the
VM's physical memory, and it would enable the VM to page out the guest's
pages. One could also do strange things like mapping a portion of the
file several times, e.g. to emulate an architecture with incomplete
address decoding. Applications that absolutely want to use anonymous
memory could pass -1 as the fd, as they do with mmap(MAP_ANONYMOUS).

Comments?

-- 
Michael "Tired" Riepe <michael-0QoEqw4nQxo@public.gmane.org>
X-Tired: Each morning I get up I die a little

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

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

* Re: file-backed guest memory
       [not found] ` <461E5181.6010504-0QoEqw4nQxo@public.gmane.org>
@ 2007-04-12 15:38   ` Avi Kivity
       [not found]     ` <461E5286.7090100-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Avi Kivity @ 2007-04-12 15:38 UTC (permalink / raw)
  To: Michael Riepe; +Cc: kvm-devel

Michael Riepe wrote:
> Hi!
>
> This is just a (probably silly) idea I had the other day. Currently, the
> guest's memory is allocated inside the kernel and exported to userspace
> via mmap(). But wouldn't it also be possible to create a file in
> userspace and pass its descriptor to kvm? If we also pass file offset
> and length parameters for each memslot, all segments can (but need not)
> reside in the same file. There would be a persistent snapshot of the
> VM's physical memory, and it would enable the VM to page out the guest's
> pages. One could also do strange things like mapping a portion of the
> file several times, e.g. to emulate an architecture with incomplete
> address decoding. Applications that absolutely want to use anonymous
> memory could pass -1 as the fd, as they do with mmap(MAP_ANONYMOUS).
>   

Arnd suggested this way back when kvm was first posted on lkml, and I 
agree that this is a very useful mechanism.  You get on-demand loading, 
swap, hugetlbfs, and maybe other nifty stuff.  I think I know how to do 
this for the current mmu, but I'm worried that it will have a 
performance impact with the nested page tables mmu.

-- 
error compiling committee.c: too many arguments to function


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

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

* Re: file-backed guest memory
       [not found]     ` <461E5286.7090100-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
@ 2007-04-12 15:47       ` Laurent Vivier
       [not found]         ` <461E5497.3090409-6ktuUTfB/bM@public.gmane.org>
  2007-04-13  6:57       ` Christian Borntraeger
  1 sibling, 1 reply; 6+ messages in thread
From: Laurent Vivier @ 2007-04-12 15:47 UTC (permalink / raw)
  To: Avi Kivity; +Cc: kvm-devel


[-- Attachment #1.1: Type: text/plain, Size: 1483 bytes --]

Avi Kivity wrote:
> Michael Riepe wrote:
>> Hi!
>>
>> This is just a (probably silly) idea I had the other day. Currently, the
>> guest's memory is allocated inside the kernel and exported to userspace
>> via mmap(). But wouldn't it also be possible to create a file in
>> userspace and pass its descriptor to kvm? If we also pass file offset
>> and length parameters for each memslot, all segments can (but need not)
>> reside in the same file. There would be a persistent snapshot of the
>> VM's physical memory, and it would enable the VM to page out the guest's
>> pages. One could also do strange things like mapping a portion of the
>> file several times, e.g. to emulate an architecture with incomplete
>> address decoding. Applications that absolutely want to use anonymous
>> memory could pass -1 as the fd, as they do with mmap(MAP_ANONYMOUS).
>>   
> 
> Arnd suggested this way back when kvm was first posted on lkml, and I 
> agree that this is a very useful mechanism.  You get on-demand loading, 
> swap, hugetlbfs, and maybe other nifty stuff.  I think I know how to do 
> this for the current mmu, but I'm worried that it will have a 
> performance impact with the nested page tables mmu.
> 

Perhaps you could use code from kqemu ?

Regards,
Laurent


-- 
------------- Laurent.Vivier-6ktuUTfB/bM@public.gmane.org  --------------
       "Any sufficiently advanced technology is
  indistinguishable from magic." - Arthur C. Clarke


[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

[-- Attachment #2: Type: text/plain, Size: 345 bytes --]

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

[-- Attachment #3: Type: text/plain, Size: 186 bytes --]

_______________________________________________
kvm-devel mailing list
kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/kvm-devel

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

* Re: file-backed guest memory
       [not found]         ` <461E5497.3090409-6ktuUTfB/bM@public.gmane.org>
@ 2007-04-12 15:56           ` Avi Kivity
  0 siblings, 0 replies; 6+ messages in thread
From: Avi Kivity @ 2007-04-12 15:56 UTC (permalink / raw)
  To: Laurent Vivier; +Cc: kvm-devel

Laurent Vivier wrote:
> Avi Kivity wrote:
>   
>> Michael Riepe wrote:
>>     
>>> Hi!
>>>
>>> This is just a (probably silly) idea I had the other day. Currently, the
>>> guest's memory is allocated inside the kernel and exported to userspace
>>> via mmap(). But wouldn't it also be possible to create a file in
>>> userspace and pass its descriptor to kvm? If we also pass file offset
>>> and length parameters for each memslot, all segments can (but need not)
>>> reside in the same file. There would be a persistent snapshot of the
>>> VM's physical memory, and it would enable the VM to page out the guest's
>>> pages. One could also do strange things like mapping a portion of the
>>> file several times, e.g. to emulate an architecture with incomplete
>>> address decoding. Applications that absolutely want to use anonymous
>>> memory could pass -1 as the fd, as they do with mmap(MAP_ANONYMOUS).
>>>   
>>>       
>> Arnd suggested this way back when kvm was first posted on lkml, and I 
>> agree that this is a very useful mechanism.  You get on-demand loading, 
>> swap, hugetlbfs, and maybe other nifty stuff.  I think I know how to do 
>> this for the current mmu, but I'm worried that it will have a 
>> performance impact with the nested page tables mmu.
>>
>>     
>
> Perhaps you could use code from kqemu ?
>
>   

The non-npt case is not so difficult, it is the npt case which I'm 
concerned about and that doesn't have a parallel in kqemu.


-- 
error compiling committee.c: too many arguments to function


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

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

* Re: file-backed guest memory
       [not found]     ` <461E5286.7090100-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
  2007-04-12 15:47       ` Laurent Vivier
@ 2007-04-13  6:57       ` Christian Borntraeger
       [not found]         ` <200704130857.15003.borntrae-tA70FqPdS9bQT0dZR+AlfA@public.gmane.org>
  1 sibling, 1 reply; 6+ messages in thread
From: Christian Borntraeger @ 2007-04-13  6:57 UTC (permalink / raw)
  To: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f

On Thursday 12 April 2007 17:38, Avi Kivity wrote:
> > But wouldn't it also be possible to create a file in
> > userspace and pass its descriptor to kvm?
[...]
> swap, hugetlbfs, and maybe other nifty stuff.  I think I know how to do 
> this for the current mmu, but I'm worried that it will have a 
> performance impact with the nested page tables mmu.

Another thing to consider is the commit "mm: tracking shared dirty pages" 
(d08b3851da41d0ee60851f2c75b118e1f7a5fc89). We need a shared mapping to 
actually have guest memory written back to the file.
The dirty page tracking change will cause the host kernel to write protect 
guest memory pages after writeback. This will often trigger guest exits due 
to host protection faults. If we want to have file backed guest memory we 
really should modify the VMA to be not eligible for dirty page tracking. 

Christian

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

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

* Re: file-backed guest memory
       [not found]         ` <200704130857.15003.borntrae-tA70FqPdS9bQT0dZR+AlfA@public.gmane.org>
@ 2007-04-14 14:14           ` Avi Kivity
  0 siblings, 0 replies; 6+ messages in thread
From: Avi Kivity @ 2007-04-14 14:14 UTC (permalink / raw)
  To: Christian Borntraeger; +Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f

Christian Borntraeger wrote:
> On Thursday 12 April 2007 17:38, Avi Kivity wrote:
>   
>>> But wouldn't it also be possible to create a file in
>>> userspace and pass its descriptor to kvm?
>>>       
> [...]
>   
>> swap, hugetlbfs, and maybe other nifty stuff.  I think I know how to do 
>> this for the current mmu, but I'm worried that it will have a 
>> performance impact with the nested page tables mmu.
>>     
>
> Another thing to consider is the commit "mm: tracking shared dirty pages" 
> (d08b3851da41d0ee60851f2c75b118e1f7a5fc89). We need a shared mapping to 
> actually have guest memory written back to the file.
> The dirty page tracking change will cause the host kernel to write protect 
> guest memory pages after writeback. This will often trigger guest exits due 
> to host protection faults. If we want to have file backed guest memory we 
> really should modify the VMA to be not eligible for dirty page tracking. 
>   

Actually the Linux mm does not know about the kvm page tables, and thus
cannot do the write protection.  I'm worried that this will confuse it
horribly.

I also think that we should teach the mm how to write protect guest
pages, perhaps less aggressively to account for the large difference in
normal pagefault cost and vmexit pagefault cost.  Hopefully this write
protection is throttled when memory is plentiful to avoid a large
performance hit, regardless of whether it's used for a virtual machine
or normal processes.

-- 
Do not meddle in the internals of kernels, for they are subtle and quick to panic.


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/

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

end of thread, other threads:[~2007-04-14 14:14 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-04-12 15:34 file-backed guest memory Michael Riepe
     [not found] ` <461E5181.6010504-0QoEqw4nQxo@public.gmane.org>
2007-04-12 15:38   ` Avi Kivity
     [not found]     ` <461E5286.7090100-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-04-12 15:47       ` Laurent Vivier
     [not found]         ` <461E5497.3090409-6ktuUTfB/bM@public.gmane.org>
2007-04-12 15:56           ` Avi Kivity
2007-04-13  6:57       ` Christian Borntraeger
     [not found]         ` <200704130857.15003.borntrae-tA70FqPdS9bQT0dZR+AlfA@public.gmane.org>
2007-04-14 14:14           ` Avi Kivity

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox