]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
acct: use VMA iterator instead of linked list
authorMatthew Wilcox (Oracle) <willy@infradead.org>
Thu, 14 Apr 2022 06:07:20 +0000 (23:07 -0700)
committerLiam R. Howlett <Liam.Howlett@oracle.com>
Tue, 26 Apr 2022 14:36:39 +0000 (10:36 -0400)
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>
Acked-by: Vlastimil Babka <vbabka@suse.cz>
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);