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

Liam R. Howlett Liam.Howlett at Oracle.com
Tue Jan 12 11:12:08 EST 2021


Use the vma interface to find the vma if one exists instead of the linked list

Signed-off-by: Liam R. Howlett <Liam.Howlett at Oracle.com>
---
 drivers/oprofile/buffer_sync.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

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;
-- 
2.28.0




More information about the maple-tree mailing list