Messages in this thread | | | Date | Wed, 22 Jun 2011 11:37:06 +0200 | From | Tejun Heo <> | Subject | Re: [RFC][PATCH 2/3] sched, workqueue: Move WQ-sleeper wakeup |
| |
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.
Thanks.
-- tejun
| |