ANDROID: 16K: Fallback to mmap lock for linker context VMA lookup
When MADV_DONTNEED was migrated to per-VMA locks, the linker_ctx()
function was updated to use lock_vma_under_rcu() to find the VMA for the
current execution context.
lock_vma_under_rcu() is a try-lock and can fail if the VMA is already
locked for modification. In this case, it returns NULL, triggering the
following BUG_ON:
/* Current execution context, the VMA must be present */
BUG_ON(!vma);
Fix this race by falling back to the mmap_read_lock() and find_vma() if
lock_vma_under_rcu() fails. This race is expected to be rare, so the
performance benefits of per-VMA locking should still be realized in the
majority of MADV_DONTNEED calls.
Bug: 440235028
Change-Id: I635008db244bb6b7ad5cc6e53f464d36d1be57a8
Signed-off-by:
Kalesh Singh <kaleshsingh@google.com>
Loading