linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] tracing: Do not register unsupported perf events
@ 2025-12-16 23:24 Steven Rostedt
  2025-12-22  9:27 ` Jiri Olsa
  2025-12-23 18:22 ` Namhyung Kim
  0 siblings, 2 replies; 4+ messages in thread
From: Steven Rostedt @ 2025-12-16 23:24 UTC (permalink / raw)
  To: LKML, Linux Trace Kernel
  Cc: Masami Hiramatsu, Mathieu Desnoyers, Ian Rogers,
	Arnaldo Carvalho de Melo, Jiri Olsa, Namhyung Kim

From: Steven Rostedt <rostedt@goodmis.org>

Synthetic events currently do not have a function to register perf events.
This leads to calling the tracepoint register functions with a NULL
function pointer which triggers:

 ------------[ cut here ]------------
 WARNING: kernel/tracepoint.c:175 at tracepoint_add_func+0x357/0x370, CPU#2: perf/2272
 Modules linked in: kvm_intel kvm irqbypass
 CPU: 2 UID: 0 PID: 2272 Comm: perf Not tainted 6.18.0-ftest-11964-ge022764176fc-dirty #323 PREEMPTLAZY
 Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.17.0-debian-1.17.0-1 04/01/2014
 RIP: 0010:tracepoint_add_func+0x357/0x370
 Code: 28 9c e8 4c 0b f5 ff eb 0f 4c 89 f7 48 c7 c6 80 4d 28 9c e8 ab 89 f4 ff 31 c0 5b 41 5c 41 5d 41 5e 41 5f 5d c3 cc cc cc cc cc <0f> 0b 49 c7 c6 ea ff ff ff e9 ee fe ff ff 0f 0b e9 f9 fe ff ff 0f
 RSP: 0018:ffffabc0c44d3c40 EFLAGS: 00010246
 RAX: 0000000000000001 RBX: ffff9380aa9e4060 RCX: 0000000000000000
 RDX: 000000000000000a RSI: ffffffff9e1d4a98 RDI: ffff937fcf5fd6c8
 RBP: 0000000000000001 R08: 0000000000000007 R09: ffff937fcf5fc780
 R10: 0000000000000003 R11: ffffffff9c193910 R12: 000000000000000a
 R13: ffffffff9e1e5888 R14: 0000000000000000 R15: ffffabc0c44d3c78
 FS:  00007f6202f5f340(0000) GS:ffff93819f00f000(0000) knlGS:0000000000000000
 CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
 CR2: 000055d3162281a8 CR3: 0000000106a56003 CR4: 0000000000172ef0
 Call Trace:
  <TASK>
  tracepoint_probe_register+0x5d/0x90
  synth_event_reg+0x3c/0x60
  perf_trace_event_init+0x204/0x340
  perf_trace_init+0x85/0xd0
  perf_tp_event_init+0x2e/0x50
  perf_try_init_event+0x6f/0x230
  ? perf_event_alloc+0x4bb/0xdc0
  perf_event_alloc+0x65a/0xdc0
  __se_sys_perf_event_open+0x290/0x9f0
  do_syscall_64+0x93/0x7b0
  ? entry_SYSCALL_64_after_hwframe+0x76/0x7e
  ? trace_hardirqs_off+0x53/0xc0
  entry_SYSCALL_64_after_hwframe+0x76/0x7e

Instead, have the code return -ENODEV, which doesn't warn and has perf
error out with:

 # perf record -e synthetic:futex_wait
Error:
The sys_perf_event_open() syscall returned with 19 (No such device) for event (synthetic:futex_wait).
"dmesg | grep -i perf" may provide additional information.

Ideally perf should support synthetic events, but for now just fix the
warning. The support can come later.

Cc: stable@vger.kernel.org
Fixes: 4b147936fa509 ("tracing: Add support for 'synthetic' events")
Reported-by: Ian Rogers <irogers@google.com>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
 kernel/trace/trace_events.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
