Re: [PATCH RFC v2 5/8] workqueue: add workqueue_set_affn_scope()

From: Chuck Lever

Date: Thu Sep 03 2026 - 10:06:14 EST




On Wed, Sep 2, 2026, at 3:36 PM, Tejun Heo wrote:
> On Wed, Sep 02, 2026 at 03:28:50PM -0400, Chuck Lever wrote:
>> An unbound workqueue's affinity scope can be changed only through
>> sysfs. A module whose workqueue contends on the pool lock at the
>> default scope has no in-kernel way to select a finer one, because
>> alloc_workqueue_attrs() and apply_workqueue_attrs() are not
>> exported. Exporting them would also invite a caller to apply freshly
>
> BTW, please feel free to export them.
>
>> +int workqueue_set_affn_scope(struct workqueue_struct *wq,
>> + enum wq_affn_scope affn_scope)
>
> No need for the line break.
>
>> +{
>> + struct workqueue_attrs *attrs;
>> + int ret = -ENOMEM;
>> +
>> + if ((unsigned int)affn_scope >= WQ_AFFN_NR_TYPES)
>> + return -EINVAL;
>> +
>> + mutex_lock(&wq_pool_mutex);
>> + attrs = alloc_workqueue_attrs();
>
> Maybe alloc outside mutex and use alloc and mutex guards?
>
> Thanks.
>
> --
> tejun

All applied to v3 (still unposted). Sorry all this has taken so long.


--
Chuck Lever (Come to NFS bake-a-thon! https://nfsv4bat.org)