]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
acct: Use VMA iterator instead of linked list
authorLiam R. Howlett <Liam.Howlett@Oracle.com>
Mon, 4 Jan 2021 19:52:15 +0000 (14:52 -0500)
committerMatthew Wilcox (Oracle) <willy@infradead.org>
Mon, 1 Nov 2021 14:43:49 +0000 (10:43 -0400)
The VMA iterator is faster than the linked list.

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

index 23a7ab8e6cbc8bdf68c0f46d8d09dfce07c5a6f5..3d8ff561879fac2fecdff0556abaa7d6afa1f879 100644 (file)
@@ -536,15 +536,14 @@ void acct_collect(long exitcode, int group_dead)
        unsigned long vsize = 0;
 
        if (group_dead && current->mm) {
+               struct mm_struct *mm = current->mm;
+               VMA_ITERATOR(vmi, mm, 0);
                struct vm_area_struct *vma;
 
-               mmap_read_lock(current->mm);
-               vma = current->mm->mmap;
-               while (vma) {
+               mmap_read_lock(mm);
+               for_each_vma(vmi, vma)
                        vsize += vma->vm_end - vma->vm_start;
-                       vma = vma->vm_next;
-               }
-               mmap_read_unlock(current->mm);
+               mmap_read_unlock(mm);
        }
 
        spin_lock_irq(&current->sighand->siglock);