[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20210428153542.2814175-72-Liam.Howlett@Oracle.com>
Date: Wed, 28 Apr 2021 15:36:22 +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 71/94] kernel/events/uprobes: Use maple tree iterators instead
of linked list
Signed-off-by: Liam R. Howlett <Liam.Howlett@...cle.com>
---
kernel/events/uprobes.c | 25 ++++++++++++++++++-------
1 file changed, 18 insertions(+), 7 deletions(-)
diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
index 907d4ee00cb2..8d3248ffbd68 100644
--- a/kernel/events/uprobes.c
+++ b/kernel/events/uprobes.c
@@ -355,13 +355,16 @@ static bool valid_ref_ctr_vma(struct uprobe *uprobe,
static struct vm_area_struct *
find_ref_ctr_vma(struct uprobe *uprobe, struct mm_struct *mm)
{
- struct vm_area_struct *tmp;
+ struct vm_area_struct *tmp = NULL;
+ MA_STATE(mas, &mm->mm_mt, 0, 0);
- for (tmp = mm->mmap; tmp; tmp = tmp->vm_next)
+ rcu_read_lock();
+ mas_for_each(&mas, tmp, ULONG_MAX)
if (valid_ref_ctr_vma(uprobe, tmp))
- return tmp;
+ break;
+ rcu_read_unlock();
- return NULL;
+ return tmp;
}
static int
@@ -1237,9 +1240,10 @@ static int unapply_uprobe(struct uprobe *uprobe, struct mm_struct *mm)
{
struct vm_area_struct *vma;
int err = 0;
+ MA_STATE(mas, &mm->mm_mt, 0, 0);
mmap_read_lock(mm);
- for (vma = mm->mmap; vma; vma = vma->vm_next) {
+ mas_for_each(&mas, vma, ULONG_MAX) {
unsigned long vaddr;
loff_t offset;
@@ -1988,8 +1992,10 @@ bool uprobe_deny_signal(void)
static void mmf_recalc_uprobes(struct mm_struct *mm)
{
struct vm_area_struct *vma;
+ MA_STATE(mas, &mm->mm_mt, 0, 0);
- for (vma = mm->mmap; vma; vma = vma->vm_next) {
+ rcu_read_lock();
+ mas_for_each(&mas, vma, ULONG_MAX) {
if (!valid_vma(vma, false))
continue;
/*
@@ -1999,10 +2005,15 @@ static void mmf_recalc_uprobes(struct mm_struct *mm)
* Or this uprobe can be filtered out.
*/
if (vma_has_uprobes(vma, vma->vm_start, vma->vm_end))
- return;
+ goto completed;
}
+ rcu_read_unlock();
clear_bit(MMF_HAS_UPROBES, &mm->flags);
+ return;
+
+completed:
+ rcu_read_unlock();
}
static int is_trap_at_addr(struct mm_struct *mm, unsigned long vaddr)
--
2.30.2
Powered by blists - more mailing lists