From: sashiko-bot@kernel.org
To: "Thomas Richter" <tmricht@linux.ibm.com>
Cc: "Christian Borntraeger" <borntraeger@linux.ibm.vom>,
"Vasily Gorbik" <gor@linux.ibm.com>,
linux-s390@vger.kernel.org, "Heiko Carstens" <hca@linux.ibm.com>,
"Alexander Gordeev" <agordeev@linux.ibm.com>
Subject: Re: [PATCH v2] s390/pai: Handle multiple PMU stop callback invocations
Date: Fri, 14 Aug 2026 14:10:18 +0000 [thread overview]
Message-ID: <20260814141018.C5F591F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260814135027.2910179-1-tmricht@linux.ibm.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] The patch uses `list_for_each_entry_safe()` to fix local iteration of `syswide_list` in `pai_have_samples()`, but fails to address a critical core perf list corruption. Synchronously calling `perf_sched_cb_dec()` inside `pai_stop()` during throttling deletes the PMU from the core perf's `sched_cb_list` while it is being actively iterated, causing a `LIST_POISON1` dereference.
--
--- Patch [1]: [PATCH v2] s390/pai: Handle multiple PMU stop callback invocations ---
commit a01c8fd8b7dcb185446a23cc1b40824b995801a5
Author: Thomas Richter <tmricht@linux.ibm.com>
s390/pai: Handle multiple PMU stop callback invocations
This commit adds a check for PERF_HES_STOPPED in PMU->stop() to handle
multiple back-to-back invocations from throttling and scheduling. It also
changes pai_have_samples() to safely iterate syswide_list to prevent list
corruption during synchronous throttling.
> diff --git a/arch/s390/kernel/perf_pai.c b/arch/s390/kernel/perf_pai.c
> index cdb8006220ca0..6d0bf4ddec8f2 100644
> --- a/arch/s390/kernel/perf_pai.c
> +++ b/arch/s390/kernel/perf_pai.c
[ ... ]
> @@ -672,9 +680,9 @@ static void pai_have_samples(int idx)
> {
> struct pai_mapptr *mp = this_cpu_ptr(pai_root[idx].mapptr);
> struct pai_map *cpump = mp->mapptr;
> - struct perf_event *event;
> + struct perf_event *event, *e2;
>
> - list_for_each_entry(event, &cpump->syswide_list, hw.tp_list)
> + list_for_each_entry_safe(event, e2, &cpump->syswide_list, hw.tp_list)
> pai_have_sample(event, cpump);
> }
[Severity: High]
This is a pre-existing issue, but does fixing the local syswide_list
iteration here still leave a similar list corruption in the core perf code?
If a system-wide PAI sampling event with a low sample period overflows
during a context switch (while inside this pai_have_samples() loop), it
can trigger perf_event_throttle(), which synchronously calls pmu->stop().
In that path, pai_stop() calls perf_sched_cb_dec(event->pmu), which mutates
the core sched_cb_list:
arch/s390/kernel/perf_pai.c:pai_stop() {
...
} else { /* Sampling */
if (!(event->attach_state & PERF_ATTACH_TASK)) {
perf_sched_cb_dec(event->pmu);
...
}
However, perf_pmu_sched_task() in kernel/events/core.c iterates that same
sched_cb_list using an unsafe list_for_each_entry() loop:
kernel/events/core.c:perf_pmu_sched_task() {
...
list_for_each_entry(cpc, this_cpu_ptr(&sched_cb_list), sched_cb_entry)
__perf_pmu_sched_task(cpc, sched_in ? next : prev, sched_in);
...
}
Could this synchronous perf_sched_cb_dec() call from pai_stop() during
throttling still cause a LIST_POISON1 dereference crash inside
perf_pmu_sched_task()?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260814135027.2910179-1-tmricht@linux.ibm.com?part=1
prev parent reply other threads:[~2026-08-14 14:10 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-14 13:50 [PATCH v2] s390/pai: Handle multiple PMU stop callback invocations Thomas Richter
2026-08-14 14:10 ` 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=20260814141018.C5F591F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=agordeev@linux.ibm.com \
--cc=borntraeger@linux.ibm.vom \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=linux-s390@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=tmricht@linux.ibm.com \
/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;
as well as URLs for NNTP newsgroup(s).