From: 高翔 <gaoxiang17@xiaomi.com>
To: "Christian König" <christian.koenig@amd.com>,
"Barry Song" <21cnbao@gmail.com>,
"Xiang Gao" <gxxa03070307@gmail.com>
Cc: "sumit.semwal@linaro.org" <sumit.semwal@linaro.org>,
"rostedt@goodmis.org" <rostedt@goodmis.org>,
"mhiramat@kernel.org" <mhiramat@kernel.org>,
"linux-media@vger.kernel.org" <linux-media@vger.kernel.org>,
"dri-devel@lists.freedesktop.org"
<dri-devel@lists.freedesktop.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"mathieu.desnoyers@efficios.com" <mathieu.desnoyers@efficios.com>,
"dhowells@redhat.com" <dhowells@redhat.com>,
"kuba@kernel.org" <kuba@kernel.org>,
"brauner@kernel.org" <brauner@kernel.org>,
"akpm@linux-foundation.org" <akpm@linux-foundation.org>,
"linux-trace-kernel@vger.kernel.org"
<linux-trace-kernel@vger.kernel.org>
Subject: 答复: [External Mail]Re: [PATCH v4] dma-buf: add some tracepoints to debug.
Date: Fri, 28 Nov 2025 13:14:14 +0000 [thread overview]
Message-ID: <1b9645fdaf324b2e8e9370e548883d49@xiaomi.com> (raw)
In-Reply-To: <faf6a25c-03a7-41d2-8dd2-ba74ee2e02a9@amd.com>
[-- Attachment #1: Type: text/plain, Size: 5527 bytes --]
> Thinking more about it I was wondering if we really need the userspace assigned name in the tracepoint in the first place.
> The ino should be sufficient to uniquely identify each dma-buf, tracing the name should only be printed if it's changing or otherwise we spam the tracelog quite a bit with it.
Many threads use dmabuf "qcom,system". If there is a userspace name, we can immediately find the dmabuf I'm using. It might indeed not be necessary in other scenarios.
> BTW We don't have any identification for an attachment, so when multiple devices attach to the same DMA-buf the trace would be quite meaningless. We should probably fix that.
This requires some thought.
________________________________
发件人: Christian König <christian.koenig@amd.com>
发送时间: 2025年11月28日 17:39:31
收件人: Barry Song; Xiang Gao
抄送: sumit.semwal@linaro.org; rostedt@goodmis.org; mhiramat@kernel.org; linux-media@vger.kernel.org; dri-devel@lists.freedesktop.org; linux-kernel@vger.kernel.org; mathieu.desnoyers@efficios.com; dhowells@redhat.com; kuba@kernel.org; brauner@kernel.org; akpm@linux-foundation.org; linux-trace-kernel@vger.kernel.org; 高翔
主题: [External Mail]Re: [PATCH v4] dma-buf: add some tracepoints to debug.
[外部邮件] 此邮件来源于小米公司外部,请谨慎处理。若对邮件安全性存疑,请将邮件转发给misec@xiaomi.com进行反馈
On 11/28/25 10:31, Barry Song wrote:
> On Fri, Nov 28, 2025 at 4:53 PM Xiang Gao <gxxa03070307@gmail.com> wrote:
>>
>> From: gaoxiang17 <gaoxiang17@xiaomi.com>
>>
>> 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.
>
> might be:
>
> 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:3031_4-18348 [005] ...1. 545.568275: dma_buf_export: exp_name=qcom,system name=(null) size=217088 ino=2750
>> binder:3031_4-18348 [005] ...1. 545.568284: dma_buf_fd: exp_name=qcom,system name=(null) size=217088 ino=2750 fd=8
>> binder:3031_4-18348 [005] ...1. 545.568399: dma_buf_mmap_internal: exp_name=qcom,system name=qcom,system size=28672 ino=2751
>> kworker/5:1-130 [005] ...1. 545.570193: dma_buf_put: exp_name=qcom,system name=ab size=28672 ino=2751
>> RenderThread-18891 [005] ...1. 545.602994: dma_buf_get: exp_name=qcom,system name=ab size=217088 ino=2750 fd=1087
>> RenderThread-9409 [000] .n.1. 545.745004: dma_buf_dynamic_attach: exp_name=qcom,system name=ab size=217088 ino=2750 is_dynamic=0 dev_name=kgsl-3d0
>> RenderThread-9409 [005] ...1. 545.747802: dma_buf_detach: exp_name=qcom,system name=bq size=12771328 ino=2764 is_dynamic=0 dev_name=kgsl-3d0
>>
>> Signed-off-by: Xiang Gao <gaoxiang17@xiaomi.com>
>> ---
>> drivers/dma-buf/dma-buf.c | 48 +++++++++-
>> include/trace/events/dma_buf.h | 160 +++++++++++++++++++++++++++++++++
>> 2 files changed, 207 insertions(+), 1 deletion(-)
>> create mode 100644 include/trace/events/dma_buf.h
>>
>> diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c
>> index 2bcf9ceca997..6e04e12f149e 100644
>> --- a/drivers/dma-buf/dma-buf.c
>> +++ b/drivers/dma-buf/dma-buf.c
>> @@ -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,11 @@ 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->name_lock);
>> + trace_dma_buf_mmap_internal(dmabuf);
>> + }
>> +
>> return dmabuf->ops->mmap(dmabuf, vma);
>> }
>>
>> @@ -745,6 +753,11 @@ struct dma_buf *dma_buf_export(const struct dma_buf_export_info *exp_info)
>>
>> __dma_buf_list_add(dmabuf);
>>
>> + if (trace_dma_buf_export_enabled()) {
>> + guard(spinlock)(&dmabuf->name_lock);
>> + trace_dma_buf_export(dmabuf);
>> + }
>> +
>
> perhaps a macro similar to the one below
>
> #define DMA_BUF_TRACE(FUNC, ...) \
> do { \
> if (FUNC##_enabled()) { \
> guard(spinlock)(&dmabuf->name_lock); \
> FUNC(__VA_ARGS__); \
> } \
> } while (0)
>
>
> This would help us avoid duplicating a lot of code.
>
> could be:
> DMA_BUF_TRACE(trace_dma_buf_put, dmabuf);
> DMA_BUF_TRACE(trace_dma_buf_attach, dmabuf, dev);
>
> ?
Thinking more about it I was wondering if we really need the userspace assigned name in the tracepoint in the first place.
The ino should be sufficient to uniquely identify each dma-buf, tracing the name should only be printed if it's changing or otherwise we spam the tracelog quite a bit with it.
BTW We don't have any identification for an attachment, so when multiple devices attach to the same DMA-buf the trace would be quite meaningless. We should probably fix that.
Regards,
Christian.
[-- Attachment #2: Type: text/html, Size: 10670 bytes --]
next prev parent reply other threads:[~2025-11-29 13:45 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-28 8:52 [PATCH v4] dma-buf: add some tracepoints to debug Xiang Gao
2025-11-28 9:31 ` Barry Song
2025-11-28 9:39 ` Christian König
2025-11-28 13:14 ` 高翔 [this message]
2025-12-01 1:44 ` 答复: [External Mail]Re: " 高翔
2025-12-01 8:24 ` Christian König
2025-11-28 13:00 ` 高翔
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1b9645fdaf324b2e8e9370e548883d49@xiaomi.com \
--to=gaoxiang17@xiaomi.com \
--cc=21cnbao@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=brauner@kernel.org \
--cc=christian.koenig@amd.com \
--cc=dhowells@redhat.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=gxxa03070307@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=mhiramat@kernel.org \
--cc=rostedt@goodmis.org \
--cc=sumit.semwal@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.