Synchronization around mmap_changing in userfaultfd

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

We have been seeing mmap_lock contention issues while using
userfaultfd for GC in Android. But now that per-vma locks are being
used in the kernel, we were hoping to use it in userfaultfd code to
pin the VMA in COPY/MOVE/ZEROPAGE etc. operations. But while going
through the code, I noticed that mmap_changing is implicitly protected
by mmap_lock:

1) All increments to it (except for userfault_remove) are done with
mmap_lock in write-mode
2) All reads (in copy/move/zeropage etc) are done with mmap_lock in read-mode

I wanted to understand if that's just out of convenience, and
therefore would it be ok to introduce a read-write semaphore in
userfaultfd_ctx to achieve the same synchronization:

1) All increments are done with this semaphore in write-mode
2) All operations (copy/move/zeropage etc) are done within the
critical section of this semaphore in read-mode and checking that
mmap_changing is 0.

If this is wrong, then kindly explain why mmap_changing needs to be
protected with mmap_lock.


Thanks,
Lokesh




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux