Re: [RFC PATCH v3] workqueue: Introduce a way to set percpu worker_pool's scheduler

From: Tejun Heo
Date: Tue Jan 23 2018 - 09:30:42 EST


Hello,

On Tue, Jan 23, 2018 at 07:00:42PM +0800, Wen Yang wrote:
...
> This patch introduces a way to set the scheduler(policy and priority)
> of percpu worker_pool, in that way, user could set proper scheduler
> policy and priority of the worker_pool as needed, which could apply
> to all the WORK_CPU_BOUND workers on the same CPU. On the other hand,
> we could using /sys/devices/virtual/workqueue/cpumask for
> WORK_CPU_UNBOUND workers to prevent them starving.

The general approach looks good to me but this is way too big a patch.
Can you please split it so that the following steps are separate?

* Rename system workqueues.
* Expose attrs for system workqueues.
* Rename unbound_attrs to attrs.
* Convert ->nice to ->sched_attrs.
* Add scheduling policy to the exposed attrs.

And one nit below.

> +static int wq_parse_sched_attr(const char *ubuf, size_t count,
> + struct sched_attr *sched)
> +{
> + char buf[SCHED_ATTR_BUF_SIZE];
> + char *sptr, *token;
> + size_t len;
> +
> + memset(buf, 0, sizeof(buf));
> + len = min(count, (size_t)(sizeof(buf) - 1));
> + strncpy(buf, ubuf, len);
> + buf[len] = 0;
> + sptr = buf;

Can't we just do sscanf?

Thanks.

--
tejun