]> 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)
committerLiam R. Howlett <Liam.Howlett@oracle.com>
Mon, 14 Mar 2022 18:49:46 +0000 (14:49 -0400)
The VMA iterator is faster than the linked list and removing the linked
list will shrink the vm_area_struct.

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>
kernel/events/core.c
kernel/events/uprobes.c

index 6859229497b1544594659d40ed301d41425da035..935e738a5eb63da327877af13b6a036096d8680f 100644 (file)
@@ -10319,8 +10319,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 6357c3580d07b3e9db116ce69c2c62de436bea64..5dee6c41f36d3e74d9666fdf8f40df96f555d96d 100644 (file)
@@ -356,9 +356,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;
 
@@ -1237,11 +1238,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;
 
@@ -1989,9 +1991,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;
                /*