From: Liam R. Howlett Date: Tue, 15 Dec 2020 20:21:51 +0000 (-0500) Subject: mm: linked list many+1 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=f4750837c8d23f143428b0112adcf62a726f5153;p=users%2Fjedix%2Flinux-maple.git mm: linked list many+1 Signed-off-by: Liam R. Howlett --- diff --git a/mm/memory.c b/mm/memory.c index 4316611a6681..1375638621ab 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -392,9 +392,10 @@ void free_mt_pgtables(struct mmu_gather *tlb, struct vm_area_struct *vma, { struct ma_state ma_next = *mas; - mas_find(&ma_next, ceiling - 1); - mas_for_each(mas, vma, ceiling - 1) { - struct vm_area_struct *next = mas_find(&ma_next, ceiling - 1); + ceiling--; + mas_find(&ma_next, ceiling); + mas_for_each(mas, vma, ceiling) { + struct vm_area_struct *next = mas_find(&ma_next, ceiling); unsigned long addr = vma->vm_start; /* @@ -413,8 +414,8 @@ void free_mt_pgtables(struct mmu_gather *tlb, struct vm_area_struct *vma, */ while (next && next->vm_start <= vma->vm_end + PMD_SIZE && !is_vm_hugetlb_page(next)) { - next = mas_find(&ma_next, ceiling - 1); - vma = mas_find(mas, ceiling - 1); + next = mas_find(&ma_next, ceiling); + vma = mas_find(mas, ceiling); unlink_anon_vmas(vma); unlink_file_vma(vma); } diff --git a/mm/mmap.c b/mm/mmap.c index ba3c6a52034f..9e5f29013dbd 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -2369,7 +2369,7 @@ static inline unsigned long detach_range(struct mm_struct *mm, /* Set the upper limit */ if (!tmp) { mm->highest_vm_end = prev ? vm_end_gap(prev) : 0; - return mm->highest_vm_end; + return USER_PGTABLES_CEILING; } return tmp->vm_start; @@ -3159,7 +3159,7 @@ void exit_mmap(struct mm_struct *mm) struct mmu_gather tlb; struct vm_area_struct *vma; unsigned long nr_accounted = 0; - MA_STATE(mas, &mm->mm_mt, 0, 0); + MA_STATE(mas, &mm->mm_mt, FIRST_USER_ADDRESS, FIRST_USER_ADDRESS); /* mm's last user has gone, and its about to be pulled down */ mmu_notifier_release(mm); @@ -3196,7 +3196,7 @@ void exit_mmap(struct mm_struct *mm) } } mas_reset(&mas); - mas_set(&mas, 0); + mas_set(&mas, FIRST_USER_ADDRESS); } arch_exit_mmap(mm); @@ -3209,8 +3209,6 @@ void exit_mmap(struct mm_struct *mm) flush_cache_mm(mm); tlb_gather_mmu(&tlb, mm, 0, -1); /* update_hiwater_rss(mm) here? but nobody should be looking */ - mas_reset(&mas); - mas_set(&mas, FIRST_USER_ADDRESS); /* Use 0 here to ensure all VMAs in the mm are unmapped */ // unmap_vmas(&tlb, vma, 0, -1); unmap_vmas_mt(&tlb, vma, &mas, 0, -1);