]> 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)
committerLiam R. Howlett <Liam.Howlett@oracle.com>
Fri, 26 Nov 2021 19:50:33 +0000 (14:50 -0500)
The VMA iterator is faster than the linked list.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
kernel/acct.c

index 3df53cf1dcd5ed08a72c68bd407b35b56513a75f..2e7bf8d41f044cb92ac29b0f59c4b830c07a2069 100644 (file)
@@ -535,15 +535,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);