Re: [PATCH RFC v2 5/8] workqueue: add workqueue_set_affn_scope()
From: Tejun Heo
Date: Wed Sep 02 2026 - 16:22:43 EST
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