dma-buf: add some tracepoints to debug.
Subsystems (3)
PATCH v2 1/1 dma-buf: add some tracepoints to debug.
From: gaoxiang17 <[email protected]>
I want to track the status of dmabuf in real time in the production environment. But now we can only check it by traversing the fd in the process or dmabuf_list.
For example:
<...>-8342 [006] ..... 199.626433: dma_buf_export: exp_name=system name=(null) size=32768 ino=2337 f_refcnt=2
<...>-8342 [006] ..... 199.626436: dma_buf_fd: exp_name=system name=(null) size=32768 ino=2337 fd=853 f_refcnt=2
<...>-8342 [006] ..... 199.626472: dma_buf_mmap_internal: exp_name=system name=system size=32768 ino=2337 f_refcnt=6
<...>-3199 [006] ..... 200.719182: dma_buf_get: exp_name=qcom,system name=acb size=184320 ino=2331 fd=111 f_refcnt=6
<...>-894 [006] ..... 199.632342: dma_buf_put: exp_name=system name=system size=32768 ino=2337 f_refcnt=2
<...>-3199 [003] ..... 213.402200: dma_buf_attach: dev_name=soc:qcom,xxx exp_name=qcom,system name=acb size=184320 ino=2331 f_refcnt=7
<...>-1229 [004] ..... 213.850270: dma_buf_detach: exp_name=qcom,system name=acb size=184320 ino=2331 f_refcnt=6--- drivers/dma-buf/dma-buf.c | 19 +++ include/trace/events/dma_buf.h | 281 +++++++++++++++++++++++++++++++++ 2 files changed, 300 insertions(+) create mode 100644 include/trace/events/dma_buf.h
drivers/dma-buf/dma-buf.c +19 -0
@@ -35,6 +35,9 @@#include "dma-buf-sysfs-stats.h" +#define CREATE_TRACE_POINTS +#include <trace/events/dma_buf.h> +static inline int is_dma_buf_file (struct file *);static DEFINE_MUTEX (dmabuf_list_mutex);
@@ -220,6 +223,8 @@ static int dma_buf_mmap_internal(struct file *file, struct vm_area_struct *vma) dmabuf->size >> PAGE_SHIFT)return -EINVAL ; +trace_dma_buf_mmap_internal (dmabuf); +return dmabuf->ops->mmap (dmabuf, vma); }
@@ -745,6 +750,8 @@ struct dma_buf *dma_buf_export(const struct dma_buf_export_info *exp_info)__dma_buf_list_add (dmabuf); +trace_dma_buf_export (dmabuf); +return dmabuf; err_dmabuf:
@@ -779,6 +786,8 @@ int dma_buf_fd(struct dma_buf *dmabuf, int flags)fd_install (fd, dmabuf->file); +trace_dma_buf_fd (dmabuf, fd); +return fd; }EXPORT_SYMBOL_NS_GPL (dma_buf_fd,"DMA_BUF" );
@@ -805,6 +814,8 @@ struct dma_buf *dma_buf_get(int fd)return ERR_PTR (-EINVAL ); } +trace_dma_buf_get (fd, file); +return file->private_data; }EXPORT_SYMBOL_NS_GPL (dma_buf_get,"DMA_BUF" );
@@ -825,6 +836,8 @@ void dma_buf_put(struct dma_buf *dmabuf)return ;fput (dmabuf->file); + +trace_dma_buf_put (dmabuf); }EXPORT_SYMBOL_NS_GPL (dma_buf_put,"DMA_BUF" );
@@ -998,6 +1011,8 @@ EXPORT_SYMBOL_NS_GPL(dma_buf_dynamic_attach, "DMA_BUF");struct dma_buf_attachment *dma_buf_attach (struct dma_buf *dmabuf,struct device *dev) { +trace_dma_buf_attach (dmabuf, dev); +return dma_buf_dynamic_attach (dmabuf, dev,NULL ,NULL ); }EXPORT_SYMBOL_NS_GPL (dma_buf_attach,"DMA_BUF" );
@@ -1024,6 +1039,8 @@ void dma_buf_detach(struct dma_buf *dmabuf, struct dma_buf_attachment *attach) dmabuf->ops->detach (dmabuf, attach);kfree (attach); + +trace_dma_buf_detach (dmabuf); }EXPORT_SYMBOL_NS_GPL (dma_buf_detach,"DMA_BUF" );
@@ -1488,6 +1505,8 @@ int dma_buf_mmap(struct dma_buf *dmabuf, struct vm_area_struct *vma,vma_set_file (vma, dmabuf->file); vma->vm_pgoff = pgoff; +trace_dma_buf_mmap (dmabuf); +return dmabuf->ops->mmap (dmabuf, vma); }EXPORT_SYMBOL_NS_GPL (dma_buf_mmap,"DMA_BUF" );
include/trace/events/dma_buf.h new file +281 -0
281 lines not on this page · raw message
Signature · 1 line
2.34.1
Steven Rostedt
maintainerQuoted 21 lines · On Wed, 26 Nov 2025 00:29:49 +0800 Xiang Gao <[email protected]> wrote:
+++
b/include/trace/events/dma_buf.hinclude/trace/events/dma_buf.h new file +19
-0@@ -0,0 +1,281 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#undef TRACE_SYSTEM +#define TRACE_SYSTEM dma_buf + +#if !defined(_TRACE_DMA_BUF_H) || defined(TRACE_HEADER_MULTI_READ ) +#define _TRACE_DMA_BUF_H + +#include <linux/dma-buf.h> +#include <linux/tracepoint.h> + +TRACE_EVENT(dma_buf_export, + + TP_PROTO(struct dma_buf *dmabuf), + + TP_ARGS(dmabuf), + + TP_STRUCT__entry( + __string(exp_name, dmabuf->exp_name) + __string(name, dmabuf->name)
include/trace/events/dma_buf.h line 29
Quoted 10 lines
include/trace/events/dma_buf.h new file +10
-0+ __field(size_t, size) + __field(ino_t, ino) +__field (long, f_refcnt) + ), + +TP_fast_assign ( + __assign_str(exp_name); +spin_lock (&dmabuf->name_lock); +__assign_str (name); +spin_unlock (&dmabuf->name_lock);
The above isn't doing what you think it's doing. The name is assigned before this by the above __string(name, dmabuf->name).
You really shouldn't be taking any locks in a tracepoint. A tracepoint is a callback, that isn't called most of the time. You could be hiding very hard to find deadlocks by taking a lock in a tracepoint callback.
You need to take the lock around the tracepoint call itself where it is called in the code. Not in the TRACE_EVENT.
You may need to have something like:
@@ -220,6 +223,8 @@ static int dma_buf_mmap_internal(struct file *file, struct vm_area_struct *vma)
dmabuf->size >> PAGE_SHIFT)
return -EINVAL;
+ if (trace_dma_buf_mmap_internal_enabled()) {
+ guard(spinlock)(&dmabuf->namelock);
+ trace_dma_buf_mmap_internal(dmabuf);
+ }
+
return dmabuf->ops->mmap(dmabuf, vma);
}
The "trace_dma_buf_mmap_internal_enabled()" is a static branch, where it is either a nop or a jump to the tracing code. It's not a normal conditional branch. It acts the same as tracepoints themselves do.
include/trace/events/dma_buf.h line 41
Quoted 12 lines
include/trace/events/dma_buf.h new file +12
-0+ __entry->size = dmabuf->size; + __entry->ino = dmabuf->file->f_inode->i_ino; + __entry->f_refcnt =file_count (dmabuf->file); + ), + +TP_printk ("exp_name=%s name=%s size=%zu ino=%lu f_refcnt=%ld" , +__get_str (exp_name), +__get_str (name), + __entry->size, + __entry->ino, + __entry->f_refcnt) +);
Below seems to be a lot of very similar TRACE_EVENT()s. A TRACE_EVENT() is literally defined as:
#define TRACE_EVENT(name, proto, args, tstruct, assign, print) \ DECLARE_EVENT_CLASS(name, \ PARAMS(proto), \ PARAMS(args), \ PARAMS(tstruct), \ PARAMS(assign), \ PARAMS(print)); \ DEFINE_EVENT(name, name, PARAMS(proto), PARAMS(args));
That is, it is both a DECLARE_EVENT_CLASS() and a DEFINE_EVENT(). You can make one DECLARE_EVENT_CLASS() and use many DEFINE_EVENT()s with it.
Each DECLARE_EVENT_CLASS() takes up around 4 to 5 kilobytes of memory. Each DEFINE_EVENT() takes around 300 bytes to 1K of memory. The more DEFINE_EVENT()s you use with a single DECLARE_EVENT_CLASS(), the more memory you save. Please try to do that.
-- Steve
Quoted 240 lines
include/trace/events/dma_buf.h new file +240
-0+ +TRACE_EVENT (dma_buf_fd, + + TP_PROTO(struct dma_buf *dmabuf, int fd), + +TP_ARGS (dmabuf, fd), + +TP_STRUCT__entry ( + __string(exp_name, dmabuf->exp_name) + __string(name, dmabuf->name) + __field(size_t, size) + __field(ino_t, ino) + __field(int, fd) +__field (long, f_refcnt) + ), + +TP_fast_assign ( + __assign_str(exp_name); + spin_lock(&dmabuf->name_lock); + __assign_str(name); + spin_unlock(&dmabuf->name_lock); + __entry->size = dmabuf->size; + __entry->ino = dmabuf->file->f_inode->i_ino; + __entry->fd = fd; + __entry->f_refcnt = file_count(dmabuf->file); + ), + +TP_printk ("exp_name=%s name=%s size=%zu ino=%lu fd=%d f_refcnt=%ld" , +__get_str (exp_name), +__get_str (name), + __entry->size, + __entry->ino, + __entry->fd, + __entry->f_refcnt) +); + +TRACE_EVENT (dma_buf_mmap_internal, + + TP_PROTO(struct dma_buf *dmabuf), + +TP_ARGS (dmabuf), + +TP_STRUCT__entry ( + __string(exp_name, dmabuf->exp_name) + __string(name, dmabuf->name) + __field(size_t, size) + __field(ino_t, ino) +__field (long, f_refcnt) + ), + +TP_fast_assign ( + __assign_str(exp_name); + spin_lock(&dmabuf->name_lock); + __assign_str(name); + spin_unlock(&dmabuf->name_lock); + __entry->size = dmabuf->size; + __entry->ino = dmabuf->file->f_inode->i_ino; + __entry->f_refcnt = file_count(dmabuf->file); + ), + +TP_printk ("exp_name=%s name=%s size=%zu ino=%lu f_refcnt=%ld" , +__get_str (exp_name), +__get_str (name), + __entry->size, + __entry->ino, + __entry->f_refcnt) +); + +TRACE_EVENT (dma_buf_mmap, + + TP_PROTO(struct dma_buf *dmabuf), + +TP_ARGS (dmabuf), + +TP_STRUCT__entry ( + __string(exp_name, dmabuf->exp_name) + __string(name, dmabuf->name) + __field(size_t, size) + __field(ino_t, ino) +__field (long, f_refcnt) + ), + +TP_fast_assign ( + __assign_str(exp_name); + spin_lock(&dmabuf->name_lock); + __assign_str(name); + spin_unlock(&dmabuf->name_lock); + __entry->size = dmabuf->size; + __entry->ino = dmabuf->file->f_inode->i_ino; + __entry->f_refcnt = file_count(dmabuf->file); + ), + +TP_printk ("exp_name=%s name=%s size=%zu ino=%lu f_refcnt=%ld" , +__get_str (exp_name), +__get_str (name), + __entry->size, + __entry->ino, + __entry->f_refcnt) +); + +TRACE_EVENT (dma_buf_attach, + + TP_PROTO(struct dma_buf *dmabuf, struct device *dev), + +TP_ARGS (dmabuf, dev), + +TP_STRUCT__entry ( + __string(dname, dev_name(dev)) + __string(exp_name, dmabuf->exp_name) + __string(name, dmabuf->name) + __field(size_t, size) + __field(ino_t, ino) +__field (long, f_refcnt) + ), + +TP_fast_assign ( + __assign_str(dname); + __assign_str(exp_name); + spin_lock(&dmabuf->name_lock); + __assign_str(name); + spin_unlock(&dmabuf->name_lock); + __entry->size = dmabuf->size; + __entry->ino = dmabuf->file->f_inode->i_ino; + __entry->f_refcnt = file_count(dmabuf->file); + ), + +TP_printk ("dev_name=%s exp_name=%s name=%s size=%zu ino=%lu f_refcnt=%ld" , +__get_str (dname), +__get_str (exp_name), +__get_str (name), + __entry->size, + __entry->ino, + __entry->f_refcnt) +); + +TRACE_EVENT (dma_buf_detach, + + TP_PROTO(struct dma_buf *dmabuf), + +TP_ARGS (dmabuf), + +TP_STRUCT__entry ( + __string(exp_name, dmabuf->exp_name) + __string(name, dmabuf->name) + __field(size_t, size) + __field(ino_t, ino) +__field (long, f_refcnt) + ), + +TP_fast_assign ( + __assign_str(exp_name); + spin_lock(&dmabuf->name_lock); + __assign_str(name); + spin_unlock(&dmabuf->name_lock); + __entry->size = dmabuf->size; + __entry->ino = dmabuf->file->f_inode->i_ino; + __entry->f_refcnt = file_count(dmabuf->file); + ), + +TP_printk ("exp_name=%s name=%s size=%zu ino=%lu f_refcnt=%ld" , +__get_str (exp_name), +__get_str (name), + __entry->size, + __entry->ino, + __entry->f_refcnt) +); + +TRACE_EVENT (dma_buf_get, + + TP_PROTO(int fd, struct file *file), + +TP_ARGS (fd, file), + +TP_STRUCT__entry ( + __string(exp_name, ((struct dma_buf *)file->private_data)->exp_name) + __string(name, ((struct dma_buf *)file->private_data)->name) + __field(size_t, size) + __field(ino_t, ino) + __field(int, fd) +__field (long, f_refcnt) + ), + +TP_fast_assign ( + struct dma_buf *dmabuf = (struct dma_buf *)file->private_data; + + __assign_str(exp_name); + spin_lock(&dmabuf->name_lock); + __assign_str(name); + spin_unlock(&dmabuf->name_lock); + __entry->size = dmabuf->size; + __entry->ino = dmabuf->file->f_inode->i_ino; + __entry->fd = fd; + __entry->f_refcnt = file_count(file); + ), + +TP_printk ("exp_name=%s name=%s size=%zu ino=%lu fd=%d f_refcnt=%ld" , +__get_str (exp_name), +__get_str (name), + __entry->size, + __entry->ino, + __entry->fd, + __entry->f_refcnt) +); + +TRACE_EVENT (dma_buf_put, + + TP_PROTO(struct dma_buf *dmabuf), + +TP_ARGS (dmabuf), + +TP_STRUCT__entry ( + __string(exp_name, dmabuf->exp_name) + __string(name, dmabuf->name) + __field(size_t, size) + __field(ino_t, ino) +__field (long, f_refcnt) + ), + +TP_fast_assign ( + __assign_str(exp_name); + spin_lock(&dmabuf->name_lock); + __assign_str(name); + spin_unlock(&dmabuf->name_lock); + __entry->size = dmabuf->size; + __entry->ino = dmabuf->file->f_inode->i_ino; + __entry->f_refcnt = file_count(dmabuf->file); + ), + +TP_printk ("exp_name=%s name=%s size=%zu ino=%lu f_refcnt=%ld" , +__get_str (exp_name), +__get_str (name), + __entry->size, + __entry->ino, + __entry->f_refcnt) +); + +#endif /* _TRACE_DMA_BUF_H */ + +/* This part must be outside protection */ +#include <trace/define_trace.h>
ok, thanks.
________________________________
发件人: Steven Rostedt <[email protected]>
发送时间: 2025年11月26日 9:39:24
收件人: Xiang Gao
抄送: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; 高翔 主题: [External Mail]Re: [PATCH v2] dma-buf: add some tracepoints to debug.
[外部邮件] 此邮件来源于小米公司外部,请谨慎处理。若对邮件安全性存疑,请将邮件转发给[email protected]进行反馈
Quoted 21 lines · On Wed, 26 Nov 2025 00:29:49 +0800 Xiang Gao <[email protected]> wrote:
+++
b/include/trace/events/dma_buf.hinclude/trace/events/dma_buf.h new file +19
-0@@ -0,0 +1,281 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#undef TRACE_SYSTEM +#define TRACE_SYSTEM dma_buf + +#if !defined(_TRACE_DMA_BUF_H) || defined(TRACE_HEADER_MULTI_READ ) +#define _TRACE_DMA_BUF_H + +#include <linux/dma-buf.h> +#include <linux/tracepoint.h> + +TRACE_EVENT(dma_buf_export, + + TP_PROTO(struct dma_buf *dmabuf), + + TP_ARGS(dmabuf), + + TP_STRUCT__entry( + __string(exp_name, dmabuf->exp_name) + __string(name, dmabuf->name)
include/trace/events/dma_buf.h line 29
Quoted 10 lines
include/trace/events/dma_buf.h new file +10
-0+ __field(size_t, size) + __field(ino_t, ino) +__field (long, f_refcnt) + ), + +TP_fast_assign ( + __assign_str(exp_name); +spin_lock (&dmabuf->name_lock); +__assign_str (name); +spin_unlock (&dmabuf->name_lock);
The above isn't doing what you think it's doing. The name is assigned before this by the above __string(name, dmabuf->name).
You really shouldn't be taking any locks in a tracepoint. A tracepoint is a callback, that isn't called most of the time. You could be hiding very hard to find deadlocks by taking a lock in a tracepoint callback.
You need to take the lock around the tracepoint call itself where it is called in the code. Not in the TRACE_EVENT.
You may need to have something like:
@@ -220,6 +223,8 @@ static int dma_buf_mmap_internal(struct file *file, struct vm_area_struct *vma)
dmabuf->size >> PAGE_SHIFT)
return -EINVAL;+ if (trace_dma_buf_mmap_internal_enabled()) {
+ guard(spinlock)(&dmabuf->namelock);
+ trace_dma_buf_mmap_internal(dmabuf);
+ }
+
return dmabuf->ops->mmap(dmabuf, vma);
}
The "trace_dma_buf_mmap_internal_enabled()" is a static branch, where it is either a nop or a jump to the tracing code. It's not a normal conditional branch. It acts the same as tracepoints themselves do.
include/trace/events/dma_buf.h line 41
Quoted 12 lines
include/trace/events/dma_buf.h new file +12
-0+ __entry->size = dmabuf->size; + __entry->ino = dmabuf->file->f_inode->i_ino; + __entry->f_refcnt =file_count (dmabuf->file); + ), + +TP_printk ("exp_name=%s name=%s size=%zu ino=%lu f_refcnt=%ld" , +__get_str (exp_name), +__get_str (name), + __entry->size, + __entry->ino, + __entry->f_refcnt) +);
Below seems to be a lot of very similar TRACE_EVENT()s. A TRACE_EVENT() is literally defined as:
#define TRACE_EVENT(name, proto, args, tstruct, assign, print) \
DECLARE_EVENT_CLASS(name, \
PARAMS(proto), \
PARAMS(args), \
PARAMS(tstruct), \
PARAMS(assign), \
PARAMS(print)); \
DEFINE_EVENT(name, name, PARAMS(proto), PARAMS(args));That is, it is both a DECLARE_EVENT_CLASS() and a DEFINE_EVENT(). You can make one DECLARE_EVENT_CLASS() and use many DEFINE_EVENT()s with it.
Each DECLARE_EVENT_CLASS() takes up around 4 to 5 kilobytes of memory. Each DEFINE_EVENT() takes around 300 bytes to 1K of memory. The more DEFINE_EVENT()s you use with a single DECLARE_EVENT_CLASS(), the more memory you save. Please try to do that.
-- Steve
Quoted 240 lines
include/trace/events/dma_buf.h new file +240
-0+ +TRACE_EVENT (dma_buf_fd, + + TP_PROTO(struct dma_buf *dmabuf, int fd), + +TP_ARGS (dmabuf, fd), + +TP_STRUCT__entry ( + __string(exp_name, dmabuf->exp_name) + __string(name, dmabuf->name) + __field(size_t, size) + __field(ino_t, ino) + __field(int, fd) +__field (long, f_refcnt) + ), + +TP_fast_assign ( + __assign_str(exp_name); + spin_lock(&dmabuf->name_lock); + __assign_str(name); + spin_unlock(&dmabuf->name_lock); + __entry->size = dmabuf->size; + __entry->ino = dmabuf->file->f_inode->i_ino; + __entry->fd = fd; + __entry->f_refcnt = file_count(dmabuf->file); + ), + +TP_printk ("exp_name=%s name=%s size=%zu ino=%lu fd=%d f_refcnt=%ld" , +__get_str (exp_name), +__get_str (name), + __entry->size, + __entry->ino, + __entry->fd, + __entry->f_refcnt) +); + +TRACE_EVENT (dma_buf_mmap_internal, + + TP_PROTO(struct dma_buf *dmabuf), + +TP_ARGS (dmabuf), + +TP_STRUCT__entry ( + __string(exp_name, dmabuf->exp_name) + __string(name, dmabuf->name) + __field(size_t, size) + __field(ino_t, ino) +__field (long, f_refcnt) + ), + +TP_fast_assign ( + __assign_str(exp_name); + spin_lock(&dmabuf->name_lock); + __assign_str(name); + spin_unlock(&dmabuf->name_lock); + __entry->size = dmabuf->size; + __entry->ino = dmabuf->file->f_inode->i_ino; + __entry->f_refcnt = file_count(dmabuf->file); + ), + +TP_printk ("exp_name=%s name=%s size=%zu ino=%lu f_refcnt=%ld" , +__get_str (exp_name), +__get_str (name), + __entry->size, + __entry->ino, + __entry->f_refcnt) +); + +TRACE_EVENT (dma_buf_mmap, + + TP_PROTO(struct dma_buf *dmabuf), + +TP_ARGS (dmabuf), + +TP_STRUCT__entry ( + __string(exp_name, dmabuf->exp_name) + __string(name, dmabuf->name) + __field(size_t, size) + __field(ino_t, ino) +__field (long, f_refcnt) + ), + +TP_fast_assign ( + __assign_str(exp_name); + spin_lock(&dmabuf->name_lock); + __assign_str(name); + spin_unlock(&dmabuf->name_lock); + __entry->size = dmabuf->size; + __entry->ino = dmabuf->file->f_inode->i_ino; + __entry->f_refcnt = file_count(dmabuf->file); + ), + +TP_printk ("exp_name=%s name=%s size=%zu ino=%lu f_refcnt=%ld" , +__get_str (exp_name), +__get_str (name), + __entry->size, + __entry->ino, + __entry->f_refcnt) +); + +TRACE_EVENT (dma_buf_attach, + + TP_PROTO(struct dma_buf *dmabuf, struct device *dev), + +TP_ARGS (dmabuf, dev), + +TP_STRUCT__entry ( + __string(dname, dev_name(dev)) + __string(exp_name, dmabuf->exp_name) + __string(name, dmabuf->name) + __field(size_t, size) + __field(ino_t, ino) +__field (long, f_refcnt) + ), + +TP_fast_assign ( + __assign_str(dname); + __assign_str(exp_name); + spin_lock(&dmabuf->name_lock); + __assign_str(name); + spin_unlock(&dmabuf->name_lock); + __entry->size = dmabuf->size; + __entry->ino = dmabuf->file->f_inode->i_ino; + __entry->f_refcnt = file_count(dmabuf->file); + ), + +TP_printk ("dev_name=%s exp_name=%s name=%s size=%zu ino=%lu f_refcnt=%ld" , +__get_str (dname), +__get_str (exp_name), +__get_str (name), + __entry->size, + __entry->ino, + __entry->f_refcnt) +); + +TRACE_EVENT (dma_buf_detach, + + TP_PROTO(struct dma_buf *dmabuf), + +TP_ARGS (dmabuf), + +TP_STRUCT__entry ( + __string(exp_name, dmabuf->exp_name) + __string(name, dmabuf->name) + __field(size_t, size) + __field(ino_t, ino) +__field (long, f_refcnt) + ), + +TP_fast_assign ( + __assign_str(exp_name); + spin_lock(&dmabuf->name_lock); + __assign_str(name); + spin_unlock(&dmabuf->name_lock); + __entry->size = dmabuf->size; + __entry->ino = dmabuf->file->f_inode->i_ino; + __entry->f_refcnt = file_count(dmabuf->file); + ), + +TP_printk ("exp_name=%s name=%s size=%zu ino=%lu f_refcnt=%ld" , +__get_str (exp_name), +__get_str (name), + __entry->size, + __entry->ino, + __entry->f_refcnt) +); + +TRACE_EVENT (dma_buf_get, + + TP_PROTO(int fd, struct file *file), + +TP_ARGS (fd, file), + +TP_STRUCT__entry ( + __string(exp_name, ((struct dma_buf *)file->private_data)->exp_name) + __string(name, ((struct dma_buf *)file->private_data)->name) + __field(size_t, size) + __field(ino_t, ino) + __field(int, fd) +__field (long, f_refcnt) + ), + +TP_fast_assign ( + struct dma_buf *dmabuf = (struct dma_buf *)file->private_data; + + __assign_str(exp_name); + spin_lock(&dmabuf->name_lock); + __assign_str(name); + spin_unlock(&dmabuf->name_lock); + __entry->size = dmabuf->size; + __entry->ino = dmabuf->file->f_inode->i_ino; + __entry->fd = fd; + __entry->f_refcnt = file_count(file); + ), + +TP_printk ("exp_name=%s name=%s size=%zu ino=%lu fd=%d f_refcnt=%ld" , +__get_str (exp_name), +__get_str (name), + __entry->size, + __entry->ino, + __entry->fd, + __entry->f_refcnt) +); + +TRACE_EVENT (dma_buf_put, + + TP_PROTO(struct dma_buf *dmabuf), + +TP_ARGS (dmabuf), + +TP_STRUCT__entry ( + __string(exp_name, dmabuf->exp_name) + __string(name, dmabuf->name) + __field(size_t, size) + __field(ino_t, ino) +__field (long, f_refcnt) + ), + +TP_fast_assign ( + __assign_str(exp_name); + spin_lock(&dmabuf->name_lock); + __assign_str(name); + spin_unlock(&dmabuf->name_lock); + __entry->size = dmabuf->size; + __entry->ino = dmabuf->file->f_inode->i_ino; + __entry->f_refcnt = file_count(dmabuf->file); + ), + +TP_printk ("exp_name=%s name=%s size=%zu ino=%lu f_refcnt=%ld" , +__get_str (exp_name), +__get_str (name), + __entry->size, + __entry->ino, + __entry->f_refcnt) +); + +#endif /* _TRACE_DMA_BUF_H */ + +/* This part must be outside protection */ +#include <trace/define_trace.h>