diff options
author | Suren Baghdasaryan <surenb@google.com> | 2023-02-27 09:36:18 -0800 |
---|---|---|
committer | Andrew Morton <akpm@linux-foundation.org> | 2023-04-05 20:02:59 -0700 |
commit | 98e51a2239d9d419d819cd61a2e720ebf19a8b0a (patch) | |
tree | 5db03b809222a234cbf9ff9d0cf69ec277c9697c /mm/memory.c | |
parent | 73046fd00b069ffd198eda099dae966e152fae39 (diff) | |
download | lwn-98e51a2239d9d419d819cd61a2e720ebf19a8b0a.tar.gz lwn-98e51a2239d9d419d819cd61a2e720ebf19a8b0a.zip |
mm: conditionally write-lock VMA in free_pgtables
Normally free_pgtables needs to lock affected VMAs except for the case
when VMAs were isolated under VMA write-lock. munmap() does just that,
isolating while holding appropriate locks and then downgrading mmap_lock
and dropping per-VMA locks before freeing page tables. Add a parameter to
free_pgtables for such scenario.
Link: https://lkml.kernel.org/r/20230227173632.3292573-20-surenb@google.com
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Diffstat (limited to 'mm/memory.c')
-rw-r--r-- | mm/memory.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/mm/memory.c b/mm/memory.c index ec7e89cc0532..8ca78ae8bba7 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -362,7 +362,7 @@ void free_pgd_range(struct mmu_gather *tlb, void free_pgtables(struct mmu_gather *tlb, struct maple_tree *mt, struct vm_area_struct *vma, unsigned long floor, - unsigned long ceiling) + unsigned long ceiling, bool mm_wr_locked) { MA_STATE(mas, mt, vma->vm_end, vma->vm_end); @@ -380,6 +380,8 @@ void free_pgtables(struct mmu_gather *tlb, struct maple_tree *mt, * Hide vma from rmap and truncate_pagecache before freeing * pgtables */ + if (mm_wr_locked) + vma_start_write(vma); unlink_anon_vmas(vma); unlink_file_vma(vma); @@ -394,6 +396,8 @@ void free_pgtables(struct mmu_gather *tlb, struct maple_tree *mt, && !is_vm_hugetlb_page(next)) { vma = next; next = mas_find(&mas, ceiling - 1); + if (mm_wr_locked) + vma_start_write(vma); unlink_anon_vmas(vma); unlink_file_vma(vma); } |