From: Liam R. Howlett Date: Wed, 20 Jul 2022 02:18:01 +0000 (+0000) Subject: mm/mprotect: use maple tree navigation instead of VMA linked list X-Git-Tag: howlett/maple/20220906~12 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=7aa5dc55734ce0818ffd9e0cba7536742ec37eff;p=users%2Fjedix%2Flinux-maple.git mm/mprotect: use maple tree navigation instead of VMA linked list Switch to navigating the VMA list with the maple tree operators in preparation for removing the linked list. Signed-off-by: Liam R. Howlett Acked-by: Vlastimil Babka --- diff --git a/mm/mprotect.c b/mm/mprotect.c index 3a4de77161e9f..85649490651b9 100644 --- a/mm/mprotect.c +++ b/mm/mprotect.c @@ -674,6 +674,7 @@ static int do_mprotect_pkey(unsigned long start, size_t len, const bool rier = (current->personality & READ_IMPLIES_EXEC) && (prot & PROT_READ); struct mmu_gather tlb; + MA_STATE(mas, ¤t->mm->mm_mt, 0, 0); start = untagged_addr(start); @@ -705,7 +706,8 @@ static int do_mprotect_pkey(unsigned long start, size_t len, if ((pkey != -1) && !mm_pkey_is_allocated(current->mm, pkey)) goto out; - vma = find_vma(current->mm, start); + mas_set(&mas, start); + vma = mas_find(&mas, ULONG_MAX); error = -ENOMEM; if (!vma) goto out; @@ -731,7 +733,7 @@ static int do_mprotect_pkey(unsigned long start, size_t len, if (start > vma->vm_start) prev = vma; else - prev = vma->vm_prev; + prev = mas_prev(&mas, 0); tlb_gather_mmu(&tlb, current->mm); for (nstart = start ; ; ) { @@ -794,7 +796,7 @@ static int do_mprotect_pkey(unsigned long start, size_t len, if (nstart >= end) break; - vma = prev->vm_next; + vma = find_vma(current->mm, prev->vm_end); if (!vma || vma->vm_start != nstart) { error = -ENOMEM; break;