All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] tracing/perf: Clear stop state in perf_trace_add()
  2026-11-03 13:07 [PATCH 0/2] perf: Fix PERF_EVENT_IOC_REFRESH for tracepoints and breakpoints Paolo Bertinetti
@ 2026-11-03 13:07 ` Paolo Bertinetti
  2026-11-03 13:14   ` sashiko-bot
  0 siblings, 1 reply; 4+ messages in thread
From: Paolo Bertinetti @ 2026-11-03 13:07 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar
  Cc: Steven Rostedt, Masami Hiramatsu, Mathieu Desnoyers,
	Arnaldo Carvalho de Melo, Namhyung Kim, Mark Rutland,
	Alexander Shishkin, Jiri Olsa, Ian Rogers, Adrian Hunter,
	James Clark, Kan Liang, Leo Yan, Francesco Nigro,
	Sumanth Korikkar, linux-perf-users, linux-trace-kernel,
	linux-kernel, regressions

Since commit 18dbcbfabfff ("perf: Fix the POLL_HUP delivery breakage"),
__perf_event_overflow() stops the event with pmu->stop() and disables
it when the PERF_EVENT_IOC_REFRESH limit is reached. When userspace
re-arms the event with PERF_EVENT_IOC_REFRESH, the event is enabled
again and pmu->add() is called with PERF_EF_START.

perf_trace_add() sets PERF_HES_STOPPED when PERF_EF_START is missing,
but never clears it. The flag set by pmu->stop() stays, and
perf_tp_event_match() drops every later hit. A tracepoint, kprobe or
uprobe event re-armed this way delivers only its first overflow. This
breaks self-profilers such as async-profiler, and the "Event re-armed
with PERF_EVENT_IOC_REFRESH" perf test fails:

  1000 events, count 1, 1 overflows (1 POLL_HUP), re-arm errno 0
  Tracepoint event : FAILED!

Set the state from PERF_EF_START on every add, as perf_swevent_add()
does.

Fixes: 18dbcbfabfff ("perf: Fix the POLL_HUP delivery breakage")
Reported-by: Francesco Nigro <nigro.fra@gmail.com>
Closes: https://lore.kernel.org/r/20261021131006.2101248-1-nigro.fra@gmail.com/
Assisted-by: LLM
Signed-off-by: Paolo Bertinetti <paolobertinetti200f4@proton.me>
Cc: stable@vger.kernel.org
Link: https://github.com/async-profiler/async-profiler/issues/1813
---
 kernel/trace/trace_event_perf.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/kernel/trace/trace_event_perf.c b/kernel/trace/trace_event_perf.c
index 5b272856e5ab..a549897ee408 100644
--- a/kernel/trace/trace_event_perf.c
+++ b/kernel/trace/trace_event_perf.c
@@ -354,8 +354,7 @@ int perf_trace_add(struct perf_event *p_event, int flags)
 	struct trace_event_call *tp_event = p_event->tp_event;
 	struct hw_perf_event *hwc = &p_event->hw;
 
