From: "Rafael J. Wysocki" <rjw@sisk.pl>
To: Oleg Nesterov <oleg@tv-sign.ru>, Pavel Machek <pavel@ucw.cz>
Cc: Gautham R Shenoy <ego@in.ibm.com>,
Johannes Berg <johannes@sipsolutions.net>,
LKML <linux-kernel@vger.kernel.org>,
Srivatsa Vaddagiri <vatsa@in.ibm.com>
Subject: Re: Problem with freezable workqueues
Date: Wed, 28 Feb 2007 00:57:35 +0100 [thread overview]
Message-ID: <200702280057.36198.rjw@sisk.pl> (raw)
In-Reply-To: <20070227232855.GA457@tv-sign.ru>
On Wednesday, 28 February 2007 00:28, Oleg Nesterov wrote:
> On 02/27, Rafael J. Wysocki wrote:
> >
> > We have a problem with freezable workqueues in 2.6.21-rc1 and in -mm
> > (there are only two of them, in XFS, but still). Namely, their worker threads
> > deadlock with workqueue_cpu_callback() that gets called during the CPU hotplug,
> > becuase workqueue_cpu_callback() tries to stop these threads while they are
> > frozen (disable_nonboot_cpus() happens after we've frozen tasks).
>
> Ugh. I know nothing, nothing, nothing about suspend. I'll try to guess.
>
> Commit: ed746e3b18f4df18afa3763155972c5835f284c5
Yes, but not only this one. Please see:
http://kernel.org/git/gitweb.cgi?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=e3c7db621bed4afb8e231cb005057f2feb5db557
> [PATCH] swsusp: Change code ordering in disk.c
>
> Change the ordering of code in kernel/power/disk.c so that device_suspend() is
> called before disable_nonboot_cpus() and platform_finish() is called after
> enable_nonboot_cpus() and before device_resume(), as indicated by the recent
> discussion on Linux-PM (cf.
> http://lists.osdl.org/pipermail/linux-pm/2006-November/004164.html).
>
> The changes here only affect the built-in swsusp.
>
> Yes? with the patch above, _cpu_down() called _after_ freeze_processes() ???
Yes, that's what we want to do.
> Honestly, I can't understand this (yes, I know nothing, nothing, nothing...).
Well, we used the CPU hotplug for disabling nonboot CPUs before
freeze_processes() was called, because the freezer used to be totally unsafe
on SMP. However, what we wanted from the beginning was to freeze tasks with
all CPUs on line (this way, for example, userland tasks should not notice that
we have played with the CPUs under them, but there are other reasons).
> > For 2.6.21-rc1 I've invented the appended workaround (works for me, waiting for
> > Johannes to confirm it works for him too), but I think we need something better
> > for -mm and future kernels.
>
> How about other kthread_stop()s ? For example, kernel/softirq.c:cpu_callback() ?
They all are PF_NOFREEZE, I suppose. If we make all workqueues nonfreezable
(as they were before), the problem won't appear.
> I think we need a general "cpu_down() after freeze" implementation, this is what
> Gautham and Srivatsa are working on, right?
Yes, certainly.
> > --- linux-2.6.21-rc1.orig/kernel/workqueue.c 2007-02-24 10:17:57.000000000 +0100
> > +++ linux-2.6.21-rc1/kernel/workqueue.c 2007-02-24 20:00:22.000000000 +0100
> > @@ -376,8 +376,19 @@ static int worker_thread(void *__cwq)
> >
> > set_current_state(TASK_INTERRUPTIBLE);
> > while (!kthread_should_stop()) {
> > - if (cwq->freezeable)
> > - try_to_freeze();
> > + if (try_to_freeze()) {
> > + /* We've just left the refrigerator. If our CPU is
> > + * a nonboot one, we might have been replaced.
> > + * The lock is taken to prevent the race with
> > + * cleanup_workqueue_thread() from happening
> > + */
> > + spin_lock_irq(&cwq->lock);
>
> I'm afraid this is racy. We can't touch *cwq, it may be freed. Suppose
> that another thread does destroy_workqueue(), and we thaw that thread
> before cwq->thread.
Okay, in that case I'd suggest removing create_freezeable_workqueue() and
make all workqueues nonfreezable once again for 2.6.21 (as far as I know, only
the two XFS workqueues are affected).
Pavel, would that be acceptable?
Rafael
next prev parent reply other threads:[~2007-02-27 23:55 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-02-27 21:51 Rafael J. Wysocki
2007-02-27 23:28 ` Oleg Nesterov
2007-02-27 23:36 ` Johannes Berg
2007-02-28 0:00 ` Rafael J. Wysocki
2007-02-28 0:00 ` Johannes Berg
2007-02-28 18:06 ` Gautham R Shenoy
2007-02-27 23:57 ` Rafael J. Wysocki [this message]
2007-02-28 0:01 ` Johannes Berg
2007-02-28 0:08 ` Rafael J. Wysocki
2007-02-28 1:14 ` Nigel Cunningham
2007-02-28 10:59 ` Rafael J. Wysocki
2007-02-28 20:36 ` Johannes Berg
2007-02-28 3:07 ` Srivatsa Vaddagiri
2007-02-28 8:48 ` Oleg Nesterov
2007-02-28 9:10 ` Srivatsa Vaddagiri
2007-02-28 9:43 ` Oleg Nesterov
2007-02-28 11:09 ` Rafael J. Wysocki
2007-02-28 18:17 ` Gautham R Shenoy
2007-02-28 18:41 ` Rafael J. Wysocki
2007-02-28 8:54 ` Pavel Machek
2007-02-28 3:01 ` Srivatsa Vaddagiri
2007-02-28 3:51 ` Srivatsa Vaddagiri
2007-02-28 11:11 ` Rafael J. Wysocki
2007-02-28 13:17 ` Srivatsa Vaddagiri
2007-02-28 13:27 ` Srivatsa Vaddagiri
2007-02-28 17:41 ` Rafael J. Wysocki
2007-02-28 17:40 ` Rafael J. Wysocki
2007-02-28 19:17 ` Rafael J. Wysocki
2007-02-28 19:32 ` Oleg Nesterov
2007-02-28 19:43 ` Rafael J. Wysocki
2007-02-28 20:08 ` Oleg Nesterov
2007-02-28 20:25 ` Rafael J. Wysocki
2007-02-28 20:35 ` Oleg Nesterov
2007-02-28 22:39 ` Rafael J. Wysocki
2007-02-28 22:44 ` Pavel Machek
2007-02-28 23:54 ` [PATCH] Make XFS workqueues nonfreezable Rafael J. Wysocki
2007-03-01 8:03 ` Andrew Morton
2007-03-01 9:15 ` Pavel Machek
2007-03-01 9:25 ` Andrew Morton
2007-02-28 21:16 ` Problem with freezable workqueues Pavel Machek
2007-03-06 0:30 ` Johannes Berg
2007-03-06 20:31 ` Rafael J. Wysocki
2007-03-06 22:25 ` Nigel Cunningham
2007-03-06 22:57 ` Rafael J. Wysocki
2007-03-07 23:10 ` Johannes Berg
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=200702280057.36198.rjw@sisk.pl \
--to=rjw@sisk.pl \
--cc=ego@in.ibm.com \
--cc=johannes@sipsolutions.net \
--cc=linux-kernel@vger.kernel.org \
--cc=oleg@tv-sign.ru \
--cc=pavel@ucw.cz \
--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®