diff mbox series

[v2,38/70] drivers/oprofile: Lookup address in tree instead of linked list.

Message ID 20210112161240.2024684-39-Liam.Howlett@Oracle.com (mailing list archive)
State New, archived
Headers show
Series RFC mm: Introducing the Maple Tree | expand

Commit Message

Liam R. Howlett Jan. 12, 2021, 4:12 p.m. UTC
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 | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)
diff mbox series

Patch

diff --git a/drivers/oprofile/buffer_sync.c b/drivers/oprofile/buffer_sync.c
index cc917865f13ab..c63703b3bcebe 100644
--- a/drivers/oprofile/buffer_sync.c
+++ b/drivers/oprofile/buffer_sync.c
@@ -253,15 +253,12 @@  static unsigned long get_exec_dcookie(struct mm_struct *mm)
 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;