[PATCH v3 60/66] mm/swapfile: Use maple tree iterator instead of vma linked list

From: Liam Howlett
Date: Mon Oct 04 2021 - 21:34:53 EST


From: "Liam R. Howlett" <Liam.Howlett@xxxxxxxxxx>

Signed-off-by: Liam R. Howlett <Liam.Howlett@xxxxxxxxxx>
---
mm/swapfile.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/mm/swapfile.c b/mm/swapfile.c
index 22d10f713848..f71695adde6c 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -2103,17 +2103,24 @@ static int unuse_mm(struct mm_struct *mm, unsigned int type,
{
struct vm_area_struct *vma;
int ret = 0;
+ MA_STATE(mas, &mm->mm_mt, 0, 0);

mmap_read_lock(mm);
- for (vma = mm->mmap; vma; vma = vma->vm_next) {
+ mas_lock(&mas);
+ mas_for_each(&mas, vma, ULONG_MAX) {
if (vma->anon_vma) {
ret = unuse_vma(vma, type, frontswap,
fs_pages_to_unuse);
if (ret)
break;
}
+
+ mas_unlock(&mas);
+ mas_pause(&mas);
cond_resched();
+ mas_lock(&mas);
}
+ mas_unlock(&mas);
mmap_read_unlock(mm);
return ret;
}
--
2.30.2