This source file includes following definitions.
- frozen
- freezing
- try_to_freeze_unsafe
- try_to_freeze
- cgroup_freezing
- freezer_do_not_count
- freezer_count
- freezer_count_unsafe
- freezer_should_skip
- freezable_schedule
- freezable_schedule_unsafe
- freezable_schedule_timeout
- freezable_schedule_timeout_interruptible
- freezable_schedule_timeout_killable
- freezable_schedule_timeout_killable_unsafe
- freezable_schedule_hrtimeout_range
- frozen
- freezing
- __thaw_task
- __refrigerator
- freeze_processes
- freeze_kernel_threads
- thaw_processes
- thaw_kernel_threads
- try_to_freeze_nowarn
- try_to_freeze
- freezer_do_not_count
- freezer_count
- freezer_should_skip
- set_freezable
1
2
3
4 #ifndef FREEZER_H_INCLUDED
5 #define FREEZER_H_INCLUDED
6
7 #include <linux/debug_locks.h>
8 #include <linux/sched.h>
9 #include <linux/wait.h>
10 #include <linux/atomic.h>
11
12 #ifdef CONFIG_FREEZER
13 extern atomic_t system_freezing_cnt;
14 extern bool pm_freezing;
15 extern bool pm_nosig_freezing;
16
17
18
19
20 extern unsigned int freeze_timeout_msecs;
21
22
23
24
25 static inline bool frozen(struct task_struct *p)
26 {
27 return p->flags & PF_FROZEN;
28 }
29
30 extern bool freezing_slow_path(struct task_struct *p);
31
32
33
34
35 static inline bool freezing(struct task_struct *p)
36 {
37 if (likely(!atomic_read(&system_freezing_cnt)))
38 return false;
39 return freezing_slow_path(p);
40 }
41
42
43 extern void __thaw_task(struct task_struct *t);
44
45 extern bool __refrigerator(bool check_kthr_stop);
46 extern int freeze_processes(void);
47 extern int freeze_kernel_threads(void);
48 extern void thaw_processes(void);
49 extern void thaw_kernel_threads(void);
50
51
52
53
54
55 static inline bool try_to_freeze_unsafe(void)
56 {
57 might_sleep();
58 if (likely(!freezing(current)))
59 return false;
60 return __refrigerator(false);
61 }
62
63 static inline bool try_to_freeze(void)
64 {
65 if (!(current->flags & PF_NOFREEZE))
66 debug_check_no_locks_held();
67 return try_to_freeze_unsafe();
68 }
69
70 extern bool freeze_task(struct task_struct *p);
71 extern bool set_freezable(void);
72
73 #ifdef CONFIG_CGROUP_FREEZER
74 extern bool cgroup_freezing(struct task_struct *task);
75 #else
76 static inline bool cgroup_freezing(struct task_struct *task)
77 {
78 return false;
79 }
80 #endif
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107 static inline void freezer_do_not_count(void)
108 {
109 current->flags |= PF_FREEZER_SKIP;
110 }
111
112
113
114
115
116
117
118
119 static inline void freezer_count(void)
120 {
121 current->flags &= ~PF_FREEZER_SKIP;
122
123
124
125
126
127 smp_mb();
128 try_to_freeze();
129 }
130
131
132 static inline void freezer_count_unsafe(void)
133 {
134 current->flags &= ~PF_FREEZER_SKIP;
135 smp_mb();
136 try_to_freeze_unsafe();
137 }
138
139
140
141
142
143
144
145
146
147
148
149 static inline bool freezer_should_skip(struct task_struct *p)
150 {
151
152
153
154
155
156
157
158 smp_mb();
159 return p->flags & PF_FREEZER_SKIP;
160 }
161
162
163
164
165
166
167
168
169 static inline void freezable_schedule(void)
170 {
171 freezer_do_not_count();
172 schedule();
173 freezer_count();
174 }
175
176
177 static inline void freezable_schedule_unsafe(void)
178 {
179 freezer_do_not_count();
180 schedule();
181 freezer_count_unsafe();
182 }
183
184
185
186
187
188 static inline long freezable_schedule_timeout(long timeout)
189 {
190 long __retval;
191 freezer_do_not_count();
192 __retval = schedule_timeout(timeout);
193 freezer_count();
194 return __retval;
195 }
196
197
198
199
200
201 static inline long freezable_schedule_timeout_interruptible(long timeout)
202 {
203 long __retval;
204 freezer_do_not_count();
205 __retval = schedule_timeout_interruptible(timeout);
206 freezer_count();
207 return __retval;
208 }
209
210
211 static inline long freezable_schedule_timeout_killable(long timeout)
212 {
213 long __retval;
214 freezer_do_not_count();
215 __retval = schedule_timeout_killable(timeout);
216 freezer_count();
217 return __retval;
218 }
219
220
221 static inline long freezable_schedule_timeout_killable_unsafe(long timeout)
222 {
223 long __retval;
224 freezer_do_not_count();
225 __retval = schedule_timeout_killable(timeout);
226 freezer_count_unsafe();
227 return __retval;
228 }
229
230
231
232
233
234 static inline int freezable_schedule_hrtimeout_range(ktime_t *expires,
235 u64 delta, const enum hrtimer_mode mode)
236 {
237 int __retval;
238 freezer_do_not_count();
239 __retval = schedule_hrtimeout_range(expires, delta, mode);
240 freezer_count();
241 return __retval;
242 }
243
244
245
246
247
248
249
250
251 #define wait_event_freezekillable_unsafe(wq, condition) \
252 ({ \
253 int __retval; \
254 freezer_do_not_count(); \
255 __retval = wait_event_killable(wq, (condition)); \
256 freezer_count_unsafe(); \
257 __retval; \
258 })
259
260 #else
261 static inline bool frozen(struct task_struct *p) { return false; }
262 static inline bool freezing(struct task_struct *p) { return false; }
263 static inline void __thaw_task(struct task_struct *t) {}
264
265 static inline bool __refrigerator(bool check_kthr_stop) { return false; }
266 static inline int freeze_processes(void) { return -ENOSYS; }
267 static inline int freeze_kernel_threads(void) { return -ENOSYS; }
268 static inline void thaw_processes(void) {}
269 static inline void thaw_kernel_threads(void) {}
270
271 static inline bool try_to_freeze_nowarn(void) { return false; }
272 static inline bool try_to_freeze(void) { return false; }
273
274 static inline void freezer_do_not_count(void) {}
275 static inline void freezer_count(void) {}
276 static inline int freezer_should_skip(struct task_struct *p) { return 0; }
277 static inline void set_freezable(void) {}
278
279 #define freezable_schedule() schedule()
280
281 #define freezable_schedule_unsafe() schedule()
282
283 #define freezable_schedule_timeout(timeout) schedule_timeout(timeout)
284
285 #define freezable_schedule_timeout_interruptible(timeout) \
286 schedule_timeout_interruptible(timeout)
287
288 #define freezable_schedule_timeout_killable(timeout) \
289 schedule_timeout_killable(timeout)
290
291 #define freezable_schedule_timeout_killable_unsafe(timeout) \
292 schedule_timeout_killable(timeout)
293
294 #define freezable_schedule_hrtimeout_range(expires, delta, mode) \
295 schedule_hrtimeout_range(expires, delta, mode)
296
297 #define wait_event_freezekillable_unsafe(wq, condition) \
298 wait_event_killable(wq, condition)
299
300 #endif
301
302 #endif