From: "Rafael J. Wysocki" <rjw@sisk.pl>
To: nigelc@bur.st
Cc: David Chinner <dgc@sgi.com>, Andrew Morton <akpm@osdl.org>,
LKML <linux-kernel@vger.kernel.org>, Pavel Machek <pavel@ucw.cz>
Subject: Re: [PATCH -mm 0/2] Use freezeable workqueues to avoid suspend-related XFS corruptions
Date: Tue, 21 Nov 2006 12:19:52 +0100 [thread overview]
Message-ID: <200611211219.53086.rjw@sisk.pl> (raw)
In-Reply-To: <1164070310.15714.15.camel@nigel.suspend2.net>
[-- Attachment #1: Type: text/plain, Size: 1806 bytes --]
Hi,
On Tuesday, 21 November 2006 01:51, Nigel Cunningham wrote:
> Hi.
>
> On Mon, 2006-11-20 at 23:55 +0100, Rafael J. Wysocki wrote:
> > On Monday, 20 November 2006 23:39, Nigel Cunningham wrote:
> > > (Sorry to reply again)
> >
> > (No big deal)
> >
> > > On Tue, 2006-11-21 at 09:26 +1100, Nigel Cunningham wrote:
> > > > Hi.
> > > >
> > > > On Mon, 2006-11-20 at 23:18 +0100, Rafael J. Wysocki wrote:
> > > > > I think I/O can only be submitted from the process context. Thus if we freeze
> > > > > all (and I mean _all_) threads that are used by filesystems, including worker
> > > > > threads, we should effectively prevent fs-related I/O from being submitted
> > > > > after tasks have been frozen.
> > > >
> > > > I know that will work. It's what I used to do before the switch to bdev
> > > > freezing. I guess I need to look again at why I made the switch. Perhaps
> > > > it was just because you guys gave freezing kthreads a bad wrap as too
> > > > invasive or something. Bdev freezing is certainly fewer lines of code.
> > >
> > > No, it looks like I wrongly believed that XFS was submitting I/O off a
> > > timer, so that freezing kthreads wasn't enough. In that case, it looks
> > > like freezing kthreads should be a good solution.
> >
> > Okay, so let's implement it. :-)
>
> Agreed. I'm a bit confused now about what the latest version of your
> patches is, but I'll be happy to switch back to kthread freezing in the
> next Suspend2 release if it will help with getting them wider testing.
The latest are:
support-for-freezeable-workqueues.patch
use-freezeable-workqueues-in-xfs.patch
(both attached for convenience) and the freezing of bdevs patch has been
dropped.
Greetings,
Rafael
--
You never change things by fighting the existing reality.
R. Buckminster Fuller
[-- Attachment #2: support-for-freezeable-workqueues.patch --]
[-- Type: text/x-diff, Size: 4019 bytes --]
include/linux/workqueue.h | 8 +++++---
kernel/workqueue.c | 20 ++++++++++++++------
2 files changed, 19 insertions(+), 9 deletions(-)
Index: linux-2.6.19-rc5-mm2/include/linux/workqueue.h
===================================================================
--- linux-2.6.19-rc5-mm2.orig/include/linux/workqueue.h
+++ linux-2.6.19-rc5-mm2/include/linux/workqueue.h
@@ -55,9 +55,11 @@ struct execute_work {
} while (0)
extern struct workqueue_struct *__create_workqueue(const char *name,
- int singlethread);
-#define create_workqueue(name) __create_workqueue((name), 0)
-#define create_singlethread_workqueue(name) __create_workqueue((name), 1)
+ int singlethread,
+ int freezeable);
+#define create_workqueue(name) __create_workqueue((name), 0, 0)
+#define create_freezeable_workqueue(name) __create_workqueue((name), 0, 1)
+#define create_singlethread_workqueue(name) __create_workqueue((name), 1, 0)
extern void destroy_workqueue(struct workqueue_struct *wq);
Index: linux-2.6.19-rc5-mm2/kernel/workqueue.c
===================================================================
--- linux-2.6.19-rc5-mm2.orig/kernel/workqueue.c
+++ linux-2.6.19-rc5-mm2/kernel/workqueue.c
@@ -31,6 +31,7 @@
#include <linux/mempolicy.h>
#include <linux/kallsyms.h>
#include <linux/debug_locks.h>
+#include <linux/freezer.h>
/*
* The per-CPU workqueue (if single thread, we always use the first
@@ -57,6 +58,8 @@ struct cpu_workqueue_struct {
struct task_struct *thread;
int run_depth; /* Detect run_workqueue() recursion depth */
+
+ int freezeable; /* Freeze the thread during suspend */
} ____cacheline_aligned;
/*
@@ -251,7 +254,8 @@ static int worker_thread(void *__cwq)
struct k_sigaction sa;
sigset_t blocked;
- current->flags |= PF_NOFREEZE;
+ if (!cwq->freezeable)
+ current->flags |= PF_NOFREEZE;
set_user_nice(current, -5);
@@ -274,6 +278,9 @@ static int worker_thread(void *__cwq)
set_current_state(TASK_INTERRUPTIBLE);
while (!kthread_should_stop()) {
+ if (cwq->freezeable)
+ try_to_freeze();
+
add_wait_queue(&cwq->more_work, &wait);
if (list_empty(&cwq->worklist))
schedule();
@@ -350,7 +357,7 @@ void fastcall flush_workqueue(struct wor
EXPORT_SYMBOL_GPL(flush_workqueue);
static struct task_struct *create_workqueue_thread(struct workqueue_struct *wq,
- int cpu)
+ int cpu, int freezeable)
{
struct cpu_workqueue_struct *cwq = per_cpu_ptr(wq->cpu_wq, cpu);
struct task_struct *p;
@@ -360,6 +367,7 @@ static struct task_struct *create_workqu
cwq->thread = NULL;
cwq->insert_sequence = 0;
cwq->remove_sequence = 0;
+ cwq->freezeable = freezeable;
INIT_LIST_HEAD(&cwq->worklist);
init_waitqueue_head(&cwq->more_work);
init_waitqueue_head(&cwq->work_done);
@@ -375,7 +383,7 @@ static struct task_struct *create_workqu
}
struct workqueue_struct *__create_workqueue(const char *name,
- int singlethread)
+ int singlethread, int freezeable)
{
int cpu, destroy = 0;
struct workqueue_struct *wq;
@@ -395,7 +403,7 @@ struct workqueue_struct *__create_workqu
mutex_lock(&workqueue_mutex);
if (singlethread) {
INIT_LIST_HEAD(&wq->list);
- p = create_workqueue_thread(wq, singlethread_cpu);
+ p = create_workqueue_thread(wq, singlethread_cpu, freezeable);
if (!p)
destroy = 1;
else
@@ -403,7 +411,7 @@ struct workqueue_struct *__create_workqu
} else {
list_add(&wq->list, &workqueues);
for_each_online_cpu(cpu) {
- p = create_workqueue_thread(wq, cpu);
+ p = create_workqueue_thread(wq, cpu, freezeable);
if (p) {
kthread_bind(p, cpu);
wake_up_process(p);
@@ -657,7 +665,7 @@ static int __devinit workqueue_cpu_callb
mutex_lock(&workqueue_mutex);
/* Create a new workqueue thread for it. */
list_for_each_entry(wq, &workqueues, list) {
- if (!create_workqueue_thread(wq, hotcpu)) {
+ if (!create_workqueue_thread(wq, hotcpu, 0)) {
printk("workqueue for %i failed\n", hotcpu);
return NOTIFY_BAD;
}
[-- Attachment #3: use-freezeable-workqueues-in-xfs.patch --]
[-- Type: text/x-diff, Size: 773 bytes --]
---
fs/xfs/linux-2.6/xfs_buf.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
Index: linux-2.6.19-rc5-mm2/fs/xfs/linux-2.6/xfs_buf.c
===================================================================
--- linux-2.6.19-rc5-mm2.orig/fs/xfs/linux-2.6/xfs_buf.c
+++ linux-2.6.19-rc5-mm2/fs/xfs/linux-2.6/xfs_buf.c
@@ -1826,11 +1826,11 @@ xfs_buf_init(void)
if (!xfs_buf_zone)
goto out_free_trace_buf;
- xfslogd_workqueue = create_workqueue("xfslogd");
+ xfslogd_workqueue = create_freezeable_workqueue("xfslogd");
if (!xfslogd_workqueue)
goto out_free_buf_zone;
- xfsdatad_workqueue = create_workqueue("xfsdatad");
+ xfsdatad_workqueue = create_freezeable_workqueue("xfsdatad");
if (!xfsdatad_workqueue)
goto out_destroy_xfslogd_workqueue;
next prev parent reply other threads:[~2006-11-21 11:23 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-11-16 8:12 [PATCH -mm 0/2] Use freezeable workqueues to avoid suspend-related XFS corruptions Rafael J. Wysocki
2006-11-16 8:15 ` [PATCH -mm 1/2] Support for freezeable workqueues Rafael J. Wysocki
2006-11-16 15:03 ` Pavel Machek
2006-11-16 8:18 ` [PATCH -mm 2/2] Use freezeable workqueues in XFS Rafael J. Wysocki
2006-11-16 15:05 ` Pavel Machek
2006-11-17 0:50 ` [PATCH -mm 0/2] Use freezeable workqueues to avoid suspend-related XFS corruptions David Chinner
2006-11-17 15:14 ` Pavel Machek
2006-11-17 16:19 ` Rafael J. Wysocki
2006-11-20 0:15 ` David Chinner
2006-11-20 11:02 ` Nigel Cunningham
2006-11-20 20:40 ` Rafael J. Wysocki
2006-11-20 22:03 ` Nigel Cunningham
2006-11-20 22:18 ` Rafael J. Wysocki
2006-11-20 22:26 ` Nigel Cunningham
2006-11-20 22:39 ` Nigel Cunningham
2006-11-20 22:55 ` Rafael J. Wysocki
2006-11-21 0:51 ` Nigel Cunningham
2006-11-21 11:19 ` Rafael J. Wysocki [this message]
2006-11-21 4:20 ` David Chinner
2006-11-20 20:12 ` Rafael J. Wysocki
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=200611211219.53086.rjw@sisk.pl \
--to=rjw@sisk.pl \
--cc=akpm@osdl.org \
--cc=dgc@sgi.com \
--cc=linux-kernel@vger.kernel.org \
--cc=nigelc@bur.st \
--cc=pavel@ucw.cz \
/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