From: sashiko-bot@kernel.org
To: "Leo Yan" <leo.yan@arm.com>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH 2/2] Revert "perf: Fix the POLL_HUP delivery breakage"
Date: Wed, 13 May 2026 23:30:12 +0000 [thread overview]
Message-ID: <20260513233012.A00D6C19425@smtp.kernel.org> (raw)
In-Reply-To: <20260512-arm_cs_clean_perf_handle-v1-2-75ff373ecd22@arm.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Removing the synchronous `event->pmu->stop(event, 0)` re-introduces a race condition where the PMU hardware is not stopped synchronously when `event_limit` reaches 0, allowing spurious hardware interrupts to clobber the `POLL_HUP` signal.
--
commit 0345ee403573bb4c49df3d0db2209160312a4bd6
Author: Leo Yan <leo.yan@arm.com>
Revert "perf: Fix the POLL_HUP delivery breakage"
This commit reverts the addition of a synchronous PMU stop call during
event overflow when the event limit reaches zero. It relies instead on
the asynchronous irq_work scheduled by perf_event_disable_inatomic() to
disable the event, removing the direct hardware stop.
Link: https://lore.kernel.org/lkml/aICYAqM5EQUlTqtX@li-2b55cdcc-350b-11b2-a85c-a78bff51fc11.ibm.com/
> diff --git a/kernel/events/core.c b/kernel/events/core.c
> --- a/kernel/events/core.c
> +++ b/kernel/events/core.c
> @@ -10750,7 +10750,6 @@ static int __perf_event_overflow(struct perf_event *event,
> ret = 1;
> event->pending_kill = POLL_HUP;
> perf_event_disable_inatomic(event);
> - event->pmu->stop(event, 0);
Does removing this synchronous stop introduce a race condition with
subsequent hardware interrupts?
Looking at perf_event_disable_inatomic(), it does not synchronously stop
the PMU hardware. Instead, it queues an asynchronous irq_work. Because
architecture PMU interrupt handlers generally re-enable the PMU globally
before returning from the NMI/IRQ, the counter can remain active and
overflow again before the scheduled irq_work actually executes.
If a subsequent overflow occurs, __perf_event_overflow() is re-entered
and unconditionally sets pending_kill to POLL_IN:
__perf_event_overflow() {
...
event->pending_kill = POLL_IN;
if (events && atomic_dec_and_test(&event->event_limit)) {
ret = 1;
event->pending_kill = POLL_HUP;
perf_event_disable_inatomic(event);
}
...
}
Since event_limit is already 0 at this point, the if condition fails, and
pending_kill remains set to POLL_IN.
When the irq_work finally runs, could this sequence cause it to deliver
POLL_IN instead of the expected POLL_HUP, silently breaking userspace
expectations?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260512-arm_cs_clean_perf_handle-v1-0-75ff373ecd22@arm.com?part=2
prev parent reply other threads:[~2026-05-13 23:30 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-12 14:59 [PATCH 0/2] perf: Revert direct PMU stop for refresh limit Leo Yan
2026-05-12 14:59 ` [PATCH 1/2] selftests/perf_events: Add test for refresh limit signals Leo Yan
2026-05-13 22:42 ` sashiko-bot
2026-05-12 14:59 ` [PATCH 2/2] Revert "perf: Fix the POLL_HUP delivery breakage" Leo Yan
2026-05-13 23:30 ` sashiko-bot [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260513233012.A00D6C19425@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=leo.yan@arm.com \
--cc=linux-perf-users@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox