* [PATCH RESEND] sched: Add core cookie update tracepoint
From: Fernand Sieber @ 2025-11-28 9:32 UTC (permalink / raw)
To: linux-kernel, peterz, mingo, vincent.guittot
Cc: linux-trace-kernel, jschoenh, dwmw, kprateek.nayak, vineethr
ftrace based analysis can be used to qualify correct behavior of cookie
based applications. Security posture can be verified by tracing the
amount of time that tasks with different cookies collocate on hyperthread
siblings and asserting that it is kept to a minimum. Performance posture
can be measured by minimizing force idle (when an hyperthread is kept
idle because it doesn't have a runnable task matching the cookie of its
sibling). It is necessary for the application doing such an analysis to
know the cookie associated with each task at any point in time.
While the task to cookie mapping is driven by userspace and thus can
alternatively be supplied through a custom side channel to an application
analysing a trace, it is more convenient and accurate if the mapping is
already part of the trace. Given that these events are infrequent the
induced overhead is negligible.
Signed-off-by: Fernand Sieber <sieberf@amazon.com>
Link: https://lore.kernel.org/r/20250128113410.263994-1-sieberf@amazon.com
---
include/trace/events/sched.h | 30 ++++++++++++++++++++++++++++++
kernel/sched/core_sched.c | 1 +
2 files changed, 31 insertions(+)
diff --git a/include/trace/events/sched.h b/include/trace/events/sched.h
index 7b2645b50e78..e3298eb0702c 100644
--- a/include/trace/events/sched.h
+++ b/include/trace/events/sched.h
@@ -826,6 +826,36 @@ TRACE_EVENT(sched_wake_idle_without_ipi,
TP_printk("cpu=%d", __entry->cpu)
);
+#ifdef CONFIG_SCHED_CORE
+/*
+ * Tracepoint for assigning cookies.
+ */
+TRACE_EVENT(sched_setcookie,
+
+ TP_PROTO(struct task_struct *tsk, unsigned long cookie),
+
+ TP_ARGS(tsk, cookie),
+
+ TP_STRUCT__entry(
+ __array(char, comm, TASK_COMM_LEN)
+ __field(pid_t, pid)
+ __field(unsigned long, oldcookie)
+ __field(unsigned long, newcookie)
+ ),
+
+ TP_fast_assign(
+ memcpy(__entry->comm, tsk->comm, TASK_COMM_LEN);
+ __entry->pid = tsk->pid;
+ __entry->oldcookie = tsk->core_cookie;
+ __entry->newcookie = cookie;
+ ),
+
+ TP_printk("comm=%s pid=%d oldcookie=%lx newcookie=%lx",
+ __entry->comm, __entry->pid,
+ __entry->oldcookie, __entry->newcookie)
+);
+#endif
+
/*
* Following tracepoints are not exported in tracefs and provide hooking
* mechanisms only for testing and debugging purposes.
diff --git a/kernel/sched/core_sched.c b/kernel/sched/core_sched.c
index 9ede71ecba7f..26eb23331fea 100644
--- a/kernel/sched/core_sched.c
+++ b/kernel/sched/core_sched.c
@@ -73,6 +73,7 @@ static unsigned long sched_core_update_cookie(struct task_struct *p,
sched_core_dequeue(rq, p, DEQUEUE_SAVE);
old_cookie = p->core_cookie;
+ trace_sched_setcookie(p, cookie);
p->core_cookie = cookie;
/*
--
2.43.0
Amazon Development Centre (South Africa) (Proprietary) Limited
29 Gogosoa Street, Observatory, Cape Town, Western Cape, 7925, South Africa
Registration Number: 2004 / 034463 / 07
^ permalink raw reply related
* Re: [PATCH v4] dma-buf: add some tracepoints to debug.
From: Barry Song @ 2025-11-28 9:31 UTC (permalink / raw)
To: Xiang Gao
Cc: sumit.semwal, christian.koenig, rostedt, mhiramat, linux-media,
dri-devel, linux-kernel, mathieu.desnoyers, dhowells, kuba,
brauner, akpm, linux-trace-kernel, gaoxiang17
In-Reply-To: <20251128085215.550100-1-gxxa03070307@gmail.com>
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);
?
^ permalink raw reply
* [PATCH v4] dma-buf: add some tracepoints to debug.
From: Xiang Gao @ 2025-11-28 8:52 UTC (permalink / raw)
To: sumit.semwal, christian.koenig, rostedt, mhiramat
Cc: linux-media, dri-devel, linux-kernel, mathieu.desnoyers, dhowells,
kuba, brauner, akpm, linux-trace-kernel, gaoxiang17
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.
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);
+ }
+
return dmabuf;
err_dmabuf:
@@ -779,6 +792,11 @@ int dma_buf_fd(struct dma_buf *dmabuf, int flags)
fd_install(fd, dmabuf->file);
+ if (trace_dma_buf_fd_enabled()) {
+ guard(spinlock)(&dmabuf->name_lock);
+ trace_dma_buf_fd(dmabuf, fd);
+ }
+
return fd;
}
EXPORT_SYMBOL_NS_GPL(dma_buf_fd, "DMA_BUF");
@@ -794,6 +812,7 @@ EXPORT_SYMBOL_NS_GPL(dma_buf_fd, "DMA_BUF");
struct dma_buf *dma_buf_get(int fd)
{
struct file *file;
+ struct dma_buf *dmabuf;
file = fget(fd);
@@ -805,7 +824,14 @@ struct dma_buf *dma_buf_get(int fd)
return ERR_PTR(-EINVAL);
}
- return file->private_data;
+ dmabuf = file->private_data;
+
+ if (trace_dma_buf_get_enabled()) {
+ guard(spinlock)(&dmabuf->name_lock);
+ trace_dma_buf_get(dmabuf, fd);
+ }
+
+ return dmabuf;
}
EXPORT_SYMBOL_NS_GPL(dma_buf_get, "DMA_BUF");
@@ -825,6 +851,11 @@ void dma_buf_put(struct dma_buf *dmabuf)
return;
fput(dmabuf->file);
+
+ if (trace_dma_buf_put_enabled()) {
+ guard(spinlock)(&dmabuf->name_lock);
+ trace_dma_buf_put(dmabuf);
+ }
}
EXPORT_SYMBOL_NS_GPL(dma_buf_put, "DMA_BUF");
@@ -979,6 +1010,11 @@ dma_buf_dynamic_attach(struct dma_buf *dmabuf, struct device *dev,
list_add(&attach->node, &dmabuf->attachments);
dma_resv_unlock(dmabuf->resv);
+ if (trace_dma_buf_dynamic_attach_enabled()) {
+ guard(spinlock)(&dmabuf->name_lock);
+ trace_dma_buf_dynamic_attach(dmabuf, dma_buf_attachment_is_dynamic(attach), dev);
+ }
+
return attach;
err_attach:
@@ -1023,6 +1059,11 @@ void dma_buf_detach(struct dma_buf *dmabuf, struct dma_buf_attachment *attach)
if (dmabuf->ops->detach)
dmabuf->ops->detach(dmabuf, attach);
+ if (trace_dma_buf_detach_enabled()) {
+ guard(spinlock)(&dmabuf->name_lock);
+ trace_dma_buf_detach(dmabuf, dma_buf_attachment_is_dynamic(attach), attach->dev);
+ }
+
kfree(attach);
}
EXPORT_SYMBOL_NS_GPL(dma_buf_detach, "DMA_BUF");
@@ -1488,6 +1529,11 @@ int dma_buf_mmap(struct dma_buf *dmabuf, struct vm_area_struct *vma,
vma_set_file(vma, dmabuf->file);
vma->vm_pgoff = pgoff;
+ if (trace_dma_buf_mmap_enabled()) {
+ guard(spinlock)(&dmabuf->name_lock);
+ trace_dma_buf_mmap(dmabuf);
+ }
+
return dmabuf->ops->mmap(dmabuf, vma);
}
EXPORT_SYMBOL_NS_GPL(dma_buf_mmap, "DMA_BUF");
diff --git a/include/trace/events/dma_buf.h b/include/trace/events/dma_buf.h
new file mode 100644
index 000000000000..f4b6ba5241fa
--- /dev/null
+++ b/include/trace/events/dma_buf.h
@@ -0,0 +1,160 @@
+/* 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>
+
+DECLARE_EVENT_CLASS(dma_buf,
+
+ 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)
+ ),
+
+ TP_fast_assign(
+ __assign_str(exp_name);
+ __assign_str(name);
+ __entry->size = dmabuf->size;
+ __entry->ino = dmabuf->file->f_inode->i_ino;
+ ),
+
+ TP_printk("exp_name=%s name=%s size=%zu ino=%lu",
+ __get_str(exp_name),
+ __get_str(name),
+ __entry->size,
+ __entry->ino)
+);
+
+DECLARE_EVENT_CLASS(dma_buf_attach_dev,
+
+ TP_PROTO(struct dma_buf *dmabuf, bool is_dynamic, struct device *dev),
+
+ TP_ARGS(dmabuf, is_dynamic, dev),
+
+ TP_STRUCT__entry(
+ __string(dev_name, dev_name(dev))
+ __string(exp_name, dmabuf->exp_name)
+ __string(name, dmabuf->name)
+ __field(size_t, size)
+ __field(ino_t, ino)
+ __field(bool, is_dynamic)
+ ),
+
+ TP_fast_assign(
+ __assign_str(dev_name);
+ __assign_str(exp_name);
+ __assign_str(name);
+ __entry->size = dmabuf->size;
+ __entry->ino = dmabuf->file->f_inode->i_ino;
+ __entry->is_dynamic = is_dynamic;
+ ),
+
+ TP_printk("exp_name=%s name=%s size=%zu ino=%lu is_dynamic=%d dev_name=%s",
+ __get_str(exp_name),
+ __get_str(name),
+ __entry->size,
+ __entry->ino,
+ __entry->is_dynamic,
+ __get_str(dev_name))
+);
+
+DECLARE_EVENT_CLASS(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)
+ ),
+
+ TP_fast_assign(
+ __assign_str(exp_name);
+ __assign_str(name);
+ __entry->size = dmabuf->size;
+ __entry->ino = dmabuf->file->f_inode->i_ino;
+ __entry->fd = fd;
+ ),
+
+ TP_printk("exp_name=%s name=%s size=%zu ino=%lu fd=%d",
+ __get_str(exp_name),
+ __get_str(name),
+ __entry->size,
+ __entry->ino,
+ __entry->fd)
+);
+
+DEFINE_EVENT(dma_buf, dma_buf_export,
+
+ TP_PROTO(struct dma_buf *dmabuf),
+
+ TP_ARGS(dmabuf)
+);
+
+DEFINE_EVENT(dma_buf, dma_buf_mmap_internal,
+
+ TP_PROTO(struct dma_buf *dmabuf),
+
+ TP_ARGS(dmabuf)
+);
+
+DEFINE_EVENT(dma_buf, dma_buf_mmap,
+
+ TP_PROTO(struct dma_buf *dmabuf),
+
+ TP_ARGS(dmabuf)
+);
+
+DEFINE_EVENT(dma_buf, dma_buf_put,
+
+ TP_PROTO(struct dma_buf *dmabuf),
+
+ TP_ARGS(dmabuf)
+);
+
+DEFINE_EVENT(dma_buf_attach_dev, dma_buf_dynamic_attach,
+
+ TP_PROTO(struct dma_buf *dmabuf, bool is_dynamic, struct device *dev),
+
+ TP_ARGS(dmabuf, is_dynamic, dev)
+);
+
+DEFINE_EVENT(dma_buf_attach_dev, dma_buf_detach,
+
+ TP_PROTO(struct dma_buf *dmabuf, bool is_dynamic, struct device *dev),
+
+ TP_ARGS(dmabuf, is_dynamic, dev)
+);
+
+DEFINE_EVENT(dma_buf_fd, dma_buf_fd,
+
+ TP_PROTO(struct dma_buf *dmabuf, int fd),
+
+ TP_ARGS(dmabuf, fd)
+);
+
+DEFINE_EVENT(dma_buf_fd, dma_buf_get,
+
+ TP_PROTO(struct dma_buf *dmabuf, int fd),
+
+ TP_ARGS(dmabuf, fd)
+);
+
+#endif /* _TRACE_DMA_BUF_H */
+
+/* This part must be outside protection */
+#include <trace/define_trace.h>
--
2.34.1
^ permalink raw reply related
* [PATCH] MIPS: ftrace: Fix memory corruption when kernel is located beyond 32 bits
From: Gregory CLEMENT @ 2025-11-28 8:30 UTC (permalink / raw)
To: Steven Rostedt, Masami Hiramatsu, Mark Rutland,
Thomas Bogendoerfer
Cc: Vladimir Kondratiev, Théo Lebrun, Benoît Monin,
Thomas Petazzoni, linux-kernel, linux-trace-kernel, linux-mips,
Gregory CLEMENT
Since commit e424054000878 ("MIPS: Tracing: Reduce the overhead of
dynamic Function Tracer"), the macro UASM_i_LA_mostly has been used,
and this macro can generate more than 2 instructions. At the same
time, the code in ftrace assumes that no more than 2 instructions can
be generated, which is why it stores them in an int[2] array. However,
as previously noted, the macro UASM_i_LA_mostly (and now UASM_i_LA)
causes a buffer overflow when _mcount is beyond 32 bits. This leads to
corruption of the variables located in the __read_mostly section.
This corruption was observed because the variable
__cpu_primary_thread_mask was corrupted, causing a hang very early
during boot.
This fix prevents the corruption by avoiding the generation of
instructions if they could exceed 2 instructions in
length. Fortunately, insn_la_mcount is only used if the instrumented
code is located outside the kernel code section, so dynamic ftrace can
still be used, albeit in a more limited scope. This is still
preferable to corrupting memory and/or crashing the kernel.
Signed-off-by: Gregory CLEMENT <gregory.clement@bootlin.com>
---
To go further and remove the limitations of dynamic trace support, the
ftrace implementation for MIPS should be completely rewritten and
inspired by what was done for arm64. This approach was chosen by
Loongson: instead of trying to manage multiple instructions added on
the fly, the support relies on a breakpoint, which is more robust.
However, this effort is significant, so I’ll leave it to those who are
motivated to work on it. If needed, I can provide some guidance on the
topic.
---
arch/mips/kernel/ftrace.c | 25 +++++++++++++++++++++----
1 file changed, 21 insertions(+), 4 deletions(-)
diff --git a/arch/mips/kernel/ftrace.c b/arch/mips/kernel/ftrace.c
index f39e85fd58fa9..b15615b285690 100644
--- a/arch/mips/kernel/ftrace.c
+++ b/arch/mips/kernel/ftrace.c
@@ -54,10 +54,20 @@ static inline void ftrace_dyn_arch_init_insns(void)
u32 *buf;
unsigned int v1;
- /* la v1, _mcount */
- v1 = 3;
- buf = (u32 *)&insn_la_mcount[0];
- UASM_i_LA(&buf, v1, MCOUNT_ADDR);
+ /* If we are not in compat space, the number of generated
+ * instructions will exceed the maximum expected limit of 2.
+ * To prevent buffer overflow, we avoid generating them.
+ * insn_la_mcount will not be used later in ftrace_make_call.
+ */
+ if (uasm_in_compat_space_p(MCOUNT_ADDR)) {
+ /* la v1, _mcount */
+ v1 = 3;
+ buf = (u32 *)&insn_la_mcount[0];
+ UASM_i_LA(&buf, v1, MCOUNT_ADDR);
+ } else {
+ pr_warn("ftrace: mcount address beyond 32 bits is not supported (%lX)\n",
+ MCOUNT_ADDR);
+ }
/* jal (ftrace_caller + 8), jump over the first two instruction */
buf = (u32 *)&insn_jal_ftrace_caller;
@@ -189,6 +199,13 @@ int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr)
unsigned int new;
unsigned long ip = rec->ip;
+ /* When the code to patch does not belong to the kernel code
+ * space, we must use insn_la_mcount. However, if MCOUNT_ADDR
+ * is not in compat space, insn_la_mcount is not usable.
+ */
+ if (!core_kernel_text(ip) && !uasm_in_compat_space_p(MCOUNT_ADDR))
+ return -EFAULT;
+
new = core_kernel_text(ip) ? insn_jal_ftrace_caller : insn_la_mcount[0];
#ifdef CONFIG_64BIT
---
base-commit: 3a8660878839faadb4f1a6dd72c3179c1df56787
change-id: 20251104-fix_mips_ftrace-7aaab89e3f77
Best regards,
--
Grégory CLEMENT, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply related
* Re: [PATCH] overflow: Introduce struct_offset() to get offset of member
From: Linus Torvalds @ 2025-11-28 5:35 UTC (permalink / raw)
To: Steven Rostedt
Cc: Kees Cook, LKML, linux-hardening, Linux Trace Kernel,
Masami Hiramatsu, Mathieu Desnoyers, Gustavo A. R. Silva
In-Reply-To: <20251127222710.324357cf@robin>
On Thu, 27 Nov 2025 at 19:27, Steven Rostedt <rostedt@goodmis.org> wrote:
>
> On Thu, 27 Nov 2025 18:00:01 -0800
> Kees Cook <kees@kernel.org> wrote:
>
> > If you have an instance and not a pointer, just slap on a & :)
>
> :-p
>
> I guess that would work. Although it will kinda look a bit strange.
> At least to me.
It does look a tiny bit odd, and it's not always wonderful, but there
are advantages to conceptually passing in the pointer rather than the
actual instance.
The two main advantages are that
(a) a pointer is *usually* what you have. Not always, no, but it's
the common thing in the kernel. We have a lot fewer cases of 'struct
on stack' than we have 'pointer to struct somewhere'.
but even more so:
(b) unless the macro makes it very *very* obvious in the name that it
only looks at the *type* of the argument, dereferencing the pointer
can easily look absolutely horrendous.
We had an example of that (b) case recently [*] where the code looked like this:
typeof(VAR) *__obj_ptr = NULL;
....__can_set_flex_counter(__obj_ptr->FAM, __count) ...
and note that combination of "NULL pointer" and "dereference that pointer".
The code was *correct*, because that '__can_set_flex_counter()' macro
in that case only looked at the *type* of the first argument, so the
dereference didn't "really" happen as an actual access to any memory
behind the pointer, but it doesn't make it really look any better. We
really don't want to have those kinds of visual patterns, it just
makes people go "WHAA?!??".
Now, with proper naming, you can make that obvious. You can make it
really clear that "this is looking just at the type of that argument,
not the value of the expression it is given".
But honestly, I think that "really clear" comes close to just having
to have that "__typeof__()" pattern.
Can people learn that a name like "struct_offset()" always just takes
the type of the first argument, and get used to patterns like that?
Sure. Absolutely. But I'm not sure we really want people to learn that
pattern if there are alternatives.
So I do think that the "struct_size()" syntax - which takes the
*pointer* to the object and then does "sizeof(*(p))" internally - is
the better syntax. Not just because we *do* typically have the pointer
as the variable we are trying to get the size of, but exactly because
we do not want it to visually look like a dereference of a pointer
that may not have a valid value yet.
Put another way: yes, it's slightly conceptually odd to pass in the
pointer in order to actually get the size (or offset of a member, in
your case) of the actual *instance*, but I think "slightly
conceptually odd" is a small price to pay to not it look more regular.
And yes, I obviously do realize that 'sizeof()' and 'offsetof' and
'__alignof__' all take the actual type, not the pointer to the type.
But they are very special operations in C, and we should not make
other operations act like them unless they have some very clear and
obvious clue.
For example, we do have 'struct_size_t()' that takes the actual type,
not the pointer to the type. It _only_ takes an explicit type, and
cannot even take an instance of an object (although we could *make* it
take an instance by adding a '__typeof__()' into that macro). But at
least the '_t' part hopefully makes that obvious, and even if we did
make it take an instance, you'd never use it on the above kind of
pointer without a valid value, because then you'd use the non-_t()
version.
So that 'xyz_t()' version then gets used for things where you
explicitly state the type, and it all looks fairly obvious, eg:
len = struct_size_t(struct pid, numbers, level + 1);
doesn't get that "WHAA?!??!" kind of reaction.
[ And so I actually think it's good that it only takes an explicit
type - if you really have an instance, I think it's better to use just
"struct_size(&instance, ...)" even if we _could_ easily make syntax
like "struct_size_t(instance, ...)" work. ]
Linus
[*] https://lore.kernel.org/all/CAHk-=wiNnECns4B3qxRsCykkHwzovT+3wG738fUhq5E+3Lxxbg@mail.gmail.com/
^ permalink raw reply
* Re: [PATCH] overflow: Introduce struct_offset() to get offset of member
From: Steven Rostedt @ 2025-11-28 3:27 UTC (permalink / raw)
To: Kees Cook
Cc: LKML, linux-hardening, Linux Trace Kernel, Masami Hiramatsu,
Mathieu Desnoyers, Linus Torvalds, Gustavo A. R. Silva
In-Reply-To: <6219BF5A-0EC3-4111-A329-D35244C9714A@kernel.org>
On Thu, 27 Nov 2025 18:00:01 -0800
Kees Cook <kees@kernel.org> wrote:
> I'd rather it keep the same API style as struct_size() if it's going to share the naming style.
Fair enough. Then I won't change it.
>
> If you have an instance and not a pointer, just slap on a & :)
:-p
I guess that would work. Although it will kinda look a bit strange.
At least to me.
-- Steve
^ permalink raw reply
* [PATCH v2] f2fs: optimize trace_f2fs_write_checkpoint with enums
From: YH Lin @ 2025-11-28 3:23 UTC (permalink / raw)
To: yes
Cc: YH Lin, Jaegeuk Kim, Chao Yu, Steven Rostedt, Masami Hiramatsu,
Mathieu Desnoyers, linux-f2fs-devel, linux-kernel,
linux-trace-kernel
In-Reply-To: <no>
This patch optimizes the tracepoint by replacing these hardcoded strings
with a new enumeration f2fs_cp_phase.
1.Defines enum f2fs_cp_phase with values for each checkpoint phase.
2.Updates trace_f2fs_write_checkpoint to accept a u16 phase argument
instead of a string pointer.
3.Uses __print_symbolic in TP_printk to convert the enum values
back to their corresponding strings for human-readable trace output.
This change reduces the storage overhead for each trace event
by replacing a variable-length string with a 2-byte integer,
while maintaining the same readable output in ftrace.
Signed-off-by: YH Lin <yhli@google.com>
V2:
- Relocate enum f2fs_cp_phase from include/trace/events/f2fs.h to fs/f2fs/f2fs.h,
as requested by Chao Yu for better structure cleanup.
---
fs/f2fs/checkpoint.c | 6 +++---
fs/f2fs/f2fs.h | 6 ++++++
include/trace/events/f2fs.h | 19 ++++++++++++++-----
3 files changed, 23 insertions(+), 8 deletions(-)
diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c
index bbe07e3a6c75..b04f82fdd143 100644
--- a/fs/f2fs/checkpoint.c
+++ b/fs/f2fs/checkpoint.c
@@ -1673,7 +1673,7 @@ int f2fs_write_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)
goto out;
}
- trace_f2fs_write_checkpoint(sbi->sb, cpc->reason, "start block_ops");
+ trace_f2fs_write_checkpoint(sbi->sb, cpc->reason, CP_PHASE_START_BLOCK_OPS);
err = block_operations(sbi);
if (err)
@@ -1681,7 +1681,7 @@ int f2fs_write_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)
stat_cp_time(cpc, CP_TIME_OP_LOCK);
- trace_f2fs_write_checkpoint(sbi->sb, cpc->reason, "finish block_ops");
+ trace_f2fs_write_checkpoint(sbi->sb, cpc->reason, CP_PHASE_FINISH_BLOCK_OPS);
f2fs_flush_merged_writes(sbi);
@@ -1747,7 +1747,7 @@ int f2fs_write_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)
/* update CP_TIME to trigger checkpoint periodically */
f2fs_update_time(sbi, CP_TIME);
- trace_f2fs_write_checkpoint(sbi->sb, cpc->reason, "finish checkpoint");
+ trace_f2fs_write_checkpoint(sbi->sb, cpc->reason, CP_PHASE_FINISH_CHECKPOINT);
out:
if (cpc->reason != CP_RESIZE)
f2fs_up_write(&sbi->cp_global_sem);
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 6f509d88c596..a995103af735 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -313,6 +313,12 @@ struct cp_control {
struct cp_stats stats;
};
+enum f2fs_cp_phase {
+ CP_PHASE_START_BLOCK_OPS,
+ CP_PHASE_FINISH_BLOCK_OPS,
+ CP_PHASE_FINISH_CHECKPOINT,
+};
+
/*
* indicate meta/data type
*/
diff --git a/include/trace/events/f2fs.h b/include/trace/events/f2fs.h
index e00611ead024..df4017dcc701 100644
--- a/include/trace/events/f2fs.h
+++ b/include/trace/events/f2fs.h
@@ -50,6 +50,9 @@ TRACE_DEFINE_ENUM(CP_PAUSE);
TRACE_DEFINE_ENUM(CP_RESIZE);
TRACE_DEFINE_ENUM(EX_READ);
TRACE_DEFINE_ENUM(EX_BLOCK_AGE);
+TRACE_DEFINE_ENUM(CP_PHASE_START_BLOCK_OPS);
+TRACE_DEFINE_ENUM(CP_PHASE_FINISH_BLOCK_OPS);
+TRACE_DEFINE_ENUM(CP_PHASE_FINISH_CHECKPOINT);
#define show_block_type(type) \
__print_symbolic(type, \
@@ -175,6 +178,12 @@ TRACE_DEFINE_ENUM(EX_BLOCK_AGE);
#define S_ALL_PERM (S_ISUID | S_ISGID | S_ISVTX | \
S_IRWXU | S_IRWXG | S_IRWXO)
+#define show_cp_phase(phase) \
+ __print_symbolic(phase, \
+ { CP_PHASE_START_BLOCK_OPS, "start block_ops" }, \
+ { CP_PHASE_FINISH_BLOCK_OPS, "finish block_ops" }, \
+ { CP_PHASE_FINISH_CHECKPOINT, "finish checkpoint" })
+
struct f2fs_sb_info;
struct f2fs_io_info;
struct extent_info;
@@ -1573,26 +1582,26 @@ TRACE_EVENT(f2fs_readpages,
TRACE_EVENT(f2fs_write_checkpoint,
- TP_PROTO(struct super_block *sb, int reason, const char *msg),
+ TP_PROTO(struct super_block *sb, int reason, u16 phase),
- TP_ARGS(sb, reason, msg),
+ TP_ARGS(sb, reason, phase),
TP_STRUCT__entry(
__field(dev_t, dev)
__field(int, reason)
- __string(dest_msg, msg)
+ __field(u16, phase)
),
TP_fast_assign(
__entry->dev = sb->s_dev;
__entry->reason = reason;
- __assign_str(dest_msg);
+ __entry->phase = phase;
),
TP_printk("dev = (%d,%d), checkpoint for %s, state = %s",
show_dev(__entry->dev),
show_cpreason(__entry->reason),
- __get_str(dest_msg))
+ show_cp_phase(__entry->phase))
);
DECLARE_EVENT_CLASS(f2fs_discard,
--
2.52.0.487.g5c8c507ade-goog
^ permalink raw reply related
* Re: [PATCH] kprobes: avoid crash when rmmod/insmod modules after ftrace_disabled
From: yebin @ 2025-11-28 2:27 UTC (permalink / raw)
To: Masami Hiramatsu (Google); +Cc: naveen, davem, linux-trace-kernel, yebin10
In-Reply-To: <20251127131820.152fd7651ece26139778cc25@kernel.org>
On 2025/11/27 12:18, Masami Hiramatsu (Google) wrote:
> On Thu, 27 Nov 2025 12:52:48 +0900
> Masami Hiramatsu (Google) <mhiramat@kernel.org> wrote:
>
>> Hi,
>>
>> Thanks for reporting!
>>
>>
>> On Tue, 25 Nov 2025 10:05:36 +0800
>> Ye Bin <yebin@huaweicloud.com> wrote:
>>
>>> From: Ye Bin <yebin10@huawei.com>
>>>
>>> There's a issue as follows when rmmod modules after ftrace disabled:
>>
>> You may see something like;
>>
>> Failed to unregister kprobe-ftrace (error -19)
>>
>> or
>>
>> Failed to disarm kprobe-ftrace at <function name> (error -19)
>>
>> right before this BUG, don't you?
>> If you reported with that line, it's more easier to understand.
>>
Yes, there is indeed a warning generated. I might not have expressed it
clearly enough. The issue below is related to the problem that occurs
when the second module is unloaded. When the first module was unloaded,
some nodes were left in the hash list, causing a use-after-free (UAF)
issue when traversing the hash list.
Therefore, this patch aims to resolve the UAF problem caused by residual
nodes in the hash list after unloading a module while ftrace is disabled.
>>
>>> BUG: unable to handle page fault for address: fffffbfff805000d
>>> PGD 817fcc067 P4D 817fcc067 PUD 817fc8067 PMD 101555067 PTE 0
>>> Oops: Oops: 0000 [#1] SMP KASAN PTI
>>> CPU: 4 UID: 0 PID: 2012 Comm: rmmod Tainted: G W OE
>>> Tainted: [W]=WARN, [O]=OOT_MODULE, [E]=UNSIGNED_MODULE
>>> RIP: 0010:kprobes_module_callback+0x89/0x790
>>> RSP: 0018:ffff88812e157d30 EFLAGS: 00010a02
>>> RAX: 1ffffffff805000d RBX: dffffc0000000000 RCX: ffffffff86a8de90
>>> RDX: ffffed1025c2af9b RSI: 0000000000000008 RDI: ffffffffc0280068
>>> RBP: 0000000000000000 R08: 0000000000000001 R09: ffffed1025c2af9a
>>> R10: ffff88812e157cd7 R11: 205d323130325420 R12: 0000000000000002
>>> R13: ffffffffc0290488 R14: 0000000000000002 R15: ffffffffc0280040
>>> FS: 00007fbc450dd740(0000) GS:ffff888420331000(0000) knlGS:0000000000000000
>>> CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
>>> CR2: fffffbfff805000d CR3: 000000010f624000 CR4: 00000000000006f0
>>> Call Trace:
>>> <TASK>
>>> notifier_call_chain+0xc6/0x280
>>> blocking_notifier_call_chain+0x60/0x90
>>> __do_sys_delete_module.constprop.0+0x32a/0x4e0
>>> do_syscall_64+0x5d/0xfa0
>>> entry_SYSCALL_64_after_hwframe+0x76/0x7e
>>>
>>> The above issue occurs because the kprobe was not removed from the hash
>>> list after ftrace_disable.
>>> To prevent the system from restarting unexpectedly after ftrace_disable,
>>> in such cases, unregister_kprobe() ensures that the probe is removed from
>>> the hash list, preventing subsequent access to already freed memory.
>>>
>>> Fixes: 6f0f1dd71953 ("kprobes: Cleanup disabling and unregistering path")
>>> Signed-off-by: Ye Bin <yebin10@huawei.com>
>>> ---
>>> kernel/kprobes.c | 26 ++++++++++++++++++++++++--
>>> 1 file changed, 24 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/kernel/kprobes.c b/kernel/kprobes.c
>>> index ab8f9fc1f0d1..d735a608b810 100644
>>> --- a/kernel/kprobes.c
>>> +++ b/kernel/kprobes.c
>>> @@ -1731,8 +1731,30 @@ static int __unregister_kprobe_top(struct kprobe *p)
>>>
>>> /* Disable kprobe. This will disarm it if needed. */
>>> ap = __disable_kprobe(p);
>>> - if (IS_ERR(ap))
>>> - return PTR_ERR(ap);
>>> + if (IS_ERR(ap)) {
>>> + int ret = PTR_ERR(ap);
>>> +
>>> + /*
>>> + * If ftrace disabled we need to delete kprobe node from
>>> + * hlist or aggregation list. If nodes are not removed when
>>> + * modules are removed, the already released nodes will
>>> + * remain in the linked list. Subsequent access to the
>>> + * linked list may then trigger exceptions.
>>> + */
>>> + if (ret != -ENODEV)
>>> + return ret;
>>> +
>>> + ap = __get_valid_kprobe(p);
>>> + if (!ap)
>>> + return ret;
>>> +
>>> + if (ap == p)
>>> + hlist_del_rcu(&ap->hlist);
>>> + else
>>> + list_del_rcu(&p->list);
>>
>> Instead of repeating this process, we should ignore
>> -ENODEV error from ftrace directly. BTW, ftrace_disabled is set
>> when ftrace_kill() is called, that means ftrace is no more usable.
>> So I think we can just ignore ftrace operation in
>> __disarm_kprobe_ftrace().
>
> So, what we need is;
>
> diff --git a/kernel/kprobes.c b/kernel/kprobes.c
> index ab8f9fc1f0d1..17d451553389 100644
> --- a/kernel/kprobes.c
> +++ b/kernel/kprobes.c
> @@ -1104,6 +1104,10 @@ static int __disarm_kprobe_ftrace(struct kprobe *p, struct ftrace_ops *ops,
> int ret;
>
> lockdep_assert_held(&kprobe_mutex);
> + if (unlikely(kprobe_ftrace_disabled)) {
> + /* Now ftrace is disabled forever, disarm is already done. */
> + return 0;
> + }
>
> if (*cnt == 1) {
> ret = unregister_ftrace_function(ops);
>
>
^ permalink raw reply
* Re: [PATCH] overflow: Introduce struct_offset() to get offset of member
From: Kees Cook @ 2025-11-28 2:00 UTC (permalink / raw)
To: Steven Rostedt
Cc: LKML, linux-hardening, Linux Trace Kernel, Masami Hiramatsu,
Mathieu Desnoyers, Linus Torvalds, Gustavo A. R. Silva
In-Reply-To: <20251127204342.05fc985e@robin>
On November 27, 2025 5:43:42 PM PST, Steven Rostedt <rostedt@goodmis.org> wrote:
>On Wed, 26 Nov 2025 23:58:01 -0800
>Kees Cook <kees@kernel.org> wrote:
>
>> > +/**
>> > + * struct_offset() - Calculate the offset of a member within a struct
>> > + * @p: Pointer to the struct
>> > + * @member: Name of the member to get the offset of
>> > + *
>> > + * Calculates the offset of a particular @member of the structure pointed
>> > + * to by @p.
>> > + *
>> > + * Return: number of bytes to the location of @member.
>> > + */
>> > +#define struct_offset(p, member) (offsetof(typeof(*(p)), member))
>>
>> I wonder if the kerndoc for this and offsetof() should reference each
>> other? "For a type instead of a pointer, use offsetof()" etc...
>
>I know I pushed this to my for-next branch already, but it's the top
>patch. Looking at my code, I actually have a lot of places that use the
>offsetof() for a structure variable and not a pointer to a structure.
>
>Thus, I wonder if it is better to have this as:
>
>#define struct_offset(s, member) (offsetof(typeof(s), member))
I'd rather it keep the same API style as struct_size() if it's going to share the naming style.
If you have an instance and not a pointer, just slap on a & :)
--
Kees Cook
^ permalink raw reply
* Re: [PATCH] overflow: Introduce struct_offset() to get offset of member
From: Steven Rostedt @ 2025-11-28 1:43 UTC (permalink / raw)
To: Kees Cook
Cc: LKML, linux-hardening, Linux Trace Kernel, Masami Hiramatsu,
Mathieu Desnoyers, Linus Torvalds, Gustavo A. R. Silva
In-Reply-To: <202511262356.6FE5084CB0@keescook>
On Wed, 26 Nov 2025 23:58:01 -0800
Kees Cook <kees@kernel.org> wrote:
> > +/**
> > + * struct_offset() - Calculate the offset of a member within a struct
> > + * @p: Pointer to the struct
> > + * @member: Name of the member to get the offset of
> > + *
> > + * Calculates the offset of a particular @member of the structure pointed
> > + * to by @p.
> > + *
> > + * Return: number of bytes to the location of @member.
> > + */
> > +#define struct_offset(p, member) (offsetof(typeof(*(p)), member))
>
> I wonder if the kerndoc for this and offsetof() should reference each
> other? "For a type instead of a pointer, use offsetof()" etc...
I know I pushed this to my for-next branch already, but it's the top
patch. Looking at my code, I actually have a lot of places that use the
offsetof() for a structure variable and not a pointer to a structure.
Thus, I wonder if it is better to have this as:
#define struct_offset(s, member) (offsetof(typeof(s), member))
And then for pointers we have:
size = struct_offset(*entry, id) + cnt;
If you forget the '*' it will error with a complaint that entry is not
a structure type. Then I could make changes like this:
diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
index 1244d2c5c384..55f1bdab4ffa 100644
--- a/kernel/trace/ring_buffer.c
+++ b/kernel/trace/ring_buffer.c
@@ -587,19 +587,19 @@ int ring_buffer_print_page_header(struct trace_buffer *buffer, struct trace_seq
trace_seq_printf(s, "\tfield: local_t commit;\t"
"offset:%u;\tsize:%u;\tsigned:%u;\n",
- (unsigned int)offsetof(typeof(field), commit),
+ (unsigned int)struct_offset(field, commit),
(unsigned int)sizeof(field.commit),
(unsigned int)is_signed_type(long));
trace_seq_printf(s, "\tfield: int overwrite;\t"
"offset:%u;\tsize:%u;\tsigned:%u;\n",
- (unsigned int)offsetof(typeof(field), commit),
+ (unsigned int)struct_offset(field, commit),
1,
(unsigned int)is_signed_type(long));
trace_seq_printf(s, "\tfield: char data;\t"
"offset:%u;\tsize:%u;\tsigned:%u;\n",
- (unsigned int)offsetof(typeof(field), data),
+ (unsigned int)struct_offset(field, data),
(unsigned int)buffer->subbuf_size,
(unsigned int)is_signed_type(char));
I would have a lot more places I can make this update then if
struct_offset() took a pointer instead of the struct itself. As adding
a '*' isn't ugly I think I like this way better.
What are your thoughts?
-- Steve
^ permalink raw reply related
* Re: [PATCH 2/3] unwind_user/fp: Use dummies instead of ifdef
From: Jens Remus @ 2025-11-27 16:51 UTC (permalink / raw)
To: linux-kernel, linux-trace-kernel, x86, Steven Rostedt,
Peter Zijlstra
Cc: Josh Poimboeuf, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
Dave Hansen, H. Peter Anvin, Mathieu Desnoyers, Indu Bhagat,
Jose E. Marchesi, Heiko Carstens, Vasily Gorbik, Ilya Leoshkevich
In-Reply-To: <20251125164349.2592874-3-jremus@linux.ibm.com>
On 11/25/2025 5:43 PM, Jens Remus wrote:
> This simplifies the code. unwind_user_next_fp() does not need to
> return -EINVAL if config option HAVE_UNWIND_USER_FP is disabled, as
> unwind_user_start() will then not select this unwind method and
> unwind_user_next() will therefore not call it.
>
> Note that enabling the config option HAVE_UNWIND_USER_FP without
> defining ARCH_INIT_USER_FP_FRAME, ARCH_INIT_USER_FP_ENTRY_FRAME, and
> unwind_user_at_function_start() will result in a compile error, which
> is helpful when implementing support for unwind user fp in an
> architecture.
>
> Signed-off-by: Jens Remus <jremus@linux.ibm.com>
> diff --git a/include/linux/unwind_user.h b/include/linux/unwind_user.h
> @@ -5,9 +5,17 @@
> #include <linux/unwind_user_types.h>
> #include <asm/unwind_user.h>
>
> -#ifndef ARCH_INIT_USER_FP_FRAME
> - #define ARCH_INIT_USER_FP_FRAME
> -#endif
> +#ifndef CONFIG_HAVE_UNWIND_USER_FP
> +
> +#define ARCH_INIT_USER_FP_FRAME
> +#define ARCH_INIT_USER_FP_ENTRY_FRAME
Will fix this as follows in the next version:
#define ARCH_INIT_USER_FP_FRAME(ws)
#define ARCH_INIT_USER_FP_ENTRY_FRAME(ws)
> +
> +static inline bool unwind_user_at_function_start(struct pt_regs *regs)
> +{
> + return false;
> +}
Would it be better to provide a generic dummy implementation (see below)
or should each arch implement that if it cannot tell whether the topmost
frame is at function start? If so, would it move from linux/unwind_user.h
to asm-generic/unwind_user.h? Either way it would need to be outside of
the !CONFIG_HAVE_UNWIND_USER_FP guard.
#ifndef unwind_user_at_function_start
static inline bool unwind_user_at_function_start(struct pt_regs *regs)
{
return false;
}
#define unwind_user_at_function_start unwind_user_at_function_start
#endif
If doing so ARCH_INIT_USER_FP_ENTRY_FRAME should be handled similar, so
that archs do not need to provide their own dummy either:
#ifndef ARCH_INIT_USER_FP_ENTRY_FRAME
#define ARCH_INIT_USER_FP_ENTRY_FRAME(ws)
#endif
In that case only ARCH_INIT_USER_FP_FRAME would remain guarded by
!CONFIG_HAVE_UNWIND_USER_FP, so that compile would fail, if enabling
CONFIG_HAVE_UNWIND_USER_FP without providing ARCH_INIT_USER_FP_FRAME:
#ifndef CONFIG_HAVE_UNWIND_USER_FP
#define ARCH_INIT_USER_FP_FRAME(ws)
#endif /* !CONFIG_HAVE_UNWIND_USER_FP */
> +
> +#endif /* !CONFIG_HAVE_UNWIND_USER_FP */
>
> int unwind_user(struct unwind_stacktrace *trace, unsigned int max_entries);
>
Thanks and regards,
Jens
--
Jens Remus
Linux on Z Development (D3303)
+49-7031-16-1128 Office
jremus@de.ibm.com
IBM
IBM Deutschland Research & Development GmbH; Vorsitzender des Aufsichtsrats: Wolfgang Wendt; Geschäftsführung: David Faller; Sitz der Gesellschaft: Böblingen; Registergericht: Amtsgericht Stuttgart, HRB 243294
IBM Data Privacy Statement: https://www.ibm.com/privacy/
^ permalink raw reply
* Re: 答复: 答复: [External Mail]Re: [PATCH v3] dma-buf: add some tracepoints to debug.
From: Christian König @ 2025-11-27 15:40 UTC (permalink / raw)
To: 高翔, Xiang Gao, sumit.semwal@linaro.org,
rostedt@goodmis.org, mhiramat@kernel.org
Cc: 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
In-Reply-To: <76293b63568547e98efd7c0644ad7a49@xiaomi.com>
On 11/27/25 16:35, 高翔 wrote:
>> Hui? Why would you add those symbols to any whitelist?
>
> This is the mechanism of android gki. To use a tracepoint in the driver module, two points are required for a successful compilation:
> 1, export tracepint
> 2, add tracepoint to android whitelist.
>
> But without exporting tracepoint, I can also use tracepoint_probe_register to solve it.
Yeah exporting the tracepoint is clearly not the correct approach.
See this is not used in a driver module, but the core kernel. Exporting the symbol would make only sense if drivers want to access it, but at least for upstream that is not the case.
So please just drop that.
Regards,
Christian.
>
>
>> The refcnt is manipulated outside of the DMA-buf code by the filesystem layer.
>> As far as I can see it is meaningless here.
> ok.
>
>
>
> ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
> *发件人:* Christian König <christian.koenig@amd.com>
> *发送时间:* 2025年11月27日 22:08:32
> *收件人:* 高翔; 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
> *主题:* Re: 答复: [External Mail]Re: [PATCH v3] dma-buf: add some tracepoints to debug.
>
> [外部邮件] 此邮件来源于小米公司外部,请谨慎处理。若对邮件安全性存疑,请将邮件转发给misec@xiaomi.com进行反馈
>
> On 11/27/25 15:05, 高翔 wrote:
>>> Exporting the tracepoints is unecessary as far as I can see
>>
>> android must export symbols before adding a whitelist.
>
> Hui? Why would you add those symbols to any whitelist?
>
>>
>>
>>> I can't come up with a reason why we should have the file refcount in the trace logs.
>>> Same for most other places.
>> I can directly observe how refcnt is changing. Then it can be known where the dmabuf was finally released.
>
> The refcnt is manipulated outside of the DMA-buf code by the filesystem layer.
>
> As far as I can see it is meaningless here.
>
> Regards,
> Christian.
>
>>
>>
>>> Print the dev_name last, it's the external device which attaches to the DMA-buf.
>> ok.
>>
>>
>>> Additional to that it would be nice to know if the attachment is dynamic or not.
>> ok.
>>
>> ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>> *发件人:* Christian König <christian.koenig@amd.com>
>> *发送时间:* 2025年11月27日 17:49:09
>> *收件人:* 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 v3] dma-buf: add some tracepoints to debug.
>>
>> [外部邮件] 此邮件来源于小米公司外部,请谨慎处理。若对邮件安全性存疑,请将邮件转发给misec@xiaomi.com进行反馈
>>
>> On 11/27/25 01:43, Xiang Gao 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.
>>>
>>> For example:
>>> binder:2962_2-2962 [005] ...1. 208.453940: dma_buf_export: exp_name=qcom,system name=(null) size=28672 ino=2580 f_refcnt=2
>>> binder:2962_2-2962 [005] ...1. 208.453943: dma_buf_fd: exp_name=qcom,system name=(null) size=28672 ino=2580 fd=9 f_refcnt=2
>>> binder:2962_2-2962 [005] ...1. 208.453977: dma_buf_mmap_internal: exp_name=qcom,system name=qcom,system size=28672 ino=2580 f_refcnt=4
>>> kworker/5:2-194 [005] ...1. 208.460580: dma_buf_put: exp_name=qcom,system name=ab pid [8176] size=28672 ino=2580 f_refcnt=3
>>> RenderThread-11305 [007] ...1. 208.599094: dma_buf_get: exp_name=qcom,system name=ab pid [8176] size=217088 ino=2579 fd=1114 f_refcnt=7
>>> RenderThread-11305 [007] ...1. 208.599098: dma_buf_attach: dev_name=kgsl-3d0 exp_name=qcom,system name=ab pid [8176] size=217088 ino=2579 f_refcnt=7
>>> <...>-14 [001] ...1. 208.726359: dma_buf_detach: dev_name=kgsl-3d0 exp_name=qcom,system name=ab pid [3317] size=217088 ino=2581 f_refcnt=3
>>>
>>> Signed-off-by: Xiang Gao <gaoxiang17@xiaomi.com>
>>> ---
>>> drivers/dma-buf/dma-buf.c | 57 ++++++++++-
>>> include/trace/events/dma_buf.h | 166 +++++++++++++++++++++++++++++++++
>>> 2 files changed, 222 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..7cef816ddcac 100644
>>> --- a/drivers/dma-buf/dma-buf.c
>>> +++ b/drivers/dma-buf/dma-buf.c
>>> @@ -35,6 +35,18 @@
>>>
>>> #include "dma-buf-sysfs-stats.h"
>>>
>>> +#define CREATE_TRACE_POINTS
>>> +#include <trace/events/dma_buf.h>
>>> +
>>> +EXPORT_TRACEPOINT_SYMBOL(dma_buf_export);
>>> +EXPORT_TRACEPOINT_SYMBOL(dma_buf_mmap_internal);
>>> +EXPORT_TRACEPOINT_SYMBOL(dma_buf_mmap);
>>> +EXPORT_TRACEPOINT_SYMBOL(dma_buf_put);
>>> +EXPORT_TRACEPOINT_SYMBOL(dma_buf_attach);
>>> +EXPORT_TRACEPOINT_SYMBOL(dma_buf_detach);
>>> +EXPORT_TRACEPOINT_SYMBOL(dma_buf_fd);
>>> +EXPORT_TRACEPOINT_SYMBOL(dma_buf_get);
>>
>> Exporting the tracepoints is unecessary as far as I can see
>>
>>> +
>>> static inline int is_dma_buf_file(struct file *);
>>>
>>> static DEFINE_MUTEX(dmabuf_list_mutex);
>>> @@ -220,6 +232,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 +762,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);
>>> + }
>>> +
>>> return dmabuf;
>>>
>>> err_dmabuf:
>>> @@ -779,6 +801,11 @@ int dma_buf_fd(struct dma_buf *dmabuf, int flags)
>>>
>>> fd_install(fd, dmabuf->file);
>>>
>>> + if (trace_dma_buf_fd_enabled()) {
>>> + guard(spinlock)(&dmabuf->name_lock);
>>> + trace_dma_buf_fd(dmabuf, fd);
>>> + }
>>> +
>>> return fd;
>>> }
>>> EXPORT_SYMBOL_NS_GPL(dma_buf_fd, "DMA_BUF");
>>> @@ -794,6 +821,7 @@ EXPORT_SYMBOL_NS_GPL(dma_buf_fd, "DMA_BUF");
>>> struct dma_buf *dma_buf_get(int fd)
>>> {
>>> struct file *file;
>>> + struct dma_buf *dmabuf;
>>>
>>> file = fget(fd);
>>>
>>> @@ -805,7 +833,14 @@ struct dma_buf *dma_buf_get(int fd)
>>> return ERR_PTR(-EINVAL);
>>> }
>>>
>>> - return file->private_data;
>>> + dmabuf = file->private_data;
>>> +
>>> + if (trace_dma_buf_get_enabled()) {
>>> + guard(spinlock)(&dmabuf->name_lock);
>>> + trace_dma_buf_get(dmabuf, fd);
>>> + }
>>> +
>>> + return dmabuf;
>>> }
>>> EXPORT_SYMBOL_NS_GPL(dma_buf_get, "DMA_BUF");
>>>
>>> @@ -825,6 +860,11 @@ void dma_buf_put(struct dma_buf *dmabuf)
>>> return;
>>>
>>> fput(dmabuf->file);
>>> +
>>> + if (trace_dma_buf_put_enabled()) {
>>> + guard(spinlock)(&dmabuf->name_lock);
>>> + trace_dma_buf_put(dmabuf);
>>> + }
>>> }
>>> EXPORT_SYMBOL_NS_GPL(dma_buf_put, "DMA_BUF");
>>>
>>> @@ -998,6 +1038,11 @@ EXPORT_SYMBOL_NS_GPL(dma_buf_dynamic_attach, "DMA_BUF");
>>> struct dma_buf_attachment *dma_buf_attach(struct dma_buf *dmabuf,
>>> struct device *dev)
>>> {
>>> + if (trace_dma_buf_attach_enabled()) {
>>> + guard(spinlock)(&dmabuf->name_lock);
>>> + trace_dma_buf_attach(dmabuf, dev);
>>> + }
>>> +
>>> return dma_buf_dynamic_attach(dmabuf, dev, NULL, NULL);
>>> }
>>> EXPORT_SYMBOL_NS_GPL(dma_buf_attach, "DMA_BUF");
>>> @@ -1023,6 +1068,11 @@ void dma_buf_detach(struct dma_buf *dmabuf, struct dma_buf_attachment *attach)
>>> if (dmabuf->ops->detach)
>>> dmabuf->ops->detach(dmabuf, attach);
>>>
>>> + if (trace_dma_buf_detach_enabled()) {
>>> + guard(spinlock)(&dmabuf->name_lock);
>>> + trace_dma_buf_detach(dmabuf, attach->dev);
>>> + }
>>> +
>>> kfree(attach);
>>> }
>>> EXPORT_SYMBOL_NS_GPL(dma_buf_detach, "DMA_BUF");
>>> @@ -1488,6 +1538,11 @@ int dma_buf_mmap(struct dma_buf *dmabuf, struct vm_area_struct *vma,
>>> vma_set_file(vma, dmabuf->file);
>>> vma->vm_pgoff = pgoff;
>>>
>>> + if (trace_dma_buf_mmap_enabled()) {
>>> + guard(spinlock)(&dmabuf->name_lock);
>>> + trace_dma_buf_mmap(dmabuf);
>>> + }
>>> +
>>> return dmabuf->ops->mmap(dmabuf, vma);
>>> }
>>> EXPORT_SYMBOL_NS_GPL(dma_buf_mmap, "DMA_BUF");
>>> diff --git a/include/trace/events/dma_buf.h b/include/trace/events/dma_buf.h
>>> new file mode 100644
>>> index 000000000000..fe9da89bacd0
>>> --- /dev/null
>>> +++ b/include/trace/events/dma_buf.h
>>> @@ -0,0 +1,166 @@
>>> +/* 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>
>>> +
>>> +DECLARE_EVENT_CLASS(dma_buf,
>>> +
>>> + 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);
>>> + __assign_str(name);
>>> + __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)
>>
>> I can't come up with a reason why we should have the file refcount in the trace logs.
>>
>> Same for most other places.
>>
>>> +);
>>> +
>>> +DECLARE_EVENT_CLASS(dma_buf_attach_dev,
>>> +
>>> + 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);
>>> + __assign_str(name);
>>> + __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)
>>
>> Print the dev_name last, it's the external device which attaches to the DMA-buf.
>>
>> Additional to that it would be nice to know if the attachment is dynamic or not.
>>
>> Regards,
>> Christian.
>>
>>> +);
>>> +
>>> +DECLARE_EVENT_CLASS(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);
>>> + __assign_str(name);
>>> + __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)
>>> +);
>>> +
>>> +DEFINE_EVENT(dma_buf, dma_buf_export,
>>> +
>>> + TP_PROTO(struct dma_buf *dmabuf),
>>> +
>>> + TP_ARGS(dmabuf)
>>> +);
>>> +
>>> +DEFINE_EVENT(dma_buf, dma_buf_mmap_internal,
>>> +
>>> + TP_PROTO(struct dma_buf *dmabuf),
>>> +
>>> + TP_ARGS(dmabuf)
>>> +);
>>> +
>>> +DEFINE_EVENT(dma_buf, dma_buf_mmap,
>>> +
>>> + TP_PROTO(struct dma_buf *dmabuf),
>>> +
>>> + TP_ARGS(dmabuf)
>>> +);
>>> +
>>> +DEFINE_EVENT(dma_buf, dma_buf_put,
>>> +
>>> + TP_PROTO(struct dma_buf *dmabuf),
>>> +
>>> + TP_ARGS(dmabuf)
>>> +);
>>> +
>>> +DEFINE_EVENT(dma_buf_attach_dev, dma_buf_attach,
>>> +
>>> + TP_PROTO(struct dma_buf *dmabuf, struct device *dev),
>>> +
>>> + TP_ARGS(dmabuf, dev)
>>> +);
>>> +
>>> +DEFINE_EVENT(dma_buf_attach_dev, dma_buf_detach,
>>> +
>>> + TP_PROTO(struct dma_buf *dmabuf, struct device *dev),
>>> +
>>> + TP_ARGS(dmabuf, dev)
>>> +);
>>> +
>>> +DEFINE_EVENT(dma_buf_fd, dma_buf_fd,
>>> +
>>> + TP_PROTO(struct dma_buf *dmabuf, int fd),
>>> +
>>> + TP_ARGS(dmabuf, fd)
>>> +);
>>> +
>>> +DEFINE_EVENT(dma_buf_fd, dma_buf_get,
>>> +
>>> + TP_PROTO(struct dma_buf *dmabuf, int fd),
>>> +
>>> + TP_ARGS(dmabuf, fd)
>>> +);
>>> +
>>> +#endif /* _TRACE_DMA_BUF_H */
>>> +
>>> +/* This part must be outside protection */
>>> +#include <trace/define_trace.h>
>>
>
^ permalink raw reply
* Re: [PATCH v4 2/3] tracing/fprobe: Support comma-separated symbols and :entry/:exit
From: kernel test robot @ 2025-11-27 15:00 UTC (permalink / raw)
To: Seokwoo Chung (Ryan), rostedt, mhiramat, corbet, shuah
Cc: oe-kbuild-all, mathieu.desnoyers, linux-kernel,
linux-trace-kernel, linux-doc, linux-kselftest,
Seokwoo Chung (Ryan)
In-Reply-To: <20251126184110.72241-3-seokwoo.chung130@gmail.com>
Hi Seokwoo,
kernel test robot noticed the following build warnings:
[auto build test WARNING on trace/for-next]
[also build test WARNING on linus/master v6.18-rc7 next-20251127]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Seokwoo-Chung-Ryan/docs-tracing-fprobe-Document-list-filters-and-entry-exit/20251127-024245
base: https://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace for-next
patch link: https://lore.kernel.org/r/20251126184110.72241-3-seokwoo.chung130%40gmail.com
patch subject: [PATCH v4 2/3] tracing/fprobe: Support comma-separated symbols and :entry/:exit
config: x86_64-randconfig-003-20251127 (https://download.01.org/0day-ci/archive/20251127/202511272241.s6tUpIgv-lkp@intel.com/config)
compiler: gcc-14 (Debian 14.2.0-19) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251127/202511272241.s6tUpIgv-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202511272241.s6tUpIgv-lkp@intel.com/
All warnings (new ones prefixed by >>):
kernel/trace/trace_fprobe.c: In function 'parse_fprobe_spec':
kernel/trace/trace_fprobe.c:1282:12: error: invalid storage class for function 'trace_fprobe_create_internal'
1282 | static int trace_fprobe_create_internal(int argc, const char *argv[],
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
kernel/trace/trace_fprobe.c:1513:12: error: invalid storage class for function 'trace_fprobe_create_cb'
1513 | static int trace_fprobe_create_cb(int argc, const char *argv[])
| ^~~~~~~~~~~~~~~~~~~~~~
kernel/trace/trace_fprobe.c:1530:12: error: invalid storage class for function 'trace_fprobe_create'
1530 | static int trace_fprobe_create(const char *raw_command)
| ^~~~~~~~~~~~~~~~~~~
kernel/trace/trace_fprobe.c:1535:12: error: invalid storage class for function 'trace_fprobe_release'
1535 | static int trace_fprobe_release(struct dyn_event *ev)
| ^~~~~~~~~~~~~~~~~~~~
kernel/trace/trace_fprobe.c:1545:12: error: invalid storage class for function 'trace_fprobe_show'
1545 | static int trace_fprobe_show(struct seq_file *m, struct dyn_event *ev)
| ^~~~~~~~~~~~~~~~~
kernel/trace/trace_fprobe.c:1572:12: error: invalid storage class for function 'enable_trace_fprobe'
1572 | static int enable_trace_fprobe(struct trace_event_call *call,
| ^~~~~~~~~~~~~~~~~~~
kernel/trace/trace_fprobe.c:1608:12: error: invalid storage class for function 'disable_trace_fprobe'
1608 | static int disable_trace_fprobe(struct trace_event_call *call,
| ^~~~~~~~~~~~~~~~~~~~
kernel/trace/trace_fprobe.c:1653:12: error: invalid storage class for function 'fprobe_register'
1653 | static int fprobe_register(struct trace_event_call *event,
| ^~~~~~~~~~~~~~~
kernel/trace/trace_fprobe.c:1683:19: error: invalid storage class for function 'init_fprobe_trace_early'
1683 | static __init int init_fprobe_trace_early(void)
| ^~~~~~~~~~~~~~~~~~~~~~~
In file included from include/linux/fprobe.h:6,
from kernel/trace/trace_fprobe.c:8:
include/linux/compiler.h:286:52: error: initializer element is not constant
286 | __UNIQUE_ID(__PASTE(__addressable_,sym)) = (void *)(uintptr_t)&sym;
| ^
include/linux/compiler.h:289:9: note: in expansion of macro '___ADDRESSABLE'
289 | ___ADDRESSABLE(sym, __section(".discard.addressable"))
| ^~~~~~~~~~~~~~
include/linux/init.h:250:9: note: in expansion of macro '__ADDRESSABLE'
250 | __ADDRESSABLE(fn)
| ^~~~~~~~~~~~~
include/linux/init.h:255:9: note: in expansion of macro '__define_initcall_stub'
255 | __define_initcall_stub(__stub, fn) \
| ^~~~~~~~~~~~~~~~~~~~~~
include/linux/init.h:268:9: note: in expansion of macro '____define_initcall'
268 | ____define_initcall(fn, \
| ^~~~~~~~~~~~~~~~~~~
include/linux/init.h:274:9: note: in expansion of macro '__unique_initcall'
274 | __unique_initcall(fn, id, __sec, __initcall_id(fn))
| ^~~~~~~~~~~~~~~~~
include/linux/init.h:276:35: note: in expansion of macro '___define_initcall'
276 | #define __define_initcall(fn, id) ___define_initcall(fn, id, .initcall##id)
| ^~~~~~~~~~~~~~~~~~
include/linux/init.h:294:41: note: in expansion of macro '__define_initcall'
294 | #define core_initcall(fn) __define_initcall(fn, 1)
| ^~~~~~~~~~~~~~~~~
kernel/trace/trace_fprobe.c:1702:1: note: in expansion of macro 'core_initcall'
1702 | core_initcall(init_fprobe_trace_early);
| ^~~~~~~~~~~~~
kernel/trace/trace_fprobe.c:1702:1: error: expected declaration or statement at end of input
kernel/trace/trace_fprobe.c: At top level:
>> kernel/trace/trace_fprobe.c:28:12: warning: 'trace_fprobe_create' used but never defined
28 | static int trace_fprobe_create(const char *raw_command);
| ^~~~~~~~~~~~~~~~~~~
>> kernel/trace/trace_fprobe.c:29:12: warning: 'trace_fprobe_show' used but never defined
29 | static int trace_fprobe_show(struct seq_file *m, struct dyn_event *ev);
| ^~~~~~~~~~~~~~~~~
>> kernel/trace/trace_fprobe.c:30:12: warning: 'trace_fprobe_release' used but never defined
30 | static int trace_fprobe_release(struct dyn_event *ev);
| ^~~~~~~~~~~~~~~~~~~~
>> kernel/trace/trace_fprobe.c:741:12: warning: 'fprobe_register' used but never defined
741 | static int fprobe_register(struct trace_event_call *event,
| ^~~~~~~~~~~~~~~
>> kernel/trace/trace_fprobe.c:1653:12: warning: 'fprobe_register' defined but not used [-Wunused-function]
1653 | static int fprobe_register(struct trace_event_call *event,
| ^~~~~~~~~~~~~~~
>> kernel/trace/trace_fprobe.c:1545:12: warning: 'trace_fprobe_show' defined but not used [-Wunused-function]
1545 | static int trace_fprobe_show(struct seq_file *m, struct dyn_event *ev)
| ^~~~~~~~~~~~~~~~~
>> kernel/trace/trace_fprobe.c:1535:12: warning: 'trace_fprobe_release' defined but not used [-Wunused-function]
1535 | static int trace_fprobe_release(struct dyn_event *ev)
| ^~~~~~~~~~~~~~~~~~~~
>> kernel/trace/trace_fprobe.c:1530:12: warning: 'trace_fprobe_create' defined but not used [-Wunused-function]
1530 | static int trace_fprobe_create(const char *raw_command)
| ^~~~~~~~~~~~~~~~~~~
vim +/trace_fprobe_create +28 kernel/trace/trace_fprobe.c
334e5519c375701 Masami Hiramatsu (Google 2023-06-06 27)
334e5519c375701 Masami Hiramatsu (Google 2023-06-06 @28) static int trace_fprobe_create(const char *raw_command);
334e5519c375701 Masami Hiramatsu (Google 2023-06-06 @29) static int trace_fprobe_show(struct seq_file *m, struct dyn_event *ev);
334e5519c375701 Masami Hiramatsu (Google 2023-06-06 @30) static int trace_fprobe_release(struct dyn_event *ev);
334e5519c375701 Masami Hiramatsu (Google 2023-06-06 31) static bool trace_fprobe_is_busy(struct dyn_event *ev);
334e5519c375701 Masami Hiramatsu (Google 2023-06-06 32) static bool trace_fprobe_match(const char *system, const char *event,
334e5519c375701 Masami Hiramatsu (Google 2023-06-06 33) int argc, const char **argv, struct dyn_event *ev);
334e5519c375701 Masami Hiramatsu (Google 2023-06-06 34)
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply
* Re: [PATCH v4 2/3] tracing/fprobe: Support comma-separated symbols and :entry/:exit
From: kernel test robot @ 2025-11-27 14:49 UTC (permalink / raw)
To: Seokwoo Chung (Ryan), rostedt, mhiramat, corbet, shuah
Cc: llvm, oe-kbuild-all, mathieu.desnoyers, linux-kernel,
linux-trace-kernel, linux-doc, linux-kselftest,
Seokwoo Chung (Ryan)
In-Reply-To: <20251126184110.72241-3-seokwoo.chung130@gmail.com>
Hi Seokwoo,
kernel test robot noticed the following build errors:
[auto build test ERROR on trace/for-next]
[also build test ERROR on linus/master v6.18-rc7 next-20251127]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Seokwoo-Chung-Ryan/docs-tracing-fprobe-Document-list-filters-and-entry-exit/20251127-024245
base: https://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace for-next
patch link: https://lore.kernel.org/r/20251126184110.72241-3-seokwoo.chung130%40gmail.com
patch subject: [PATCH v4 2/3] tracing/fprobe: Support comma-separated symbols and :entry/:exit
config: x86_64-randconfig-001-20251127 (https://download.01.org/0day-ci/archive/20251127/202511272254.BX8oUzwu-lkp@intel.com/config)
compiler: clang version 20.1.8 (https://github.com/llvm/llvm-project 87f0227cb60147a26a1eeb4fb06e3b505e9c7261)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251127/202511272254.BX8oUzwu-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202511272254.BX8oUzwu-lkp@intel.com/
All errors (new ones prefixed by >>):
>> kernel/trace/trace_fprobe.c:1284:1: error: function definition is not allowed here
1284 | {
| ^
kernel/trace/trace_fprobe.c:1514:1: error: function definition is not allowed here
1514 | {
| ^
kernel/trace/trace_fprobe.c:1531:1: error: function definition is not allowed here
1531 | {
| ^
kernel/trace/trace_fprobe.c:1536:1: error: function definition is not allowed here
1536 | {
| ^
kernel/trace/trace_fprobe.c:1546:1: error: function definition is not allowed here
1546 | {
| ^
kernel/trace/trace_fprobe.c:1574:1: error: function definition is not allowed here
1574 | {
| ^
kernel/trace/trace_fprobe.c:1610:1: error: function definition is not allowed here
1610 | {
| ^
kernel/trace/trace_fprobe.c:1655:1: error: function definition is not allowed here
1655 | {
| ^
kernel/trace/trace_fprobe.c:1684:1: error: function definition is not allowed here
1684 | {
| ^
>> kernel/trace/trace_fprobe.c:1702:15: error: use of undeclared identifier 'init_fprobe_trace_early'
1702 | core_initcall(init_fprobe_trace_early);
| ^
>> kernel/trace/trace_fprobe.c:1702:15: error: use of undeclared identifier 'init_fprobe_trace_early'
>> kernel/trace/trace_fprobe.c:1702:40: error: expected '}'
1702 | core_initcall(init_fprobe_trace_early);
| ^
kernel/trace/trace_fprobe.c:1175:1: note: to match this '{'
1175 | {
| ^
12 errors generated.
vim +1284 kernel/trace/trace_fprobe.c
08c9306fc2e32b Masami Hiramatsu (Google 2023-08-23 1281)
8275637215bd3d Masami Hiramatsu (Google 2025-01-17 1282) static int trace_fprobe_create_internal(int argc, const char *argv[],
8275637215bd3d Masami Hiramatsu (Google 2025-01-17 1283) struct traceprobe_parse_context *ctx)
334e5519c37570 Masami Hiramatsu (Google 2023-06-06 @1284) {
334e5519c37570 Masami Hiramatsu (Google 2023-06-06 1285) /*
334e5519c37570 Masami Hiramatsu (Google 2023-06-06 1286) * Argument syntax:
334e5519c37570 Masami Hiramatsu (Google 2023-06-06 1287) * - Add fentry probe:
334e5519c37570 Masami Hiramatsu (Google 2023-06-06 1288) * f[:[GRP/][EVENT]] [MOD:]KSYM [FETCHARGS]
334e5519c37570 Masami Hiramatsu (Google 2023-06-06 1289) * - Add fexit probe:
334e5519c37570 Masami Hiramatsu (Google 2023-06-06 1290) * f[N][:[GRP/][EVENT]] [MOD:]KSYM%return [FETCHARGS]
e2d0d7b2f42dca Masami Hiramatsu (Google 2023-06-06 1291) * - Add tracepoint probe:
e2d0d7b2f42dca Masami Hiramatsu (Google 2023-06-06 1292) * t[:[GRP/][EVENT]] TRACEPOINT [FETCHARGS]
334e5519c37570 Masami Hiramatsu (Google 2023-06-06 1293) *
334e5519c37570 Masami Hiramatsu (Google 2023-06-06 1294) * Fetch args:
334e5519c37570 Masami Hiramatsu (Google 2023-06-06 1295) * $retval : fetch return value
334e5519c37570 Masami Hiramatsu (Google 2023-06-06 1296) * $stack : fetch stack address
334e5519c37570 Masami Hiramatsu (Google 2023-06-06 1297) * $stackN : fetch Nth entry of stack (N:0-)
334e5519c37570 Masami Hiramatsu (Google 2023-06-06 1298) * $argN : fetch Nth argument (N:1-)
334e5519c37570 Masami Hiramatsu (Google 2023-06-06 1299) * $comm : fetch current task comm
334e5519c37570 Masami Hiramatsu (Google 2023-06-06 1300) * @ADDR : fetch memory at ADDR (ADDR should be in kernel)
334e5519c37570 Masami Hiramatsu (Google 2023-06-06 1301) * @SYM[+|-offs] : fetch memory at SYM +|- offs (SYM is a data symbol)
334e5519c37570 Masami Hiramatsu (Google 2023-06-06 1302) * Dereferencing memory fetch:
334e5519c37570 Masami Hiramatsu (Google 2023-06-06 1303) * +|-offs(ARG) : fetch memory at ARG +|- offs address.
334e5519c37570 Masami Hiramatsu (Google 2023-06-06 1304) * Alias name of args:
334e5519c37570 Masami Hiramatsu (Google 2023-06-06 1305) * NAME=FETCHARG : set NAME as alias of FETCHARG.
334e5519c37570 Masami Hiramatsu (Google 2023-06-06 1306) * Type of args:
334e5519c37570 Masami Hiramatsu (Google 2023-06-06 1307) * FETCHARG:TYPE : use TYPE instead of unsigned long.
334e5519c37570 Masami Hiramatsu (Google 2023-06-06 1308) */
8275637215bd3d Masami Hiramatsu (Google 2025-01-17 1309) struct trace_fprobe *tf __free(free_trace_fprobe) = NULL;
334e5519c37570 Masami Hiramatsu (Google 2023-06-06 1310) const char *event = NULL, *group = FPROBE_EVENT_SYSTEM;
d643eaa7082dc3 Masami Hiramatsu (Google 2025-07-23 1311) struct module *mod __free(module_put) = NULL;
8275637215bd3d Masami Hiramatsu (Google 2025-01-17 1312) const char **new_argv __free(kfree) = NULL;
a90d508c939bee Seokwoo Chung (Ryan 2025-11-26 1313) char *parsed_nofilter __free(kfree) = NULL;
a90d508c939bee Seokwoo Chung (Ryan 2025-11-26 1314) char *parsed_filter __free(kfree) = NULL;
d643eaa7082dc3 Masami Hiramatsu (Google 2025-07-23 1315) char *symbol __free(kfree) = NULL;
d643eaa7082dc3 Masami Hiramatsu (Google 2025-07-23 1316) char *ebuf __free(kfree) = NULL;
d643eaa7082dc3 Masami Hiramatsu (Google 2025-07-23 1317) char *gbuf __free(kfree) = NULL;
d643eaa7082dc3 Masami Hiramatsu (Google 2025-07-23 1318) char *sbuf __free(kfree) = NULL;
d643eaa7082dc3 Masami Hiramatsu (Google 2025-07-23 1319) char *abuf __free(kfree) = NULL;
8275637215bd3d Masami Hiramatsu (Google 2025-01-17 1320) char *dbuf __free(kfree) = NULL;
d643eaa7082dc3 Masami Hiramatsu (Google 2025-07-23 1321) int i, new_argc = 0, ret = 0;
e2d0d7b2f42dca Masami Hiramatsu (Google 2023-06-06 1322) bool is_tracepoint = false;
a90d508c939bee Seokwoo Chung (Ryan 2025-11-26 1323) bool list_mode = false;
d643eaa7082dc3 Masami Hiramatsu (Google 2025-07-23 1324) bool is_return = false;
334e5519c37570 Masami Hiramatsu (Google 2023-06-06 1325)
e2d0d7b2f42dca Masami Hiramatsu (Google 2023-06-06 1326) if ((argv[0][0] != 'f' && argv[0][0] != 't') || argc < 2)
334e5519c37570 Masami Hiramatsu (Google 2023-06-06 1327) return -ECANCELED;
334e5519c37570 Masami Hiramatsu (Google 2023-06-06 1328)
e2d0d7b2f42dca Masami Hiramatsu (Google 2023-06-06 1329) if (argv[0][0] == 't') {
e2d0d7b2f42dca Masami Hiramatsu (Google 2023-06-06 1330) is_tracepoint = true;
e2d0d7b2f42dca Masami Hiramatsu (Google 2023-06-06 1331) group = TRACEPOINT_EVENT_SYSTEM;
e2d0d7b2f42dca Masami Hiramatsu (Google 2023-06-06 1332) }
e2d0d7b2f42dca Masami Hiramatsu (Google 2023-06-06 1333)
a2224559cbba1d Masami Hiramatsu (Google 2024-12-26 1334) if (argv[0][1] != '\0') {
a2224559cbba1d Masami Hiramatsu (Google 2024-12-26 1335) if (argv[0][1] != ':') {
a2224559cbba1d Masami Hiramatsu (Google 2024-12-26 1336) trace_probe_log_set_index(0);
334e5519c37570 Masami Hiramatsu (Google 2023-06-06 1337) trace_probe_log_err(1, BAD_MAXACT);
8275637215bd3d Masami Hiramatsu (Google 2025-01-17 1338) return -EINVAL;
334e5519c37570 Masami Hiramatsu (Google 2023-06-06 1339) }
a2224559cbba1d Masami Hiramatsu (Google 2024-12-26 1340) event = &argv[0][2];
334e5519c37570 Masami Hiramatsu (Google 2023-06-06 1341) }
334e5519c37570 Masami Hiramatsu (Google 2023-06-06 1342)
334e5519c37570 Masami Hiramatsu (Google 2023-06-06 1343) trace_probe_log_set_index(1);
334e5519c37570 Masami Hiramatsu (Google 2023-06-06 1344)
a90d508c939bee Seokwoo Chung (Ryan 2025-11-26 1345) /* Parse spec early (single vs list, suffix, base symbol) */
a90d508c939bee Seokwoo Chung (Ryan 2025-11-26 1346) ret = parse_fprobe_spec(argv[1], is_tracepoint, &symbol, &is_return,
a90d508c939bee Seokwoo Chung (Ryan 2025-11-26 1347) &list_mode, &parsed_filter, &parsed_nofilter);
08c9306fc2e32b Masami Hiramatsu (Google 2023-08-23 1348) if (ret < 0)
8275637215bd3d Masami Hiramatsu (Google 2025-01-17 1349) return -EINVAL;
08c9306fc2e32b Masami Hiramatsu (Google 2023-08-23 1350)
a90d508c939bee Seokwoo Chung (Ryan 2025-11-26 1351) for (i = 2; i < argc; i++) {
a90d508c939bee Seokwoo Chung (Ryan 2025-11-26 1352) char *tmp = strstr(argv[i], "$retval");
a90d508c939bee Seokwoo Chung (Ryan 2025-11-26 1353)
a90d508c939bee Seokwoo Chung (Ryan 2025-11-26 1354) if (tmp && !isalnum(tmp[7]) && tmp[7] != '_') {
a90d508c939bee Seokwoo Chung (Ryan 2025-11-26 1355) if (is_tracepoint) {
a90d508c939bee Seokwoo Chung (Ryan 2025-11-26 1356) trace_probe_log_set_index(i);
a90d508c939bee Seokwoo Chung (Ryan 2025-11-26 1357) trace_probe_log_err(tmp - argv[i], RETVAL_ON_PROBE);
a90d508c939bee Seokwoo Chung (Ryan 2025-11-26 1358) return -EINVAL;
a90d508c939bee Seokwoo Chung (Ryan 2025-11-26 1359) }
a90d508c939bee Seokwoo Chung (Ryan 2025-11-26 1360) is_return = true;
a90d508c939bee Seokwoo Chung (Ryan 2025-11-26 1361) break;
a90d508c939bee Seokwoo Chung (Ryan 2025-11-26 1362) }
a90d508c939bee Seokwoo Chung (Ryan 2025-11-26 1363) }
a90d508c939bee Seokwoo Chung (Ryan 2025-11-26 1364)
334e5519c37570 Masami Hiramatsu (Google 2023-06-06 1365) trace_probe_log_set_index(0);
334e5519c37570 Masami Hiramatsu (Google 2023-06-06 1366) if (event) {
d643eaa7082dc3 Masami Hiramatsu (Google 2025-07-23 1367) gbuf = kmalloc(MAX_EVENT_NAME_LEN, GFP_KERNEL);
d643eaa7082dc3 Masami Hiramatsu (Google 2025-07-23 1368) if (!gbuf)
d643eaa7082dc3 Masami Hiramatsu (Google 2025-07-23 1369) return -ENOMEM;
334e5519c37570 Masami Hiramatsu (Google 2023-06-06 1370) ret = traceprobe_parse_event_name(&event, &group, gbuf,
334e5519c37570 Masami Hiramatsu (Google 2023-06-06 1371) event - argv[0]);
334e5519c37570 Masami Hiramatsu (Google 2023-06-06 1372) if (ret)
8275637215bd3d Masami Hiramatsu (Google 2025-01-17 1373) return -EINVAL;
334e5519c37570 Masami Hiramatsu (Google 2023-06-06 1374) }
334e5519c37570 Masami Hiramatsu (Google 2023-06-06 1375)
334e5519c37570 Masami Hiramatsu (Google 2023-06-06 1376) if (!event) {
a90d508c939bee Seokwoo Chung (Ryan 2025-11-26 1377) /*
a90d508c939bee Seokwoo Chung (Ryan 2025-11-26 1378) * Event name rules:
a90d508c939bee Seokwoo Chung (Ryan 2025-11-26 1379) * - For list/wildcard: require explicit [GROUP/]EVENT
a90d508c939bee Seokwoo Chung (Ryan 2025-11-26 1380) * - For single literal: autogenerate symbol__entry/symbol__exit
a90d508c939bee Seokwoo Chung (Ryan 2025-11-26 1381) */
a90d508c939bee Seokwoo Chung (Ryan 2025-11-26 1382) if (list_mode || has_wildcard(symbol)) {
a90d508c939bee Seokwoo Chung (Ryan 2025-11-26 1383) trace_probe_log_err(0, NO_GROUP_NAME);
a90d508c939bee Seokwoo Chung (Ryan 2025-11-26 1384) return -EINVAL;
a90d508c939bee Seokwoo Chung (Ryan 2025-11-26 1385) }
d643eaa7082dc3 Masami Hiramatsu (Google 2025-07-23 1386) ebuf = kmalloc(MAX_EVENT_NAME_LEN, GFP_KERNEL);
d643eaa7082dc3 Masami Hiramatsu (Google 2025-07-23 1387) if (!ebuf)
d643eaa7082dc3 Masami Hiramatsu (Google 2025-07-23 1388) return -ENOMEM;
334e5519c37570 Masami Hiramatsu (Google 2023-06-06 1389) /* Make a new event name */
e2d0d7b2f42dca Masami Hiramatsu (Google 2023-06-06 1390) if (is_tracepoint)
d643eaa7082dc3 Masami Hiramatsu (Google 2025-07-23 1391) snprintf(ebuf, MAX_EVENT_NAME_LEN, "%s%s",
b576e09701c7d0 Masami Hiramatsu (Google 2023-06-06 1392) isdigit(*symbol) ? "_" : "", symbol);
e2d0d7b2f42dca Masami Hiramatsu (Google 2023-06-06 1393) else
d643eaa7082dc3 Masami Hiramatsu (Google 2025-07-23 1394) snprintf(ebuf, MAX_EVENT_NAME_LEN, "%s__%s", symbol,
334e5519c37570 Masami Hiramatsu (Google 2023-06-06 1395) is_return ? "exit" : "entry");
d643eaa7082dc3 Masami Hiramatsu (Google 2025-07-23 1396) sanitize_event_name(ebuf);
d643eaa7082dc3 Masami Hiramatsu (Google 2025-07-23 1397) event = ebuf;
334e5519c37570 Masami Hiramatsu (Google 2023-06-06 1398) }
334e5519c37570 Masami Hiramatsu (Google 2023-06-06 1399)
b576e09701c7d0 Masami Hiramatsu (Google 2023-06-06 1400) if (is_return)
8275637215bd3d Masami Hiramatsu (Google 2025-01-17 1401) ctx->flags |= TPARG_FL_RETURN;
b576e09701c7d0 Masami Hiramatsu (Google 2023-06-06 1402) else
8275637215bd3d Masami Hiramatsu (Google 2025-01-17 1403) ctx->flags |= TPARG_FL_FENTRY;
b576e09701c7d0 Masami Hiramatsu (Google 2023-06-06 1404)
2867495dea8632 Masami Hiramatsu (Google 2025-04-01 1405) ctx->funcname = NULL;
b576e09701c7d0 Masami Hiramatsu (Google 2023-06-06 1406) if (is_tracepoint) {
2867495dea8632 Masami Hiramatsu (Google 2025-04-01 1407) /* Get tracepoint and lock its module until the end of the registration. */
2867495dea8632 Masami Hiramatsu (Google 2025-04-01 1408) struct tracepoint *tpoint;
2867495dea8632 Masami Hiramatsu (Google 2025-04-01 1409)
8275637215bd3d Masami Hiramatsu (Google 2025-01-17 1410) ctx->flags |= TPARG_FL_TPOINT;
2867495dea8632 Masami Hiramatsu (Google 2025-04-01 1411) mod = NULL;
2867495dea8632 Masami Hiramatsu (Google 2025-04-01 1412) tpoint = find_tracepoint(symbol, &mod);
d643eaa7082dc3 Masami Hiramatsu (Google 2025-07-23 1413) if (tpoint) {
d643eaa7082dc3 Masami Hiramatsu (Google 2025-07-23 1414) sbuf = kmalloc(KSYM_NAME_LEN, GFP_KERNEL);
d643eaa7082dc3 Masami Hiramatsu (Google 2025-07-23 1415) if (!sbuf)
d643eaa7082dc3 Masami Hiramatsu (Google 2025-07-23 1416) return -ENOMEM;
2867495dea8632 Masami Hiramatsu (Google 2025-04-01 1417) ctx->funcname = kallsyms_lookup((unsigned long)tpoint->probestub,
2867495dea8632 Masami Hiramatsu (Google 2025-04-01 1418) NULL, NULL, NULL, sbuf);
b576e09701c7d0 Masami Hiramatsu (Google 2023-06-06 1419) }
d643eaa7082dc3 Masami Hiramatsu (Google 2025-07-23 1420) }
a90d508c939bee Seokwoo Chung (Ryan 2025-11-26 1421)
a90d508c939bee Seokwoo Chung (Ryan 2025-11-26 1422) if (!list_mode && !has_wildcard(symbol) && !is_tracepoint)
e3d6e1b9a34c74 Masami Hiramatsu (Google 2025-04-01 1423) ctx->funcname = symbol;
b576e09701c7d0 Masami Hiramatsu (Google 2023-06-06 1424)
d643eaa7082dc3 Masami Hiramatsu (Google 2025-07-23 1425) abuf = kmalloc(MAX_BTF_ARGS_LEN, GFP_KERNEL);
d643eaa7082dc3 Masami Hiramatsu (Google 2025-07-23 1426) if (!abuf)
d643eaa7082dc3 Masami Hiramatsu (Google 2025-07-23 1427) return -ENOMEM;
18b1e870a49671 Masami Hiramatsu (Google 2023-06-06 1428) argc -= 2; argv += 2;
18b1e870a49671 Masami Hiramatsu (Google 2023-06-06 1429) new_argv = traceprobe_expand_meta_args(argc, argv, &new_argc,
8275637215bd3d Masami Hiramatsu (Google 2025-01-17 1430) abuf, MAX_BTF_ARGS_LEN, ctx);
8275637215bd3d Masami Hiramatsu (Google 2025-01-17 1431) if (IS_ERR(new_argv))
8275637215bd3d Masami Hiramatsu (Google 2025-01-17 1432) return PTR_ERR(new_argv);
18b1e870a49671 Masami Hiramatsu (Google 2023-06-06 1433) if (new_argv) {
18b1e870a49671 Masami Hiramatsu (Google 2023-06-06 1434) argc = new_argc;
18b1e870a49671 Masami Hiramatsu (Google 2023-06-06 1435) argv = new_argv;
18b1e870a49671 Masami Hiramatsu (Google 2023-06-06 1436) }
57faaa04804ccb Masami Hiramatsu (Google 2025-03-27 1437) if (argc > MAX_TRACE_ARGS) {
57faaa04804ccb Masami Hiramatsu (Google 2025-03-27 1438) trace_probe_log_set_index(2);
57faaa04804ccb Masami Hiramatsu (Google 2025-03-27 1439) trace_probe_log_err(0, TOO_MANY_ARGS);
8275637215bd3d Masami Hiramatsu (Google 2025-01-17 1440) return -E2BIG;
57faaa04804ccb Masami Hiramatsu (Google 2025-03-27 1441) }
18b1e870a49671 Masami Hiramatsu (Google 2023-06-06 1442)
d9b15224dd8ff8 Ye Bin 2024-03-22 1443 ret = traceprobe_expand_dentry_args(argc, argv, &dbuf);
d9b15224dd8ff8 Ye Bin 2024-03-22 1444 if (ret)
8275637215bd3d Masami Hiramatsu (Google 2025-01-17 1445) return ret;
d9b15224dd8ff8 Ye Bin 2024-03-22 1446
334e5519c37570 Masami Hiramatsu (Google 2023-06-06 1447) /* setup a probe */
2867495dea8632 Masami Hiramatsu (Google 2025-04-01 1448) tf = alloc_trace_fprobe(group, event, symbol, argc, is_return, is_tracepoint);
334e5519c37570 Masami Hiramatsu (Google 2023-06-06 1449) if (IS_ERR(tf)) {
334e5519c37570 Masami Hiramatsu (Google 2023-06-06 1450) ret = PTR_ERR(tf);
334e5519c37570 Masami Hiramatsu (Google 2023-06-06 1451) /* This must return -ENOMEM, else there is a bug */
334e5519c37570 Masami Hiramatsu (Google 2023-06-06 1452) WARN_ON_ONCE(ret != -ENOMEM);
8275637215bd3d Masami Hiramatsu (Google 2025-01-17 1453) return ret;
334e5519c37570 Masami Hiramatsu (Google 2023-06-06 1454) }
e2d0d7b2f42dca Masami Hiramatsu (Google 2023-06-06 1455)
a90d508c939bee Seokwoo Chung (Ryan 2025-11-26 1456) /* carry list parsing result into tf */
a90d508c939bee Seokwoo Chung (Ryan 2025-11-26 1457) if (!is_tracepoint) {
a90d508c939bee Seokwoo Chung (Ryan 2025-11-26 1458) tf->list_mode = list_mode;
a90d508c939bee Seokwoo Chung (Ryan 2025-11-26 1459) if (parsed_filter) {
a90d508c939bee Seokwoo Chung (Ryan 2025-11-26 1460) tf->filter = kstrdup(parsed_filter, GFP_KERNEL);
a90d508c939bee Seokwoo Chung (Ryan 2025-11-26 1461) if (!tf->filter)
a90d508c939bee Seokwoo Chung (Ryan 2025-11-26 1462) return -ENOMEM;
a90d508c939bee Seokwoo Chung (Ryan 2025-11-26 1463) }
a90d508c939bee Seokwoo Chung (Ryan 2025-11-26 1464) if (parsed_nofilter) {
a90d508c939bee Seokwoo Chung (Ryan 2025-11-26 1465) tf->nofilter = kstrdup(parsed_nofilter, GFP_KERNEL);
a90d508c939bee Seokwoo Chung (Ryan 2025-11-26 1466) if (!tf->nofilter)
a90d508c939bee Seokwoo Chung (Ryan 2025-11-26 1467) return -ENOMEM;
a90d508c939bee Seokwoo Chung (Ryan 2025-11-26 1468) }
a90d508c939bee Seokwoo Chung (Ryan 2025-11-26 1469) }
a90d508c939bee Seokwoo Chung (Ryan 2025-11-26 1470)
334e5519c37570 Masami Hiramatsu (Google 2023-06-06 1471) /* parse arguments */
73f35080477e89 Mikel Rychliski 2024-09-30 1472 for (i = 0; i < argc; i++) {
334e5519c37570 Masami Hiramatsu (Google 2023-06-06 1473) trace_probe_log_set_index(i + 2);
8275637215bd3d Masami Hiramatsu (Google 2025-01-17 1474) ctx->offset = 0;
8275637215bd3d Masami Hiramatsu (Google 2025-01-17 1475) ret = traceprobe_parse_probe_arg(&tf->tp, i, argv[i], ctx);
334e5519c37570 Masami Hiramatsu (Google 2023-06-06 1476) if (ret)
8275637215bd3d Masami Hiramatsu (Google 2025-01-17 1477) return ret; /* This can be -ENOMEM */
334e5519c37570 Masami Hiramatsu (Google 2023-06-06 1478) }
334e5519c37570 Masami Hiramatsu (Google 2023-06-06 1479)
25f00e40ce7953 Masami Hiramatsu (Google 2024-03-04 1480) if (is_return && tf->tp.entry_arg) {
25f00e40ce7953 Masami Hiramatsu (Google 2024-03-04 1481) tf->fp.entry_handler = trace_fprobe_entry_handler;
25f00e40ce7953 Masami Hiramatsu (Google 2024-03-04 1482) tf->fp.entry_data_size = traceprobe_get_entry_data_size(&tf->tp);
db5e228611b118 Masami Hiramatsu (Google 2025-02-26 1483) if (ALIGN(tf->fp.entry_data_size, sizeof(long)) > MAX_FPROBE_DATA_SIZE) {
db5e228611b118 Masami Hiramatsu (Google 2025-02-26 1484) trace_probe_log_set_index(2);
db5e228611b118 Masami Hiramatsu (Google 2025-02-26 1485) trace_probe_log_err(0, TOO_MANY_EARGS);
db5e228611b118 Masami Hiramatsu (Google 2025-02-26 1486) return -E2BIG;
db5e228611b118 Masami Hiramatsu (Google 2025-02-26 1487) }
25f00e40ce7953 Masami Hiramatsu (Google 2024-03-04 1488) }
25f00e40ce7953 Masami Hiramatsu (Google 2024-03-04 1489)
334e5519c37570 Masami Hiramatsu (Google 2023-06-06 1490) ret = traceprobe_set_print_fmt(&tf->tp,
334e5519c37570 Masami Hiramatsu (Google 2023-06-06 1491) is_return ? PROBE_PRINT_RETURN : PROBE_PRINT_NORMAL);
334e5519c37570 Masami Hiramatsu (Google 2023-06-06 1492) if (ret < 0)
8275637215bd3d Masami Hiramatsu (Google 2025-01-17 1493) return ret;
334e5519c37570 Masami Hiramatsu (Google 2023-06-06 1494)
2db832ec9090d3 Masami Hiramatsu (Google 2025-04-01 1495) ret = register_trace_fprobe_event(tf);
334e5519c37570 Masami Hiramatsu (Google 2023-06-06 1496) if (ret) {
334e5519c37570 Masami Hiramatsu (Google 2023-06-06 1497) trace_probe_log_set_index(1);
334e5519c37570 Masami Hiramatsu (Google 2023-06-06 1498) if (ret == -EILSEQ)
334e5519c37570 Masami Hiramatsu (Google 2023-06-06 1499) trace_probe_log_err(0, BAD_INSN_BNDRY);
334e5519c37570 Masami Hiramatsu (Google 2023-06-06 1500) else if (ret == -ENOENT)
334e5519c37570 Masami Hiramatsu (Google 2023-06-06 1501) trace_probe_log_err(0, BAD_PROBE_ADDR);
334e5519c37570 Masami Hiramatsu (Google 2023-06-06 1502) else if (ret != -ENOMEM && ret != -EEXIST)
334e5519c37570 Masami Hiramatsu (Google 2023-06-06 1503) trace_probe_log_err(0, FAIL_REG_PROBE);
8275637215bd3d Masami Hiramatsu (Google 2025-01-17 1504) return -EINVAL;
334e5519c37570 Masami Hiramatsu (Google 2023-06-06 1505) }
334e5519c37570 Masami Hiramatsu (Google 2023-06-06 1506)
8275637215bd3d Masami Hiramatsu (Google 2025-01-17 1507) /* 'tf' is successfully registered. To avoid freeing, assign NULL. */
8275637215bd3d Masami Hiramatsu (Google 2025-01-17 1508) tf = NULL;
8275637215bd3d Masami Hiramatsu (Google 2025-01-17 1509)
8275637215bd3d Masami Hiramatsu (Google 2025-01-17 1510) return 0;
8275637215bd3d Masami Hiramatsu (Google 2025-01-17 1511) }
8275637215bd3d Masami Hiramatsu (Google 2025-01-17 1512)
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply
* Re: 答复: [External Mail]Re: [PATCH v3] dma-buf: add some tracepoints to debug.
From: Christian König @ 2025-11-27 14:08 UTC (permalink / raw)
To: 高翔, Xiang Gao, sumit.semwal@linaro.org,
rostedt@goodmis.org, mhiramat@kernel.org
Cc: 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
In-Reply-To: <f8233e36f4d74643a424180d1bd66d47@xiaomi.com>
On 11/27/25 15:05, 高翔 wrote:
>> Exporting the tracepoints is unecessary as far as I can see
>
> android must export symbols before adding a whitelist.
Hui? Why would you add those symbols to any whitelist?
>
>
>> I can't come up with a reason why we should have the file refcount in the trace logs.
>> Same for most other places.
> I can directly observe how refcnt is changing. Then it can be known where the dmabuf was finally released.
The refcnt is manipulated outside of the DMA-buf code by the filesystem layer.
As far as I can see it is meaningless here.
Regards,
Christian.
>
>
>> Print the dev_name last, it's the external device which attaches to the DMA-buf.
> ok.
>
>
>> Additional to that it would be nice to know if the attachment is dynamic or not.
> ok.
>
> ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
> *发件人:* Christian König <christian.koenig@amd.com>
> *发送时间:* 2025年11月27日 17:49:09
> *收件人:* 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 v3] dma-buf: add some tracepoints to debug.
>
> [外部邮件] 此邮件来源于小米公司外部,请谨慎处理。若对邮件安全性存疑,请将邮件转发给misec@xiaomi.com进行反馈
>
> On 11/27/25 01:43, Xiang Gao 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.
>>
>> For example:
>> binder:2962_2-2962 [005] ...1. 208.453940: dma_buf_export: exp_name=qcom,system name=(null) size=28672 ino=2580 f_refcnt=2
>> binder:2962_2-2962 [005] ...1. 208.453943: dma_buf_fd: exp_name=qcom,system name=(null) size=28672 ino=2580 fd=9 f_refcnt=2
>> binder:2962_2-2962 [005] ...1. 208.453977: dma_buf_mmap_internal: exp_name=qcom,system name=qcom,system size=28672 ino=2580 f_refcnt=4
>> kworker/5:2-194 [005] ...1. 208.460580: dma_buf_put: exp_name=qcom,system name=ab pid [8176] size=28672 ino=2580 f_refcnt=3
>> RenderThread-11305 [007] ...1. 208.599094: dma_buf_get: exp_name=qcom,system name=ab pid [8176] size=217088 ino=2579 fd=1114 f_refcnt=7
>> RenderThread-11305 [007] ...1. 208.599098: dma_buf_attach: dev_name=kgsl-3d0 exp_name=qcom,system name=ab pid [8176] size=217088 ino=2579 f_refcnt=7
>> <...>-14 [001] ...1. 208.726359: dma_buf_detach: dev_name=kgsl-3d0 exp_name=qcom,system name=ab pid [3317] size=217088 ino=2581 f_refcnt=3
>>
>> Signed-off-by: Xiang Gao <gaoxiang17@xiaomi.com>
>> ---
>> drivers/dma-buf/dma-buf.c | 57 ++++++++++-
>> include/trace/events/dma_buf.h | 166 +++++++++++++++++++++++++++++++++
>> 2 files changed, 222 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..7cef816ddcac 100644
>> --- a/drivers/dma-buf/dma-buf.c
>> +++ b/drivers/dma-buf/dma-buf.c
>> @@ -35,6 +35,18 @@
>>
>> #include "dma-buf-sysfs-stats.h"
>>
>> +#define CREATE_TRACE_POINTS
>> +#include <trace/events/dma_buf.h>
>> +
>> +EXPORT_TRACEPOINT_SYMBOL(dma_buf_export);
>> +EXPORT_TRACEPOINT_SYMBOL(dma_buf_mmap_internal);
>> +EXPORT_TRACEPOINT_SYMBOL(dma_buf_mmap);
>> +EXPORT_TRACEPOINT_SYMBOL(dma_buf_put);
>> +EXPORT_TRACEPOINT_SYMBOL(dma_buf_attach);
>> +EXPORT_TRACEPOINT_SYMBOL(dma_buf_detach);
>> +EXPORT_TRACEPOINT_SYMBOL(dma_buf_fd);
>> +EXPORT_TRACEPOINT_SYMBOL(dma_buf_get);
>
> Exporting the tracepoints is unecessary as far as I can see
>
>> +
>> static inline int is_dma_buf_file(struct file *);
>>
>> static DEFINE_MUTEX(dmabuf_list_mutex);
>> @@ -220,6 +232,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 +762,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);
>> + }
>> +
>> return dmabuf;
>>
>> err_dmabuf:
>> @@ -779,6 +801,11 @@ int dma_buf_fd(struct dma_buf *dmabuf, int flags)
>>
>> fd_install(fd, dmabuf->file);
>>
>> + if (trace_dma_buf_fd_enabled()) {
>> + guard(spinlock)(&dmabuf->name_lock);
>> + trace_dma_buf_fd(dmabuf, fd);
>> + }
>> +
>> return fd;
>> }
>> EXPORT_SYMBOL_NS_GPL(dma_buf_fd, "DMA_BUF");
>> @@ -794,6 +821,7 @@ EXPORT_SYMBOL_NS_GPL(dma_buf_fd, "DMA_BUF");
>> struct dma_buf *dma_buf_get(int fd)
>> {
>> struct file *file;
>> + struct dma_buf *dmabuf;
>>
>> file = fget(fd);
>>
>> @@ -805,7 +833,14 @@ struct dma_buf *dma_buf_get(int fd)
>> return ERR_PTR(-EINVAL);
>> }
>>
>> - return file->private_data;
>> + dmabuf = file->private_data;
>> +
>> + if (trace_dma_buf_get_enabled()) {
>> + guard(spinlock)(&dmabuf->name_lock);
>> + trace_dma_buf_get(dmabuf, fd);
>> + }
>> +
>> + return dmabuf;
>> }
>> EXPORT_SYMBOL_NS_GPL(dma_buf_get, "DMA_BUF");
>>
>> @@ -825,6 +860,11 @@ void dma_buf_put(struct dma_buf *dmabuf)
>> return;
>>
>> fput(dmabuf->file);
>> +
>> + if (trace_dma_buf_put_enabled()) {
>> + guard(spinlock)(&dmabuf->name_lock);
>> + trace_dma_buf_put(dmabuf);
>> + }
>> }
>> EXPORT_SYMBOL_NS_GPL(dma_buf_put, "DMA_BUF");
>>
>> @@ -998,6 +1038,11 @@ EXPORT_SYMBOL_NS_GPL(dma_buf_dynamic_attach, "DMA_BUF");
>> struct dma_buf_attachment *dma_buf_attach(struct dma_buf *dmabuf,
>> struct device *dev)
>> {
>> + if (trace_dma_buf_attach_enabled()) {
>> + guard(spinlock)(&dmabuf->name_lock);
>> + trace_dma_buf_attach(dmabuf, dev);
>> + }
>> +
>> return dma_buf_dynamic_attach(dmabuf, dev, NULL, NULL);
>> }
>> EXPORT_SYMBOL_NS_GPL(dma_buf_attach, "DMA_BUF");
>> @@ -1023,6 +1068,11 @@ void dma_buf_detach(struct dma_buf *dmabuf, struct dma_buf_attachment *attach)
>> if (dmabuf->ops->detach)
>> dmabuf->ops->detach(dmabuf, attach);
>>
>> + if (trace_dma_buf_detach_enabled()) {
>> + guard(spinlock)(&dmabuf->name_lock);
>> + trace_dma_buf_detach(dmabuf, attach->dev);
>> + }
>> +
>> kfree(attach);
>> }
>> EXPORT_SYMBOL_NS_GPL(dma_buf_detach, "DMA_BUF");
>> @@ -1488,6 +1538,11 @@ int dma_buf_mmap(struct dma_buf *dmabuf, struct vm_area_struct *vma,
>> vma_set_file(vma, dmabuf->file);
>> vma->vm_pgoff = pgoff;
>>
>> + if (trace_dma_buf_mmap_enabled()) {
>> + guard(spinlock)(&dmabuf->name_lock);
>> + trace_dma_buf_mmap(dmabuf);
>> + }
>> +
>> return dmabuf->ops->mmap(dmabuf, vma);
>> }
>> EXPORT_SYMBOL_NS_GPL(dma_buf_mmap, "DMA_BUF");
>> diff --git a/include/trace/events/dma_buf.h b/include/trace/events/dma_buf.h
>> new file mode 100644
>> index 000000000000..fe9da89bacd0
>> --- /dev/null
>> +++ b/include/trace/events/dma_buf.h
>> @@ -0,0 +1,166 @@
>> +/* 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>
>> +
>> +DECLARE_EVENT_CLASS(dma_buf,
>> +
>> + 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);
>> + __assign_str(name);
>> + __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)
>
> I can't come up with a reason why we should have the file refcount in the trace logs.
>
> Same for most other places.
>
>> +);
>> +
>> +DECLARE_EVENT_CLASS(dma_buf_attach_dev,
>> +
>> + 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);
>> + __assign_str(name);
>> + __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)
>
> Print the dev_name last, it's the external device which attaches to the DMA-buf.
>
> Additional to that it would be nice to know if the attachment is dynamic or not.
>
> Regards,
> Christian.
>
>> +);
>> +
>> +DECLARE_EVENT_CLASS(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);
>> + __assign_str(name);
>> + __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)
>> +);
>> +
>> +DEFINE_EVENT(dma_buf, dma_buf_export,
>> +
>> + TP_PROTO(struct dma_buf *dmabuf),
>> +
>> + TP_ARGS(dmabuf)
>> +);
>> +
>> +DEFINE_EVENT(dma_buf, dma_buf_mmap_internal,
>> +
>> + TP_PROTO(struct dma_buf *dmabuf),
>> +
>> + TP_ARGS(dmabuf)
>> +);
>> +
>> +DEFINE_EVENT(dma_buf, dma_buf_mmap,
>> +
>> + TP_PROTO(struct dma_buf *dmabuf),
>> +
>> + TP_ARGS(dmabuf)
>> +);
>> +
>> +DEFINE_EVENT(dma_buf, dma_buf_put,
>> +
>> + TP_PROTO(struct dma_buf *dmabuf),
>> +
>> + TP_ARGS(dmabuf)
>> +);
>> +
>> +DEFINE_EVENT(dma_buf_attach_dev, dma_buf_attach,
>> +
>> + TP_PROTO(struct dma_buf *dmabuf, struct device *dev),
>> +
>> + TP_ARGS(dmabuf, dev)
>> +);
>> +
>> +DEFINE_EVENT(dma_buf_attach_dev, dma_buf_detach,
>> +
>> + TP_PROTO(struct dma_buf *dmabuf, struct device *dev),
>> +
>> + TP_ARGS(dmabuf, dev)
>> +);
>> +
>> +DEFINE_EVENT(dma_buf_fd, dma_buf_fd,
>> +
>> + TP_PROTO(struct dma_buf *dmabuf, int fd),
>> +
>> + TP_ARGS(dmabuf, fd)
>> +);
>> +
>> +DEFINE_EVENT(dma_buf_fd, dma_buf_get,
>> +
>> + TP_PROTO(struct dma_buf *dmabuf, int fd),
>> +
>> + TP_ARGS(dmabuf, fd)
>> +);
>> +
>> +#endif /* _TRACE_DMA_BUF_H */
>> +
>> +/* This part must be outside protection */
>> +#include <trace/define_trace.h>
>
^ permalink raw reply
* Re: [PATCH v4 2/3] tracing/fprobe: Support comma-separated symbols and :entry/:exit
From: kernel test robot @ 2025-11-27 12:12 UTC (permalink / raw)
To: Seokwoo Chung (Ryan), rostedt, mhiramat, corbet, shuah
Cc: oe-kbuild-all, mathieu.desnoyers, linux-kernel,
linux-trace-kernel, linux-doc, linux-kselftest,
Seokwoo Chung (Ryan)
In-Reply-To: <20251126184110.72241-3-seokwoo.chung130@gmail.com>
Hi Seokwoo,
kernel test robot noticed the following build warnings:
[auto build test WARNING on trace/for-next]
[also build test WARNING on linus/master v6.18-rc7 next-20251127]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Seokwoo-Chung-Ryan/docs-tracing-fprobe-Document-list-filters-and-entry-exit/20251127-024245
base: https://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace for-next
patch link: https://lore.kernel.org/r/20251126184110.72241-3-seokwoo.chung130%40gmail.com
patch subject: [PATCH v4 2/3] tracing/fprobe: Support comma-separated symbols and :entry/:exit
config: x86_64-randconfig-003-20251127 (https://download.01.org/0day-ci/archive/20251127/202511271925.xuaUx8bB-lkp@intel.com/config)
compiler: gcc-14 (Debian 14.2.0-19) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251127/202511271925.xuaUx8bB-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202511271925.xuaUx8bB-lkp@intel.com/
All warnings (new ones prefixed by >>):
kernel/trace/trace_fprobe.c: In function 'parse_fprobe_spec':
kernel/trace/trace_fprobe.c:1282:12: error: invalid storage class for function 'trace_fprobe_create_internal'
1282 | static int trace_fprobe_create_internal(int argc, const char *argv[],
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
kernel/trace/trace_fprobe.c:1513:12: error: invalid storage class for function 'trace_fprobe_create_cb'
1513 | static int trace_fprobe_create_cb(int argc, const char *argv[])
| ^~~~~~~~~~~~~~~~~~~~~~
kernel/trace/trace_fprobe.c:1530:12: error: invalid storage class for function 'trace_fprobe_create'
1530 | static int trace_fprobe_create(const char *raw_command)
| ^~~~~~~~~~~~~~~~~~~
kernel/trace/trace_fprobe.c:1535:12: error: invalid storage class for function 'trace_fprobe_release'
1535 | static int trace_fprobe_release(struct dyn_event *ev)
| ^~~~~~~~~~~~~~~~~~~~
kernel/trace/trace_fprobe.c:1545:12: error: invalid storage class for function 'trace_fprobe_show'
1545 | static int trace_fprobe_show(struct seq_file *m, struct dyn_event *ev)
| ^~~~~~~~~~~~~~~~~
kernel/trace/trace_fprobe.c:1572:12: error: invalid storage class for function 'enable_trace_fprobe'
1572 | static int enable_trace_fprobe(struct trace_event_call *call,
| ^~~~~~~~~~~~~~~~~~~
kernel/trace/trace_fprobe.c:1608:12: error: invalid storage class for function 'disable_trace_fprobe'
1608 | static int disable_trace_fprobe(struct trace_event_call *call,
| ^~~~~~~~~~~~~~~~~~~~
kernel/trace/trace_fprobe.c:1653:12: error: invalid storage class for function 'fprobe_register'
1653 | static int fprobe_register(struct trace_event_call *event,
| ^~~~~~~~~~~~~~~
kernel/trace/trace_fprobe.c:1683:19: error: invalid storage class for function 'init_fprobe_trace_early'
1683 | static __init int init_fprobe_trace_early(void)
| ^~~~~~~~~~~~~~~~~~~~~~~
In file included from include/linux/fprobe.h:6,
from kernel/trace/trace_fprobe.c:8:
include/linux/compiler.h:286:52: error: initializer element is not constant
286 | __UNIQUE_ID(__PASTE(__addressable_,sym)) = (void *)(uintptr_t)&sym;
| ^
include/linux/compiler.h:289:9: note: in expansion of macro '___ADDRESSABLE'
289 | ___ADDRESSABLE(sym, __section(".discard.addressable"))
| ^~~~~~~~~~~~~~
include/linux/init.h:250:9: note: in expansion of macro '__ADDRESSABLE'
250 | __ADDRESSABLE(fn)
| ^~~~~~~~~~~~~
include/linux/init.h:255:9: note: in expansion of macro '__define_initcall_stub'
255 | __define_initcall_stub(__stub, fn) \
| ^~~~~~~~~~~~~~~~~~~~~~
include/linux/init.h:268:9: note: in expansion of macro '____define_initcall'
268 | ____define_initcall(fn, \
| ^~~~~~~~~~~~~~~~~~~
include/linux/init.h:274:9: note: in expansion of macro '__unique_initcall'
274 | __unique_initcall(fn, id, __sec, __initcall_id(fn))
| ^~~~~~~~~~~~~~~~~
include/linux/init.h:276:35: note: in expansion of macro '___define_initcall'
276 | #define __define_initcall(fn, id) ___define_initcall(fn, id, .initcall##id)
| ^~~~~~~~~~~~~~~~~~
include/linux/init.h:294:41: note: in expansion of macro '__define_initcall'
294 | #define core_initcall(fn) __define_initcall(fn, 1)
| ^~~~~~~~~~~~~~~~~
kernel/trace/trace_fprobe.c:1702:1: note: in expansion of macro 'core_initcall'
1702 | core_initcall(init_fprobe_trace_early);
| ^~~~~~~~~~~~~
kernel/trace/trace_fprobe.c:1702:1: error: expected declaration or statement at end of input
kernel/trace/trace_fprobe.c: At top level:
>> kernel/trace/trace_fprobe.c:28:12: warning: 'trace_fprobe_create' used but never defined
28 | static int trace_fprobe_create(const char *raw_command);
| ^~~~~~~~~~~~~~~~~~~
>> kernel/trace/trace_fprobe.c:29:12: warning: 'trace_fprobe_show' used but never defined
29 | static int trace_fprobe_show(struct seq_file *m, struct dyn_event *ev);
| ^~~~~~~~~~~~~~~~~
>> kernel/trace/trace_fprobe.c:30:12: warning: 'trace_fprobe_release' used but never defined
30 | static int trace_fprobe_release(struct dyn_event *ev);
| ^~~~~~~~~~~~~~~~~~~~
>> kernel/trace/trace_fprobe.c:741:12: warning: 'fprobe_register' used but never defined
741 | static int fprobe_register(struct trace_event_call *event,
| ^~~~~~~~~~~~~~~
>> kernel/trace/trace_fprobe.c:1653:12: warning: 'fprobe_register' defined but not used [-Wunused-function]
1653 | static int fprobe_register(struct trace_event_call *event,
| ^~~~~~~~~~~~~~~
>> kernel/trace/trace_fprobe.c:1545:12: warning: 'trace_fprobe_show' defined but not used [-Wunused-function]
1545 | static int trace_fprobe_show(struct seq_file *m, struct dyn_event *ev)
| ^~~~~~~~~~~~~~~~~
>> kernel/trace/trace_fprobe.c:1535:12: warning: 'trace_fprobe_release' defined but not used [-Wunused-function]
1535 | static int trace_fprobe_release(struct dyn_event *ev)
| ^~~~~~~~~~~~~~~~~~~~
>> kernel/trace/trace_fprobe.c:1530:12: warning: 'trace_fprobe_create' defined but not used [-Wunused-function]
1530 | static int trace_fprobe_create(const char *raw_command)
| ^~~~~~~~~~~~~~~~~~~
vim +/trace_fprobe_create +28 kernel/trace/trace_fprobe.c
334e5519c37570 Masami Hiramatsu (Google 2023-06-06 27)
334e5519c37570 Masami Hiramatsu (Google 2023-06-06 @28) static int trace_fprobe_create(const char *raw_command);
334e5519c37570 Masami Hiramatsu (Google 2023-06-06 @29) static int trace_fprobe_show(struct seq_file *m, struct dyn_event *ev);
334e5519c37570 Masami Hiramatsu (Google 2023-06-06 @30) static int trace_fprobe_release(struct dyn_event *ev);
334e5519c37570 Masami Hiramatsu (Google 2023-06-06 31) static bool trace_fprobe_is_busy(struct dyn_event *ev);
334e5519c37570 Masami Hiramatsu (Google 2023-06-06 32) static bool trace_fprobe_match(const char *system, const char *event,
334e5519c37570 Masami Hiramatsu (Google 2023-06-06 33) int argc, const char **argv, struct dyn_event *ev);
334e5519c37570 Masami Hiramatsu (Google 2023-06-06 34)
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply
* Re: [PATCH v3] dma-buf: add some tracepoints to debug.
From: Christian König @ 2025-11-27 9:49 UTC (permalink / raw)
To: Xiang Gao, sumit.semwal, rostedt, mhiramat
Cc: linux-media, dri-devel, linux-kernel, mathieu.desnoyers, dhowells,
kuba, brauner, akpm, linux-trace-kernel, gaoxiang17
In-Reply-To: <20251127004352.376307-1-gxxa03070307@gmail.com>
On 11/27/25 01:43, Xiang Gao 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.
>
> For example:
> binder:2962_2-2962 [005] ...1. 208.453940: dma_buf_export: exp_name=qcom,system name=(null) size=28672 ino=2580 f_refcnt=2
> binder:2962_2-2962 [005] ...1. 208.453943: dma_buf_fd: exp_name=qcom,system name=(null) size=28672 ino=2580 fd=9 f_refcnt=2
> binder:2962_2-2962 [005] ...1. 208.453977: dma_buf_mmap_internal: exp_name=qcom,system name=qcom,system size=28672 ino=2580 f_refcnt=4
> kworker/5:2-194 [005] ...1. 208.460580: dma_buf_put: exp_name=qcom,system name=ab pid [8176] size=28672 ino=2580 f_refcnt=3
> RenderThread-11305 [007] ...1. 208.599094: dma_buf_get: exp_name=qcom,system name=ab pid [8176] size=217088 ino=2579 fd=1114 f_refcnt=7
> RenderThread-11305 [007] ...1. 208.599098: dma_buf_attach: dev_name=kgsl-3d0 exp_name=qcom,system name=ab pid [8176] size=217088 ino=2579 f_refcnt=7
> <...>-14 [001] ...1. 208.726359: dma_buf_detach: dev_name=kgsl-3d0 exp_name=qcom,system name=ab pid [3317] size=217088 ino=2581 f_refcnt=3
>
> Signed-off-by: Xiang Gao <gaoxiang17@xiaomi.com>
> ---
> drivers/dma-buf/dma-buf.c | 57 ++++++++++-
> include/trace/events/dma_buf.h | 166 +++++++++++++++++++++++++++++++++
> 2 files changed, 222 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..7cef816ddcac 100644
> --- a/drivers/dma-buf/dma-buf.c
> +++ b/drivers/dma-buf/dma-buf.c
> @@ -35,6 +35,18 @@
>
> #include "dma-buf-sysfs-stats.h"
>
> +#define CREATE_TRACE_POINTS
> +#include <trace/events/dma_buf.h>
> +
> +EXPORT_TRACEPOINT_SYMBOL(dma_buf_export);
> +EXPORT_TRACEPOINT_SYMBOL(dma_buf_mmap_internal);
> +EXPORT_TRACEPOINT_SYMBOL(dma_buf_mmap);
> +EXPORT_TRACEPOINT_SYMBOL(dma_buf_put);
> +EXPORT_TRACEPOINT_SYMBOL(dma_buf_attach);
> +EXPORT_TRACEPOINT_SYMBOL(dma_buf_detach);
> +EXPORT_TRACEPOINT_SYMBOL(dma_buf_fd);
> +EXPORT_TRACEPOINT_SYMBOL(dma_buf_get);
Exporting the tracepoints is unecessary as far as I can see
> +
> static inline int is_dma_buf_file(struct file *);
>
> static DEFINE_MUTEX(dmabuf_list_mutex);
> @@ -220,6 +232,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 +762,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);
> + }
> +
> return dmabuf;
>
> err_dmabuf:
> @@ -779,6 +801,11 @@ int dma_buf_fd(struct dma_buf *dmabuf, int flags)
>
> fd_install(fd, dmabuf->file);
>
> + if (trace_dma_buf_fd_enabled()) {
> + guard(spinlock)(&dmabuf->name_lock);
> + trace_dma_buf_fd(dmabuf, fd);
> + }
> +
> return fd;
> }
> EXPORT_SYMBOL_NS_GPL(dma_buf_fd, "DMA_BUF");
> @@ -794,6 +821,7 @@ EXPORT_SYMBOL_NS_GPL(dma_buf_fd, "DMA_BUF");
> struct dma_buf *dma_buf_get(int fd)
> {
> struct file *file;
> + struct dma_buf *dmabuf;
>
> file = fget(fd);
>
> @@ -805,7 +833,14 @@ struct dma_buf *dma_buf_get(int fd)
> return ERR_PTR(-EINVAL);
> }
>
> - return file->private_data;
> + dmabuf = file->private_data;
> +
> + if (trace_dma_buf_get_enabled()) {
> + guard(spinlock)(&dmabuf->name_lock);
> + trace_dma_buf_get(dmabuf, fd);
> + }
> +
> + return dmabuf;
> }
> EXPORT_SYMBOL_NS_GPL(dma_buf_get, "DMA_BUF");
>
> @@ -825,6 +860,11 @@ void dma_buf_put(struct dma_buf *dmabuf)
> return;
>
> fput(dmabuf->file);
> +
> + if (trace_dma_buf_put_enabled()) {
> + guard(spinlock)(&dmabuf->name_lock);
> + trace_dma_buf_put(dmabuf);
> + }
> }
> EXPORT_SYMBOL_NS_GPL(dma_buf_put, "DMA_BUF");
>
> @@ -998,6 +1038,11 @@ EXPORT_SYMBOL_NS_GPL(dma_buf_dynamic_attach, "DMA_BUF");
> struct dma_buf_attachment *dma_buf_attach(struct dma_buf *dmabuf,
> struct device *dev)
> {
> + if (trace_dma_buf_attach_enabled()) {
> + guard(spinlock)(&dmabuf->name_lock);
> + trace_dma_buf_attach(dmabuf, dev);
> + }
> +
> return dma_buf_dynamic_attach(dmabuf, dev, NULL, NULL);
> }
> EXPORT_SYMBOL_NS_GPL(dma_buf_attach, "DMA_BUF");
> @@ -1023,6 +1068,11 @@ void dma_buf_detach(struct dma_buf *dmabuf, struct dma_buf_attachment *attach)
> if (dmabuf->ops->detach)
> dmabuf->ops->detach(dmabuf, attach);
>
> + if (trace_dma_buf_detach_enabled()) {
> + guard(spinlock)(&dmabuf->name_lock);
> + trace_dma_buf_detach(dmabuf, attach->dev);
> + }
> +
> kfree(attach);
> }
> EXPORT_SYMBOL_NS_GPL(dma_buf_detach, "DMA_BUF");
> @@ -1488,6 +1538,11 @@ int dma_buf_mmap(struct dma_buf *dmabuf, struct vm_area_struct *vma,
> vma_set_file(vma, dmabuf->file);
> vma->vm_pgoff = pgoff;
>
> + if (trace_dma_buf_mmap_enabled()) {
> + guard(spinlock)(&dmabuf->name_lock);
> + trace_dma_buf_mmap(dmabuf);
> + }
> +
> return dmabuf->ops->mmap(dmabuf, vma);
> }
> EXPORT_SYMBOL_NS_GPL(dma_buf_mmap, "DMA_BUF");
> diff --git a/include/trace/events/dma_buf.h b/include/trace/events/dma_buf.h
> new file mode 100644
> index 000000000000..fe9da89bacd0
> --- /dev/null
> +++ b/include/trace/events/dma_buf.h
> @@ -0,0 +1,166 @@
> +/* 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>
> +
> +DECLARE_EVENT_CLASS(dma_buf,
> +
> + 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);
> + __assign_str(name);
> + __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)
I can't come up with a reason why we should have the file refcount in the trace logs.
Same for most other places.
> +);
> +
> +DECLARE_EVENT_CLASS(dma_buf_attach_dev,
> +
> + 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);
> + __assign_str(name);
> + __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)
Print the dev_name last, it's the external device which attaches to the DMA-buf.
Additional to that it would be nice to know if the attachment is dynamic or not.
Regards,
Christian.
> +);
> +
> +DECLARE_EVENT_CLASS(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);
> + __assign_str(name);
> + __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)
> +);
> +
> +DEFINE_EVENT(dma_buf, dma_buf_export,
> +
> + TP_PROTO(struct dma_buf *dmabuf),
> +
> + TP_ARGS(dmabuf)
> +);
> +
> +DEFINE_EVENT(dma_buf, dma_buf_mmap_internal,
> +
> + TP_PROTO(struct dma_buf *dmabuf),
> +
> + TP_ARGS(dmabuf)
> +);
> +
> +DEFINE_EVENT(dma_buf, dma_buf_mmap,
> +
> + TP_PROTO(struct dma_buf *dmabuf),
> +
> + TP_ARGS(dmabuf)
> +);
> +
> +DEFINE_EVENT(dma_buf, dma_buf_put,
> +
> + TP_PROTO(struct dma_buf *dmabuf),
> +
> + TP_ARGS(dmabuf)
> +);
> +
> +DEFINE_EVENT(dma_buf_attach_dev, dma_buf_attach,
> +
> + TP_PROTO(struct dma_buf *dmabuf, struct device *dev),
> +
> + TP_ARGS(dmabuf, dev)
> +);
> +
> +DEFINE_EVENT(dma_buf_attach_dev, dma_buf_detach,
> +
> + TP_PROTO(struct dma_buf *dmabuf, struct device *dev),
> +
> + TP_ARGS(dmabuf, dev)
> +);
> +
> +DEFINE_EVENT(dma_buf_fd, dma_buf_fd,
> +
> + TP_PROTO(struct dma_buf *dmabuf, int fd),
> +
> + TP_ARGS(dmabuf, fd)
> +);
> +
> +DEFINE_EVENT(dma_buf_fd, dma_buf_get,
> +
> + TP_PROTO(struct dma_buf *dmabuf, int fd),
> +
> + TP_ARGS(dmabuf, fd)
> +);
> +
> +#endif /* _TRACE_DMA_BUF_H */
> +
> +/* This part must be outside protection */
> +#include <trace/define_trace.h>
^ permalink raw reply
* Re: [PATCH] overflow: Introduce struct_offset() to get offset of member
From: Kees Cook @ 2025-11-27 7:58 UTC (permalink / raw)
To: Steven Rostedt
Cc: LKML, linux-hardening, Linux Trace Kernel, Masami Hiramatsu,
Mathieu Desnoyers, Linus Torvalds, Gustavo A. R. Silva
In-Reply-To: <20251126145249.05b1770a@gandalf.local.home>
On Wed, Nov 26, 2025 at 02:52:49PM -0500, Steven Rostedt wrote:
> From: Steven Rostedt <rostedt@goodmis.org>
>
> The trace_marker_raw file in tracefs takes a buffer from user space that
> contains an id as well as a raw data string which is usually a binary
> structure. The structure used has the following:
>
> struct raw_data_entry {
> struct trace_entry ent;
> unsigned int id;
> char buf[];
> };
>
> Since the passed in "cnt" variable is both the size of buf as well as the
> size of id, the code to allocate the location on the ring buffer had:
>
> size = struct_size(entry, buf, cnt - sizeof(entry->id));
>
> Which is quite ugly and hard to understand. Instead, add a helper macro
> called struct_offset() which then changes the above to a simple and easy
> to understand:
>
> size = struct_offset(entry, id) + cnt;
>
> This will likely come in handy for other use cases too.
>
> Link: https://lore.kernel.org/all/CAHk-=whYZVoEdfO1PmtbirPdBMTV9Nxt9f09CK0k6S+HJD3Zmg@mail.gmail.com/
>
> Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Works for me!
Reviewed-by: Kees Cook <kees@kernel.org>
> ---
> include/linux/overflow.h | 12 ++++++++++++
> kernel/trace/trace.c | 2 +-
> 2 files changed, 13 insertions(+), 1 deletion(-)
>
> diff --git a/include/linux/overflow.h b/include/linux/overflow.h
> index 725f95f7e416..736f633b2d5f 100644
> --- a/include/linux/overflow.h
> +++ b/include/linux/overflow.h
> @@ -458,6 +458,18 @@ static inline size_t __must_check size_sub(size_t minuend, size_t subtrahend)
> #define struct_size_t(type, member, count) \
> struct_size((type *)NULL, member, count)
>
> +/**
> + * struct_offset() - Calculate the offset of a member within a struct
> + * @p: Pointer to the struct
> + * @member: Name of the member to get the offset of
> + *
> + * Calculates the offset of a particular @member of the structure pointed
> + * to by @p.
> + *
> + * Return: number of bytes to the location of @member.
> + */
> +#define struct_offset(p, member) (offsetof(typeof(*(p)), member))
I wonder if the kerndoc for this and offsetof() should reference each
other? "For a type instead of a pointer, use offsetof()" etc...
--
Kees Cook
^ permalink raw reply
* Re: [PATCH v4 0/3] Support comma-separated symbols and :entry/:exit
From: Masami Hiramatsu @ 2025-11-27 6:12 UTC (permalink / raw)
To: Seokwoo Chung (Ryan)
Cc: rostedt, corbet, shuah, mathieu.desnoyers, linux-kernel,
linux-trace-kernel, linux-doc, linux-kselftest
In-Reply-To: <20251126184110.72241-1-seokwoo.chung130@gmail.com>
On Wed, 26 Nov 2025 13:41:07 -0500
"Seokwoo Chung (Ryan)" <seokwoo.chung130@gmail.com> wrote:
> Extend fprobe to support list-style filters and explicit entry/exit suffixes.
> Currentyl, fprobe only supports a single symbol (or wildcard) per event.
> This patch allows users to specify a comma-separated list of symbols.
>
> New Syntax:
> - f:[GRP/][EVENT] func1,func2,func3:entry
> - f:[GRP/][EVENT] func1,func2,func3:exit
Thanks for updating!
>
> Logic changes:
> - Refactor parsing logic into 'parse_fprobe_spec'
> - Support '!' prefix for exclusion
> - Disable BTF lookup ('ctx->funcname = NULL') when a list or wildcard is used,
> as a single function signature cannot apply to multiple functions.
> - Reject legacy '%return' suffix when used with lists or wildcards
> - Update tracefs/README
>
> Testing:
> Verified on x86_64 via QEMU. Checked registration of lists, exclusions, and
> explicit suffixes. Verified rejection of invalid syntax including trailing
> commas and mixed legacy/new syntax.
>
> Seokwoo Chung (Ryan) (3):
> docs: tracing/fprobe: Document list filters and :entry/:exit
> tracing/fprobe: Support comma-separated symbols and :entry/:exit
For the next time, please add docs patch after code change because of bisect.
(Or, include the document update into code update.)
> selftests/ftrace: Add accept cases for fprobe list syntax
Testing after code is good. :)
Thank you,
>
> Changes in v4:
> - Added validation to reject trailing commas (empty tokens) in symbol lists
> - Added vaildation to reject mixed of list syntax with %return suffix
> - Refactored parse_fprobe_spec to user __free(kfree) for automatic memory
> cleanup
> - Removed the now-unused parse_symbol_and_return function to avoid compiler
> warnings.
> - Tigtened %return detection to ensure it only matches as a strict suffix, not a
> substring
> - Link to v3: https://lore.kernel.org/lkml/20250904103219.f4937968362bfff1ecd3f004@kernel.org/
>
> Documentation/trace/fprobetrace.rst | 17 +-
> kernel/trace/trace.c | 3 +-
> kernel/trace/trace_fprobe.c | 209 ++++++++++++++----
> .../ftrace/test.d/dynevent/fprobe_list.tc | 92 ++++++++
> 4 files changed, 269 insertions(+), 52 deletions(-)
> create mode 100644 tools/testing/selftests/ftrace/test.d/dynevent/fprobe_list.tc
>
> --
> 2.43.0
>
--
Masami Hiramatsu (Google) <mhiramat@kernel.org>
^ permalink raw reply
* Re: [PATCH v4 2/3] tracing/fprobe: Support comma-separated symbols and :entry/:exit
From: Masami Hiramatsu @ 2025-11-27 6:11 UTC (permalink / raw)
To: Seokwoo Chung (Ryan)
Cc: rostedt, corbet, shuah, mathieu.desnoyers, linux-kernel,
linux-trace-kernel, linux-doc, linux-kselftest
In-Reply-To: <20251126184110.72241-3-seokwoo.chung130@gmail.com>
On Wed, 26 Nov 2025 13:41:09 -0500
"Seokwoo Chung (Ryan)" <seokwoo.chung130@gmail.com> wrote:
> - Update DEFINE_FREE to use standard __free()
> - Extend fprobe to support multiple symbols per event. Add parsing logic for
> lists, ! exclusions, and explicit suffixes. Update tracefs/README to reflect
> the new syntax
>
> Signed-off-by: Seokwoo Chung (Ryan) <seokwoo.chung130@gmail.com>
> ---
> kernel/trace/trace.c | 3 +-
> kernel/trace/trace_fprobe.c | 209 +++++++++++++++++++++++++++---------
> 2 files changed, 163 insertions(+), 49 deletions(-)
>
> diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
> index d1e527cf2aae..e0b77268a702 100644
> --- a/kernel/trace/trace.c
> +++ b/kernel/trace/trace.c
> @@ -5518,7 +5518,8 @@ static const char readme_msg[] =
> "\t r[maxactive][:[<group>/][<event>]] <place> [<args>]\n"
> #endif
> #ifdef CONFIG_FPROBE_EVENTS
> - "\t f[:[<group>/][<event>]] <func-name>[%return] [<args>]\n"
> + "\t f[:[<group>/][<event>]] <func-name>[:entry|:exit] [<args>]\n"
> + "\t (single symbols still accept %return)\n"
Hm, I would like to keep previous line. What about this (instead of
adding a note line)?
"\t f[:[<group>/][<event>]] <func-name>[%return] [<args>]\n"
"\t f[:[<group>/][<event>]] <func-list>[:entry|:exit] [<args>]\n"
This shows both syntax exists clearly, and the new one accepts a list
of functions.
> "\t t[:[<group>/][<event>]] <tracepoint> [<args>]\n"
> #endif
> #ifdef CONFIG_HIST_TRIGGERS
> diff --git a/kernel/trace/trace_fprobe.c b/kernel/trace/trace_fprobe.c
> index 8001dbf16891..6307d7d7dd9c 100644
> --- a/kernel/trace/trace_fprobe.c
> +++ b/kernel/trace/trace_fprobe.c
> @@ -187,11 +187,14 @@ DEFINE_FREE(tuser_put, struct tracepoint_user *,
> */
> struct trace_fprobe {
> struct dyn_event devent;
> + char *filter;
Please do not sort the field alphabetically. It should be gathered by
semantics.
> struct fprobe fp;
> + bool list_mode;
So filter should be here.
> + char *nofilter;
> const char *symbol;
> + struct trace_probe tp;
Actually trace_probe must be the last field, because it has a variable
length array at the end.
> bool tprobe;
> struct tracepoint_user *tuser;
> - struct trace_probe tp;
> };
>
> static bool is_trace_fprobe(struct dyn_event *ev)
> @@ -559,6 +562,8 @@ static void free_trace_fprobe(struct trace_fprobe *tf)
> trace_probe_cleanup(&tf->tp);
> if (tf->tuser)
> tracepoint_user_put(tf->tuser);
> + kfree(tf->filter);
> + kfree(tf->nofilter);
> kfree(tf->symbol);
> kfree(tf);
> }
> @@ -838,7 +843,12 @@ static int __register_trace_fprobe(struct trace_fprobe *tf)
> if (trace_fprobe_is_tracepoint(tf))
> return __regsiter_tracepoint_fprobe(tf);
>
> - /* TODO: handle filter, nofilter or symbol list */
> + /* Registration path:
> + * - list_mode: pass filter/nofilter
> + * - single: pass symbol only (legacy)
> + */
> + if (tf->list_mode)
If tf have filter or nofilter, that means it is list_mode, right?
if (tf->filter || tf->nofilter)
is more straight.
I think you can add
static bool trace_fprobe_has_list(struct trace_fprobe *tf)
{
return tf->filter || tf->nofilter;
}
then we don't need tf::list_mode.
> + return register_fprobe(&tf->fp, tf->filter, tf->nofilter);
> return register_fprobe(&tf->fp, tf->symbol, NULL);
> }
>
> @@ -1154,60 +1164,119 @@ static struct notifier_block tprobe_event_module_nb = {
> };
> #endif /* CONFIG_MODULES */
>
> -static int parse_symbol_and_return(int argc, const char *argv[],
> - char **symbol, bool *is_return,
> - bool is_tracepoint)
> +static bool has_wildcard(const char *s)
> {
> - char *tmp = strchr(argv[1], '%');
> - int i;
> + return s && (strchr(s, '*') || strchr(s, '?'));
> +}
>
> - if (tmp) {
> - int len = tmp - argv[1];
> +static int parse_fprobe_spec(const char *in, bool is_tracepoint,
> + char **base, bool *is_return, bool *list_mode,
> + char **filter, char **nofilter)
> +{
> + char *work __free(kfree) = NULL;
> + char *b __free(kfree) = NULL;
> + char *f __free(kfree) = NULL;
> + char *nf __free(kfree) = NULL;
> + bool legacy_ret = false;
> + bool list = false;
> + const char *p;
> + int ret = 0;
>
> - if (!is_tracepoint && !strcmp(tmp, "%return")) {
> - *is_return = true;
> - } else {
> - trace_probe_log_err(len, BAD_ADDR_SUFFIX);
> - return -EINVAL;
> - }
> - *symbol = kmemdup_nul(argv[1], len, GFP_KERNEL);
> - } else
> - *symbol = kstrdup(argv[1], GFP_KERNEL);
> - if (!*symbol)
> - return -ENOMEM;
> + if (!in || !base || !is_return || !list_mode || !filter || !nofilter)
> + return -EINVAL;
>
> - if (*is_return)
> - return 0;
> + *base = NULL; *filter = NULL; *nofilter = NULL;
> + *is_return = false; *list_mode = false;
>
> if (is_tracepoint) {
> - tmp = *symbol;
> - while (*tmp && (isalnum(*tmp) || *tmp == '_'))
> - tmp++;
> - if (*tmp) {
> - /* find a wrong character. */
> - trace_probe_log_err(tmp - *symbol, BAD_TP_NAME);
> - kfree(*symbol);
> - *symbol = NULL;
> + if (strchr(in, ',') || strchr(in, ':'))
> return -EINVAL;
> - }
> + if (strstr(in, "%return"))
> + return -EINVAL;
Please report some error before returning !ENOMEM error by
trace_probe_log_err().
> + for (p = in; *p; p++)
> + if (!isalnum(*p) && *p != '_')
> + return -EINVAL;
> + b = kstrdup(in, GFP_KERNEL);
> + if (!b)
> + return -ENOMEM;
> + *base = no_free_ptr(b);
> + return 0;
> }
>
> - /* If there is $retval, this should be a return fprobe. */
> - for (i = 2; i < argc; i++) {
> - tmp = strstr(argv[i], "$retval");
> - if (tmp && !isalnum(tmp[7]) && tmp[7] != '_') {
> - if (is_tracepoint) {
> - trace_probe_log_set_index(i);
> - trace_probe_log_err(tmp - argv[i], RETVAL_ON_PROBE);
> - kfree(*symbol);
> - *symbol = NULL;
> + work = kstrdup(in, GFP_KERNEL);
> + if (!work)
> + return -ENOMEM;
> +
> + p = strstr(work, "%return");
> + if (p && p[7] == '\0') {
> + *is_return = true;
> + legacy_ret = true;
> + *(char *)p = '\0';
> + } else {
> + /*
> + * If "symbol:entry" or "symbol:exit" is given, it is new
> + * style probe.
> + */
> + p = strrchr(work, ':');
> + if (p) {
> + if (!strcmp(p, ":exit")) {
> + *is_return = true;
> + *(char *)p = '\0';
> + } else if (!strcmp(p, ":entry")) {
> + *(char *)p = '\0';
> + } else {
trace_probe_log_err(p - work, BAD_LIST_SUFFIX);
> return -EINVAL;
> }
> - *is_return = true;
> - break;
> }
> }
> - return 0;
> +
> + list = !!strchr(work, ',');
> +
> + if (list && legacy_ret) {
trace_probe_log_err(<legacy_ret offset>, BAD_LEGACY_RET);
> + return -EINVAL;
> + }
Or, you don't need this brace for 1 line if block.
> +
> + if (legacy_ret)
> + *is_return = true;
You've already done this for legacy_ret.
> +
> + b = kstrdup(work, GFP_KERNEL);
> + if (!b)
> + return -ENOMEM;
> +
> + if (list) {
> + char *tmp = b, *tok;
> + size_t fsz, nfsz;
> +
> + fsz = nfsz = strlen(b) + 1;
fsz and nfsz are used only once. Can be replaced with "strlen(b) + 1".
> +
> + f = kzalloc(fsz, GFP_KERNEL);
> + nf = kzalloc(nfsz, GFP_KERNEL);
> + if (!f || !nf)
> + return -ENOMEM;
> +
> + while ((tok = strsep(&tmp, ",")) != NULL) {
> + char *dst;
> + bool neg = (*tok == '!');
> +
> + if (*tok == '\0') {
> + trace_probe_log_err(tmp - b - 1, BAD_TP_NAME);
> + return -EINVAL;
Forgot a closing brace here. (did you build and test it?)
> +
> + if (neg)
> + tok++;
> + dst = neg ? nf : f;
> + if (dst[0] != '\0')
> + strcat(dst, ",");
> + strcat(dst, tok);
> + }
> + *list_mode = true;
> + }
> +
> + *base = no_free_ptr(b);
> + *filter = no_free_ptr(f);
> + *nofilter = no_free_ptr(nf);
> +
> + return ret;
> }
>
> static int trace_fprobe_create_internal(int argc, const char *argv[],
> @@ -1241,6 +1310,8 @@ static int trace_fprobe_create_internal(int argc, const char *argv[],
> const char *event = NULL, *group = FPROBE_EVENT_SYSTEM;
> struct module *mod __free(module_put) = NULL;
> const char **new_argv __free(kfree) = NULL;
> + char *parsed_nofilter __free(kfree) = NULL;
> + char *parsed_filter __free(kfree) = NULL;
> char *symbol __free(kfree) = NULL;
> char *ebuf __free(kfree) = NULL;
> char *gbuf __free(kfree) = NULL;
> @@ -1249,6 +1320,7 @@ static int trace_fprobe_create_internal(int argc, const char *argv[],
> char *dbuf __free(kfree) = NULL;
> int i, new_argc = 0, ret = 0;
> bool is_tracepoint = false;
> + bool list_mode = false;
> bool is_return = false;
>
> if ((argv[0][0] != 'f' && argv[0][0] != 't') || argc < 2)
> @@ -1270,11 +1342,26 @@ static int trace_fprobe_create_internal(int argc, const char *argv[],
>
> trace_probe_log_set_index(1);
>
> - /* a symbol(or tracepoint) must be specified */
> - ret = parse_symbol_and_return(argc, argv, &symbol, &is_return, is_tracepoint);
> + /* Parse spec early (single vs list, suffix, base symbol) */
> + ret = parse_fprobe_spec(argv[1], is_tracepoint, &symbol, &is_return,
> + &list_mode, &parsed_filter, &parsed_nofilter);
> if (ret < 0)
> return -EINVAL;
>
> + for (i = 2; i < argc; i++) {
> + char *tmp = strstr(argv[i], "$retval");
> +
> + if (tmp && !isalnum(tmp[7]) && tmp[7] != '_') {
> + if (is_tracepoint) {
> + trace_probe_log_set_index(i);
> + trace_probe_log_err(tmp - argv[i], RETVAL_ON_PROBE);
> + return -EINVAL;
> + }
> + is_return = true;
> + break;
> + }
> + }
> +
> trace_probe_log_set_index(0);
> if (event) {
> gbuf = kmalloc(MAX_EVENT_NAME_LEN, GFP_KERNEL);
> @@ -1287,6 +1374,15 @@ static int trace_fprobe_create_internal(int argc, const char *argv[],
> }
>
> if (!event) {
> + /*
> + * Event name rules:
> + * - For list/wildcard: require explicit [GROUP/]EVENT
> + * - For single literal: autogenerate symbol__entry/symbol__exit
> + */
> + if (list_mode || has_wildcard(symbol)) {
> + trace_probe_log_err(0, NO_GROUP_NAME);
> + return -EINVAL;
> + }
> ebuf = kmalloc(MAX_EVENT_NAME_LEN, GFP_KERNEL);
> if (!ebuf)
> return -ENOMEM;
> @@ -1322,7 +1418,8 @@ static int trace_fprobe_create_internal(int argc, const char *argv[],
> NULL, NULL, NULL, sbuf);
> }
> }
> - if (!ctx->funcname)
> +
> + if (!list_mode && !has_wildcard(symbol) && !is_tracepoint)
> ctx->funcname = symbol;
>
> abuf = kmalloc(MAX_BTF_ARGS_LEN, GFP_KERNEL);
> @@ -1356,6 +1453,21 @@ static int trace_fprobe_create_internal(int argc, const char *argv[],
> return ret;
> }
>
> + /* carry list parsing result into tf */
> + if (!is_tracepoint) {
> + tf->list_mode = list_mode;
> + if (parsed_filter) {
> + tf->filter = kstrdup(parsed_filter, GFP_KERNEL);
> + if (!tf->filter)
> + return -ENOMEM;
> + }
You can just move it.
tf->filter = no_free_ptr(parsed_filter);
> + if (parsed_nofilter) {
> + tf->nofilter = kstrdup(parsed_nofilter, GFP_KERNEL);
> + if (!tf->nofilter)
> + return -ENOMEM;
> + }
Ditto.
> + }
> +
> /* parse arguments */
> for (i = 0; i < argc; i++) {
> trace_probe_log_set_index(i + 2);
> @@ -1442,8 +1554,9 @@ static int trace_fprobe_show(struct seq_file *m, struct dyn_event *ev)
> seq_printf(m, ":%s/%s", trace_probe_group_name(&tf->tp),
> trace_probe_name(&tf->tp));
>
> - seq_printf(m, " %s%s", trace_fprobe_symbol(tf),
> - trace_fprobe_is_return(tf) ? "%return" : "");
> + seq_printf(m, " %s", trace_fprobe_symbol(tf));
> + if (!trace_fprobe_is_tracepoint(tf) && trace_fprobe_is_return(tf))
> + seq_puts(m, ":exit");
>
> for (i = 0; i < tf->tp.nr_args; i++)
> seq_printf(m, " %s=%s", tf->tp.args[i].name, tf->tp.args[i].comm);
> --
> 2.43.0
>
Please build and run ftracetest under tools/testing/selftests.
Thank you,
--
Masami Hiramatsu (Google) <mhiramat@kernel.org>
^ permalink raw reply
* Re: [PATCH] kprobes: avoid crash when rmmod/insmod modules after ftrace_disabled
From: Masami Hiramatsu @ 2025-11-27 4:18 UTC (permalink / raw)
To: Masami Hiramatsu; +Cc: Ye Bin, naveen, davem, linux-trace-kernel, yebin10
In-Reply-To: <20251127125248.a1367d15c0bbc7faad3b0e87@kernel.org>
On Thu, 27 Nov 2025 12:52:48 +0900
Masami Hiramatsu (Google) <mhiramat@kernel.org> wrote:
> Hi,
>
> Thanks for reporting!
>
>
> On Tue, 25 Nov 2025 10:05:36 +0800
> Ye Bin <yebin@huaweicloud.com> wrote:
>
> > From: Ye Bin <yebin10@huawei.com>
> >
> > There's a issue as follows when rmmod modules after ftrace disabled:
>
> You may see something like;
>
> Failed to unregister kprobe-ftrace (error -19)
>
> or
>
> Failed to disarm kprobe-ftrace at <function name> (error -19)
>
> right before this BUG, don't you?
> If you reported with that line, it's more easier to understand.
>
>
> > BUG: unable to handle page fault for address: fffffbfff805000d
> > PGD 817fcc067 P4D 817fcc067 PUD 817fc8067 PMD 101555067 PTE 0
> > Oops: Oops: 0000 [#1] SMP KASAN PTI
> > CPU: 4 UID: 0 PID: 2012 Comm: rmmod Tainted: G W OE
> > Tainted: [W]=WARN, [O]=OOT_MODULE, [E]=UNSIGNED_MODULE
> > RIP: 0010:kprobes_module_callback+0x89/0x790
> > RSP: 0018:ffff88812e157d30 EFLAGS: 00010a02
> > RAX: 1ffffffff805000d RBX: dffffc0000000000 RCX: ffffffff86a8de90
> > RDX: ffffed1025c2af9b RSI: 0000000000000008 RDI: ffffffffc0280068
> > RBP: 0000000000000000 R08: 0000000000000001 R09: ffffed1025c2af9a
> > R10: ffff88812e157cd7 R11: 205d323130325420 R12: 0000000000000002
> > R13: ffffffffc0290488 R14: 0000000000000002 R15: ffffffffc0280040
> > FS: 00007fbc450dd740(0000) GS:ffff888420331000(0000) knlGS:0000000000000000
> > CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> > CR2: fffffbfff805000d CR3: 000000010f624000 CR4: 00000000000006f0
> > Call Trace:
> > <TASK>
> > notifier_call_chain+0xc6/0x280
> > blocking_notifier_call_chain+0x60/0x90
> > __do_sys_delete_module.constprop.0+0x32a/0x4e0
> > do_syscall_64+0x5d/0xfa0
> > entry_SYSCALL_64_after_hwframe+0x76/0x7e
> >
> > The above issue occurs because the kprobe was not removed from the hash
> > list after ftrace_disable.
> > To prevent the system from restarting unexpectedly after ftrace_disable,
> > in such cases, unregister_kprobe() ensures that the probe is removed from
> > the hash list, preventing subsequent access to already freed memory.
> >
> > Fixes: 6f0f1dd71953 ("kprobes: Cleanup disabling and unregistering path")
> > Signed-off-by: Ye Bin <yebin10@huawei.com>
> > ---
> > kernel/kprobes.c | 26 ++++++++++++++++++++++++--
> > 1 file changed, 24 insertions(+), 2 deletions(-)
> >
> > diff --git a/kernel/kprobes.c b/kernel/kprobes.c
> > index ab8f9fc1f0d1..d735a608b810 100644
> > --- a/kernel/kprobes.c
> > +++ b/kernel/kprobes.c
> > @@ -1731,8 +1731,30 @@ static int __unregister_kprobe_top(struct kprobe *p)
> >
> > /* Disable kprobe. This will disarm it if needed. */
> > ap = __disable_kprobe(p);
> > - if (IS_ERR(ap))
> > - return PTR_ERR(ap);
> > + if (IS_ERR(ap)) {
> > + int ret = PTR_ERR(ap);
> > +
> > + /*
> > + * If ftrace disabled we need to delete kprobe node from
> > + * hlist or aggregation list. If nodes are not removed when
> > + * modules are removed, the already released nodes will
> > + * remain in the linked list. Subsequent access to the
> > + * linked list may then trigger exceptions.
> > + */
> > + if (ret != -ENODEV)
> > + return ret;
> > +
> > + ap = __get_valid_kprobe(p);
> > + if (!ap)
> > + return ret;
> > +
> > + if (ap == p)
> > + hlist_del_rcu(&ap->hlist);
> > + else
> > + list_del_rcu(&p->list);
>
> Instead of repeating this process, we should ignore
> -ENODEV error from ftrace directly. BTW, ftrace_disabled is set
> when ftrace_kill() is called, that means ftrace is no more usable.
> So I think we can just ignore ftrace operation in
> __disarm_kprobe_ftrace().
So, what we need is;
diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index ab8f9fc1f0d1..17d451553389 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -1104,6 +1104,10 @@ static int __disarm_kprobe_ftrace(struct kprobe *p, struct ftrace_ops *ops,
int ret;
lockdep_assert_held(&kprobe_mutex);
+ if (unlikely(kprobe_ftrace_disabled)) {
+ /* Now ftrace is disabled forever, disarm is already done. */
+ return 0;
+ }
if (*cnt == 1) {
ret = unregister_ftrace_function(ops);
--
Masami Hiramatsu (Google) <mhiramat@kernel.org>
^ permalink raw reply related
* Re: [PATCH] arm64: simplify arch_uprobe_xol_was_trapped return
From: Anshuman Khandual @ 2025-11-27 3:59 UTC (permalink / raw)
To: Osama Abdelkader, mhiramat, oleg, peterz, catalin.marinas, will
Cc: linux-arm-kernel, linux-kernel, linux-trace-kernel
In-Reply-To: <20251126223130.216302-1-osama.abdelkader@gmail.com>
On 27/11/25 4:01 AM, Osama Abdelkader wrote:
> convert arch_uprobe_xol_was_trapped() from explicit if/return true
> return false pattern to direct boolean expression return in
> arch/arm64/kernel/probes/uprobes.c
>
> Signed-off-by: Osama Abdelkader <osama.abdelkader@gmail.com>
Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com>
> ---
> arch/arm64/kernel/probes/uprobes.c | 5 +----
> 1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/arch/arm64/kernel/probes/uprobes.c b/arch/arm64/kernel/probes/uprobes.c
> index 2799bdb2fb82..b38c1dab7eb4 100644
> --- a/arch/arm64/kernel/probes/uprobes.c
> +++ b/arch/arm64/kernel/probes/uprobes.c
> @@ -103,10 +103,7 @@ bool arch_uprobe_xol_was_trapped(struct task_struct *t)
> * insn itself is trapped, then detect the case with the help of
> * invalid fault code which is being set in arch_uprobe_pre_xol
> */
> - if (t->thread.fault_code != UPROBE_INV_FAULT_CODE)
> - return true;
> -
> - return false;
> + return t->thread.fault_code != UPROBE_INV_FAULT_CODE;
> }
>
> bool arch_uprobe_skip_sstep(struct arch_uprobe *auprobe, struct pt_regs *regs)
^ permalink raw reply
* Re: [PATCH] kprobes: avoid crash when rmmod/insmod modules after ftrace_disabled
From: Masami Hiramatsu @ 2025-11-27 3:52 UTC (permalink / raw)
To: Ye Bin; +Cc: naveen, davem, linux-trace-kernel, yebin10
In-Reply-To: <20251125020536.2484381-1-yebin@huaweicloud.com>
Hi,
Thanks for reporting!
On Tue, 25 Nov 2025 10:05:36 +0800
Ye Bin <yebin@huaweicloud.com> wrote:
> From: Ye Bin <yebin10@huawei.com>
>
> There's a issue as follows when rmmod modules after ftrace disabled:
You may see something like;
Failed to unregister kprobe-ftrace (error -19)
or
Failed to disarm kprobe-ftrace at <function name> (error -19)
right before this BUG, don't you?
If you reported with that line, it's more easier to understand.
> BUG: unable to handle page fault for address: fffffbfff805000d
> PGD 817fcc067 P4D 817fcc067 PUD 817fc8067 PMD 101555067 PTE 0
> Oops: Oops: 0000 [#1] SMP KASAN PTI
> CPU: 4 UID: 0 PID: 2012 Comm: rmmod Tainted: G W OE
> Tainted: [W]=WARN, [O]=OOT_MODULE, [E]=UNSIGNED_MODULE
> RIP: 0010:kprobes_module_callback+0x89/0x790
> RSP: 0018:ffff88812e157d30 EFLAGS: 00010a02
> RAX: 1ffffffff805000d RBX: dffffc0000000000 RCX: ffffffff86a8de90
> RDX: ffffed1025c2af9b RSI: 0000000000000008 RDI: ffffffffc0280068
> RBP: 0000000000000000 R08: 0000000000000001 R09: ffffed1025c2af9a
> R10: ffff88812e157cd7 R11: 205d323130325420 R12: 0000000000000002
> R13: ffffffffc0290488 R14: 0000000000000002 R15: ffffffffc0280040
> FS: 00007fbc450dd740(0000) GS:ffff888420331000(0000) knlGS:0000000000000000
> CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> CR2: fffffbfff805000d CR3: 000000010f624000 CR4: 00000000000006f0
> Call Trace:
> <TASK>
> notifier_call_chain+0xc6/0x280
> blocking_notifier_call_chain+0x60/0x90
> __do_sys_delete_module.constprop.0+0x32a/0x4e0
> do_syscall_64+0x5d/0xfa0
> entry_SYSCALL_64_after_hwframe+0x76/0x7e
>
> The above issue occurs because the kprobe was not removed from the hash
> list after ftrace_disable.
> To prevent the system from restarting unexpectedly after ftrace_disable,
> in such cases, unregister_kprobe() ensures that the probe is removed from
> the hash list, preventing subsequent access to already freed memory.
>
> Fixes: 6f0f1dd71953 ("kprobes: Cleanup disabling and unregistering path")
> Signed-off-by: Ye Bin <yebin10@huawei.com>
> ---
> kernel/kprobes.c | 26 ++++++++++++++++++++++++--
> 1 file changed, 24 insertions(+), 2 deletions(-)
>
> diff --git a/kernel/kprobes.c b/kernel/kprobes.c
> index ab8f9fc1f0d1..d735a608b810 100644
> --- a/kernel/kprobes.c
> +++ b/kernel/kprobes.c
> @@ -1731,8 +1731,30 @@ static int __unregister_kprobe_top(struct kprobe *p)
>
> /* Disable kprobe. This will disarm it if needed. */
> ap = __disable_kprobe(p);
> - if (IS_ERR(ap))
> - return PTR_ERR(ap);
> + if (IS_ERR(ap)) {
> + int ret = PTR_ERR(ap);
> +
> + /*
> + * If ftrace disabled we need to delete kprobe node from
> + * hlist or aggregation list. If nodes are not removed when
> + * modules are removed, the already released nodes will
> + * remain in the linked list. Subsequent access to the
> + * linked list may then trigger exceptions.
> + */
> + if (ret != -ENODEV)
> + return ret;
> +
> + ap = __get_valid_kprobe(p);
> + if (!ap)
> + return ret;
> +
> + if (ap == p)
> + hlist_del_rcu(&ap->hlist);
> + else
> + list_del_rcu(&p->list);
Instead of repeating this process, we should ignore
-ENODEV error from ftrace directly. BTW, ftrace_disabled is set
when ftrace_kill() is called, that means ftrace is no more usable.
So I think we can just ignore ftrace operation in
__disarm_kprobe_ftrace().
Thank you,
> +
> + return ret;
> + }
>
> WARN_ON(ap != p && !kprobe_aggrprobe(ap));
>
> --
> 2.34.1
>
--
Masami Hiramatsu (Google) <mhiramat@kernel.org>
^ permalink raw reply
* Re: [PATCH] arm64: simplify arch_uprobe_xol_was_trapped return
From: Masami Hiramatsu @ 2025-11-27 2:14 UTC (permalink / raw)
To: Osama Abdelkader
Cc: oleg, peterz, catalin.marinas, will, linux-arm-kernel,
linux-kernel, linux-trace-kernel
In-Reply-To: <20251126223130.216302-1-osama.abdelkader@gmail.com>
On Thu, 27 Nov 2025 00:31:30 +0200
Osama Abdelkader <osama.abdelkader@gmail.com> wrote:
> convert arch_uprobe_xol_was_trapped() from explicit if/return true
> return false pattern to direct boolean expression return in
> arch/arm64/kernel/probes/uprobes.c
>
> Signed-off-by: Osama Abdelkader <osama.abdelkader@gmail.com>
Looks good to me.
Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Thanks!
> ---
> arch/arm64/kernel/probes/uprobes.c | 5 +----
> 1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/arch/arm64/kernel/probes/uprobes.c b/arch/arm64/kernel/probes/uprobes.c
> index 2799bdb2fb82..b38c1dab7eb4 100644
> --- a/arch/arm64/kernel/probes/uprobes.c
> +++ b/arch/arm64/kernel/probes/uprobes.c
> @@ -103,10 +103,7 @@ bool arch_uprobe_xol_was_trapped(struct task_struct *t)
> * insn itself is trapped, then detect the case with the help of
> * invalid fault code which is being set in arch_uprobe_pre_xol
> */
> - if (t->thread.fault_code != UPROBE_INV_FAULT_CODE)
> - return true;
> -
> - return false;
> + return t->thread.fault_code != UPROBE_INV_FAULT_CODE;
> }
>
> bool arch_uprobe_skip_sstep(struct arch_uprobe *auprobe, struct pt_regs *regs)
> --
> 2.43.0
>
--
Masami Hiramatsu (Google) <mhiramat@kernel.org>
^ permalink raw reply
* [PATCH v3] dma-buf: add some tracepoints to debug.
From: Xiang Gao @ 2025-11-27 0:43 UTC (permalink / raw)
To: sumit.semwal, christian.koenig, rostedt, mhiramat
Cc: linux-media, dri-devel, linux-kernel, mathieu.desnoyers, dhowells,
kuba, brauner, akpm, linux-trace-kernel, gaoxiang17
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.
For example:
binder:2962_2-2962 [005] ...1. 208.453940: dma_buf_export: exp_name=qcom,system name=(null) size=28672 ino=2580 f_refcnt=2
binder:2962_2-2962 [005] ...1. 208.453943: dma_buf_fd: exp_name=qcom,system name=(null) size=28672 ino=2580 fd=9 f_refcnt=2
binder:2962_2-2962 [005] ...1. 208.453977: dma_buf_mmap_internal: exp_name=qcom,system name=qcom,system size=28672 ino=2580 f_refcnt=4
kworker/5:2-194 [005] ...1. 208.460580: dma_buf_put: exp_name=qcom,system name=ab pid [8176] size=28672 ino=2580 f_refcnt=3
RenderThread-11305 [007] ...1. 208.599094: dma_buf_get: exp_name=qcom,system name=ab pid [8176] size=217088 ino=2579 fd=1114 f_refcnt=7
RenderThread-11305 [007] ...1. 208.599098: dma_buf_attach: dev_name=kgsl-3d0 exp_name=qcom,system name=ab pid [8176] size=217088 ino=2579 f_refcnt=7
<...>-14 [001] ...1. 208.726359: dma_buf_detach: dev_name=kgsl-3d0 exp_name=qcom,system name=ab pid [3317] size=217088 ino=2581 f_refcnt=3
Signed-off-by: Xiang Gao <gaoxiang17@xiaomi.com>
---
drivers/dma-buf/dma-buf.c | 57 ++++++++++-
include/trace/events/dma_buf.h | 166 +++++++++++++++++++++++++++++++++
2 files changed, 222 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..7cef816ddcac 100644
--- a/drivers/dma-buf/dma-buf.c
+++ b/drivers/dma-buf/dma-buf.c
@@ -35,6 +35,18 @@
#include "dma-buf-sysfs-stats.h"
+#define CREATE_TRACE_POINTS
+#include <trace/events/dma_buf.h>
+
+EXPORT_TRACEPOINT_SYMBOL(dma_buf_export);
+EXPORT_TRACEPOINT_SYMBOL(dma_buf_mmap_internal);
+EXPORT_TRACEPOINT_SYMBOL(dma_buf_mmap);
+EXPORT_TRACEPOINT_SYMBOL(dma_buf_put);
+EXPORT_TRACEPOINT_SYMBOL(dma_buf_attach);
+EXPORT_TRACEPOINT_SYMBOL(dma_buf_detach);
+EXPORT_TRACEPOINT_SYMBOL(dma_buf_fd);
+EXPORT_TRACEPOINT_SYMBOL(dma_buf_get);
+
static inline int is_dma_buf_file(struct file *);
static DEFINE_MUTEX(dmabuf_list_mutex);
@@ -220,6 +232,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 +762,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);
+ }
+
return dmabuf;
err_dmabuf:
@@ -779,6 +801,11 @@ int dma_buf_fd(struct dma_buf *dmabuf, int flags)
fd_install(fd, dmabuf->file);
+ if (trace_dma_buf_fd_enabled()) {
+ guard(spinlock)(&dmabuf->name_lock);
+ trace_dma_buf_fd(dmabuf, fd);
+ }
+
return fd;
}
EXPORT_SYMBOL_NS_GPL(dma_buf_fd, "DMA_BUF");
@@ -794,6 +821,7 @@ EXPORT_SYMBOL_NS_GPL(dma_buf_fd, "DMA_BUF");
struct dma_buf *dma_buf_get(int fd)
{
struct file *file;
+ struct dma_buf *dmabuf;
file = fget(fd);
@@ -805,7 +833,14 @@ struct dma_buf *dma_buf_get(int fd)
return ERR_PTR(-EINVAL);
}
- return file->private_data;
+ dmabuf = file->private_data;
+
+ if (trace_dma_buf_get_enabled()) {
+ guard(spinlock)(&dmabuf->name_lock);
+ trace_dma_buf_get(dmabuf, fd);
+ }
+
+ return dmabuf;
}
EXPORT_SYMBOL_NS_GPL(dma_buf_get, "DMA_BUF");
@@ -825,6 +860,11 @@ void dma_buf_put(struct dma_buf *dmabuf)
return;
fput(dmabuf->file);
+
+ if (trace_dma_buf_put_enabled()) {
+ guard(spinlock)(&dmabuf->name_lock);
+ trace_dma_buf_put(dmabuf);
+ }
}
EXPORT_SYMBOL_NS_GPL(dma_buf_put, "DMA_BUF");
@@ -998,6 +1038,11 @@ EXPORT_SYMBOL_NS_GPL(dma_buf_dynamic_attach, "DMA_BUF");
struct dma_buf_attachment *dma_buf_attach(struct dma_buf *dmabuf,
struct device *dev)
{
+ if (trace_dma_buf_attach_enabled()) {
+ guard(spinlock)(&dmabuf->name_lock);
+ trace_dma_buf_attach(dmabuf, dev);
+ }
+
return dma_buf_dynamic_attach(dmabuf, dev, NULL, NULL);
}
EXPORT_SYMBOL_NS_GPL(dma_buf_attach, "DMA_BUF");
@@ -1023,6 +1068,11 @@ void dma_buf_detach(struct dma_buf *dmabuf, struct dma_buf_attachment *attach)
if (dmabuf->ops->detach)
dmabuf->ops->detach(dmabuf, attach);
+ if (trace_dma_buf_detach_enabled()) {
+ guard(spinlock)(&dmabuf->name_lock);
+ trace_dma_buf_detach(dmabuf, attach->dev);
+ }
+
kfree(attach);
}
EXPORT_SYMBOL_NS_GPL(dma_buf_detach, "DMA_BUF");
@@ -1488,6 +1538,11 @@ int dma_buf_mmap(struct dma_buf *dmabuf, struct vm_area_struct *vma,
vma_set_file(vma, dmabuf->file);
vma->vm_pgoff = pgoff;
+ if (trace_dma_buf_mmap_enabled()) {
+ guard(spinlock)(&dmabuf->name_lock);
+ trace_dma_buf_mmap(dmabuf);
+ }
+
return dmabuf->ops->mmap(dmabuf, vma);
}
EXPORT_SYMBOL_NS_GPL(dma_buf_mmap, "DMA_BUF");
diff --git a/include/trace/events/dma_buf.h b/include/trace/events/dma_buf.h
new file mode 100644
index 000000000000..fe9da89bacd0
--- /dev/null
+++ b/include/trace/events/dma_buf.h
@@ -0,0 +1,166 @@
+/* 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>
+
+DECLARE_EVENT_CLASS(dma_buf,
+
+ 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);
+ __assign_str(name);
+ __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)
+);
+
+DECLARE_EVENT_CLASS(dma_buf_attach_dev,
+
+ 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);
+ __assign_str(name);
+ __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)
+);
+
+DECLARE_EVENT_CLASS(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);
+ __assign_str(name);
+ __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)
+);
+
+DEFINE_EVENT(dma_buf, dma_buf_export,
+
+ TP_PROTO(struct dma_buf *dmabuf),
+
+ TP_ARGS(dmabuf)
+);
+
+DEFINE_EVENT(dma_buf, dma_buf_mmap_internal,
+
+ TP_PROTO(struct dma_buf *dmabuf),
+
+ TP_ARGS(dmabuf)
+);
+
+DEFINE_EVENT(dma_buf, dma_buf_mmap,
+
+ TP_PROTO(struct dma_buf *dmabuf),
+
+ TP_ARGS(dmabuf)
+);
+
+DEFINE_EVENT(dma_buf, dma_buf_put,
+
+ TP_PROTO(struct dma_buf *dmabuf),
+
+ TP_ARGS(dmabuf)
+);
+
+DEFINE_EVENT(dma_buf_attach_dev, dma_buf_attach,
+
+ TP_PROTO(struct dma_buf *dmabuf, struct device *dev),
+
+ TP_ARGS(dmabuf, dev)
+);
+
+DEFINE_EVENT(dma_buf_attach_dev, dma_buf_detach,
+
+ TP_PROTO(struct dma_buf *dmabuf, struct device *dev),
+
+ TP_ARGS(dmabuf, dev)
+);
+
+DEFINE_EVENT(dma_buf_fd, dma_buf_fd,
+
+ TP_PROTO(struct dma_buf *dmabuf, int fd),
+
+ TP_ARGS(dmabuf, fd)
+);
+
+DEFINE_EVENT(dma_buf_fd, dma_buf_get,
+
+ TP_PROTO(struct dma_buf *dmabuf, int fd),
+
+ TP_ARGS(dmabuf, fd)
+);
+
+#endif /* _TRACE_DMA_BUF_H */
+
+/* This part must be outside protection */
+#include <trace/define_trace.h>
--
2.34.1
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox