]> 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)
committerLiam R. Howlett <Liam.Howlett@oracle.com>
Wed, 4 Jan 2023 20:59:24 +0000 (15:59 -0500)
commitbd721138594284a71a3325e0801a9c69222b0ad1
tree031b809c4e77bc013f9d58490c55a42d33ab10a4
parentc5f2f83a20231aba101889a7d5a4ea555f718f8b
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