lkml.org 
[lkml]   [2015]   [Jun]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 3/5] vhost: support upto 509 memory regions


On 18/06/2015 16:47, Michael S. Tsirkin wrote:
>> However, with Igor's patches a memory_region_del_subregion will cause a
>> mmap(MAP_NORESERVE), which _does_ have the effect of making the hva go away.
>>
>> I guess one way to do it would be to alias the same page in two places,
>> one for use by vhost and one for use by everything else. However, the
>> kernel does not provide the means to do this kind of aliasing for
>> anonymous mmaps.
>
> Basically pages go away on munmap, so won't simple
> lock
> munmap
> mmap(MAP_NORESERVE)
> unlock
> do the trick?

Not sure I follow. Here we have this:

VCPU 1 VCPU 2 I/O worker
----------------------------------------------------------------------------------------
take big QEMU lock
p = address_space_map(hva, len)
pass I/O request to worker thread
read(fd, p, len)
release big QEMU lock

memory_region_del_subregion
mmap(MAP_NORESERVE)

read returns EFAULT
wake up VCPU 1
take big QEMU lock
EFAULT? What's that?

In another scenario you are less lucky: the memory accesses
between address_space_map/unmap aren't done in the kernel and
you get a plain old SIGSEGV.

This is not something that you can fix with a lock. The very
purpose of the map/unmap API is to do stuff asynchronously while
the lock is released.

Thanks,

Paolo


\
 
 \ /
  Last update: 2015-06-18 18:21    [W:0.710 / U:0.240 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site