From: sashiko-bot@kernel.org
To: "Tvrtko Ursulin" <tvrtko.ursulin@igalia.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [RFC v4 1/2] workqueue: Add support for real-time workers
Date: Tue, 04 Aug 2026 10:41:12 +0000 [thread overview]
Message-ID: <20260804104112.852271F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260804101925.55414-2-tvrtko.ursulin@igalia.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
New issues:
- [High] The rescuer thread for a WQ_RTPRI workqueue executes at SCHED_NORMAL (nice -20) rather than SCHED_FIFO, breaking real-time forward-progress guarantees during memory reclaim.
Pre-existing issues:
- [High] restore_unbound_workers_cpumask() restores worker CPU affinity to the generic pool cpumask instead of the strict pod cpumask, permanently breaking strict CPU affinity upon CPU hotplug.
--
--- Patch [1]: [RFC v4 1/2] workqueue: Add support for real-time workers ---
commit ef8ef0836020dc31230998f47b57b20e84e4a78c
Author: Tvrtko Ursulin <tvrtko.ursulin@igalia.com>
workqueue: Add support for real-time workers
This commit adds support for real-time workers to workqueues by introducing
the WQ_RTPRI flag. These workers use the SCHED_FIFO scheduling policy to
minimize latency spikes for low-latency use cases like DRM scheduling.
> diff --git a/kernel/workqueue.c b/kernel/workqueue.c
> index 78068ae8f28a6..6b60380a87425 100644
> --- a/kernel/workqueue.c
> +++ b/kernel/workqueue.c
[ ... ]
> @@ -5814,6 +5829,12 @@ static struct workqueue_struct *__alloc_workqueue(const char *fmt,
> return NULL;
> }
>
> + if (flags & WQ_RTPRI) {
> + if (WARN_ON_ONCE((flags & (WQ_HIGHPRI | WQ_UNBOUND)) !=
> + WQ_UNBOUND))
> + return NULL;
> + }
> +
[Severity: High]
Does this code handle the rescuer thread correctly if WQ_RTPRI is combined
with WQ_MEM_RECLAIM?
If normal SCHED_FIFO workers block and memory reclaim is required, the
rescuer thread is created without setting a real-time policy. In
rescuer_thread(), it unconditionally calls set_user_nice() which leaves the
task in SCHED_NORMAL:
kernel/workqueue.c:rescuer_thread() {
...
set_user_nice(current, RESCUER_NICE_LEVEL);
...
}
Will this cause a priority inversion where the rescuer runs at a lower
priority than other RT tasks and normal RT workers, potentially starving
the rescuer?
[ ... ]
> @@ -8023,23 +8057,34 @@ void __init workqueue_init_early(void)
[ ... ]
> /* create default unbound and ordered wq attrs */
> - for (i = 0; i < NR_STD_WORKER_POOLS; i++) {
> + for (i = 0; i < NR_WQ_ATTRIBUTES; i++) {
> struct workqueue_attrs *attrs;
>
> BUG_ON(!(attrs = alloc_workqueue_attrs()));
> + attrs->prio = std_prio[i];
> attrs->nice = std_nice[i];
> + if (i == WQ_PRIO_RT) {
> + /*
> + * RT workqueues have strict CPU affinity for low
> + * latency execution.
> + */
> + attrs->affn_scope = WQ_AFFN_CPU;
> + attrs->affn_strict = true;
> + }
[Severity: High]
This is a pre-existing issue and was not introduced by the patch under
review, but does CPU hotplug break this strict affinity?
When a CPU comes online, restore_unbound_workers_cpumask() resets the
workers' affinity mask to pool->attrs->cpumask & cpu_online_mask instead
of using the strict pod isolation:
kernel/workqueue.c:restore_unbound_workers_cpumask() {
...
cpumask_and(&cpumask, pool->attrs->cpumask, cpu_online_mask);
/* as we're called from CPU_ONLINE, the following shouldn't fail */
for_each_pool_worker(worker, pool)
WARN_ON_ONCE(set_cpus_allowed_ptr(worker->task, &cpumask) < 0);
...
}
Since pool->attrs->cpumask represents the global workqueue mask, will
WQ_RTPRI workers suddenly be permitted to migrate freely across all online
CPUs after a hotplug event, completely destroying the strict pod isolation?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260804101925.55414-1-tvrtko.ursulin@igalia.com?part=1
next prev parent reply other threads:[~2026-08-04 10:41 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-04 10:19 [RFC v4 0/2] Realtime workqueues and panthor realtime submission Tvrtko Ursulin
2026-08-04 10:19 ` [RFC v4 1/2] workqueue: Add support for real-time workers Tvrtko Ursulin
2026-08-04 10:41 ` sashiko-bot [this message]
2026-08-04 10:19 ` [RFC v4 2/2] drm/panthor: Create per queue priority workqueues Tvrtko Ursulin
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=20260804104112.852271F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=tvrtko.ursulin@igalia.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