Thread (137 messages) 137 messages, 6 authors, 2021-05-31

Re: [PATCH 76/94] mm/khugepaged: Use maple tree iterators instead of vma

From: Liam Howlett <hidden>
Date: 2021-05-04 14:06:14
Also in: lkml

* Hillf Danton [off-list ref] [210504 00:29]:
On Wed, 28 Apr 2021 15:36:24  Liam R. Howlett wrote:
quoted
---
 mm/khugepaged.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
Good work. And a nit below.
quoted
diff --git a/mm/khugepaged.c b/mm/khugepaged.c
index 33cf91529f0b..4983a25c5a90 100644
--- a/mm/khugepaged.c
+++ b/mm/khugepaged.c
@@ -2063,6 +2063,7 @@ static unsigned int khugepaged_scan_mm_slot(unsigned =
int pages,
 	struct mm_struct *mm;
 	struct vm_area_struct *vma;
 	int progress = 0;
+	MA_STATE(mas, NULL, 0, 0);

 	VM_BUG_ON(!pages);
 	lockdep_assert_held(&khugepaged_mm_lock);
@@ -2079,18 +2080,22 @@ static unsigned int khugepaged_scan_mm_slot(unsigne=
d int pages,
 	khugepaged_collapse_pte_mapped_thps(mm_slot);

 	mm = mm_slot->mm;
+	mas.tree = &mm->mm_mt;
 	/*
 	 * Don't wait for semaphore (to avoid long wait times).  Just move to
 	 * the next mm on the list.
 	 */
 	vma = NULL;
+	mas_set(&mas, khugepaged_scan.address);
 	if (unlikely(!mmap_read_trylock(mm)))
 		goto breakouterloop_mmap_lock;
+
+	rcu_read_lock();
 	if (likely(!khugepaged_test_exit(mm)))
-		vma = find_vma(mm, khugepaged_scan.address);
+		vma = mas_find(&mas, ULONG_MAX);

 	progress++;
-	for (; vma; vma = vma->vm_next) {
+	mas_for_each(&mas, vma, ULONG_MAX) {
 		unsigned long hstart, hend;

 		cond_resched();
Given the added rcu_read_lock(), take another look at this scheduling
entry?
Yes, thank you for pointing this out.  It is certainly an issue.
quoted
@@ -2129,6 +2134,7 @@ static unsigned int khugepaged_scan_mm_slot(unsigned =
int pages,
 				pgoff_t pgoff = linear_page_index(vma,
 						khugepaged_scan.address);

+				rcu_read_unlock();
 				mmap_read_unlock(mm);
 				ret = 1;
 				khugepaged_scan_file(mm, file, pgoff, hpage);
@@ -2149,6 +2155,7 @@ static unsigned int khugepaged_scan_mm_slot(unsigned =
int pages,
 		}
 	}
 breakouterloop:
+	rcu_read_unlock();
 	mmap_read_unlock(mm); /* exit_mmap will destroy ptes after this */
 breakouterloop_mmap_lock:

--
2.30.2
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help