From a4f940596fcb4c2f1382dae2da56235ddeaea3e4 Mon Sep 17 00:00:00 2001 From: Jianqun Xu Date: Fri, 25 Mar 2022 16:18:03 +0800 Subject: [PATCH] dma-buf: rk_heaps: optimize dump information format cat /sys/kernel/debug/rk_dma_heap/dma_heap_info |grep Alloc Alloc by (vmpi ) [0x05fe3000-0x061a4fff] 0x001c2000 (1800 KiB) Alloc by (vmpi ) [0x05fe2000-0x05fe2fff] 0x00001000 (4 KiB) Alloc by (vmpi ) [0x05fe1000-0x05fe1fff] 0x00001000 (4 KiB) Alloc by (vmpi ) [0x05a6d000-0x05fe0fff] 0x00574000 (5584 KiB) Alloc by (vmpi ) [0x05987000-0x05a6cfff] 0x000e6000 (920 KiB) Alloc by (vmpi ) [0x0594d000-0x05986fff] 0x0003a000 (232 KiB) Alloc by (vmpi ) [0x0594c000-0x0594cfff] 0x00001000 (4 KiB) Alloc by (vmpi ) [0x053d8000-0x0594bfff] 0x00574000 (5584 KiB) Alloc by (vmpi ) [0x052f2000-0x053d7fff] 0x000e6000 (920 KiB) Alloc by (vmpi ) [0x052b8000-0x052f1fff] 0x0003a000 (232 KiB) Alloc by (vmpi ) [0x04556000-0x04a9bfff] 0x00546000 (5400 KiB) Alloc by (vmpi ) [0x04010000-0x04555fff] 0x00546000 (5400 KiB) Alloc by (rkisp-vir0 ) [0x04000000-0x04003fff] 0x00004000 (16 KiB) Alloc by (rkisp-vir0 ) [0x04004000-0x04007fff] 0x00004000 (16 KiB) Alloc by (rkisp-vir0 ) [0x04008000-0x0400bfff] 0x00004000 (16 KiB) Alloc by (rkisp-vir0 ) [0x0400c000-0x0400ffff] 0x00004000 (16 KiB) Alloc by (ffa00000.rkisp ) [0x04a9c000-0x04a9cfff] 0x00001000 (4 KiB) Alloc by (ffa00000.rkisp ) [0x04a9d000-0x04a9dfff] 0x00001000 (4 KiB) Alloc by (ffa00000.rkisp ) [0x04a9e000-0x05216fff] 0x00779000 (7652 KiB) Alloc by (ffa00000.rkisp ) [0x05217000-0x05246fff] 0x00030000 (192 KiB) Alloc by (ffa00000.rkisp ) [0x05247000-0x052b7fff] 0x00071000 (452 KiB) cat /sys/kernel/debug/rk_dma_heap/dma_heap_info |grep Total Total : 0x21a5000 (34452 KiB) Signed-off-by: Jianqun Xu Change-Id: I3b739689e394f9d5fbfe50df2cf87d6f5cc744de --- drivers/dma-buf/rk_heaps/rk-dma-heap.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/dma-buf/rk_heaps/rk-dma-heap.c b/drivers/dma-buf/rk_heaps/rk-dma-heap.c index f920962c1967..251d07375155 100644 --- a/drivers/dma-buf/rk_heaps/rk-dma-heap.c +++ b/drivers/dma-buf/rk_heaps/rk-dma-heap.c @@ -39,6 +39,7 @@ static DEFINE_XARRAY_ALLOC(rk_dma_heap_minors); struct proc_dir_entry *proc_rk_dma_heap_dir; #define RK_DMA_HEAP_CMA_DEFAULT_SIZE SZ_32M +#define K(size) ((unsigned long)((size) >> 10)) static unsigned long rk_dma_heap_size __initdata; static unsigned long rk_dma_heap_base __initdata; @@ -545,9 +546,9 @@ static int rk_dma_heap_dump_dmabuf(const struct dma_buf *dmabuf, void *data) dmabuf->file->f_inode->i_ino); size = buf->end - buf->start + 1; seq_printf(heap->s, - "\tAlloc by (%s)\t[%pa-%pa]\t%pa\n", + "\tAlloc by (%-20s)\t[%pa-%pa]\t%pa (%lu KiB)\n", buf->orig_alloc, &buf->start, - &buf->end, &size); + &buf->end, &size, K(size)); seq_puts(heap->s, "\t\tAttached Devices:\n"); attach_count = 0; ret = dma_resv_lock_interruptible(dmabuf->resv, @@ -585,8 +586,8 @@ static int rk_dma_heap_dump_contig(void *data) list_for_each_entry(buf, &heap->contig_list, node) { size = buf->end - buf->start + 1; seq_printf(heap->s, "dma-heap:<%s> -non dmabuf\n", heap->name); - seq_printf(heap->s, "\tAlloc by (%s)\t[%pa-%pa]\t%pa\n", - buf->orig_alloc, &buf->start, &buf->end, &size); + seq_printf(heap->s, "\tAlloc by (%-20s)\t[%pa-%pa]\t%pa (%lu KiB)\n", + buf->orig_alloc, &buf->start, &buf->end, &size, K(size)); } mutex_unlock(&heap->contig_lock); @@ -660,7 +661,7 @@ static int rk_dma_heap_debug_show(struct seq_file *s, void *unused) rk_dma_heap_dump_contig(heap); total += heap->total_size; } - seq_printf(s, "\nTotal : 0x%lx\n", total); + seq_printf(s, "\nTotal : 0x%lx (%lu KiB)\n", total, K(total)); mutex_unlock(&rk_heap_list_lock); return 0; @@ -709,7 +710,7 @@ static int rk_dma_heap_proc_show(struct seq_file *s, void *unused) rk_dma_heap_dump_contig(heap); total += heap->total_size; } - seq_printf(s, "\nTotal : 0x%lx\n", total); + seq_printf(s, "\nTotal : 0x%lx (%lu KiB)\n", total, K(total)); mutex_unlock(&rk_heap_list_lock); return 0;