]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
mm/khugepaged: stop using vma linked list
authorLiam R. Howlett <Liam.Howlett@Oracle.com>
Thu, 14 Apr 2022 06:07:21 +0000 (23:07 -0700)
committerLiam R. Howlett <Liam.Howlett@oracle.com>
Thu, 14 Apr 2022 21:49:48 +0000 (17:49 -0400)
Use vma iterator & find_vma() instead of vma linked list.

Link: https://lkml.kernel.org/r/20220404143501.2016403-54-Liam.Howlett@oracle.com
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/huge_memory.c
mm/khugepaged.c

index 297af16e66f257cf8e16a8c11a3413182501e0e4..6ca56eb756810686e728d8983f6deae5d293c513 100644 (file)
@@ -2274,11 +2274,11 @@ void vma_adjust_trans_huge(struct vm_area_struct *vma,
        split_huge_pmd_if_needed(vma, end);
 
        /*
-        * If we're also updating the vma->vm_next->vm_start,
+        * If we're also updating the next vma vm_start,
         * check if we need to split it.
         */
        if (adjust_next > 0) {
-               struct vm_area_struct *next = vma->vm_next;
+               struct vm_area_struct *next = find_vma(vma->vm_mm, vma->vm_end);
                unsigned long nstart = next->vm_start;
                nstart += adjust_next;
                split_huge_pmd_if_needed(next, nstart);
index 2f6e4d6ffb79cd5882aab4af0bef0c93bf1dddc2..edd643de2347553c09f3bdc7186193cf0cf46029 100644 (file)
@@ -2089,10 +2089,12 @@ static unsigned int khugepaged_scan_mm_slot(unsigned int pages,
        __releases(&khugepaged_mm_lock)
        __acquires(&khugepaged_mm_lock)
 {
+       struct vma_iterator vmi;
        struct mm_slot *mm_slot;
        struct mm_struct *mm;
        struct vm_area_struct *vma;
        int progress = 0;
+       unsigned long address;
 
        VM_BUG_ON(!pages);
        lockdep_assert_held(&khugepaged_mm_lock);
@@ -2116,11 +2118,14 @@ static unsigned int khugepaged_scan_mm_slot(unsigned int pages,
        vma = NULL;
        if (unlikely(!mmap_read_trylock(mm)))
                goto breakouterloop_mmap_lock;
-       if (likely(!khugepaged_test_exit(mm)))
-               vma = find_vma(mm, khugepaged_scan.address);
 
        progress++;
-       for (; vma; vma = vma->vm_next) {
+       if (unlikely(khugepaged_test_exit(mm)))
+               goto breakouterloop;
+
+       address = khugepaged_scan.address;
+       vma_iter_init(&vmi, mm, address);
+       for_each_vma(vmi, vma) {
                unsigned long hstart, hend;
 
                cond_resched();