dma-buf: add some tracepoints to debug.
Subsystems (3)
A message that is not in the archive (sent off-list or not yet received): [email protected]/
PATCH v13 1/1 dma-buf: add some tracepoints to debug.
From: gaoxiang17 <[email protected]>
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---
Changes since v12: https://lore.kernel.org/all/[email protected]/
- list history changes
Changes since v11: https://lore.kernel.org/all/[email protected]/
- Lined up the backslashes nicely for the macro DMA_BUF_TRACE.
- Used DEFINE_EVENT_CONDITION() to move the condition branch into the tracepoint.
Changes since v10: https://lore.kernel.org/all/[email protected]/
- Always expose dmabuf->name_lock if lockdep is enabled.
Changes since v9: https://lore.kernel.org/all/[email protected]/
- Fixed some whitespace issues with the macro DMA_BUF_TRACE again.
Changes since v8: https://lore.kernel.org/all/[email protected]/
- Expose dmabuf->name_lock when lockdep is enabled but trace event is not.
Changes since v7: https://lore.kernel.org/all/[email protected]/
- Fixed some whitespace issues with the macro DMA_BUF_TRACE.
Changes since v6: https://lore.kernel.org/all/[email protected]/
- Add a comment for the macro DMA_BUF_TRACE.
Changes since v5: https://lore.kernel.org/all/[email protected]/
- Add the macro DMA_BUF_TRACE.
- Modify the commit message.
Changes since v4: https://lore.kernel.org/all/[email protected]/
- Remove the tracepoints exporting.
- Remove the file refcount for the trace.
- Print the dev_name last.
- Add the parameter of whether dma_buf attachment is dynamic.
Changes since v3: https://lore.kernel.org/all/[email protected]/
- Take the dmabuf->name_lock around the tracepoint call itself.
- Used DECLARE_EVENT_CLASS() and a DEFINE_EVENT().
Changes since v2: https://lore.kernel.org/all/[email protected]/
- Add more explanation to the commit message.
drivers/dma-buf/dma-buf.c | 9 ++---- include/trace/events/dma_buf.h | 50 ++++++++++++++++++---------------- 2 files changed, 29 insertions(+), 30 deletions(-)
drivers/dma-buf/dma-buf.c +3 -6
@@ -48,12 +48,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)
@@ -806,8 +804,7 @@ 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); +DMA_BUF_TRACE (trace_dma_buf_fd, dmabuf, fd);return fd; }
include/trace/events/dma_buf.h +26 -24
90 lines not on this page · raw message
Signature · 1 line
2.34.1
Quoted 15 lines · On Fri, 9 Jan 2026 19:54:11 +0800 Xiang Gao <[email protected]> wrote:
From: gaoxiang17 <[email protected]>
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
Quoted 1 line
Signed-off-by Xiang Gao <[email protected]>
This may already been accepted but just for the record. For the tracing POV:
-- Steve