]> www.infradead.org Git - users/willy/linux.git/commitdiff
fix-parent
authorMatthew Wilcox (Oracle) <willy@infradead.org>
Tue, 19 Oct 2021 19:07:57 +0000 (15:07 -0400)
committerMatthew Wilcox (Oracle) <willy@infradead.org>
Wed, 20 Oct 2021 19:59:58 +0000 (15:59 -0400)
arch/x86/kernel/tboot.c
drivers/firmware/efi/efi.c
include/linux/mm_types.h
kernel/fork.c
mm/init-mm.c
mm/internal.h
mm/mmap.c

index 6f978f722dff400c0457504d8d1c5cd2fd3db1f7..859e8d2ea0703ffefe0fc7fca6849880de68e94c 100644 (file)
@@ -98,7 +98,7 @@ void __init tboot_probe(void)
 static pgd_t *tboot_pg_dir;
 static struct mm_struct tboot_mm = {
        .mm_rb          = RB_ROOT,
-       .mm_mt          = MTREE_INIT(mm_mt, MAPLE_ALLOC_RANGE),
+       .mm_mt          = MTREE_INIT_EXT(mm_mt, MM_MT_FLAGS, tboot_mm.mmap_lock),
        .pgd            = swapper_pg_dir,
        .mm_users       = ATOMIC_INIT(2),
        .mm_count       = ATOMIC_INIT(1),
index 1aaecca36e236d63c5f13e12e290dbc534918d6f..5ef8c668db259fde3bdebc3d4caf923b5b0e7151 100644 (file)
@@ -55,7 +55,7 @@ static unsigned long __initdata rt_prop = EFI_INVALID_TABLE_ADDR;
 
 struct mm_struct efi_mm = {
        .mm_rb                  = RB_ROOT,
-       .mm_mt                  = MTREE_INIT(mm_mt, MAPLE_ALLOC_RANGE),
+       .mm_mt                  = MTREE_INIT_EXT(mm_mt, MM_MT_FLAGS, efi_mm.mmap_lock),
        .mm_users               = ATOMIC_INIT(2),
        .mm_count               = ATOMIC_INIT(1),
        .write_protect_seq      = SEQCNT_ZERO(efi_mm.write_protect_seq),
index 2fc27dff8b6caad6aee3e85f24662bf9b378ecf9..86959ece1284a4cb47b36a40178c4f7a65cfa6bd 100644 (file)
@@ -591,6 +591,7 @@ struct mm_struct {
        unsigned long cpu_bitmap[];
 };
 
+#define MM_MT_FLAGS    (MT_FLAGS_ALLOC_RANGE | MT_FLAGS_LOCK_EXTERN)
 extern struct mm_struct init_mm;
 
 /* Pointer magic because the dynamic array size confuses some compilers. */
index e8d602de40e8ef0ddb1d3d9208e27bfc4c7c06e3..3f3f823541ccefd1b5031a44a2821d153adfd979 100644 (file)
@@ -1041,7 +1041,8 @@ static struct mm_struct *mm_init(struct mm_struct *mm, struct task_struct *p,
 {
        mm->mmap = NULL;
        mm->mm_rb = RB_ROOT;
-       mt_init_flags(&mm->mm_mt, MAPLE_ALLOC_RANGE);
+       mt_init_flags(&mm->mm_mt, MM_MT_FLAGS);
+       mt_set_external_lock(&mm->mm_mt, &mm->mmap_lock);
        mm->vmacache_seqnum = 0;
        atomic_set(&mm->mm_users, 1);
        atomic_set(&mm->mm_count, 1);
index e4a058f7e8b612229a117e54f6a1e9f6b2cbbe5e..7622ca24eeb75cc410d150436a67a2568068b416 100644 (file)
@@ -29,7 +29,7 @@
  */
 struct mm_struct init_mm = {
        .mm_rb          = RB_ROOT,
-       .mm_mt          = MTREE_INIT(mm_mt, MAPLE_ALLOC_RANGE),
+       .mm_mt          = MTREE_INIT_EXT(mm_mt, MM_MT_FLAGS, init_mm.mmap_lock),
        .pgd            = swapper_pg_dir,
        .mm_users       = ATOMIC_INIT(2),
        .mm_count       = ATOMIC_INIT(1),
index 3f45e1d0c02b1213a6e39e1ca1ac4d9c1f7e7685..28970ab39d6a2255212ed283282b57b8eeee101e 100644 (file)
@@ -375,9 +375,7 @@ static inline int vma_mas_store(struct vm_area_struct *vma, struct ma_state *mas
 #endif
        mas->index = vma->vm_start;
        mas->last = vma->vm_end - 1;
-       mas_lock(mas);
        ret = mas_store_gfp(mas, vma, GFP_KERNEL);
-       mas_unlock(mas);
        return ret;
 }
 
@@ -411,9 +409,7 @@ static inline int vma_mas_remove(struct vm_area_struct *vma, struct ma_state *ma
 #endif
        mas->index = vma->vm_start;
        mas->last = vma->vm_end - 1;
-       mas_lock(mas);
        ret = mas_store_gfp(mas, NULL, GFP_KERNEL);
-       mas_unlock(mas);
        return ret;
 }
 
index b9078e6d7d610d533c35aba6f14fea1ff087b092..4ab971a8062599b147873bf3ebb168df70cf73a8 100644 (file)
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -762,8 +762,10 @@ static void __vma_link_file(struct vm_area_struct *vma)
 static inline void vma_mt_szero(struct mm_struct *mm, unsigned long start,
                                unsigned long end)
 {
+       MA_STATE(mas, &mm->mm_mt, start, end - 1);
+
        trace_vma_mt_szero(mm, start, end);
-       mtree_store_range(&mm->mm_mt, start, end - 1, NULL, GFP_KERNEL);
+       mas_erase(&mas);
 }
 
 /*
@@ -777,9 +779,10 @@ static inline void vma_mt_szero(struct mm_struct *mm, unsigned long start,
 static inline
 void vma_mt_store(struct mm_struct *mm, struct vm_area_struct *vma)
 {
+       MA_STATE(mas, &mm->mm_mt, vma->vm_start, vma->vm_end - 1);
+
        trace_vma_mt_store(mm, vma);
-       mtree_store_range(&mm->mm_mt, vma->vm_start, vma->vm_end - 1, vma,
-               GFP_KERNEL);
+       mas_store_gfp(&mas, vma, GFP_KERNEL);
 }
 
 void vma_store(struct mm_struct *mm, struct vm_area_struct *vma) {
@@ -3382,7 +3385,11 @@ void exit_mmap(struct mm_struct *mm)
        }
 
        trace_exit_mmap(mm);
-       mtree_destroy(&mm->mm_mt);
+       /* Take the mmap lock to satisfy lockdep.  Nobody else can see it */
+       mmap_write_lock(mm);
+       __mt_destroy(&mm->mm_mt);
+       mmap_write_unlock(mm);
+
        vm_unacct_memory(nr_accounted);
 }