-	if (!(flags & PERF_EF_START))
-		p_event->hw.state = PERF_HES_STOPPED;
+	hwc->state = (flags & PERF_EF_START) ? 0 : PERF_HES_STOPPED;
 
 	if (is_sampling_event(p_event)) {
 		hwc->last_period = hwc->sample_period;
-- 
2.53.0



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

* [PATCH 1/2] tracing/perf: Clear stop state in perf_trace_add()
@ 2026-11-03 13:09 Paolo Bertinetti
  2026-11-03 13:14 ` sashiko-bot
  0 siblings, 1 reply; 4+ messages in thread
From: Paolo Bertinetti @ 2026-11-03 13:09 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar
  Cc: Steven Rostedt, Masami Hiramatsu, Mathieu Desnoyers,
	Arnaldo Carvalho de Melo, Namhyung Kim, Mark Rutland,
	Alexander Shishkin, Jiri Olsa, Ian Rogers, Adrian Hunter,
	James Clark, Kan Liang, Leo Yan, Francesco Nigro,
	Sumanth Korikkar, linux-perf-users, linux-trace-kernel,
	linux-kernel, regressions

Since commit 18dbcbfabfff ("perf: Fix the POLL_HUP delivery breakage"),
__perf_event_overflow() stops the event with pmu->stop() and disables
it when the PERF_EVENT_IOC_REFRESH limit is reached. When userspace
re-arms the event with PERF_EVENT_IOC_REFRESH, the event is enabled
again and pmu->add() is called with PERF_EF_START.

perf_trace_add() sets PERF_HES_STOPPED when PERF_EF_START is missing,
but never clears it. The flag set by pmu->stop() stays, and
perf_tp_event_match() drops every later hit. A tracepoint, kprobe or
uprobe event re-armed this way delivers only its first overflow. This
breaks self-profilers such as async-profiler, and the "Event re-armed
with PERF_EVENT_IOC_REFRESH" perf test fails:

  1000 events, count 1, 1 overflows (1 POLL_HUP), re-arm errno 0
  Tracepoint event : FAILED!

Set the state from PERF_EF_START on every add, as perf_swevent_add()
does.

Fixes: 18dbcbfabfff ("perf: Fix the POLL_HUP delivery breakage")
Reported-by: Francesco Nigro <nigro.fra@gmail.com>
Closes: https://lore.kernel.org/r/20261021131006.2101248-1-nigro.fra@gmail.com/
Assisted-by: LLM
Signed-off-by: Paolo Bertinetti <paolobertinetti200f4@proton.me>
Cc: stable@vger.kernel.org
Link: https://github.com/async-profiler/async-profiler/issues/1813
---
 kernel/trace/trace_event_perf.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/kernel/trace/trace_event_perf.c b/kernel/trace/trace_event_perf.c
index 5b272856e5ab..a549897ee408 100644
--- a/kernel/trace/trace_event_perf.c
+++ b/kernel/trace/trace_event_perf.c
@@ -354,8 +354,7 @@ int perf_trace_add(struct perf_event *p_event, int flags)
 	struct trace_event_call *tp_event = p_event->tp_event;
 	struct hw_perf_event *hwc = &p_event->hw;
 
-	if (!(flags & PERF_EF_START))
-		p_event->hw.state = PERF_HES_STOPPED;
+	hwc->state = (flags & PERF_EF_START) ? 0 : PERF_HES_STOPPED;
 
 	if (is_sampling_event(p_event)) {
 		hwc->last_period = hwc->sample_period;
-- 
2.53.0



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

* Re: [PATCH 1/2] tracing/perf: Clear stop state in perf_trace_add()
  2026-11-03 13:07 ` [PATCH 1/2] tracing/perf: Clear stop state in perf_trace_add() Paolo Bertinetti
@ 2026-11-03 13:14   ` sashiko-bot
  0 siblings, 0 replies; 4+ messages in thread
From: sashiko-bot @ 2026-11-03 13:14 UTC (permalink / raw)
  To: Paolo Bertinetti; +Cc: linux-perf-users

> Since commit 18dbcbfabfff ("perf: Fix the POLL_HUP delivery breakage"),
> __perf_event_overflow() stops the event with pmu->stop() and disables
> it when the PERF_EVENT_IOC_REFRESH limit is reached. When userspace
> re-arms the event with PERF_EVENT_IOC_REFRESH, the event is enabled
> again and pmu->add() is called with PERF_EF_START.
> 
> perf_trace_add() sets PERF_HES_STOPPED when PERF_EF_START is missing,
> but never clears it. The flag set by pmu->stop() stays, and
> perf_tp_event_match() drops every later hit. A tracepoint, kprobe or
> uprobe event re-armed this way delivers only its first overflow. This
> breaks self-profilers such as async-profiler, and the "Event re-armed
> with PERF_EVENT_IOC_REFRESH" perf test fails:
> 
>   1000 events, count 1, 1 overflows (1 POLL_HUP), re-arm errno 0
>   Tracepoint event : FAILED!
> 
> Set the state from PERF_EF_START on every add, as perf_swevent_add()
> does.
> 
> Fixes: 18dbcbfabfff ("perf: Fix the POLL_HUP delivery breakage")
> Reported-by: Francesco Nigro <nigro.fra@gmail.com>
> Closes: https://lore.kernel.org/r/20261021131006.2101248-1-nigro.fra@gmail.com/
> Assisted-by: LLM
> Signed-off-by: Paolo Bertinetti <paolobertinetti200f4@proton.me>

Sashiko has reviewed this patch and found no issues.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261103130732.764081-1-paolobertinetti200f4@proton.me?part=1


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

* Re: [PATCH 1/2] tracing/perf: Clear stop state in perf_trace_add()
  2026-11-03 13:09 [PATCH 1/2] tracing/perf: Clear stop state in perf_trace_add() Paolo Bertinetti
@ 2026-11-03 13:14 ` sashiko-bot
  0 siblings, 0 replies; 4+ messages in thread
From: sashiko-bot @ 2026-11-03 13:14 UTC (permalink / raw)
  To: Paolo Bertinetti; +Cc: linux-perf-users

> Since commit 18dbcbfabfff ("perf: Fix the POLL_HUP delivery breakage"),
> __perf_event_overflow() stops the event with pmu->stop() and disables
> it when the PERF_EVENT_IOC_REFRESH limit is reached. When userspace
> re-arms the event with PERF_EVENT_IOC_REFRESH, the event is enabled
> again and pmu->add() is called with PERF_EF_START.
> 
> perf_trace_add() sets PERF_HES_STOPPED when PERF_EF_START is missing,
> but never clears it. The flag set by pmu->stop() stays, and
> perf_tp_event_match() drops every later hit. A tracepoint, kprobe or
> uprobe event re-armed this way delivers only its first overflow. This
> breaks self-profilers such as async-profiler, and the "Event re-armed
> with PERF_EVENT_IOC_REFRESH" perf test fails:
> 
>   1000 events, count 1, 1 overflows (1 POLL_HUP), re-arm errno 0
>   Tracepoint event : FAILED!
> 
> Set the state from PERF_EF_START on every add, as perf_swevent_add()
> does.
> 
> Fixes: 18dbcbfabfff ("perf: Fix the POLL_HUP delivery breakage")
> Reported-by: Francesco Nigro <nigro.fra@gmail.com>
> Closes: https://lore.kernel.org/r/20261021131006.2101248-1-nigro.fra@gmail.com/
> Assisted-by: LLM
> Signed-off-by: Paolo Bertinetti <paolobertinetti200f4@proton.me>

Sashiko has reviewed this patch and found no issues.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261103130859.764885-2-paolobertinetti200f4@proton.me?part=1


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

end of thread, other threads:[~2026-11-03 13:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-03 13:09 [PATCH 1/2] tracing/perf: Clear stop state in perf_trace_add() Paolo Bertinetti
2026-11-03 13:14 ` sashiko-bot
  -- strict thread matches above, loose matches on Subject: below --
2026-11-03 13:07 [PATCH 0/2] perf: Fix PERF_EVENT_IOC_REFRESH for tracepoints and breakpoints Paolo Bertinetti
2026-11-03 13:07 ` [PATCH 1/2] tracing/perf: Clear stop state in perf_trace_add() Paolo Bertinetti
2026-11-03 13:14   ` sashiko-bot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.