From: Oleg Nesterov <oleg@tv-sign.ru>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Srivatsa Vaddagiri <vatsa@in.ibm.com>,
Gautham R Shenoy <ego@in.ibm.com>,
"Rafael J. Wysocki" <rjw@sisk.pl>,
linux-kernel@vger.kernel.org
Subject: [PATCH] worker_thread: fix racy try_to_freeze() usage
Date: Sun, 8 Apr 2007 22:20:47 +0400 [thread overview]
Message-ID: <20070408182047.GA317@tv-sign.ru> (raw)
worker_thread() can miss freeze_process()->signal_wake_up() if it happens
between try_to_freeze() and prepare_to_wait(). We should check freezing()
before entering schedule().
This race was introduced by me in
[PATCH 1/1] workqueue: don't migrate pending works from the dead CPU
Looks like mm/vmscan.c:kswapd() has the same race.
Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru>
--- 2.6.21-rc5-mm4/kernel/workqueue.c~wq_freeze 2007-04-07 20:11:14.000000000 +0400
+++ 2.6.21-rc5-mm4/kernel/workqueue.c 2007-04-08 21:37:43.000000000 +0400
@@ -307,14 +307,14 @@ static int worker_thread(void *__cwq)
do_sigaction(SIGCHLD, &sa, (struct k_sigaction *)0);
for (;;) {
- if (cwq->wq->freezeable)
- try_to_freeze();
-
prepare_to_wait(&cwq->more_work, &wait, TASK_INTERRUPTIBLE);
- if (!cwq->should_stop && list_empty(&cwq->worklist))
+ if (!freezing(current) && !cwq->should_stop
+ && list_empty(&cwq->worklist))
schedule();
finish_wait(&cwq->more_work, &wait);
+ try_to_freeze();
+
if (cwq_should_stop(cwq))
break;
reply other threads:[~2007-04-08 18:20 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20070408182047.GA317@tv-sign.ru \
--to=oleg@tv-sign.ru \
--cc=akpm@linux-foundation.org \
--cc=ego@in.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rjw@sisk.pl \
--cc=vatsa@in.ibm.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®