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>,
Bradley Morgan <include@grrlz.net>, 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 v7 2/4] workqueue: Separate sysfs mutable vs immutable wq attribute sanitizing
Date: Thu, 22 Oct 2026 10:38:46 +0100 [thread overview]
Message-ID: <20261022093848.5727-3-tvrtko.ursulin@igalia.com> (raw)
In-Reply-To: <20261022093848.5727-1-tvrtko.ursulin@igalia.com>
In preparation for adding more sanitization steps split the current ones
into ones which are immutable and the ones which can be modified from
sysfs.
Point being that the mutable steps must only run on the initial workqueue
creation, while the immutable properties need to be sanitized every time
attributes are applied.
Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@igalia.com>
Cc: Boris Brezillon <boris.brezillon@collabora.com>
Cc: Bradley Morgan <include@grrlz.net>
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>
---
kernel/workqueue.c | 49 ++++++++++++++++++++++++++++------------------
1 file changed, 30 insertions(+), 19 deletions(-)
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index d8cf546d853f..c634b20f1874 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -5706,6 +5706,32 @@ static void apply_wqattrs_cleanup(struct apply_wqattrs_ctx *ctx)
}
}
+/* Sanitize attributes not modifiable via sysfs. */
+static void
+sanitize_immutable_workqueue_attrs(struct workqueue_struct *wq,
+ struct workqueue_attrs *attrs)
+{
+ if (wq->flags & __WQ_ORDERED)
+ attrs->ordered = true;
+}
+
+/* Sanitize attributes modifiable via sysfs. */
+static void
+sanitize_mutable_workqueue_attrs(struct workqueue_struct *wq,
+ struct workqueue_attrs *attrs)
+{
+ if (wq->flags & WQ_HIGHPRI)
+ attrs->nice = HIGHPRI_NICE_LEVEL;
+}
+
+static void
+sanitize_workqueue_attrs(struct workqueue_struct *wq,
+ struct workqueue_attrs *attrs)
+{
+ sanitize_immutable_workqueue_attrs(wq, attrs);
+ sanitize_mutable_workqueue_attrs(wq, attrs);
+}
+
/* allocate the attrs and pwqs for later installation */
static struct apply_wqattrs_ctx *
apply_wqattrs_prepare(struct workqueue_struct *wq,
@@ -5735,6 +5761,7 @@ apply_wqattrs_prepare(struct workqueue_struct *wq,
* every possible CPU and never falls back, so it has no default.
*/
copy_workqueue_attrs(new_attrs, attrs);
+ sanitize_immutable_workqueue_attrs(wq, new_attrs);
wqattrs_actualize_cpumask(new_attrs, unbound_cpumask);
cpumask_copy(new_attrs->__pod_cpumask, new_attrs->cpumask);
if (!(wq->flags & WQ_PERCPU)) {
@@ -5757,6 +5784,7 @@ apply_wqattrs_prepare(struct workqueue_struct *wq,
/* save the user configured attrs and sanitize it. */
copy_workqueue_attrs(new_attrs, attrs);
+ sanitize_immutable_workqueue_attrs(wq, new_attrs);
cpumask_and(new_attrs->cpumask, new_attrs->cpumask, cpu_possible_mask);
cpumask_copy(new_attrs->__pod_cpumask, new_attrs->cpumask);
ctx->attrs = new_attrs;
@@ -5919,24 +5947,6 @@ static void unbound_wq_update_pwq(struct workqueue_struct *wq, int cpu)
put_pwq_unlocked(old_pwq);
}
-/* the attrs @wq asked for, as spelled by its flags */
-static struct workqueue_attrs *alloc_wq_std_attrs(struct workqueue_struct *wq)
-{
- struct workqueue_attrs *attrs;
-
- attrs = alloc_workqueue_attrs();
- if (!attrs)
- return NULL;
-
- if (wq->flags & WQ_HIGHPRI)
- attrs->nice = HIGHPRI_NICE_LEVEL;
-
- if (wq->flags & __WQ_ORDERED)
- attrs->ordered = true;
-
- return attrs;
-}
-
static int alloc_and_link_pwqs(struct workqueue_struct *wq)
{
struct workqueue_attrs *attrs;
@@ -5948,10 +5958,11 @@ static int alloc_and_link_pwqs(struct workqueue_struct *wq)
if (!wq->cpu_pwq)
goto enomem;
- attrs = alloc_wq_std_attrs(wq);
+ attrs = alloc_workqueue_attrs();
if (!attrs)
goto enomem;
+ sanitize_workqueue_attrs(wq, attrs);
ret = apply_workqueue_attrs_locked(wq, attrs);
free_workqueue_attrs(attrs);
if (ret)
--
2.56.0
next prev parent reply other threads:[~2026-10-22 9:39 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-22 9:38 [PATCH v7 0/4] Realtime workqueues and panthor realtime submission Tvrtko Ursulin
2026-10-22 9:38 ` [PATCH v7 1/4] workqueue: Simplify unbound sysfs attribute registration Tvrtko Ursulin
2026-10-23 13:14 ` Liviu Dudau
2026-10-22 9:38 ` Tvrtko Ursulin [this message]
2026-10-23 13:17 ` [PATCH v7 2/4] workqueue: Separate sysfs mutable vs immutable wq attribute sanitizing Liviu Dudau
2026-10-22 9:38 ` [PATCH v7 3/4] workqueue: Add support for real-time workers Tvrtko Ursulin
2026-10-23 13:23 ` Liviu Dudau
2026-10-22 9:38 ` [PATCH v7 4/4] drm/panthor: Create per queue priority workqueues Tvrtko Ursulin
2026-10-23 13:26 ` Liviu Dudau
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=20261022093848.5727-3-tvrtko.ursulin@igalia.com \
--to=tvrtko.ursulin@igalia.com \
--cc=boris.brezillon@collabora.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=include@grrlz.net \
--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®