[PATCH v2 31/61] drivers/misc/cxl: Use maple tree iterators for cxl_prefault_vma()

Liam Howlett liam.howlett at oracle.com
Tue Aug 17 08:47:21 PDT 2021


From: "Liam R. Howlett" <Liam.Howlett at Oracle.com>

Signed-off-by: Liam R. Howlett <Liam.Howlett at Oracle.com>
---
 drivers/misc/cxl/fault.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/misc/cxl/fault.c b/drivers/misc/cxl/fault.c
index 60c829113299..60a33b953ef4 100644
--- a/drivers/misc/cxl/fault.c
+++ b/drivers/misc/cxl/fault.c
@@ -313,6 +313,7 @@ static void cxl_prefault_vma(struct cxl_context *ctx)
 	struct vm_area_struct *vma;
 	int rc;
 	struct mm_struct *mm;
+	MA_STATE(mas, NULL, 0, 0);
 
 	mm = get_mem_context(ctx);
 	if (mm == NULL) {
@@ -321,8 +322,10 @@ static void cxl_prefault_vma(struct cxl_context *ctx)
 		return;
 	}
 
+	mas.tree = &mm->mm_mt;
 	mmap_read_lock(mm);
-	for (vma = mm->mmap; vma; vma = vma->vm_next) {
+	rcu_read_lock();
+	mas_for_each(&mas, vma, ULONG_MAX) {
 		for (ea = vma->vm_start; ea < vma->vm_end;
 				ea = next_segment(ea, slb.vsid)) {
 			rc = copro_calculate_slb(mm, ea, &slb);
@@ -336,6 +339,7 @@ static void cxl_prefault_vma(struct cxl_context *ctx)
 			last_esid = slb.esid;
 		}
 	}
+	rcu_read_unlock();
 	mmap_read_unlock(mm);
 
 	mmput(mm);
-- 
2.30.2



More information about the maple-tree mailing list