diff options
author | Rafael J. Wysocki <rjw@sisk.pl> | 2007-07-17 07:03:35 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-07-17 13:23:02 -0400 |
commit | 831441862956fffa17b9801db37e6ea1650b0f69 (patch) | |
tree | b0334921341f8f1734bdd3243de76d676329d21c /fs | |
parent | 787d2214c19bcc9b6ac48af0ce098277a801eded (diff) |
Freezer: make kernel threads nonfreezable by default
Currently, the freezer treats all tasks as freezable, except for the kernel
threads that explicitly set the PF_NOFREEZE flag for themselves. This
approach is problematic, since it requires every kernel thread to either
set PF_NOFREEZE explicitly, or call try_to_freeze(), even if it doesn't
care for the freezing of tasks at all.
It seems better to only require the kernel threads that want to or need to
be frozen to use some freezer-related code and to remove any
freezer-related code from the other (nonfreezable) kernel threads, which is
done in this patch.
The patch causes all kernel threads to be nonfreezable by default (ie. to
have PF_NOFREEZE set by default) and introduces the set_freezable()
function that should be called by the freezable kernel threads in order to
unset PF_NOFREEZE. It also makes all of the currently freezable kernel
threads call set_freezable(), so it shouldn't cause any (intentional)
change of behaviour to appear. Additionally, it updates documentation to
describe the freezing of tasks more accurately.
[akpm@linux-foundation.org: build fixes]
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Acked-by: Nigel Cunningham <nigel@nigel.suspend2.net>
Cc: Pavel Machek <pavel@ucw.cz>
Cc: Oleg Nesterov <oleg@tv-sign.ru>
Cc: Gautham R Shenoy <ego@in.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/cifs/cifsfs.c | 1 | ||||
-rw-r--r-- | fs/cifs/connect.c | 1 | ||||
-rw-r--r-- | fs/jffs2/background.c | 1 | ||||
-rw-r--r-- | fs/lockd/svc.c | 2 | ||||
-rw-r--r-- | fs/nfs/callback.c | 2 | ||||
-rw-r--r-- | fs/nfsd/nfssvc.c | 2 | ||||
-rw-r--r-- | fs/xfs/linux-2.6/xfs_super.c | 1 |
7 files changed, 10 insertions, 0 deletions
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c index 8b0cbf4a4ad0..bd0f2f2353ce 100644 --- a/fs/cifs/cifsfs.c +++ b/fs/cifs/cifsfs.c | |||
@@ -849,6 +849,7 @@ static int cifs_oplock_thread(void * dummyarg) | |||
849 | __u16 netfid; | 849 | __u16 netfid; |
850 | int rc; | 850 | int rc; |
851 | 851 | ||
852 | set_freezable(); | ||
852 | do { | 853 | do { |
853 | if (try_to_freeze()) | 854 | if (try_to_freeze()) |
854 | continue; | 855 | continue; |
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index f4e92661b223..0a1b8bd1dfcb 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c | |||
@@ -363,6 +363,7 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server) | |||
363 | GFP_KERNEL); | 363 | GFP_KERNEL); |
364 | } | 364 | } |
365 | 365 | ||
366 | set_freezable(); | ||
366 | while (!kthread_should_stop()) { | 367 | while (!kthread_should_stop()) { |
367 | if (try_to_freeze()) | 368 | if (try_to_freeze()) |
368 | continue; | 369 | continue; |
diff --git a/fs/jffs2/background.c b/fs/jffs2/background.c index 0c82dfcfd246..143c5530caf3 100644 --- a/fs/jffs2/background.c +++ b/fs/jffs2/background.c | |||
@@ -81,6 +81,7 @@ static int jffs2_garbage_collect_thread(void *_c) | |||
81 | 81 | ||
82 | set_user_nice(current, 10); | 82 | set_user_nice(current, 10); |
83 | 83 | ||
84 | set_freezable(); | ||
84 | for (;;) { | 85 | for (;;) { |
85 | allow_signal(SIGHUP); | 86 | allow_signal(SIGHUP); |
86 | 87 | ||
diff --git a/fs/lockd/svc.c b/fs/lockd/svc.c index 26809325469c..9fcdef50aad6 100644 --- a/fs/lockd/svc.c +++ b/fs/lockd/svc.c | |||
@@ -25,6 +25,7 @@ | |||
25 | #include <linux/smp.h> | 25 | #include <linux/smp.h> |
26 | #include <linux/smp_lock.h> | 26 | #include <linux/smp_lock.h> |
27 | #include <linux/mutex.h> | 27 | #include <linux/mutex.h> |
28 | #include <linux/freezer.h> | ||
28 | 29 | ||
29 | #include <linux/sunrpc/types.h> | 30 | #include <linux/sunrpc/types.h> |
30 | #include <linux/sunrpc/stats.h> | 31 | #include <linux/sunrpc/stats.h> |
@@ -119,6 +120,7 @@ lockd(struct svc_rqst *rqstp) | |||
119 | complete(&lockd_start_done); | 120 | complete(&lockd_start_done); |
120 | 121 | ||
121 | daemonize("lockd"); | 122 | daemonize("lockd"); |
123 | set_freezable(); | ||
122 | 124 | ||
123 | /* Process request with signals blocked, but allow SIGKILL. */ | 125 | /* Process request with signals blocked, but allow SIGKILL. */ |
124 | allow_signal(SIGKILL); | 126 | allow_signal(SIGKILL); |
diff --git a/fs/nfs/callback.c b/fs/nfs/callback.c index 75f309c8741a..a796be5051bf 100644 --- a/fs/nfs/callback.c +++ b/fs/nfs/callback.c | |||
@@ -14,6 +14,7 @@ | |||
14 | #include <linux/sunrpc/svcsock.h> | 14 | #include <linux/sunrpc/svcsock.h> |
15 | #include <linux/nfs_fs.h> | 15 | #include <linux/nfs_fs.h> |
16 | #include <linux/mutex.h> | 16 | #include <linux/mutex.h> |
17 | #include <linux/freezer.h> | ||
17 | 18 | ||
18 | #include <net/inet_sock.h> | 19 | #include <net/inet_sock.h> |
19 | 20 | ||
@@ -67,6 +68,7 @@ static void nfs_callback_svc(struct svc_rqst *rqstp) | |||
67 | daemonize("nfsv4-svc"); | 68 | daemonize("nfsv4-svc"); |
68 | /* Process request with signals blocked, but allow SIGKILL. */ | 69 | /* Process request with signals blocked, but allow SIGKILL. */ |
69 | allow_signal(SIGKILL); | 70 | allow_signal(SIGKILL); |
71 | set_freezable(); | ||
70 | 72 | ||
71 | complete(&nfs_callback_info.started); | 73 | complete(&nfs_callback_info.started); |
72 | 74 | ||
diff --git a/fs/nfsd/nfssvc.c b/fs/nfsd/nfssvc.c index ff55950efb43..5c8192bcbced 100644 --- a/fs/nfsd/nfssvc.c +++ b/fs/nfsd/nfssvc.c | |||
@@ -19,6 +19,7 @@ | |||
19 | #include <linux/slab.h> | 19 | #include <linux/slab.h> |
20 | #include <linux/smp.h> | 20 | #include <linux/smp.h> |
21 | #include <linux/smp_lock.h> | 21 | #include <linux/smp_lock.h> |
22 | #include <linux/freezer.h> | ||
22 | #include <linux/fs_struct.h> | 23 | #include <linux/fs_struct.h> |
23 | 24 | ||
24 | #include <linux/sunrpc/types.h> | 25 | #include <linux/sunrpc/types.h> |
@@ -432,6 +433,7 @@ nfsd(struct svc_rqst *rqstp) | |||
432 | * dirty pages. | 433 | * dirty pages. |
433 | */ | 434 | */ |
434 | current->flags |= PF_LESS_THROTTLE; | 435 | current->flags |= PF_LESS_THROTTLE; |
436 | set_freezable(); | ||
435 | 437 | ||
436 | /* | 438 | /* |
437 | * The main request loop | 439 | * The main request loop |
diff --git a/fs/xfs/linux-2.6/xfs_super.c b/fs/xfs/linux-2.6/xfs_super.c index 06894cf00b12..4528f9a3f304 100644 --- a/fs/xfs/linux-2.6/xfs_super.c +++ b/fs/xfs/linux-2.6/xfs_super.c | |||
@@ -562,6 +562,7 @@ xfssyncd( | |||
562 | bhv_vfs_sync_work_t *work, *n; | 562 | bhv_vfs_sync_work_t *work, *n; |
563 | LIST_HEAD (tmp); | 563 | LIST_HEAD (tmp); |
564 | 564 | ||
565 | set_freezable(); | ||
565 | timeleft = xfs_syncd_centisecs * msecs_to_jiffies(10); | 566 | timeleft = xfs_syncd_centisecs * msecs_to_jiffies(10); |
566 | for (;;) { | 567 | for (;;) { |
567 | timeleft = schedule_timeout_interruptible(timeleft); | 568 | timeleft = schedule_timeout_interruptible(timeleft); |