Oleg Nesterov 13c22168b7 destroy_workqueue() can livelock
Pointed out by Michal Schmidt <mschmidt@redhat.com>.

The bug was introduced in 2.6.22 by me.

cleanup_workqueue_thread() does flush_cpu_workqueue(cwq) in a loop until
->worklist becomes empty.  This is live-lockable, a re-niced caller can get
CPU after wake_up() and insert a new barrier before the lower-priority
cwq->thread has a chance to clear ->current_work.

Change cleanup_workqueue_thread() to do flush_cpu_workqueue(cwq) only once.
 We can rely on the fact that run_workqueue() won't return until it flushes
all works.  So it is safe to call kthread_stop() after that, the "should
stop" request won't be noticed until run_workqueue() returns.

Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru>
Cc: Michal Schmidt <mschmidt@redhat.com>
Cc: Srivatsa Vaddagiri <vatsa@in.ibm.com>
Cc: <stable@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2007-07-17 10:23:03 -07:00
..
2007-07-16 09:05:47 -07:00
2007-07-16 09:05:48 -07:00
2007-07-16 09:05:49 -07:00
2006-12-07 08:39:36 -08:00
2007-07-16 09:05:50 -07:00
2006-12-04 02:00:22 -05:00
2007-07-16 09:05:47 -07:00
2007-05-09 12:30:56 -07:00
2007-05-21 09:18:19 -07:00
2007-07-17 10:23:03 -07:00
2007-07-13 14:14:28 +02:00
2007-07-16 09:05:49 -07:00
2007-07-16 09:05:49 -07:00
2007-07-16 09:05:49 -07:00
2007-07-09 18:51:58 +02:00
2007-07-16 09:05:50 -07:00
2007-07-16 09:05:43 -07:00
2007-07-16 09:05:50 -07:00
2007-07-17 10:23:03 -07:00
2007-07-16 09:05:48 -07:00
2007-07-16 09:05:47 -07:00
2007-05-09 08:57:56 +02:00
2007-07-17 10:23:03 -07:00