Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

dma-buf: add some tracepoints to debug.

Since we can only inspect dmabuf by iterating over process FDs or the
dmabuf_list, we need to add our own tracepoints to track its status in
real time in production.

For example:
binder:3016_1-3102 [006] ...1. 255.126521: dma_buf_export: exp_name=qcom,system size=12685312 ino=2738
binder:3016_1-3102 [006] ...1. 255.126528: dma_buf_fd: exp_name=qcom,system size=12685312 ino=2738 fd=8
binder:3016_1-3102 [006] ...1. 255.126642: dma_buf_mmap_internal: exp_name=qcom,system size=28672 ino=2739
kworker/6:1-86 [006] ...1. 255.127194: dma_buf_put: exp_name=qcom,system size=12685312 ino=2738
RenderThread-9293 [006] ...1. 316.618179: dma_buf_get: exp_name=qcom,system size=12771328 ino=2762 fd=176
RenderThread-9293 [006] ...1. 316.618195: dma_buf_dynamic_attach: exp_name=qcom,system size=12771328 ino=2762 attachment:ffffff880a18dd00 is_dynamic=0 dev_name=kgsl-3d0
RenderThread-9293 [006] ...1. 318.878220: dma_buf_detach: exp_name=qcom,system size=12771328 ino=2762 attachment:ffffff880a18dd00 is_dynamic=0 dev_name=kgsl-3d0

Signed-off-by: Xiang Gao <gaoxiang17@xiaomi.com>
Reviewed-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Christian König <christian.koenig@amd.com>
Link: https://lore.kernel.org/r/20260109115411.115270-1-gxxa03070307@gmail.com

authored by

gaoxiang17 and committed by
Christian König
3b3ddafd d51e390a

+29 -30
+3 -6
drivers/dma-buf/dma-buf.c
··· 46 46 */ 47 47 #define DMA_BUF_TRACE(FUNC, ...) \ 48 48 do { \ 49 - if (FUNC##_enabled()) { \ 49 + /* Always expose lock if lockdep is enabled */ \ 50 + if (IS_ENABLED(CONFIG_LOCKDEP) || FUNC##_enabled()) { \ 50 51 guard(spinlock)(&dmabuf->name_lock); \ 51 52 FUNC(__VA_ARGS__); \ 52 - } else if (IS_ENABLED(CONFIG_LOCKDEP)) { \ 53 - /* Expose this lock when lockdep is enabled */ \ 54 - guard(spinlock)(&dmabuf->name_lock); \ 55 53 } \ 56 54 } while (0) 57 55 ··· 793 795 return -EINVAL; 794 796 795 797 fd = FD_ADD(flags, dmabuf->file); 796 - if (fd >= 0) 797 - DMA_BUF_TRACE(trace_dma_buf_fd, dmabuf, fd); 798 + DMA_BUF_TRACE(trace_dma_buf_fd, dmabuf, fd); 798 799 799 800 return fd; 800 801 }
+26 -24
include/trace/events/dma_buf.h
··· 15 15 TP_ARGS(dmabuf), 16 16 17 17 TP_STRUCT__entry( 18 - __string(exp_name, dmabuf->exp_name) 19 - __field(size_t, size) 20 - __field(ino_t, ino) 18 + __string( exp_name, dmabuf->exp_name) 19 + __field( size_t, size) 20 + __field( ino_t, ino) 21 21 ), 22 22 23 23 TP_fast_assign( 24 24 __assign_str(exp_name); 25 - __entry->size = dmabuf->size; 26 - __entry->ino = dmabuf->file->f_inode->i_ino; 25 + __entry->size = dmabuf->size; 26 + __entry->ino = dmabuf->file->f_inode->i_ino; 27 27 ), 28 28 29 29 TP_printk("exp_name=%s size=%zu ino=%lu", ··· 40 40 TP_ARGS(dmabuf, attach, is_dynamic, dev), 41 41 42 42 TP_STRUCT__entry( 43 - __string(dev_name, dev_name(dev)) 44 - __string(exp_name, dmabuf->exp_name) 45 - __field(size_t, size) 46 - __field(ino_t, ino) 47 - __field(struct dma_buf_attachment *, attach) 48 - __field(bool, is_dynamic) 43 + __string( dev_name, dev_name(dev)) 44 + __string( exp_name, dmabuf->exp_name) 45 + __field( size_t, size) 46 + __field( ino_t, ino) 47 + __field( struct dma_buf_attachment *, attach) 48 + __field( bool, is_dynamic) 49 49 ), 50 50 51 51 TP_fast_assign( 52 52 __assign_str(dev_name); 53 53 __assign_str(exp_name); 54 - __entry->size = dmabuf->size; 55 - __entry->ino = dmabuf->file->f_inode->i_ino; 56 - __entry->is_dynamic = is_dynamic; 57 - __entry->attach = attach; 54 + __entry->size = dmabuf->size; 55 + __entry->ino = dmabuf->file->f_inode->i_ino; 56 + __entry->is_dynamic = is_dynamic; 57 + __entry->attach = attach; 58 58 ), 59 59 60 60 TP_printk("exp_name=%s size=%zu ino=%lu attachment:%p is_dynamic=%d dev_name=%s", ··· 73 73 TP_ARGS(dmabuf, fd), 74 74 75 75 TP_STRUCT__entry( 76 - __string(exp_name, dmabuf->exp_name) 77 - __field(size_t, size) 78 - __field(ino_t, ino) 79 - __field(int, fd) 76 + __string( exp_name, dmabuf->exp_name) 77 + __field( size_t, size) 78 + __field( ino_t, ino) 79 + __field( int, fd) 80 80 ), 81 81 82 82 TP_fast_assign( 83 83 __assign_str(exp_name); 84 - __entry->size = dmabuf->size; 85 - __entry->ino = dmabuf->file->f_inode->i_ino; 86 - __entry->fd = fd; 84 + __entry->size = dmabuf->size; 85 + __entry->ino = dmabuf->file->f_inode->i_ino; 86 + __entry->fd = fd; 87 87 ), 88 88 89 89 TP_printk("exp_name=%s size=%zu ino=%lu fd=%d", ··· 137 137 TP_ARGS(dmabuf, attach, is_dynamic, dev) 138 138 ); 139 139 140 - DEFINE_EVENT(dma_buf_fd, dma_buf_fd, 140 + DEFINE_EVENT_CONDITION(dma_buf_fd, dma_buf_fd, 141 141 142 142 TP_PROTO(struct dma_buf *dmabuf, int fd), 143 143 144 - TP_ARGS(dmabuf, fd) 144 + TP_ARGS(dmabuf, fd), 145 + 146 + TP_CONDITION(fd >= 0) 145 147 ); 146 148 147 149 DEFINE_EVENT(dma_buf_fd, dma_buf_get,