public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Lai Jiangshan <laijs@cn.fujitsu.com>
To: Tejun Heo <tj@kernel.org>
Cc: <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 4/5] workqueue: don't expose workqueue_attrs to users
Date: Tue, 12 May 2015 10:15:28 +0800	[thread overview]
Message-ID: <55516240.6000601@cn.fujitsu.com> (raw)
In-Reply-To: <20150511145952.GE11388@htj.duckdns.org>

On 05/11/2015 10:59 PM, Tejun Heo wrote:
> On Mon, May 11, 2015 at 05:35:51PM +0800, Lai Jiangshan wrote:
>> workqueue_attrs is an internal-like structure and is exposed with
>> apply_workqueue_attrs() whose user has to investigate the structure
>> before use.
>>
>> And the apply_workqueue_attrs() API is inconvenient with the structure.
>> The user (although there is no user yet currently) has to assemble
>> several LoC to use:
>> 	attrs = alloc_workqueue_attrs();
>> 	if (!attrs)
>> 		return;
>> 	attrs->nice = ...;
>> 	copy cpumask;
>> 	attrs->no_numa = ...;
>> 	apply_workqueue_attrs();
>> 	free_workqueue_attrs();
>>
>> It is too elaborate. This patch changes apply_workqueue_attrs() API,
>> and one-line-code is enough to be called from user:
>> 	apply_workqueue_attrs(wq, cpumask, nice, numa);
>>
>> This patch also reduces the code of workqueue.c, about -50 lines.
>> wq_sysfs_prep_attrs() is removed, wq_[nice|cpumask|numa]_store()
>> directly access to the ->unbound_attrs with the protection
>> of apply_wqattrs_lock();
>>
>> This patch is also a preparation patch of next patch which
>> remove no_numa out from the structure workqueue_attrs which
>> requires apply_workqueue_attrs() has an argument to pass numa affinity.
> 
> I'm not sure about this.  Yeah, sure, it's a bit more lines of code
> but at the same time this'd allow us to make the public interface
> atomic too.  What we prolly should do is changing the interface so
> that we do
> 
> 	attrs = prepare_workqueue_attrs(gfp_mask);	/* allocate, lock & copy */
> 	/* modify attrs as desired */
> 	commit_workqueue_attrs(attrs);			/* apply, unlock and free */

I think the workqueue.c has too much complicated and rarely used APIs
and exposes too much in this way.  No one can set the nice value
and the cpuallowed of a task atomically.

If the user want atomic-able, Her/he can just disable WQ_SYSFS
on its workqueue and maintain a copy of the cpumask, nice, numa values
under its own lock.

> 
> Thanks.
> 


  reply	other threads:[~2015-05-12  2:12 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-11  9:35 [PATCH 0/5] workqueue: cleanup for apply_workqueue_attrs() Lai Jiangshan
2015-05-11  9:35 ` [PATCH 1/5] workqueue: wq_pool_mutex protects the attrs-installation Lai Jiangshan
2015-05-11 12:23   ` Tejun Heo
2016-03-10 21:44   ` Steven Rostedt
2016-03-11 17:50     ` Tejun Heo
2016-07-11 20:50     ` Steven Rostedt
2016-07-12 15:09       ` Tejun Heo
2016-07-12 15:20         ` Tejun Heo
2016-07-12 15:23           ` Steven Rostedt
2015-05-11  9:35 ` [PATCH 2/5] workqueue: merge the similar code Lai Jiangshan
2015-05-11 14:31   ` Tejun Heo
2015-05-12  2:03     ` Lai Jiangshan
2015-05-12 13:16       ` Tejun Heo
2015-05-11  9:35 ` [PATCH 3/5] workqueue: ensure attrs-changing be sequentially Lai Jiangshan
2015-05-11 14:55   ` Tejun Heo
2015-05-12  5:09     ` Lai Jiangshan
2015-05-12 13:19       ` Tejun Heo
2015-05-11  9:35 ` [PATCH 4/5] workqueue: don't expose workqueue_attrs to users Lai Jiangshan
2015-05-11 14:59   ` Tejun Heo
2015-05-12  2:15     ` Lai Jiangshan [this message]
2015-05-12 13:22       ` Tejun Heo
2015-05-13  1:43         ` Lai Jiangshan
2015-05-13 13:52           ` Tejun Heo
2015-05-11  9:35 ` [PATCH 5/5] workqueue: remove no_numa from workqueue_attrs Lai Jiangshan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=55516240.6000601@cn.fujitsu.com \
    --to=laijs@cn.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tj@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox