diff options
author | Tejun Heo <tj@kernel.org> | 2011-11-21 15:32:22 -0500 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2011-11-21 15:32:22 -0500 |
commit | a0acae0e886d44bd5ce6d2f173c1ace0fcf0d9f6 (patch) | |
tree | 0b763388360a5a9043986e1f2201e43df74ebc46 /include/linux/freezer.h | |
parent | 3a7cbd50f74907580eb47a8d08e1f29741b81abf (diff) |
freezer: unexport refrigerator() and update try_to_freeze() slightly
There is no reason to export two functions for entering the
refrigerator. Calling refrigerator() instead of try_to_freeze()
doesn't save anything noticeable or removes any race condition.
* Rename refrigerator() to __refrigerator() and make it return bool
indicating whether it scheduled out for freezing.
* Update try_to_freeze() to return bool and relay the return value of
__refrigerator() if freezing().
* Convert all refrigerator() users to try_to_freeze().
* Update documentation accordingly.
* While at it, add might_sleep() to try_to_freeze().
Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Samuel Ortiz <samuel@sortiz.org>
Cc: Chris Mason <chris.mason@oracle.com>
Cc: "Theodore Ts'o" <tytso@mit.edu>
Cc: Steven Whitehouse <swhiteho@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Jan Kara <jack@suse.cz>
Cc: KONISHI Ryusuke <konishi.ryusuke@lab.ntt.co.jp>
Cc: Christoph Hellwig <hch@infradead.org>
Diffstat (limited to 'include/linux/freezer.h')
-rw-r--r-- | include/linux/freezer.h | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/include/linux/freezer.h b/include/linux/freezer.h index a5386e3ee756..7a9427e9fe47 100644 --- a/include/linux/freezer.h +++ b/include/linux/freezer.h | |||
@@ -47,18 +47,17 @@ static inline bool should_send_signal(struct task_struct *p) | |||
47 | /* Takes and releases task alloc lock using task_lock() */ | 47 | /* Takes and releases task alloc lock using task_lock() */ |
48 | extern int thaw_process(struct task_struct *p); | 48 | extern int thaw_process(struct task_struct *p); |
49 | 49 | ||
50 | extern void refrigerator(void); | 50 | extern bool __refrigerator(void); |
51 | extern int freeze_processes(void); | 51 | extern int freeze_processes(void); |
52 | extern int freeze_kernel_threads(void); | 52 | extern int freeze_kernel_threads(void); |
53 | extern void thaw_processes(void); | 53 | extern void thaw_processes(void); |
54 | 54 | ||
55 | static inline int try_to_freeze(void) | 55 | static inline bool try_to_freeze(void) |
56 | { | 56 | { |
57 | if (freezing(current)) { | 57 | might_sleep(); |
58 | refrigerator(); | 58 | if (likely(!freezing(current))) |
59 | return 1; | 59 | return false; |
60 | } else | 60 | return __refrigerator(); |
61 | return 0; | ||
62 | } | 61 | } |
63 | 62 | ||
64 | extern bool freeze_task(struct task_struct *p, bool sig_only); | 63 | extern bool freeze_task(struct task_struct *p, bool sig_only); |
@@ -181,12 +180,12 @@ static inline void set_freeze_flag(struct task_struct *p) {} | |||
181 | static inline void clear_freeze_flag(struct task_struct *p) {} | 180 | static inline void clear_freeze_flag(struct task_struct *p) {} |
182 | static inline int thaw_process(struct task_struct *p) { return 1; } | 181 | static inline int thaw_process(struct task_struct *p) { return 1; } |
183 | 182 | ||
184 | static inline void refrigerator(void) {} | 183 | static inline bool __refrigerator(void) { return false; } |
185 | static inline int freeze_processes(void) { return -ENOSYS; } | 184 | static inline int freeze_processes(void) { return -ENOSYS; } |
186 | static inline int freeze_kernel_threads(void) { return -ENOSYS; } | 185 | static inline int freeze_kernel_threads(void) { return -ENOSYS; } |
187 | static inline void thaw_processes(void) {} | 186 | static inline void thaw_processes(void) {} |
188 | 187 | ||
189 | static inline int try_to_freeze(void) { return 0; } | 188 | static inline bool try_to_freeze(void) { return false; } |
190 | 189 | ||
191 | static inline void freezer_do_not_count(void) {} | 190 | static inline void freezer_do_not_count(void) {} |
192 | static inline void freezer_count(void) {} | 191 | static inline void freezer_count(void) {} |