aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/freezer.h
diff options
context:
space:
mode:
authorRafael J. Wysocki <rjw@sisk.pl>2007-10-18 06:04:45 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-10-18 17:37:19 -0400
commite42837bcd35b75bb59ae5d3e62f87be1aeeb05c3 (patch)
treeaa9666b080dc75ef3fa27992f042a422f7a979b7 /include/linux/freezer.h
parent2e1318956ce6bf149af5c5e98499b5cd99f99c89 (diff)
freezer: introduce freezer-friendly waiting macros
Introduce freezer-friendly wrappers around wait_event_interruptible() and wait_event_interruptible_timeout(), originally defined in <linux/wait.h>, to be used in freezable kernel threads. Make some of the freezable kernel threads use them. This is necessary for the freezer to stop sending signals to kernel threads, which is implemented in the next patch. Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl> Acked-by: Pavel Machek <pavel@ucw.cz> Cc: Nigel Cunningham <nigel@nigel.suspend2.net> 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.h38
1 files changed, 38 insertions, 0 deletions
diff --git a/include/linux/freezer.h b/include/linux/freezer.h
index efded00ad08c..08934995c7ab 100644
--- a/include/linux/freezer.h
+++ b/include/linux/freezer.h
@@ -4,6 +4,7 @@
4#define FREEZER_H_INCLUDED 4#define FREEZER_H_INCLUDED
5 5
6#include <linux/sched.h> 6#include <linux/sched.h>
7#include <linux/wait.h>
7 8
8#ifdef CONFIG_PM_SLEEP 9#ifdef CONFIG_PM_SLEEP
9/* 10/*
@@ -126,6 +127,36 @@ static inline void set_freezable(void)
126 current->flags &= ~PF_NOFREEZE; 127 current->flags &= ~PF_NOFREEZE;
127} 128}
128 129
130/*
131 * Freezer-friendly wrappers around wait_event_interruptible() and
132 * wait_event_interruptible_timeout(), originally defined in <linux/wait.h>
133 */
134
135#define wait_event_freezable(wq, condition) \
136({ \
137 int __retval; \
138 do { \
139 __retval = wait_event_interruptible(wq, \
140 (condition) || freezing(current)); \
141 if (__retval && !freezing(current)) \
142 break; \
143 else if (!(condition)) \
144 __retval = -ERESTARTSYS; \
145 } while (try_to_freeze()); \
146 __retval; \
147})
148
149
150#define wait_event_freezable_timeout(wq, condition, timeout) \
151({ \
152 long __retval = timeout; \
153 do { \
154 __retval = wait_event_interruptible_timeout(wq, \
155 (condition) || freezing(current), \
156 __retval); \
157 } while (try_to_freeze()); \
158 __retval; \
159})
129#else /* !CONFIG_PM_SLEEP */ 160#else /* !CONFIG_PM_SLEEP */
130static inline int frozen(struct task_struct *p) { return 0; } 161static inline int frozen(struct task_struct *p) { return 0; }
131static inline int freezing(struct task_struct *p) { return 0; } 162static inline int freezing(struct task_struct *p) { return 0; }
@@ -143,6 +174,13 @@ static inline void freezer_do_not_count(void) {}
143static inline void freezer_count(void) {} 174static inline void freezer_count(void) {}
144static inline int freezer_should_skip(struct task_struct *p) { return 0; } 175static inline int freezer_should_skip(struct task_struct *p) { return 0; }
145static inline void set_freezable(void) {} 176static inline void set_freezable(void) {}
177
178#define wait_event_freezable(wq, condition) \
179 wait_event_interruptible(wq, condition)
180
181#define wait_event_freezable_timeout(wq, condition, timeout) \
182 wait_event_interruptible_timeout(wq, condition, timeout)
183
146#endif /* !CONFIG_PM_SLEEP */ 184#endif /* !CONFIG_PM_SLEEP */
147 185
148#endif /* FREEZER_H_INCLUDED */ 186#endif /* FREEZER_H_INCLUDED */