Skip to content

Commit de7e71e

Browse files
committed
mm: simplify and improve print_vma_addr() output
Use '%pD' to print out the filename, and print out the actual offset within the file too, rather than just what the virtual address of the mapping is (which doesn't tell you anything about any mapping offsets). Also, use the exact vma_lookup() instead of find_vma() - the latter looks up any vma _after_ the address, which is of questionable value (yes, maybe you fell off the beginning, but you'd be more likely to fall off the end). Signed-off-by: Linus Torvalds <[email protected]>
1 parent f8a6e48 commit de7e71e

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

mm/memory.c

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6210,21 +6210,14 @@ void print_vma_addr(char *prefix, unsigned long ip)
62106210
if (!mmap_read_trylock(mm))
62116211
return;
62126212

6213-
vma = find_vma(mm, ip);
6213+
vma = vma_lookup(mm, ip);
62146214
if (vma && vma->vm_file) {
62156215
struct file *f = vma->vm_file;
6216-
char *buf = (char *)__get_free_page(GFP_NOWAIT);
6217-
if (buf) {
6218-
char *p;
6219-
6220-
p = file_path(f, buf, PAGE_SIZE);
6221-
if (IS_ERR(p))
6222-
p = "?";
6223-
printk("%s%s[%lx+%lx]", prefix, kbasename(p),
6224-
vma->vm_start,
6225-
vma->vm_end - vma->vm_start);
6226-
free_page((unsigned long)buf);
6227-
}
6216+
ip -= vma->vm_start;
6217+
ip += vma->vm_pgoff << PAGE_SHIFT;
6218+
printk("%s%pD[%lx,%lx+%lx]", prefix, f, ip,
6219+
vma->vm_start,
6220+
vma->vm_end - vma->vm_start);
62286221
}
62296222
mmap_read_unlock(mm);
62306223
}

0 commit comments

Comments
 (0)