]> www.infradead.org Git - users/jedix/linux-maple.git/commit
mm: add per-VMA lock and helper functions to control it
authorSuren Baghdasaryan <surenb@google.com>
Wed, 11 May 2022 23:32:37 +0000 (16:32 -0700)
committerSuren Baghdasaryan <surenb@google.com>
Wed, 23 Nov 2022 02:09:44 +0000 (02:09 +0000)
commit0a1a9e2fe8e9389e58fecfaf15483862956be16c
tree48869f51e1592ca9188b2bc2c4847fcdc79816d5
parentdfc30ac6744827f806f5c2a28ce3de57a9a73686
mm: add per-VMA lock and helper functions to control it

Introduce a per-VMA rw_semaphore to be used during page fault handling
instead of mmap_lock. Because there are cases when multiple VMAs need
to be exclusively locked during VMA tree modifications, instead of the
usual lock/unlock patter we mark a VMA as locked by taking per-VMA lock
exclusively and setting vma->lock_seq to the current mm->lock_seq. When
mmap_write_lock holder is done with all modifications and drops mmap_lock,
it will increment mm->lock_seq, effectively unlocking all VMAs marked as
locked.
VMA lock is placed on the cache line boundary so that its 'count' field
falls into the first cache line while the rest of the fields fall into
the second cache line. This lets the 'count' field to be cached with
other frequently accessed fields and used quickly in uncontended case
while 'owner' and other fields used in the contended case will not
invalidate the first cache line while waiting on the lock.

Signed-off-by: Suren Baghdasaryan <surenb@google.com>
include/linux/mm.h
include/linux/mm_types.h
include/linux/mmap_lock.h
kernel/fork.c
mm/init-mm.c