Re: [RFC][PATCH 2/3] sched, workqueue: Move WQ-sleeper wakeup

From: Tejun Heo
Date: Wed Jun 22 2011 - 05:37:19 EST

On Wed, Jun 22, 2011 at 11:27:28AM +0200, Peter Zijlstra wrote:
> On Wed, 2011-06-22 at 11:24 +0200, Tejun Heo wrote:
> > 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?

Hmmm... I don't see how that would matter. Please consider the
following scenario.

* A work item calls schedule() for whatever reason.

* schedule() calls sched_submit_work() which in turn calls
wq_worker_sleeping() which adjusts nr_running. All this happens
with preemption enabled.

* sched_submit_work() returns but before schedule() does
preempt_disable(), an IRQ is delivered. By the time IRQ return path
is executed, TIF_NEED_RESCHED is set which in turn calls schedule()
again and repeats the above two steps for the same worker.


To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at