index a5a93d243047..754b14ca87a7 100644
--- a/kernel/trace/trace_events.c
+++ b/kernel/trace/trace_events.c
@@ -710,6 +710,8 @@ int trace_event_reg(struct trace_event_call *call,
 
 #ifdef CONFIG_PERF_EVENTS
 	case TRACE_REG_PERF_REGISTER:
+		if (!call->class->perf_probe)
+			return -ENODEV;
 		return tracepoint_probe_register(call->tp,
 						 call->class->perf_probe,
 						 call);
-- 
2.51.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] tracing: Do not register unsupported perf events
  2025-12-16 23:24 [PATCH] tracing: Do not register unsupported perf events Steven Rostedt
@ 2025-12-22  9:27 ` Jiri Olsa
  2025-12-23 18:22 ` Namhyung Kim
  1 sibling, 0 replies; 4+ messages in thread
From: Jiri Olsa @ 2025-12-22  9:27 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: LKML, Linux Trace Kernel, Masami Hiramatsu, Mathieu Desnoyers,
	Ian Rogers, Arnaldo Carvalho de Melo, Namhyung Kim

On Tue, Dec 16, 2025 at 06:24:40PM -0500, Steven Rostedt wrote:
> From: Steven Rostedt <rostedt@goodmis.org>
> 
> Synthetic events currently do not have a function to register perf events.
> This leads to calling the tracepoint register functions with a NULL
> function pointer which triggers:
> 
>  ------------[ cut here ]------------
>  WARNING: kernel/tracepoint.c:175 at tracepoint_add_func+0x357/0x370, CPU#2: perf/2272
>  Modules linked in: kvm_intel kvm irqbypass
>  CPU: 2 UID: 0 PID: 2272 Comm: perf Not tainted 6.18.0-ftest-11964-ge022764176fc-dirty #323 PREEMPTLAZY
>  Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.17.0-debian-1.17.0-1 04/01/2014
>  RIP: 0010:tracepoint_add_func+0x357/0x370
>  Code: 28 9c e8 4c 0b f5 ff eb 0f 4c 89 f7 48 c7 c6 80 4d 28 9c e8 ab 89 f4 ff 31 c0 5b 41 5c 41 5d 41 5e 41 5f 5d c3 cc cc cc cc cc <0f> 0b 49 c7 c6 ea ff ff ff e9 ee fe ff ff 0f 0b e9 f9 fe ff ff 0f
>  RSP: 0018:ffffabc0c44d3c40 EFLAGS: 00010246
>  RAX: 0000000000000001 RBX: ffff9380aa9e4060 RCX: 0000000000000000
>  RDX: 000000000000000a RSI: ffffffff9e1d4a98 RDI: ffff937fcf5fd6c8
>  RBP: 0000000000000001 R08: 0000000000000007 R09: ffff937fcf5fc780
>  R10: 0000000000000003 R11: ffffffff9c193910 R12: 000000000000000a
>  R13: ffffffff9e1e5888 R14: 0000000000000000 R15: ffffabc0c44d3c78
>  FS:  00007f6202f5f340(0000) GS:ffff93819f00f000(0000) knlGS:0000000000000000
>  CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
>  CR2: 000055d3162281a8 CR3: 0000000106a56003 CR4: 0000000000172ef0
>  Call Trace:
>   <TASK>
>   tracepoint_probe_register+0x5d/0x90
>   synth_event_reg+0x3c/0x60
>   perf_trace_event_init+0x204/0x340
>   perf_trace_init+0x85/0xd0
>   perf_tp_event_init+0x2e/0x50
>   perf_try_init_event+0x6f/0x230
>   ? perf_event_alloc+0x4bb/0xdc0
>   perf_event_alloc+0x65a/0xdc0
>   __se_sys_perf_event_open+0x290/0x9f0
>   do_syscall_64+0x93/0x7b0
>   ? entry_SYSCALL_64_after_hwframe+0x76/0x7e
>   ? trace_hardirqs_off+0x53/0xc0
>   entry_SYSCALL_64_after_hwframe+0x76/0x7e
> 
> Instead, have the code return -ENODEV, which doesn't warn and has perf
> error out with:
> 
>  # perf record -e synthetic:futex_wait
> Error:
> The sys_perf_event_open() syscall returned with 19 (No such device) for event (synthetic:futex_wait).
> "dmesg | grep -i perf" may provide additional information.
> 
> Ideally perf should support synthetic events, but for now just fix the
> warning. The support can come later.
> 
> Cc: stable@vger.kernel.org
> Fixes: 4b147936fa509 ("tracing: Add support for 'synthetic' events")
> Reported-by: Ian Rogers <irogers@google.com>
> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>

