aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
authorChristoph Lameter <christoph@lameter.com>2005-06-25 02:13:50 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-06-25 20:10:13 -0400
commit3e1d1d28d99dabe63c64f7f40f1ca1d646de1f73 (patch)
treed1e7c1e2e8902072042aefc3a7976b271cf76021 /include/linux
parentb3e112bcc19abd8e9657dca34a87316786e096f3 (diff)
[PATCH] Cleanup patch for process freezing
1. Establish a simple API for process freezing defined in linux/include/sched.h: frozen(process) Check for frozen process freezing(process) Check if a process is being frozen freeze(process) Tell a process to freeze (go to refrigerator) thaw_process(process) Restart process frozen_process(process) Process is frozen now 2. Remove all references to PF_FREEZE and PF_FROZEN from all kernel sources except sched.h 3. Fix numerous locations where try_to_freeze is manually done by a driver 4. Remove the argument that is no longer necessary from two function calls. 5. Some whitespace cleanup 6. Clear potential race in refrigerator (provides an open window of PF_FREEZE cleared before setting PF_FROZEN, recalc_sigpending does not check PF_FROZEN). This patch does not address the problem of freeze_processes() violating the rule that a task may only modify its own flags by setting PF_FREEZE. This is not clean in an SMP environment. freeze(process) is therefore not SMP safe! Signed-off-by: Christoph Lameter <christoph@lameter.com> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/sched.h73
1 files changed, 59 insertions, 14 deletions
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 2c69682b0444..e7fd09b0557f 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -1245,33 +1245,78 @@ extern void normalize_rt_tasks(void);
1245 1245
1246#endif 1246#endif
1247 1247
1248/* try_to_freeze
1249 *
1250 * Checks whether we need to enter the refrigerator
1251 * and returns 1 if we did so.
1252 */
1253#ifdef CONFIG_PM 1248#ifdef CONFIG_PM
1254extern void refrigerator(unsigned long); 1249/*
1250 * Check if a process has been frozen
1251 */
1252static inline int frozen(struct task_struct *p)
1253{
1254 return p->flags & PF_FROZEN;
1255}
1256
1257/*
1258 * Check if there is a request to freeze a process
1259 */
1260static inline int freezing(struct task_struct *p)
1261{
1262 return p->flags & PF_FREEZE;
1263}
1264
1265/*
1266 * Request that a process be frozen
1267 * FIXME: SMP problem. We may not modify other process' flags!
1268 */
1269static inline void freeze(struct task_struct *p)
1270{
1271 p->flags |= PF_FREEZE;
1272}
1273
1274/*
1275 * Wake up a frozen process
1276 */
1277static inline int thaw_process(struct task_struct *p)
1278{
1279 if (frozen(p)) {
1280 p->flags &= ~PF_FROZEN;
1281 wake_up_process(p);
1282 return 1;
1283 }
1284 return 0;
1285}
1286
1287/*
1288 * freezing is complete, mark process as frozen
1289 */
1290static inline void frozen_process(struct task_struct *p)
1291{
1292 p->flags = (p->flags & ~PF_FREEZE) | PF_FROZEN;
1293}
1294
1295extern void refrigerator(void);
1255extern int freeze_processes(void); 1296extern int freeze_processes(void);
1256extern void thaw_processes(void); 1297extern void thaw_processes(void);
1257 1298
1258static inline int try_to_freeze(unsigned long refrigerator_flags) 1299static inline int try_to_freeze(void)
1259{ 1300{
1260 if (unlikely(current->flags & PF_FREEZE)) { 1301 if (freezing(current)) {
1261 refrigerator(refrigerator_flags); 1302 refrigerator();
1262 return 1; 1303 return 1;
1263 } else 1304 } else
1264 return 0; 1305 return 0;
1265} 1306}
1266#else 1307#else
1267static inline void refrigerator(unsigned long flag) {} 1308static inline int frozen(struct task_struct *p) { return 0; }
1309static inline int freezing(struct task_struct *p) { return 0; }
1310static inline void freeze(struct task_struct *p) { BUG(); }
1311static inline int thaw_process(struct task_struct *p) { return 1; }
1312static inline void frozen_process(struct task_struct *p) { BUG(); }
1313
1314static inline void refrigerator(void) {}
1268static inline int freeze_processes(void) { BUG(); return 0; } 1315static inline int freeze_processes(void) { BUG(); return 0; }
1269static inline void thaw_processes(void) {} 1316static inline void thaw_processes(void) {}
1270 1317
1271static inline int try_to_freeze(unsigned long refrigerator_flags) 1318static inline int try_to_freeze(void) { return 0; }
1272{ 1319
1273 return 0;
1274}
1275#endif /* CONFIG_PM */ 1320#endif /* CONFIG_PM */
1276#endif /* __KERNEL__ */ 1321#endif /* __KERNEL__ */
1277 1322