]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
perf: Use VMA iterator
authorLiam R. Howlett <Liam.Howlett@Oracle.com>
Mon, 4 Jan 2021 19:52:39 +0000 (14:52 -0500)
committerMatthew Wilcox (Oracle) <willy@infradead.org>
Mon, 1 Nov 2021 14:43:49 +0000 (10:43 -0400)
The VMA iterator is faster than the linked list and removing the linked
list will shrink the vm_area_struct.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
kernel/events/core.c
kernel/events/uprobes.c

index 0c000cb01eeb159bb60b06a9ccf7e539dcdf0344..2f940c91fd58f8171c64926b0bbe351ed3255afa 100644 (file)
@@ -10162,8 +10162,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 af24dc3febbef1aafdd8e702c3af2bfdfc3046c5..33ca0209730df584ce1528f3841b9d1fd7bb1ba3 100644 (file)
@@ -355,9 +355,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;
 
@@ -1236,11 +1237,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;
 
@@ -1988,9 +1990,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;
                /*