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 /include/linux/freezer.h | |
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 'include/linux/freezer.h')
-rw-r--r-- | include/linux/freezer.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/include/linux/freezer.h b/include/linux/freezer.h index 4631086f5060..2d38b1a74662 100644 --- a/include/linux/freezer.h +++ b/include/linux/freezer.h | |||
@@ -1,5 +1,8 @@ | |||
1 | /* Freezer declarations */ | 1 | /* Freezer declarations */ |
2 | 2 | ||
3 | #ifndef FREEZER_H_INCLUDED | ||
4 | #define FREEZER_H_INCLUDED | ||
5 | |||
3 | #include <linux/sched.h> | 6 | #include <linux/sched.h> |
4 | 7 | ||
5 | #ifdef CONFIG_PM | 8 | #ifdef CONFIG_PM |
@@ -115,6 +118,14 @@ static inline int freezer_should_skip(struct task_struct *p) | |||
115 | return !!(p->flags & PF_FREEZER_SKIP); | 118 | return !!(p->flags & PF_FREEZER_SKIP); |
116 | } | 119 | } |
117 | 120 | ||
121 | /* | ||
122 | * Tell the freezer that the current task should be frozen by it | ||
123 | */ | ||
124 | static inline void set_freezable(void) | ||
125 | { | ||
126 | current->flags &= ~PF_NOFREEZE; | ||
127 | } | ||
128 | |||
118 | #else | 129 | #else |
119 | static inline int frozen(struct task_struct *p) { return 0; } | 130 | static inline int frozen(struct task_struct *p) { return 0; } |
120 | static inline int freezing(struct task_struct *p) { return 0; } | 131 | static inline int freezing(struct task_struct *p) { return 0; } |
@@ -130,4 +141,7 @@ static inline int try_to_freeze(void) { return 0; } | |||
130 | static inline void freezer_do_not_count(void) {} | 141 | static inline void freezer_do_not_count(void) {} |
131 | static inline void freezer_count(void) {} | 142 | static inline void freezer_count(void) {} |
132 | static inline int freezer_should_skip(struct task_struct *p) { return 0; } | 143 | static inline int freezer_should_skip(struct task_struct *p) { return 0; } |
144 | static inline void set_freezable(void) {} | ||
133 | #endif | 145 | #endif |
146 | |||
147 | #endif /* FREEZER_H_INCLUDED */ | ||