All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <a.p.zijlstra@chello.nl>
To: Tejun Heo <tj@kernel.org>
Cc: linux-kernel@vger.kernel.org,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Ingo Molnar <mingo@elte.hu>, Thomas Gleixner <tglx@linutronix.de>,
	Jens Axboe <jaxboe@fusionio.com>
Subject: Re: [RFC][PATCH 2/3] sched, workqueue: Move WQ-sleeper wakeup
Date: Wed, 22 Jun 2011 11:27:28 +0200	[thread overview]
Message-ID: <1308734848.1022.16.camel@twins> (raw)
In-Reply-To: <20110622092430.GA30101@htj.dyndns.org>

On Wed, 2011-06-22 at 11:24 +0200, Tejun Heo wrote:
> Hello, Peter.
> 
> On Wed, Jun 22, 2011 at 01:34:46AM +0200, Peter Zijlstra wrote:
> > -/**
> >   * wake_up_process - Wake up a specific process
> >   * @p: The process to be woken up.
> >   *
> > @@ -4215,6 +4181,19 @@ static inline void sched_submit_work(voi
> >  
> >  	if (tsk->state && !(preempt_count() & PREEMPT_ACTIVE)) {
> >  		/*
> > +		 * If a worker went to sleep, notify and ask workqueue
> > +		 * whether it wants to wake up a task to maintain
> > +		 * concurrency.
> > +		 */
> > +		if (tsk->flags & PF_WQ_WORKER) {
> > +			struct task_struct *to_wakeup;
> > +
> > +			to_wakeup = wq_worker_sleeping(tsk, smp_processor_id());
> > +			if (to_wakeup)
> > +				wake_up_process(to_wakeup);
> > +		}
> > +
> > +		/*
> 
> Preemption could still be enabled here, right?  What prevents
> preemtion kicking after wq_worker_sleeping() and do it again thus
> breaking nr_running tracking.

Aren't all PF_WQ_WORKER threads cpu-bound?

> >  		 * If we are going to sleep and we have plugged IO
> >  		 * queued, make sure to submit it to avoid deadlocks.
> >  		 */
> > @@ -4256,19 +4235,6 @@ asmlinkage void __sched schedule(void)
> >  		} else {
> >  			deactivate_task(rq, prev, DEQUEUE_SLEEP);
> >  			prev->on_rq = 0;
> > -
> > -			/*
> > -			 * If a worker went to sleep, notify and ask workqueue
> > -			 * whether it wants to wake up a task to maintain
> > -			 * concurrency.
> > -			 */
> > -			if (prev->flags & PF_WQ_WORKER) {
> > -				struct task_struct *to_wakeup;
> > -
> > -				to_wakeup = wq_worker_sleeping(prev, cpu);
> > -				if (to_wakeup)
> > -					try_to_wake_up_local(to_wakeup);
> > -			}
> 
> Similarly, the if the 'if {}' part of the above if/else is taken, the
> task never goes to sleep and nr_running will again be broken.

Bah, indeed, I forgot about that, 2am isn't the best of times to do
these things.

  reply	other threads:[~2011-06-22  9:28 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-21 23:34 [RFC][PATCH 0/3] Move WQ,unplug scheduler hooks Peter Zijlstra
2011-06-21 23:34 ` [RFC][PATCH 1/3] sched, block: Move unplug Peter Zijlstra
2011-06-22  7:01   ` Jens Axboe
2011-06-22 13:53     ` Thomas Gleixner
2011-06-22 14:01       ` Jens Axboe
2011-06-22 14:30         ` Thomas Gleixner
2011-06-22 14:38           ` Peter Zijlstra
2011-06-22 15:08             ` Vivek Goyal
2011-06-22 16:04               ` Jens Axboe
2011-06-21 23:34 ` [RFC][PATCH 2/3] sched, workqueue: Move WQ-sleeper wakeup Peter Zijlstra
2011-06-22  9:24   ` Tejun Heo
2011-06-22  9:27     ` Peter Zijlstra [this message]
2011-06-22  9:37       ` Tejun Heo
2011-06-22 13:47     ` Thomas Gleixner
2011-06-21 23:34 ` [RFC][PATCH 3/3] block: Break long IRQ disabled region Peter Zijlstra
2011-06-22  7:03   ` Jens Axboe

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=1308734848.1022.16.camel@twins \
    --to=a.p.zijlstra@chello.nl \
    --cc=jaxboe@fusionio.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=tglx@linutronix.de \
    --cc=tj@kernel.org \
    --cc=torvalds@linux-foundation.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.