diff options
Diffstat (limited to 'include/linux/sched.h')
| -rw-r--r-- | include/linux/sched.h | 111 |
1 files changed, 88 insertions, 23 deletions
diff --git a/include/linux/sched.h b/include/linux/sched.h index 2c69682b0444..9530b1903160 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h | |||
| @@ -368,6 +368,11 @@ struct signal_struct { | |||
| 368 | #endif | 368 | #endif |
| 369 | }; | 369 | }; |
| 370 | 370 | ||
| 371 | /* Context switch must be unlocked if interrupts are to be enabled */ | ||
| 372 | #ifdef __ARCH_WANT_INTERRUPTS_ON_CTXSW | ||
| 373 | # define __ARCH_WANT_UNLOCKED_CTXSW | ||
| 374 | #endif | ||
| 375 | |||
| 371 | /* | 376 | /* |
| 372 | * Bits in flags field of signal_struct. | 377 | * Bits in flags field of signal_struct. |
| 373 | */ | 378 | */ |
| @@ -460,10 +465,11 @@ enum idle_type | |||
| 460 | #define SD_LOAD_BALANCE 1 /* Do load balancing on this domain. */ | 465 | #define SD_LOAD_BALANCE 1 /* Do load balancing on this domain. */ |
| 461 | #define SD_BALANCE_NEWIDLE 2 /* Balance when about to become idle */ | 466 | #define SD_BALANCE_NEWIDLE 2 /* Balance when about to become idle */ |
| 462 | #define SD_BALANCE_EXEC 4 /* Balance on exec */ | 467 | #define SD_BALANCE_EXEC 4 /* Balance on exec */ |
| 463 | #define SD_WAKE_IDLE 8 /* Wake to idle CPU on task wakeup */ | 468 | #define SD_BALANCE_FORK 8 /* Balance on fork, clone */ |
| 464 | #define SD_WAKE_AFFINE 16 /* Wake task to waking CPU */ | 469 | #define SD_WAKE_IDLE 16 /* Wake to idle CPU on task wakeup */ |
| 465 | #define SD_WAKE_BALANCE 32 /* Perform balancing at task wakeup */ | 470 | #define SD_WAKE_AFFINE 32 /* Wake task to waking CPU */ |
| 466 | #define SD_SHARE_CPUPOWER 64 /* Domain members share cpu power */ | 471 | #define SD_WAKE_BALANCE 64 /* Perform balancing at task wakeup */ |
| 472 | #define SD_SHARE_CPUPOWER 128 /* Domain members share cpu power */ | ||
| 467 | 473 | ||
| 468 | struct sched_group { | 474 | struct sched_group { |
| 469 | struct sched_group *next; /* Must be a circular list */ | 475 | struct sched_group *next; /* Must be a circular list */ |
| @@ -488,6 +494,11 @@ struct sched_domain { | |||
| 488 | unsigned long long cache_hot_time; /* Task considered cache hot (ns) */ | 494 | unsigned long long cache_hot_time; /* Task considered cache hot (ns) */ |
| 489 | unsigned int cache_nice_tries; /* Leave cache hot tasks for # tries */ | 495 | unsigned int cache_nice_tries; /* Leave cache hot tasks for # tries */ |
| 490 | unsigned int per_cpu_gain; /* CPU % gained by adding domain cpus */ | 496 | unsigned int per_cpu_gain; /* CPU % gained by adding domain cpus */ |
| 497 | unsigned int busy_idx; | ||
| 498 | unsigned int idle_idx; | ||
| 499 | unsigned int newidle_idx; | ||
| 500 | unsigned int wake_idx; | ||
| 501 | unsigned int forkexec_idx; | ||
| 491 | int flags; /* See SD_* */ | 502 | int flags; /* See SD_* */ |
| 492 | 503 | ||
| 493 | /* Runtime fields. */ | 504 | /* Runtime fields. */ |
| @@ -511,10 +522,16 @@ struct sched_domain { | |||
| 511 | unsigned long alb_failed; | 522 | unsigned long alb_failed; |
| 512 | unsigned long alb_pushed; | 523 | unsigned long alb_pushed; |
| 513 | 524 | ||
| 514 | /* sched_balance_exec() stats */ | 525 | /* SD_BALANCE_EXEC stats */ |
| 515 | unsigned long sbe_attempts; | 526 | unsigned long sbe_cnt; |
| 527 | unsigned long sbe_balanced; | ||
| 516 | unsigned long sbe_pushed; | 528 | unsigned long sbe_pushed; |
| 517 | 529 | ||
| 530 | /* SD_BALANCE_FORK stats */ | ||
| 531 | unsigned long sbf_cnt; | ||
| 532 | unsigned long sbf_balanced; | ||
| 533 | unsigned long sbf_pushed; | ||
| 534 | |||
| 518 | /* try_to_wake_up() stats */ | 535 | /* try_to_wake_up() stats */ |
| 519 | unsigned long ttwu_wake_remote; | 536 | unsigned long ttwu_wake_remote; |
| 520 | unsigned long ttwu_move_affine; | 537 | unsigned long ttwu_move_affine; |
| @@ -522,6 +539,8 @@ struct sched_domain { | |||
| 522 | #endif | 539 | #endif |
| 523 | }; | 540 | }; |
| 524 | 541 | ||
| 542 | extern void partition_sched_domains(cpumask_t *partition1, | ||
| 543 | cpumask_t *partition2); | ||
| 525 | #ifdef ARCH_HAS_SCHED_DOMAIN | 544 | #ifdef ARCH_HAS_SCHED_DOMAIN |
| 526 | /* Useful helpers that arch setup code may use. Defined in kernel/sched.c */ | 545 | /* Useful helpers that arch setup code may use. Defined in kernel/sched.c */ |
| 527 | extern cpumask_t cpu_isolated_map; | 546 | extern cpumask_t cpu_isolated_map; |
| @@ -582,6 +601,9 @@ struct task_struct { | |||
| 582 | 601 | ||
| 583 | int lock_depth; /* BKL lock depth */ | 602 | int lock_depth; /* BKL lock depth */ |
| 584 | 603 | ||
| 604 | #if defined(CONFIG_SMP) && defined(__ARCH_WANT_UNLOCKED_CTXSW) | ||
| 605 | int oncpu; | ||
| 606 | #endif | ||
| 585 | int prio, static_prio; | 607 | int prio, static_prio; |
| 586 | struct list_head run_list; | 608 | struct list_head run_list; |
| 587 | prio_array_t *array; | 609 | prio_array_t *array; |
| @@ -704,8 +726,6 @@ struct task_struct { | |||
| 704 | spinlock_t alloc_lock; | 726 | spinlock_t alloc_lock; |
| 705 | /* Protection of proc_dentry: nesting proc_lock, dcache_lock, write_lock_irq(&tasklist_lock); */ | 727 | /* Protection of proc_dentry: nesting proc_lock, dcache_lock, write_lock_irq(&tasklist_lock); */ |
| 706 | spinlock_t proc_lock; | 728 | spinlock_t proc_lock; |
| 707 | /* context-switch lock */ | ||
| 708 | spinlock_t switch_lock; | ||
| 709 | 729 | ||
| 710 | /* journalling filesystem info */ | 730 | /* journalling filesystem info */ |
| 711 | void *journal_info; | 731 | void *journal_info; |
| @@ -912,7 +932,7 @@ extern void FASTCALL(wake_up_new_task(struct task_struct * tsk, | |||
| 912 | #else | 932 | #else |
| 913 | static inline void kick_process(struct task_struct *tsk) { } | 933 | static inline void kick_process(struct task_struct *tsk) { } |
| 914 | #endif | 934 | #endif |
| 915 | extern void FASTCALL(sched_fork(task_t * p)); | 935 | extern void FASTCALL(sched_fork(task_t * p, int clone_flags)); |
| 916 | extern void FASTCALL(sched_exit(task_t * p)); | 936 | extern void FASTCALL(sched_exit(task_t * p)); |
| 917 | 937 | ||
| 918 | extern int in_group_p(gid_t); | 938 | extern int in_group_p(gid_t); |
| @@ -1245,33 +1265,78 @@ extern void normalize_rt_tasks(void); | |||
| 1245 | 1265 | ||
| 1246 | #endif | 1266 | #endif |
| 1247 | 1267 | ||
| 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 | 1268 | #ifdef CONFIG_PM |
| 1254 | extern void refrigerator(unsigned long); | 1269 | /* |
| 1270 | * Check if a process has been frozen | ||
| 1271 | */ | ||
| 1272 | static inline int frozen(struct task_struct *p) | ||
| 1273 | { | ||
| 1274 | return p->flags & PF_FROZEN; | ||
| 1275 | } | ||
| 1276 | |||
| 1277 | /* | ||
| 1278 | * Check if there is a request to freeze a process | ||
| 1279 | */ | ||
| 1280 | static inline int freezing(struct task_struct *p) | ||
| 1281 | { | ||
| 1282 | return p->flags & PF_FREEZE; | ||
| 1283 | } | ||
| 1284 | |||
| 1285 | /* | ||
| 1286 | * Request that a process be frozen | ||
| 1287 | * FIXME: SMP problem. We may not modify other process' flags! | ||
| 1288 | */ | ||
| 1289 | static inline void freeze(struct task_struct *p) | ||
| 1290 | { | ||
| 1291 | p->flags |= PF_FREEZE; | ||
| 1292 | } | ||
| 1293 | |||
| 1294 | /* | ||
| 1295 | * Wake up a frozen process | ||
| 1296 | */ | ||
| 1297 | static inline int thaw_process(struct task_struct *p) | ||
| 1298 | { | ||
| 1299 | if (frozen(p)) { | ||
| 1300 | p->flags &= ~PF_FROZEN; | ||
| 1301 | wake_up_process(p); | ||
| 1302 | return 1; | ||
| 1303 | } | ||
| 1304 | return 0; | ||
| 1305 | } | ||
| 1306 | |||
| 1307 | /* | ||
| 1308 | * freezing is complete, mark process as frozen | ||
| 1309 | */ | ||
| 1310 | static inline void frozen_process(struct task_struct *p) | ||
| 1311 | { | ||
| 1312 | p->flags = (p->flags & ~PF_FREEZE) | PF_FROZEN; | ||
| 1313 | } | ||
| 1314 | |||
| 1315 | extern void refrigerator(void); | ||
| 1255 | extern int freeze_processes(void); | 1316 | extern int freeze_processes(void); |
| 1256 | extern void thaw_processes(void); | 1317 | extern void thaw_processes(void); |
| 1257 | 1318 | ||
| 1258 | static inline int try_to_freeze(unsigned long refrigerator_flags) | 1319 | static inline int try_to_freeze(void) |
| 1259 | { | 1320 | { |
| 1260 | if (unlikely(current->flags & PF_FREEZE)) { | 1321 | if (freezing(current)) { |
| 1261 | refrigerator(refrigerator_flags); | 1322 | refrigerator(); |
| 1262 | return 1; | 1323 | return 1; |
| 1263 | } else | 1324 | } else |
| 1264 | return 0; | 1325 | return 0; |
| 1265 | } | 1326 | } |
| 1266 | #else | 1327 | #else |
| 1267 | static inline void refrigerator(unsigned long flag) {} | 1328 | static inline int frozen(struct task_struct *p) { return 0; } |
| 1329 | static inline int freezing(struct task_struct *p) { return 0; } | ||
| 1330 | static inline void freeze(struct task_struct *p) { BUG(); } | ||
| 1331 | static inline int thaw_process(struct task_struct *p) { return 1; } | ||
| 1332 | static inline void frozen_process(struct task_struct *p) { BUG(); } | ||
| 1333 | |||
| 1334 | static inline void refrigerator(void) {} | ||
| 1268 | static inline int freeze_processes(void) { BUG(); return 0; } | 1335 | static inline int freeze_processes(void) { BUG(); return 0; } |
| 1269 | static inline void thaw_processes(void) {} | 1336 | static inline void thaw_processes(void) {} |
| 1270 | 1337 | ||
| 1271 | static inline int try_to_freeze(unsigned long refrigerator_flags) | 1338 | static inline int try_to_freeze(void) { return 0; } |
| 1272 | { | 1339 | |
| 1273 | return 0; | ||
| 1274 | } | ||
| 1275 | #endif /* CONFIG_PM */ | 1340 | #endif /* CONFIG_PM */ |
| 1276 | #endif /* __KERNEL__ */ | 1341 | #endif /* __KERNEL__ */ |
| 1277 | 1342 | ||