lgtm

Acked-by: Jiri Olsa <jolsa@kernel.org>

jirka


> ---
>  kernel/trace/trace_events.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
> index a5a93d243047..754b14ca87a7 100644
> --- a/kernel/trace/trace_events.c
> +++ b/kernel/trace/trace_events.c
> @@ -710,6 +710,8 @@ int trace_event_reg(struct trace_event_call *call,
>  
>  #ifdef CONFIG_PERF_EVENTS
>  	case TRACE_REG_PERF_REGISTER:
> +		if (!call->class->perf_probe)
> +			return -ENODEV;
>  		return tracepoint_probe_register(call->tp,
>  						 call->class->perf_probe,
>  						 call);
> -- 
> 2.51.0
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] tracing: Do not register unsupported perf events
  2025-12-16 23:24 [PATCH] tracing: Do not register unsupported perf events Steven Rostedt
  2025-12-22  9:27 ` Jiri Olsa
@ 2025-12-23 18:22 ` Namhyung Kim
  2025-12-23 21:46   ` Steven Rostedt
  1 sibling, 1 reply; 4+ messages in thread
From: Namhyung Kim @ 2025-12-23 18:22 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: LKML, Linux Trace Kernel, Masami Hiramatsu, Mathieu Desnoyers,
	Ian Rogers, Arnaldo Carvalho de Melo, Jiri Olsa

Hi Steve,

On Tue, Dec 16, 2025 at 06:24:40PM -0500, Steven Rostedt wrote:
> From: Steven Rostedt <rostedt@goodmis.org>
> 
> Synthetic events currently do not have a function to register perf events.
> This leads to calling the tracepoint register functions with a NULL
> function pointer which triggers:
> 
>  ------------[ cut here ]------------
>  WARNING: kernel/tracepoint.c:175 at tracepoint_add_func+0x357/0x370, CPU#2: perf/2272
>  Modules linked in: kvm_intel kvm irqbypass
>  CPU: 2 UID: 0 PID: 2272 Comm: perf Not tainted 6.18.0-ftest-11964-ge022764176fc-dirty #323 PREEMPTLAZY
>  Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.17.0-debian-1.17.0-1 04/01/2014
>  RIP: 0010:tracepoint_add_func+0x357/0x370
>  Code: 28 9c e8 4c 0b f5 ff eb 0f 4c 89 f7 48 c7 c6 80 4d 28 9c e8 ab 89 f4 ff 31 c0 5b 41 5c 41 5d 41 5e 41 5f 5d c3 cc cc cc cc cc <0f> 0b 49 c7 c6 ea ff ff ff e9 ee fe ff ff 0f 0b e9 f9 fe ff ff 0f
>  RSP: 0018:ffffabc0c44d3c40 EFLAGS: 00010246
>  RAX: 0000000000000001 RBX: ffff9380aa9e4060 RCX: 0000000000000000
>  RDX: 000000000000000a RSI: ffffffff9e1d4a98 RDI: ffff937fcf5fd6c8
>  RBP: 0000000000000001 R08: 0000000000000007 R09: ffff937fcf5fc780
>  R10: 0000000000000003 R11: ffffffff9c193910 R12: 000000000000000a
>  R13: ffffffff9e1e5888 R14: 0000000000000000 R15: ffffabc0c44d3c78
>  FS:  00007f6202f5f340(0000) GS:ffff93819f00f000(0000) knlGS:0000000000000000
>  CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
>  CR2: 000055d3162281a8 CR3: 0000000106a56003 CR4: 0000000000172ef0
>  Call Trace:
>   <TASK>
>   tracepoint_probe_register+0x5d/0x90
>   synth_event_reg+0x3c/0x60
>   perf_trace_event_init+0x204/0x340
>   perf_trace_init+0x85/0xd0
>   perf_tp_event_init+0x2e/0x50
>   perf_try_init_event+0x6f/0x230
>   ? perf_event_alloc+0x4bb/0xdc0
>   perf_event_alloc+0x65a/0xdc0
>   __se_sys_perf_event_open+0x290/0x9f0
>   do_syscall_64+0x93/0x7b0
>   ? entry_SYSCALL_64_after_hwframe+0x76/0x7e
>   ? trace_hardirqs_off+0x53/0xc0
>   entry_SYSCALL_64_after_hwframe+0x76/0x7e
> 
> Instead, have the code return -ENODEV, which doesn't warn and has perf
> error out with:
> 
>  # perf record -e synthetic:futex_wait
> Error:
> The sys_perf_event_open() syscall returned with 19 (No such device) for event (synthetic:futex_wait).
> "dmesg | grep -i perf" may provide additional information.
> 
> Ideally perf should support synthetic events, but for now just fix the
> warning. The support can come later.
> 
> Cc: stable@vger.kernel.org
> Fixes: 4b147936fa509 ("tracing: Add support for 'synthetic' events")
> Reported-by: Ian Rogers <irogers@google.com>
> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>

Reviewed-by: Namhyung Kim <namhyung@kernel.org>

Thanks,
Namhyung

> ---
>  kernel/trace/trace_events.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
> index a5a93d243047..754b14ca87a7 100644
> --- a/kernel/trace/trace_events.c
> +++ b/kernel/trace/trace_events.c
> @@ -710,6 +710,8 @@ int trace_event_reg(struct trace_event_call *call,
>  
>  #ifdef CONFIG_PERF_EVENTS
>  	case TRACE_REG_PERF_REGISTER:
> +		if (!call->class->perf_probe)
> +			return -ENODEV;
>  		return tracepoint_probe_register(call->tp,
>  						 call->class->perf_probe,
>  						 call);
> -- 
> 2.51.0
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] tracing: Do not register unsupported perf events
  2025-12-23 18:22 ` Namhyung Kim
