Re: [PATCH v7 3/4] workqueue: Add support for real-time workers

From: Tejun Heo

Date: Fri Oct 23 2026 - 17:28:23 EST


Hello, Tvrtko.

On Thu, Oct 22, 2026 at 10:38:47AM +0100, Tvrtko Ursulin wrote:
> struct workqueue_attrs {
> /**
> - * @nice: nice level
> + * @prio: priority encoded analogous to task_struct->prio.
> */
> - int nice;
> + int prio;

Can the nice to prio conversion be split into a preparation patch with
no functional change, so that this patch only adds WQ_RT on top?

> sanitize_immutable_workqueue_attrs(struct workqueue_struct *wq,
> struct workqueue_attrs *attrs)
> {
> + 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;
> + }

Can WQ_RT set only the priority and leave the affinity at the defaults?
If the pinning is needed for the latency, can you share numbers with
and without it?

> mutex_lock(&wq->mutex);
> - written = scnprintf(buf, PAGE_SIZE, "%d\n", wq->attrs->nice);
> + if (wq->attrs->prio == RT_PRIORITY)
> + written = scnprintf(buf, PAGE_SIZE, "rt\n");
> + else
> + written = scnprintf(buf, PAGE_SIZE, "%d\n",
> + PRIO_TO_NICE(wq->attrs->prio));

Can the sysfs interface comment above struct wq_device be updated too?
It still lists nice as RW int, while nice reads "rt" and is read-only
for WQ_RT.

> +rt_prio = prog.constant('RT_PRIORITY', filename='kernel/workqueue.c')
> ...
> + nice = pool.attrs.prio.value_()
> + if nice == rt_prio:
> + nice = 'rt'
> + else:
> + nice = nice - 120 # PRIO_TO_NICE

These fail on a kernel without this patch, where neither RT_PRIORITY
nor attrs.prio exists. Can they fall back to nice, the way wq_attrs()
falls back to unbound_attrs for the earlier rename?

Thanks.

--
tejun