]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
drivers/oprofile: Lookup address in tree instead of linked list.
authorLiam R. Howlett <Liam.Howlett@Oracle.com>
Mon, 4 Jan 2021 19:42:37 +0000 (14:42 -0500)
committerLiam R. Howlett <Liam.Howlett@Oracle.com>
Thu, 28 Jan 2021 17:38:12 +0000 (12:38 -0500)
Use the vma interface to find the vma if one exists instead of the linked list

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
drivers/oprofile/buffer_sync.c

index cc917865f13abfdc4b2b9520c10856de16a2e221..c63703b3bcebe0a5671f92cea0bc804a066a81c3 100644 (file)
@@ -253,15 +253,12 @@ done:
 static unsigned long
 lookup_dcookie(struct mm_struct *mm, unsigned long addr, off_t *offset)
 {
-       unsigned long cookie = NO_COOKIE;
+       unsigned long cookie = INVALID_COOKIE;
        struct vm_area_struct *vma;
 
        mmap_read_lock(mm);
-       for (vma = find_vma(mm, addr); vma; vma = vma->vm_next) {
-
-               if (addr < vma->vm_start || addr >= vma->vm_end)
-                       continue;
-
+       vma = find_vma_intersection(mm, addr, addr + 1);
+       if (vma) {
                if (vma->vm_file) {
                        cookie = fast_get_dcookie(&vma->vm_file->f_path);
                        *offset = (vma->vm_pgoff << PAGE_SHIFT) + addr -
@@ -269,13 +266,10 @@ lookup_dcookie(struct mm_struct *mm, unsigned long addr, off_t *offset)
                } else {
                        /* must be an anonymous map */
                        *offset = addr;
+                       cookie = NO_COOKIE;
                }
-
-               break;
        }
 
-       if (!vma)
-               cookie = INVALID_COOKIE;
        mmap_read_unlock(mm);
 
        return cookie;