]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
mm/khugepaged: stop using vma linked list
authorMatthew Wilcox (Oracle) <willy@infradead.org>
Wed, 20 Jul 2022 02:18:00 +0000 (02:18 +0000)
committerLiam R. Howlett <Liam.Howlett@oracle.com>
Tue, 6 Sep 2022 19:44:25 +0000 (15:44 -0400)
Use vma iterator & find_vma() instead of vma linked list.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
Reviewed-by: Davidlohr Bueso <dave@stgolabs.net>
mm/huge_memory.c
mm/khugepaged.c

index 83c47a989260999ae173e0b6c7eaa3886aba04b8..6c5c23ef658a54fc380f3349108452c908670c11 100644 (file)
@@ -2339,11 +2339,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 d3313b7a8fe5cb643e05530e2f6b902e3bd847ae..126dc35276c4b3caff37d4e6894002ecca7435f0 100644 (file)
@@ -2053,6 +2053,7 @@ static unsigned int khugepaged_scan_mm_slot(unsigned int pages, int *result,
        __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;
@@ -2081,11 +2082,13 @@ static unsigned int khugepaged_scan_mm_slot(unsigned int pages, int *result,
        vma = NULL;
        if (unlikely(!mmap_read_trylock(mm)))
                goto breakouterloop_mmap_lock;
-       if (likely(!hpage_collapse_test_exit(mm)))
-               vma = find_vma(mm, khugepaged_scan.address);
 
        progress++;
-       for (; vma; vma = vma->vm_next) {
+       if (unlikely(hpage_collapse_test_exit(mm)))
+               goto breakouterloop;
+
+       vma_iter_init(&vmi, mm, khugepaged_scan.address);
+       for_each_vma(vmi, vma) {
                unsigned long hstart, hend;
 
                cond_resched();