[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20210817154651.1570984-55-Liam.Howlett@oracle.com>
Date: Tue, 17 Aug 2021 15:47:32 +0000
From: Liam Howlett <liam.howlett@...cle.com>
To: "maple-tree@...ts.infradead.org" <maple-tree@...ts.infradead.org>,
"linux-mm@...ck.org" <linux-mm@...ck.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
Andrew Morton <akpm@...ux-foundation.org>
CC: Song Liu <songliubraving@...com>,
Davidlohr Bueso <dave@...olabs.net>,
"Paul E . McKenney" <paulmck@...nel.org>,
Matthew Wilcox <willy@...radead.org>,
Laurent Dufour <ldufour@...ux.ibm.com>,
David Rientjes <rientjes@...gle.com>,
Axel Rasmussen <axelrasmussen@...gle.com>,
Suren Baghdasaryan <surenb@...gle.com>,
Vlastimil Babka <vbabka@...e.cz>,
Rik van Riel <riel@...riel.com>,
Peter Zijlstra <peterz@...radead.org>,
Michel Lespinasse <walken.cr@...il.com>,
Liam Howlett <liam.howlett@...cle.com>
Subject: [PATCH v2 54/61] mm/mprotect: Use maple tree navigation instead of
vma linked list
From: "Liam R. Howlett" <Liam.Howlett@...cle.com>
Signed-off-by: Liam R. Howlett <Liam.Howlett@...cle.com>
---
mm/mprotect.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/mm/mprotect.c b/mm/mprotect.c
index 883e2cc85cad..a4041d2c0dfb 100644
--- a/mm/mprotect.c
+++ b/mm/mprotect.c
@@ -528,6 +528,7 @@ static int do_mprotect_pkey(unsigned long start, size_t len,
const int grows = prot & (PROT_GROWSDOWN|PROT_GROWSUP);
const bool rier = (current->personality & READ_IMPLIES_EXEC) &&
(prot & PROT_READ);
+ MA_STATE(mas, ¤t->mm->mm_mt, start, start);
start = untagged_addr(start);
@@ -559,11 +560,15 @@ 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);
+ rcu_read_lock();
+ vma = mas_find(&mas, ULONG_MAX);
error = -ENOMEM;
- if (!vma)
+ if (!vma) {
+ rcu_read_unlock();
goto out;
- prev = vma->vm_prev;
+ }
+ prev = mas_prev(&mas, 0);
+ rcu_read_unlock();
if (unlikely(grows & PROT_GROWSDOWN)) {
if (vma->vm_start >= end)
goto out;
@@ -644,7 +649,7 @@ static int do_mprotect_pkey(unsigned long start, size_t len,
if (nstart >= end)
goto out;
- vma = prev->vm_next;
+ vma = vma_next(current->mm, prev);
if (!vma || vma->vm_start != nstart) {
error = -ENOMEM;
goto out;
--
2.30.2
Powered by blists - more mailing lists