Re: [PATCH v7 2/4] workqueue: Separate sysfs mutable vs immutable wq attribute sanitizing

From: Tvrtko Ursulin

Date: Mon Nov 02 2026 - 13:36:38 EST



On 23/10/2026 22:28, Tejun Heo wrote:
Hello, Tvrtko.

On Thu, Oct 22, 2026 at 10:38:46AM +0100, Tvrtko Ursulin wrote:
+/* Sanitize attributes not modifiable via sysfs. */
+static void
+sanitize_immutable_workqueue_attrs(struct workqueue_struct *wq,
+ struct workqueue_attrs *attrs)
...
+/* Sanitize attributes modifiable via sysfs. */
+static void
+sanitize_mutable_workqueue_attrs(struct workqueue_struct *wq,
+ struct workqueue_attrs *attrs)
...
+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);
+}

The three helpers seem a bit excessive for what they do, and the
immutable call in sanitize_workqueue_attrs() is redundant, as
apply_wqattrs_prepare() runs sanitize_immutable_workqueue_attrs() on
both of its copies anyway.

Okay I dropped sanitize_workqueue_attrs() locally. I was trying to express the logic behind mutable and immutable, which also leads me to...

Could the comment on sanitize_immutable_workqueue_attrs() state the
contract? These attrs follow from the workqueue flags and are enforced
on every apply, apply_workqueue_attrs() callers included, not only
sysfs.

...the topic of what would be the best commentary for both.

Would these comments work:

/*
* Sanitize attributes derived from the workqueue flags and which need to be
* enforced on every attribute application.
*/
static void
sanitize_immutable_workqueue_attrs(struct workqueue_struct *wq,
struct workqueue_attrs *attrs)
{
if (wq->flags & __WQ_ORDERED)
attrs->ordered = true;
}

/*
* Sanitize attributes derived from the workqueue flags and which need to be
* enforced only on workqueue creation.
*/
static void
sanitize_mutable_workqueue_attrs(struct workqueue_struct *wq,
struct workqueue_attrs *attrs)
{
if (wq->flags & WQ_HIGHPRI)
attrs->nice = HIGHPRI_NICE_LEVEL;
}

Regards,

Tvrtko