From: sashiko-bot@kernel.org
To: "Mohamed Ayman" <mohamedaymanworkspace@gmail.com>
Cc: linux-rt-devel@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4] coresight: Fix scheduling while atomic in coresight_cpu_pm_notify()
Date: Wed, 22 Jul 2026 04:45:03 +0000 [thread overview]
Message-ID: <20260722044503.BCEF31F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260722043023.6978-1-mohamedaymanworkspace@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] The 'scheduling while atomic' bug remains unfixed in `coresight_put_percpu_source_ref()`, which can still trigger a system panic on PREEMPT_RT for other callers.
--
--- Patch [1]: [PATCH v4] coresight: Fix scheduling while atomic in coresight_cpu_pm_notify() ---
commit ced604f31de6d94adb2f729f01f491fe1766f6d1
Author: Mohamed Ayman <mohamedaymanworkspace@gmail.com>
coresight: Fix scheduling while atomic in coresight_cpu_pm_notify()
This commit addresses a "scheduling while atomic" bug on PREEMPT_RT in the
PM notifier path. It removes the get/put kobject reference dance, and instead
reads the per-cpu source pointer directly under the coresight_dev_lock.
> diff --git a/drivers/hwtracing/coresight/coresight-core.c b/drivers/hwtracing/coresight/coresight-core.c
> index 6d65c43d574fd..9461fac9f1a3d 100644
> --- a/drivers/hwtracing/coresight/coresight-core.c
> +++ b/drivers/hwtracing/coresight/coresight-core.c
> @@ -1850,16 +1850,13 @@ static void coresight_release_device_list(void)
> static struct coresight_path *coresight_cpu_get_active_path(enum cs_mode mode)
> {
> struct coresight_device *source;
> - bool is_active = false;
> + struct coresight_path *path = NULL;
>
> - source = coresight_get_percpu_source_ref(smp_processor_id());
> - if (!source)
> - return NULL;
> -
> - if (coresight_get_mode(source) & mode)
> - is_active = true;
> + guard(raw_spinlock_irqsave)(&coresight_dev_lock);
>
> - coresight_put_percpu_source_ref(source);
[Severity: High]
This is a pre-existing issue, but while this patch avoids the bug in this
specific PM notifier path, does coresight_put_percpu_source_ref() still
contain the exact same "scheduling while atomic" vulnerability for other
callers?
Looking at coresight_put_percpu_source_ref() in
drivers/hwtracing/coresight/coresight-core.c:
guard(raw_spinlock_irqsave)(&coresight_dev_lock);
/*
* TODO: coresight_device_release() is invoked to release resources when
* the device's refcount reaches zero. It then calls free_percpu(),
* which acquires pcpu_lock — a sleepable lock when PREEMPT_RT is
* enabled. Since the raw spinlock coresight_dev_lock is held, this can
* lead to a potential "scheduling while atomic" issue.
*/
put_device(&csdev->dev);
If put_device() drops the final reference concurrently with device
unregistration, it synchronously triggers the release function
coresight_device_release(). This cascade eventually calls free_percpu(),
which on PREEMPT_RT attempts to acquire the sleepable pcpu_lock.
Because coresight_put_percpu_source_ref() holds coresight_dev_lock (a raw
spinlock) via the guard during the put_device() call, could acquiring the
sleeping lock still cause a kernel panic if other callers hit this race?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260722043023.6978-1-mohamedaymanworkspace@gmail.com?part=1
prev parent reply other threads:[~2026-07-22 4:45 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-12 21:04 [PATCH] coresight: Fix scheduling while atomic in coresight_device_release() Mohamed Ayman
2026-07-12 21:17 ` sashiko-bot
2026-07-13 3:07 ` Jie Gan
2026-07-13 23:00 ` [PATCH v2] coresight: Fix scheduling while atomic in coresight_put_percpu_source_ref() Mohamed Ayman
2026-07-13 23:17 ` sashiko-bot
2026-07-14 10:42 ` Sebastian Andrzej Siewior
2026-07-14 19:42 ` MOHAMED AYMAN
2026-07-15 6:58 ` Sebastian Andrzej Siewior
2026-07-16 3:07 ` MOHAMED AYMAN
2026-07-16 12:32 ` Sebastian Andrzej Siewior
2026-07-16 21:41 ` [PATCH v3] coresight: Fix scheduling while atomic in coresight_cpu_pm_notify() Mohamed Ayman
2026-07-16 22:05 ` sashiko-bot
2026-07-17 8:14 ` Sebastian Andrzej Siewior
2026-07-17 10:49 ` Leo Yan
2026-07-17 15:58 ` Leo Yan
2026-07-17 16:12 ` Sebastian Andrzej Siewior
2026-07-19 9:33 ` MOHAMED AYMAN
2026-07-21 14:57 ` Leo Yan
2026-07-21 15:21 ` Leo Yan
2026-07-22 4:30 ` [PATCH v4] " Mohamed Ayman
2026-07-22 4:45 ` 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=20260722044503.BCEF31F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rt-devel@lists.linux.dev \
--cc=mohamedaymanworkspace@gmail.com \
--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
all inboxes | Powered by JetHome®