[Lguest] proposed patch for mmap'ed private block device

Anthony Liguori aliguori at us.ibm.com
Fri May 23 04:38:43 EST 2008


ron minnich wrote:
> On Thu, May 22, 2008 at 5:11 AM, Rusty Russell <rusty at rustcorp.com.au> wrote:
>
>   
> BTW I'm intrigued by your idea of mapping disk directly into guest.
> I'd like to preserve the copy-on-write semantics of the mmap block
> device. I wonder if we could do the folliowing:
> 1. set up special E820 "copy on write" map entry
> 2. kernel boots, maps that e820 segment write-protected
> 3. write faults on that segment result in copy-on-write behavior for
> the page in question
>   

Assuming the guest gives you buffers that are page aligned and DMA 
requests a multiple of page size, you could just mmap(MAP_FIXED) into 
the guest's physical address space.  As long as your careful to pass the 
correct 'write' parameter to get_user_pages(), this would even preserve 
CoW behavior.

There are two issues with this.  The first is that you have to 
invalidate any cached shadow page table entries whenever you do this 
mmap().  This can be done either with an ioctl() or mmu-notifiers.  The 
second issue, which is more difficult to address, if you're likely to 
create a ton of vma's with this.  This is bad for overall performance.

In KVM, we may get around this by using the slots API.  I'm not really 
sure yet though.

This mmap() IO approach gets particularly interesting when combined with 
a content-address storage device.

Regards,

Anthony Liguori
> Probably more trouble than it's worth but intriguiing. The E820 map
> could be kind of useful for this sort of thing.
>
> Thanks
>
> ron
>   




More information about the Lguest mailing list