file-backed guest memory
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?
Signature · 8 lines
Michael "Tired" Riepe <[email protected]> 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
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 14 lines · Michael Riepe
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 withmmap(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.
Signature · 8 lines
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
A message that is not in the archive (sent off-list or not yet received): 461E5286.7090100-atKUWr5tajBWk0Htik3J/[email protected]
Quoted 16 lines · Avi Kivity
Quoted 14 lines · Michael Riepe
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 withmmap(MAP_ANONYMOUS).
Quoted 6 lines
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
Signature · 3 lines
------------- Laurent.Vivier-6ktuUTfB/[email protected] -------------- "Any sufficiently advanced technology is indistinguishable from magic." - Arthur C. Clarke
-------------------------------------------------------------------------
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
_______________________________________________
kvm-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/kvm-devel
A message that is not in the archive (sent off-list or not yet received): 461E5497.3090409-6ktuUTfB/[email protected]
Quoted 27 lines · Laurent Vivier
Quoted 17 lines · Avi Kivity
Quoted 15 lines · Michael Riepe
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 withmmap(MAP_ANONYMOUS).Quoted 7 lines
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.
Quoted 3 lines
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.
Signature · 8 lines
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
Quoted 2 lines · Avi Kivity
Quoted 2 lines
But wouldn't it also be possible to create a file in userspace and pass its descriptor to kvm?
[...]
Quoted 3 lines
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
A message that is not in the archive (sent off-list or not yet received): 200704130857.15003.borntrae-tA70FqPdS9bQT0dZR+AlfA@public.gmane.org
Quoted 12 lines · Christian Borntraeger
Quoted 3 lines · Avi Kivity
Quoted 3 lines
But wouldn't it also be possible to create a file in userspace and pass its descriptor to kvm?
[...]
Quoted 4 lines
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.
Quoted 8 lines
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.
Signature · 8 lines
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/