Commit 5805ad40 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] worker_thread race fix

Fix a waitqueue-handling race in worker_thread().
parent df125ce9
...@@ -201,19 +201,20 @@ static int worker_thread(void *__cwq) ...@@ -201,19 +201,20 @@ static int worker_thread(void *__cwq)
siginitset(&sa.sa.sa_mask, sigmask(SIGCHLD)); siginitset(&sa.sa.sa_mask, sigmask(SIGCHLD));
do_sigaction(SIGCHLD, &sa, (struct k_sigaction *)0); do_sigaction(SIGCHLD, &sa, (struct k_sigaction *)0);
set_current_state(TASK_INTERRUPTIBLE);
while (!kthread_should_stop()) { while (!kthread_should_stop()) {
set_task_state(current, TASK_INTERRUPTIBLE);
add_wait_queue(&cwq->more_work, &wait); add_wait_queue(&cwq->more_work, &wait);
if (list_empty(&cwq->worklist)) if (list_empty(&cwq->worklist))
schedule(); schedule();
else else
set_task_state(current, TASK_RUNNING); __set_current_state(TASK_RUNNING);
remove_wait_queue(&cwq->more_work, &wait); remove_wait_queue(&cwq->more_work, &wait);
if (!list_empty(&cwq->worklist)) if (!list_empty(&cwq->worklist))
run_workqueue(cwq); run_workqueue(cwq);
set_current_state(TASK_INTERRUPTIBLE);
} }
__set_current_state(TASK_RUNNING);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment