From: sashiko-bot@kernel.org
To: "Thomas Richter" <tmricht@linux.ibm.com>
Cc: "Heiko Carstens" <hca@linux.ibm.com>,
"Vasily Gorbik" <gor@linux.ibm.com>,
"Christian Borntraeger" <borntraeger@linux.ibm.com>,
"Alexander Gordeev" <agordeev@linux.ibm.com>,
linux-s390@vger.kernel.org
Subject: Re: [PATCH 3/3 v5] s390/pai: Support CPU hotplug for PMU PAI
Date: Mon, 24 Aug 2026 13:27:42 +0000 [thread overview]
Message-ID: <20260824132743.07F5B1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260824131751.179275-4-tmricht@linux.ibm.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Calling `cpus_read_lock()` inside CPU hotplug callbacks causes a guaranteed self-deadlock.
--
--- Patch [3]: [PATCH 3/3 v5] s390/pai: Support CPU hotplug for PMU PAI ---
commit c7c540e2c7341f700711120ef64b2203ca9970ed
Author: Thomas Richter <tmricht@linux.ibm.com>
s390/pai: Support CPU hotplug for PMU PAI
This patch adds CPU hotplug support for the PAI PMU driver. It allocates and
frees per-CPU data structures during CPU online and offline operations to
prevent a kernel panic when PMU callbacks run on newly onlined CPUs.
> diff --git a/arch/s390/kernel/perf_pai.c b/arch/s390/kernel/perf_pai.c
> --- a/arch/s390/kernel/perf_pai.c
> +++ b/arch/s390/kernel/perf_pai.c
[ ... ]
> @@ -1216,8 +1256,38 @@ static int __init paipmu_setup(void)
> return install_ok;
> }
>
> +static int pai_online_cpu(unsigned int cpu)
> +{
> + int rc;
> +
> + cpus_read_lock();
[Severity: High]
Will this cause a self-deadlock? The CPU hotplug core already holds the
cpu_hotplug_lock for writing when it invokes the hotplug callbacks.
Attempting to acquire it for reading via cpus_read_lock() here seems like
it would cause a deadlock, as percpu_rwsem does not support recursive
read-after-write locking.
> + mutex_lock(&pai_reserve_mutex);
> + rc = pai_alloc_cpu(PAI_PMU_CRYPTO, cpu, true);
> + if (!rc) {
> + rc = pai_alloc_cpu(PAI_PMU_EXT, cpu, true);
> + if (rc)
> + pai_event_destroy_cpu(PAI_PMU_CRYPTO, cpu, true);
> + }
> + mutex_unlock(&pai_reserve_mutex);
> + cpus_read_unlock();
> + return rc;
> +}
> +
> +static int pai_offline_cpu(unsigned int cpu)
> +{
> + cpus_read_lock();
[Severity: High]
Similarly, does calling cpus_read_lock() here in the offline callback cause
a self-deadlock for the same reason?
> + mutex_lock(&pai_reserve_mutex);
> + pai_event_destroy_cpu(PAI_PMU_CRYPTO, cpu, true);
> + pai_event_destroy_cpu(PAI_PMU_EXT, cpu, true);
> + mutex_unlock(&pai_reserve_mutex);
> + cpus_read_unlock();
> + return 0;
> +}
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260824131751.179275-1-tmricht@linux.ibm.com?part=3
prev parent reply other threads:[~2026-08-24 13:27 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-24 13:17 [PATCH 0/3 v5] Add CPU hotplug support for PAI PMU Thomas Richter
2026-08-24 13:17 ` [PATCH 1/3] s390/pai: Use PAI PMU index as parameter replacing event Thomas Richter
2026-08-24 13:26 ` sashiko-bot
2026-08-24 13:17 ` [PATCH 2/3] s390/pai: Move locking to event init and delete Thomas Richter
2026-08-24 13:29 ` sashiko-bot
2026-08-24 13:17 ` [PATCH 3/3 v5] s390/pai: Support CPU hotplug for PMU PAI Thomas Richter
2026-08-24 13:27 ` 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=20260824132743.07F5B1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=agordeev@linux.ibm.com \
--cc=borntraeger@linux.ibm.com \
--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