Thread (1 message) 1 message, 1 author, 2021-07-15
STALE1850d

[PATCH RFC 12/13] mm: simplify the printing with '%pd' specifier

From: Jia He <hidden>
Date: 2021-07-15 03:16:45
Also in: lkml
Subsystem: memory management, memory management - core, the rest · Maintainers: Andrew Morton, David Hildenbrand, Linus Torvalds

Use '%pd' to simplify the printing since kbasename(file_path()) is to
get the last dentry of the full path.

Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-mm@kvack.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Jia He <redacted>
---
 mm/memory.c | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)
diff --git a/mm/memory.c b/mm/memory.c
index 747a01d495f2..350692ada6f7 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -5217,18 +5217,14 @@ void print_vma_addr(char *prefix, unsigned long ip)
 	vma = find_vma(mm, ip);
 	if (vma && vma->vm_file) {
 		struct file *f = vma->vm_file;
-		char *buf = (char *)__get_free_page(GFP_NOWAIT);
-		if (buf) {
-			char *p;
-
-			p = file_path(f, buf, PAGE_SIZE);
-			if (IS_ERR(p))
-				p = "?";
-			printk("%s%s[%lx+%lx]", prefix, kbasename(p),
+
+		if (f)
+			printk("%s%pd[%lx+%lx]", prefix, f->f_path.dentry,
 					vma->vm_start,
 					vma->vm_end - vma->vm_start);
-			free_page((unsigned long)buf);
-		}
+		else
+			printk("%s?[%lx+%lx]", prefix, vma->vm_start,
+					vma->vm_end - vma->vm_start);
 	}
 	mmap_read_unlock(mm);
 }
-- 
2.17.1

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help