@ 2025-12-23 21:46   ` Steven Rostedt
  0 siblings, 0 replies; 4+ messages in thread
From: Steven Rostedt @ 2025-12-23 21:46 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: LKML, Linux Trace Kernel, Masami Hiramatsu, Mathieu Desnoyers,
	Ian Rogers, Arnaldo Carvalho de Melo, Jiri Olsa

On Tue, 23 Dec 2025 10:22:18 -0800
Namhyung Kim <namhyung@kernel.org> wrote:

> Reviewed-by: Namhyung Kim <namhyung@kernel.org>
> 
> Thanks,
> Namhyung
> 
> > ---
> >  kernel/trace/trace_events.c | 2 ++
> >  1 file changed, 2 insertions(+)
> > 
> > diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
> > index a5a93d243047..754b14ca87a7 100644
> > --- a/kernel/trace/trace_events.c
> > +++ b/kernel/trace/trace_events.c
> > @@ -710,6 +710,8 @@ int trace_event_reg(struct trace_event_call *call,
> >  
> >  #ifdef CONFIG_PERF_EVENTS
> >  	case TRACE_REG_PERF_REGISTER:
> > +		if (!call->class->perf_probe)
> > +			return -ENODEV;

Thanks Namhyung (and Jiri), but this actually already made it upstream as
it was a bug fix and I wanted to get it into the next rc release (rc2).

But, the real fix is having perf be able to handle synthetic_events as real
events.

Can you please review this patch:

  https://lore.kernel.org/linux-trace-kernel/20251217113920.50b56246@gandalf.local.home/

I plan on queuing that for the next merge window.

Thanks,

-- Steve


> >  		return tracepoint_probe_register(call->tp,
> >  						 call->class->perf_probe,
> >  						 call);
> > -- 

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-12-23 21:45 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-16 23:24 [PATCH] tracing: Do not register unsupported perf events Steven Rostedt
2025-12-22  9:27 ` Jiri Olsa
2025-12-23 18:22 ` Namhyung Kim
2025-12-23 21:46   ` Steven Rostedt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).