From: Tvrtko Ursulin <tvrtko.ursulin@igalia.com>
To: linux-kernel@vger.kernel.org
Cc: dri-devel@lists.freedesktop.org, kernel-dev@igalia.com,
Tvrtko Ursulin <tvrtko.ursulin@igalia.com>,
Boris Brezillon <boris.brezillon@collabora.com>,
Chia-I Wu <olv@google.com>, Liviu Dudau <liviu.dudau@arm.com>,
Matthew Brost <matthew.brost@intel.com>,
Steven Price <steven.price@arm.com>, Tejun Heo <tj@kernel.org>
Subject: [PATCH v8 5/6] workqueue: Imply strict CPU affinity for WQ_RT
Date: Wed, 4 Nov 2026 09:52:24 +0000 [thread overview]
Message-ID: <20261104095225.32654-6-tvrtko.ursulin@igalia.com> (raw)
In-Reply-To: <20261104095225.32654-1-tvrtko.ursulin@igalia.com>
Imply and set strict CPU affinity for WQ_RT workqueues for even lower
worst case execution latency.
With this, a benchmark which measures the GPU submit latency against a
real-time Vulkan queue when faced with CPU saturation, highlights a
dramatic reduction in maximum observed latencies and further reduction in
the median, and 95- and 98-the percentiles:
us 7.3.0 WQ_RT +strict_affinity
median 30 21 11
min 2 3 2
max 1038 941 108
95pct 2384 49 28
98pct 2922 63 51
Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@igalia.com>
Cc: Boris Brezillon <boris.brezillon@collabora.com>
Cc: Chia-I Wu <olv@google.com>
Cc: Liviu Dudau <liviu.dudau@arm.com>
Cc: Matthew Brost <matthew.brost@intel.com>
Cc: Steven Price <steven.price@arm.com>
Cc: Tejun Heo <tj@kernel.org>
---
Documentation/core-api/workqueue.rst | 5 +++--
kernel/workqueue.c | 13 ++++++++++---
2 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/Documentation/core-api/workqueue.rst b/Documentation/core-api/workqueue.rst
index 54697907f2b0..d699c3832b19 100644
--- a/Documentation/core-api/workqueue.rst
+++ b/Documentation/core-api/workqueue.rst
@@ -226,8 +226,9 @@ resources, scheduled and executed.
implements concurrency management among its workers.
``WQ_RT``
- Real-time priority workqueues must be created as unbound. Their worker threads
- use the FIFO scheduling policy with the lowest applicable priority.
+ Real-time priority workqueues must be created as unbound and will be
+ configured with the strict CPU affinity set. Their worker threads use the FIFO
+ scheduling policy with the lowest applicable priority.
To be used sparingly for use cases such as the real-time GPU rendering
contexts accessible to privileged clients.
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 637240667cf7..26a26831bee7 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -5723,8 +5723,12 @@ static void
sanitize_immutable_workqueue_attrs(struct workqueue_struct *wq,
struct workqueue_attrs *attrs)
{
- if (wq->flags & WQ_RT)
+ if (wq->flags & WQ_RT) {
attrs->prio = RT_PRIORITY;
+ /* Strict CPU affinity for low latency execution. */
+ attrs->affn_scope = WQ_AFFN_CPU;
+ attrs->affn_strict = true;
+ }
if (wq->flags & __WQ_ORDERED)
attrs->ordered = true;
@@ -7847,8 +7851,11 @@ static umode_t wq_sysfs_unbound_group_visible(struct kobject *kobj,
if (!(wq->flags & WQ_UNBOUND))
return 0;
- /* Do not allow priority changes for RT workers. */
- if ((wq->flags & WQ_RT) && (attr == &dev_attr_nice.attr))
+ /* Do not allow priority and affinity changes for RT workers. */
+ if ((wq->flags & WQ_RT) &&
+ (attr == &dev_attr_nice.attr ||
+ attr == &dev_attr_affinity_scope.attr ||
+ attr == &dev_attr_affinity_strict.attr))
return 0444;
return attr->mode;
--
2.56.0
next prev parent reply other threads:[~2026-11-04 9:52 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-04 9:52 [PATCH v8 0/6] Realtime workqueues and panthor realtime submission Tvrtko Ursulin
2026-11-04 9:52 ` [PATCH v8 1/6] workqueue: Simplify unbound sysfs attribute registration Tvrtko Ursulin
2026-11-04 9:52 ` [PATCH v8 2/6] workqueue: Separate sysfs mutable vs immutable wq attribute sanitizing Tvrtko Ursulin
2026-11-04 9:52 ` [PATCH v8 3/6] workqueue: Convert nice value tracking to priority based Tvrtko Ursulin
2026-11-04 9:52 ` [PATCH v8 4/6] workqueue: Add support for real-time workers Tvrtko Ursulin
2026-11-04 9:52 ` Tvrtko Ursulin [this message]
2026-11-04 9:52 ` [PATCH v8 6/6] 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=20261104095225.32654-6-tvrtko.ursulin@igalia.com \
--to=tvrtko.ursulin@igalia.com \
--cc=boris.brezillon@collabora.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=kernel-dev@igalia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=liviu.dudau@arm.com \
--cc=matthew.brost@intel.com \
--cc=olv@google.com \
--cc=steven.price@arm.com \
--cc=tj@kernel.org \
/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®