]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
perf: use VMA iterator
authorLiam R. Howlett <Liam.Howlett@Oracle.com>
Thu, 14 Apr 2022 06:07:20 +0000 (23:07 -0700)
committerLiam R. Howlett <Liam.Howlett@oracle.com>
Thu, 14 Apr 2022 21:49:48 +0000 (17:49 -0400)
The VMA iterator is faster than the linked list and removing the linked
list will shrink the vm_area_struct.

Link: https://lkml.kernel.org/r/20220404143501.2016403-49-Liam.Howlett@oracle.com
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
Acked-by: Vlastimil Babka <vbabka@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
kernel/events/core.c
kernel/events/uprobes.c

index 23bb19716ad3dc032aa3e22e16904eaea6b817cf..b20b14d8dba7bb75dd3cc377884f8db4ae67aada 100644 (file)
@@ -10211,8 +10211,9 @@ static void perf_addr_filter_apply(struct perf_addr_filter *filter,
                                   struct perf_addr_filter_range *fr)
 {
        struct vm_area_struct *vma;
+       VMA_ITERATOR(vmi, mm, 0);
 
-       for (vma = mm->mmap; vma; vma = vma->vm_next) {
+       for_each_vma(vmi, vma) {
                if (!vma->vm_file)
                        continue;
 
index 4ef5385815d3c1eb4dc7b703ac849d48ebc94073..c3b2f695cc743628d177b0d804dab9b362c9ffc0 100644 (file)
@@ -349,9 +349,10 @@ 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)
 {
+       VMA_ITERATOR(vmi, mm, 0);
        struct vm_area_struct *tmp;
 
-       for (tmp = mm->mmap; tmp; tmp = tmp->vm_next)
+       for_each_vma(vmi, tmp)
                if (valid_ref_ctr_vma(uprobe, tmp))
                        return tmp;
 
@@ -1230,11 +1231,12 @@ int uprobe_apply(struct inode *inode, loff_t offset,
 
 static int unapply_uprobe(struct uprobe *uprobe, struct mm_struct *mm)
 {
+       VMA_ITERATOR(vmi, mm, 0);
        struct vm_area_struct *vma;
        int err = 0;
 
        mmap_read_lock(mm);
-       for (vma = mm->mmap; vma; vma = vma->vm_next) {
+       for_each_vma(vmi, vma) {
                unsigned long vaddr;
                loff_t offset;
 
@@ -1982,9 +1984,10 @@ bool uprobe_deny_signal(void)
 
 static void mmf_recalc_uprobes(struct mm_struct *mm)
 {
+       VMA_ITERATOR(vmi, mm, 0);
        struct vm_area_struct *vma;
 
-       for (vma = mm->mmap; vma; vma = vma->vm_next) {
+       for_each_vma(vmi, vma) {
                if (!valid_vma(vma, false))
                        continue;
                /*