Commit 3b3ddafd authored by gaoxiang17's avatar gaoxiang17 Committed by Christian König
Browse files

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: default avatarXiang Gao <gaoxiang17@xiaomi.com>
Reviewed-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
Reviewed-by: default avatarChristian König <christian.koenig@amd.com>
Signed-off-by: default avatarChristian König <christian.koenig@amd.com>
Link: https://lore.kernel.org/r/20260109115411.115270-1-gxxa03070307@gmail.com
parent d51e390a
Loading
Loading
Loading
Loading
+3 −6
Original line number Diff line number Diff line
@@ -46,12 +46,10 @@
 */
#define DMA_BUF_TRACE(FUNC, ...)					\
	do {								\
		if (FUNC##_enabled()) {					\
		/* Always expose lock if lockdep is enabled */		\
		if (IS_ENABLED(CONFIG_LOCKDEP) || FUNC##_enabled()) {	\
			guard(spinlock)(&dmabuf->name_lock);		\
			FUNC(__VA_ARGS__);				\
		} else if (IS_ENABLED(CONFIG_LOCKDEP)) {		\
			/* Expose this lock when lockdep is enabled */	\
			guard(spinlock)(&dmabuf->name_lock);		\
		}							\
	} while (0)

@@ -795,7 +793,6 @@ int dma_buf_fd(struct dma_buf *dmabuf, int flags)
		return -EINVAL;

	fd = FD_ADD(flags, dmabuf->file);
	if (fd >= 0)
	DMA_BUF_TRACE(trace_dma_buf_fd, dmabuf, fd);

	return fd;
+26 −24
Original line number Diff line number Diff line
@@ -137,11 +137,13 @@ DEFINE_EVENT(dma_buf_attach_dev, dma_buf_detach,
	TP_ARGS(dmabuf, attach, is_dynamic, dev)
);

DEFINE_EVENT(dma_buf_fd, dma_buf_fd,
DEFINE_EVENT_CONDITION(dma_buf_fd, dma_buf_fd,

	TP_PROTO(struct dma_buf *dmabuf, int fd),

	TP_ARGS(dmabuf, fd)
	TP_ARGS(dmabuf, fd),

	TP_CONDITION(fd >= 0)
);

DEFINE_EVENT(dma_buf_fd, dma_buf_get,