public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Frederic Weisbecker <fweisbec@gmail.com>
To: Tejun Heo <tj@kernel.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Lai Jiangshan <laijs@cn.fujitsu.com>,
	Christoph Lameter <cl@linux.com>,
	Kevin Hilman <khilman@linaro.org>,
	Mike Galbraith <bitbucket@online.de>,
	"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
	Viresh Kumar <viresh.kumar@linaro.org>
Subject: Re: [PATCH 1/5] workqueue: Allow changing attributions of ordered workqueues
Date: Tue, 20 May 2014 16:32:31 +0200	[thread overview]
Message-ID: <20140520143229.GB17741@localhost.localdomain> (raw)
In-Reply-To: <20140519201531.GC27506@mtj.dyndns.org>

On Mon, May 19, 2014 at 04:15:31PM -0400, Tejun Heo wrote:
> Hello,
> 
> On Sat, May 17, 2014 at 03:41:55PM +0200, Frederic Weisbecker wrote:
> > > > -	last_pool = get_work_pool(work);
> > > > +	last_pool = wq->flags & __WQ_ORDERED ? NULL : get_work_pool(work);
> > > >  	if (last_pool && last_pool != pwq->pool) {
> > > >  		struct worker *worker;
> > > 
> > > I'm not a big fan of the fact that ordered queues need to be handled
> > > differently when queueing, but as the code is currently written, this
> > > is pretty much necessary to maintain execution order, right?
> > >
> > > Otherwise, you end up with requeueing work items targeting the pwq it
> > > was executing on and new ones targeting the newest one screwing up the
> > > ordering.  I think that'd be a lot more important to note in the
> > > comment.  This is a correctness measure.  Back-to-back requeueing
> > > being affected by this is just a side-effect.
> > 
> > In the case of ordered workqueues it actually doesn't matter much in
> > term of ordering. But it's needed when pwqs are replaced (as it happens
> > in apply_workqueue_attrs(). We must make sure works requeueing themselves
> > don't always requeue to the old pwq otherwise it will never be able to
> > switch and be released. Also the next work items will be queued on the next
> 
> But that's the same for other pwqs too.  Back-to-back requeueing will
> hold back pwq switching on any workqueue.

I don't think so, because non ordered pwqs aren't created with 0 max_active,
so they can run before the old pwq is released. It's not holding back the new
one and creating a starvation there.

But maybe I forget other details.

> 
> > pwq but this one will never be able to run due to the old workqueue still
> > being used by the item requeing itself. So we also risk starvation on the
> > new workqueue.
> > 
> > But the ordering itself is actually fine for ordered workqueue. It's actually
> > enforced by the fact that only one pwq can run at a time for a given workqueue.
> 
> Maybe I'm confused but I don't think it'd be.  Let's say there was an
> attribute change with one work item, A, which is performing
> back-to-back requeueing and another one, B, which queues itself
> intermittently.  If B is queued while A is executing, followed by A
> requeueing itself, the expected execution order is A - B - A; however,
> without the above exception for ordered workqueues, it'd end up A - A
> - B because B will end up on the new pwq while A on the older one and
> max_active won't be transferred to the new pwq before it becomes
> empty.

Ah right AAB instead of ABA is possible indeed. I don't know if some workqueue
rely on such guarantee but it's possible.

In which case we have one more reason to make an exception on ordered workqueues
previous pwq reuse.

> 
> > > Just collapse it into the calling function.  This obfuscates more than
> > > helps.
> > 
> > Yeah but the condition is already big. Lets hope the result won't be too ugly.
> 
> I didn't mean that the condition should be encoded in the if
> conditional.  It's fine to break it out using a separate variable or
> whatever.  I just don't think breaking it out to a separate function
> is helping anything.

Alright.

Thanks.

  reply	other threads:[~2014-05-20 14:32 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-16 16:16 [RFC PATCH 0/5] workqueue: Introduce low-level unbound wq sysfs cpumask v3 Frederic Weisbecker
2014-05-16 16:16 ` [PATCH 1/5] workqueue: Allow changing attributions of ordered workqueues Frederic Weisbecker
2014-05-16 20:12   ` Tejun Heo
2014-05-17 13:41     ` Frederic Weisbecker
2014-05-19 20:15       ` Tejun Heo
2014-05-20 14:32         ` Frederic Weisbecker [this message]
2014-05-20 14:35           ` Tejun Heo
2014-05-20 15:08             ` Frederic Weisbecker
2014-05-21  7:29   ` Lai Jiangshan
2014-05-21 19:18     ` Tejun Heo
2014-05-16 16:16 ` [PATCH 2/5] workqueue: Reorder sysfs code Frederic Weisbecker
2014-05-16 16:16 ` [PATCH 3/5] workqueue: Create low-level unbound workqueues cpumask Frederic Weisbecker
2014-05-16 17:52   ` Christoph Lameter
2014-05-16 18:35     ` Tejun Heo
2014-05-16 18:52       ` Christoph Lameter
2014-05-16 19:00         ` Tejun Heo
2014-05-16 19:22           ` Tejun Heo
2014-05-16 19:32           ` Christoph Lameter
2014-05-16 19:34             ` Tejun Heo
2014-05-16 19:45               ` Tejun Heo
2014-05-16 23:02                 ` Christoph Lameter
2014-05-16 23:48                   ` Tejun Heo
2014-05-17 22:45                     ` Christoph Lameter
2014-05-18  2:51                       ` Tejun Heo
2014-05-16 16:16 ` [PATCH 4/5] workqueue: Split apply attrs code from its locking Frederic Weisbecker
2014-05-16 16:16 ` [PATCH 5/5] workqueue: Allow modifying low level unbound workqueue cpumask Frederic Weisbecker
2014-05-16 20:50   ` Tejun Heo
2014-05-20 19:32     ` Frederic Weisbecker
2014-05-20 19:56       ` Tejun Heo
2014-05-20 20:08         ` Frederic Weisbecker
2014-07-11  8:41 ` [RFC PATCH 0/5] workqueue: Introduce low-level unbound wq sysfs cpumask v3 Lai Jiangshan
2014-07-11 13:11   ` Frederic Weisbecker

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=20140520143229.GB17741@localhost.localdomain \
    --to=fweisbec@gmail.com \
    --cc=bitbucket@online.de \
    --cc=cl@linux.com \
    --cc=khilman@linaro.org \
    --cc=laijs@cn.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=paulmck@linux.vnet.ibm.com \
    --cc=tj@kernel.org \
    --cc=viresh.kumar@linaro.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