]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
kernel/fork: Convert dup_mmap to use maple tree
authorLiam R. Howlett <Liam.Howlett@Oracle.com>
Fri, 24 Jul 2020 17:32:30 +0000 (13:32 -0400)
committerLiam R. Howlett <Liam.Howlett@Oracle.com>
Sat, 25 Jul 2020 01:20:23 +0000 (21:20 -0400)
Use the maple tree iterator to duplicate the mm_struct trees.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
kernel/fork.c

index 8b38eebf7e106f390e7a195469b1c9ed723d0e8b..04b480e532b2fcd5cda854b3755453998c0e9795 100644 (file)
@@ -489,6 +489,7 @@ static __latent_entropy int dup_mmap(struct mm_struct *mm,
        struct rb_node **rb_link, *rb_parent;
        int retval;
        unsigned long charge;
+       MA_STATE(old_mas, &oldmm->mm_mt, 0, 0);
        LIST_HEAD(uf);
 
        uprobe_start_dup_mmap();
@@ -522,9 +523,17 @@ static __latent_entropy int dup_mmap(struct mm_struct *mm,
                goto out;
 
        prev = NULL;
-       for (mpnt = oldmm->mmap; mpnt; mpnt = mpnt->vm_next) {
+
+       mas_lock(&old_mas);
+       mas_for_each(&old_mas, mpnt, ULONG_MAX) {
                struct file *file;
 
+               if (xa_is_zero(mpnt))
+                       continue;
+
+               mas_pause(&old_mas);
+               mas_unlock(&old_mas);
+
                if (mpnt->vm_flags & VM_DONTCOPY) {
                        vm_stat_account(mm, mpnt->vm_flags, -vma_pages(mpnt));
                        continue;
@@ -616,7 +625,11 @@ static __latent_entropy int dup_mmap(struct mm_struct *mm,
 
                if (retval)
                        goto out;
+
+               mas_lock(&old_mas);
        }
+       mas_unlock(&old_mas);
+
        /* a new mm has just been created */
        retval = arch_dup_mmap(oldmm, mm);
 out: