diff options
| author | Michal Marek <mmarek@suse.cz> | 2014-01-02 08:02:06 -0500 |
|---|---|---|
| committer | Michal Marek <mmarek@suse.cz> | 2014-01-02 08:02:06 -0500 |
| commit | 37e2c2a775fc887acd1432908478dfd532f7f00f (patch) | |
| tree | e51ebc699d8e262fd47e0913be6a711cb1a7b565 /include/linux/sched.h | |
| parent | 1c8ddae09f4c102b97c9086cc70347e89468a547 (diff) | |
| parent | 6ce4eac1f600b34f2f7f58f9cd8f0503d79e42ae (diff) | |
Merge commit v3.13-rc1 into kbuild/misc
Diffstat (limited to 'include/linux/sched.h')
| -rw-r--r-- | include/linux/sched.h | 195 |
1 files changed, 165 insertions, 30 deletions
diff --git a/include/linux/sched.h b/include/linux/sched.h index 6682da36b293..7e35d4b9e14a 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h | |||
| @@ -22,6 +22,7 @@ struct sched_param { | |||
| 22 | #include <linux/errno.h> | 22 | #include <linux/errno.h> |
| 23 | #include <linux/nodemask.h> | 23 | #include <linux/nodemask.h> |
| 24 | #include <linux/mm_types.h> | 24 | #include <linux/mm_types.h> |
| 25 | #include <linux/preempt_mask.h> | ||
| 25 | 26 | ||
| 26 | #include <asm/page.h> | 27 | #include <asm/page.h> |
| 27 | #include <asm/ptrace.h> | 28 | #include <asm/ptrace.h> |
| @@ -285,6 +286,14 @@ static inline void lockup_detector_init(void) | |||
| 285 | } | 286 | } |
| 286 | #endif | 287 | #endif |
| 287 | 288 | ||
| 289 | #ifdef CONFIG_DETECT_HUNG_TASK | ||
| 290 | void reset_hung_task_detector(void); | ||
| 291 | #else | ||
| 292 | static inline void reset_hung_task_detector(void) | ||
| 293 | { | ||
| 294 | } | ||
| 295 | #endif | ||
| 296 | |||
| 288 | /* Attach to any functions which should be ignored in wchan output. */ | 297 | /* Attach to any functions which should be ignored in wchan output. */ |
| 289 | #define __sched __attribute__((__section__(".sched.text"))) | 298 | #define __sched __attribute__((__section__(".sched.text"))) |
| 290 | 299 | ||
| @@ -322,6 +331,10 @@ static inline void arch_pick_mmap_layout(struct mm_struct *mm) {} | |||
| 322 | extern void set_dumpable(struct mm_struct *mm, int value); | 331 | extern void set_dumpable(struct mm_struct *mm, int value); |
| 323 | extern int get_dumpable(struct mm_struct *mm); | 332 | extern int get_dumpable(struct mm_struct *mm); |
| 324 | 333 | ||
| 334 | #define SUID_DUMP_DISABLE 0 /* No setuid dumping */ | ||
| 335 | #define SUID_DUMP_USER 1 /* Dump as user of process */ | ||
| 336 | #define SUID_DUMP_ROOT 2 /* Dump as root */ | ||
| 337 | |||
| 325 | /* mm flags */ | 338 | /* mm flags */ |
| 326 | /* dumpable bits */ | 339 | /* dumpable bits */ |
| 327 | #define MMF_DUMPABLE 0 /* core dump is permitted */ | 340 | #define MMF_DUMPABLE 0 /* core dump is permitted */ |
| @@ -427,6 +440,14 @@ struct task_cputime { | |||
| 427 | .sum_exec_runtime = 0, \ | 440 | .sum_exec_runtime = 0, \ |
| 428 | } | 441 | } |
| 429 | 442 | ||
| 443 | #define PREEMPT_ENABLED (PREEMPT_NEED_RESCHED) | ||
| 444 | |||
| 445 | #ifdef CONFIG_PREEMPT_COUNT | ||
| 446 | #define PREEMPT_DISABLED (1 + PREEMPT_ENABLED) | ||
| 447 | #else | ||
| 448 | #define PREEMPT_DISABLED PREEMPT_ENABLED | ||
| 449 | #endif | ||
| 450 | |||
| 430 | /* | 451 | /* |
| 431 | * Disable preemption until the scheduler is running. | 452 | * Disable preemption until the scheduler is running. |
| 432 | * Reset by start_kernel()->sched_init()->init_idle(). | 453 | * Reset by start_kernel()->sched_init()->init_idle(). |
| @@ -434,7 +455,7 @@ struct task_cputime { | |||
| 434 | * We include PREEMPT_ACTIVE to avoid cond_resched() from working | 455 | * We include PREEMPT_ACTIVE to avoid cond_resched() from working |
| 435 | * before the scheduler is active -- see should_resched(). | 456 | * before the scheduler is active -- see should_resched(). |
| 436 | */ | 457 | */ |
| 437 | #define INIT_PREEMPT_COUNT (1 + PREEMPT_ACTIVE) | 458 | #define INIT_PREEMPT_COUNT (PREEMPT_DISABLED + PREEMPT_ACTIVE) |
| 438 | 459 | ||
| 439 | /** | 460 | /** |
| 440 | * struct thread_group_cputimer - thread group interval timer counts | 461 | * struct thread_group_cputimer - thread group interval timer counts |
| @@ -768,6 +789,7 @@ enum cpu_idle_type { | |||
| 768 | #define SD_ASYM_PACKING 0x0800 /* Place busy groups earlier in the domain */ | 789 | #define SD_ASYM_PACKING 0x0800 /* Place busy groups earlier in the domain */ |
| 769 | #define SD_PREFER_SIBLING 0x1000 /* Prefer to place tasks in a sibling domain */ | 790 | #define SD_PREFER_SIBLING 0x1000 /* Prefer to place tasks in a sibling domain */ |
| 770 | #define SD_OVERLAP 0x2000 /* sched_domains of this level overlap */ | 791 | #define SD_OVERLAP 0x2000 /* sched_domains of this level overlap */ |
| 792 | #define SD_NUMA 0x4000 /* cross-node balancing */ | ||
| 771 | 793 | ||
| 772 | extern int __weak arch_sd_sibiling_asym_packing(void); | 794 | extern int __weak arch_sd_sibiling_asym_packing(void); |
| 773 | 795 | ||
| @@ -811,6 +833,10 @@ struct sched_domain { | |||
| 811 | 833 | ||
| 812 | u64 last_update; | 834 | u64 last_update; |
| 813 | 835 | ||
| 836 | /* idle_balance() stats */ | ||
| 837 | u64 max_newidle_lb_cost; | ||
| 838 | unsigned long next_decay_max_lb_cost; | ||
| 839 | |||
| 814 | #ifdef CONFIG_SCHEDSTATS | 840 | #ifdef CONFIG_SCHEDSTATS |
| 815 | /* load_balance() stats */ | 841 | /* load_balance() stats */ |
| 816 | unsigned int lb_count[CPU_MAX_IDLE_TYPES]; | 842 | unsigned int lb_count[CPU_MAX_IDLE_TYPES]; |
| @@ -1029,6 +1055,8 @@ struct task_struct { | |||
| 1029 | struct task_struct *last_wakee; | 1055 | struct task_struct *last_wakee; |
| 1030 | unsigned long wakee_flips; | 1056 | unsigned long wakee_flips; |
| 1031 | unsigned long wakee_flip_decay_ts; | 1057 | unsigned long wakee_flip_decay_ts; |
| 1058 | |||
| 1059 | int wake_cpu; | ||
| 1032 | #endif | 1060 | #endif |
| 1033 | int on_rq; | 1061 | int on_rq; |
| 1034 | 1062 | ||
| @@ -1046,15 +1074,6 @@ struct task_struct { | |||
| 1046 | struct hlist_head preempt_notifiers; | 1074 | struct hlist_head preempt_notifiers; |
| 1047 | #endif | 1075 | #endif |
| 1048 | 1076 | ||
| 1049 | /* | ||
| 1050 | * fpu_counter contains the number of consecutive context switches | ||
| 1051 | * that the FPU is used. If this is over a threshold, the lazy fpu | ||
| 1052 | * saving becomes unlazy to save the trap. This is an unsigned char | ||
| 1053 | * so that after 256 times the counter wraps and the behavior turns | ||
| 1054 | * lazy again; this to deal with bursty apps that only use FPU for | ||
| 1055 | * a short time | ||
| 1056 | */ | ||
| 1057 | unsigned char fpu_counter; | ||
| 1058 | #ifdef CONFIG_BLK_DEV_IO_TRACE | 1077 | #ifdef CONFIG_BLK_DEV_IO_TRACE |
| 1059 | unsigned int btrace_seq; | 1078 | unsigned int btrace_seq; |
| 1060 | #endif | 1079 | #endif |
| @@ -1324,10 +1343,41 @@ struct task_struct { | |||
| 1324 | #endif | 1343 | #endif |
| 1325 | #ifdef CONFIG_NUMA_BALANCING | 1344 | #ifdef CONFIG_NUMA_BALANCING |
| 1326 | int numa_scan_seq; | 1345 | int numa_scan_seq; |
| 1327 | int numa_migrate_seq; | ||
| 1328 | unsigned int numa_scan_period; | 1346 | unsigned int numa_scan_period; |
| 1347 | unsigned int numa_scan_period_max; | ||
| 1348 | int numa_preferred_nid; | ||
| 1349 | int numa_migrate_deferred; | ||
| 1350 | unsigned long numa_migrate_retry; | ||
| 1329 | u64 node_stamp; /* migration stamp */ | 1351 | u64 node_stamp; /* migration stamp */ |
| 1330 | struct callback_head numa_work; | 1352 | struct callback_head numa_work; |
| 1353 | |||
| 1354 | struct list_head numa_entry; | ||
| 1355 | struct numa_group *numa_group; | ||
| 1356 | |||
| 1357 | /* | ||
| 1358 | * Exponential decaying average of faults on a per-node basis. | ||
| 1359 | * Scheduling placement decisions are made based on the these counts. | ||
| 1360 | * The values remain static for the duration of a PTE scan | ||
| 1361 | */ | ||
| 1362 | unsigned long *numa_faults; | ||
| 1363 | unsigned long total_numa_faults; | ||
| 1364 | |||
| 1365 | /* | ||
| 1366 | * numa_faults_buffer records faults per node during the current | ||
| 1367 | * scan window. When the scan completes, the counts in numa_faults | ||
| 1368 | * decay and these values are copied. | ||
| 1369 | */ | ||
| 1370 | unsigned long *numa_faults_buffer; | ||
| 1371 | |||
| 1372 | /* | ||
| 1373 | * numa_faults_locality tracks if faults recorded during the last | ||
| 1374 | * scan window were remote/local. The task scan period is adapted | ||
| 1375 | * based on the locality of the faults with different weights | ||
| 1376 | * depending on whether they were shared or private faults | ||
| 1377 | */ | ||
| 1378 | unsigned long numa_faults_locality[2]; | ||
| 1379 | |||
| 1380 | unsigned long numa_pages_migrated; | ||
| 1331 | #endif /* CONFIG_NUMA_BALANCING */ | 1381 | #endif /* CONFIG_NUMA_BALANCING */ |
| 1332 | 1382 | ||
| 1333 | struct rcu_head rcu; | 1383 | struct rcu_head rcu; |
| @@ -1394,11 +1444,10 @@ struct task_struct { | |||
| 1394 | } memcg_batch; | 1444 | } memcg_batch; |
| 1395 | unsigned int memcg_kmem_skip_account; | 1445 | unsigned int memcg_kmem_skip_account; |
| 1396 | struct memcg_oom_info { | 1446 | struct memcg_oom_info { |
| 1447 | struct mem_cgroup *memcg; | ||
| 1448 | gfp_t gfp_mask; | ||
| 1449 | int order; | ||
| 1397 | unsigned int may_oom:1; | 1450 | unsigned int may_oom:1; |
| 1398 | unsigned int in_memcg_oom:1; | ||
| 1399 | unsigned int oom_locked:1; | ||
| 1400 | int wakeups; | ||
| 1401 | struct mem_cgroup *wait_on_memcg; | ||
| 1402 | } memcg_oom; | 1451 | } memcg_oom; |
| 1403 | #endif | 1452 | #endif |
| 1404 | #ifdef CONFIG_UPROBES | 1453 | #ifdef CONFIG_UPROBES |
| @@ -1413,16 +1462,33 @@ struct task_struct { | |||
| 1413 | /* Future-safe accessor for struct task_struct's cpus_allowed. */ | 1462 | /* Future-safe accessor for struct task_struct's cpus_allowed. */ |
| 1414 | #define tsk_cpus_allowed(tsk) (&(tsk)->cpus_allowed) | 1463 | #define tsk_cpus_allowed(tsk) (&(tsk)->cpus_allowed) |
| 1415 | 1464 | ||
| 1465 | #define TNF_MIGRATED 0x01 | ||
| 1466 | #define TNF_NO_GROUP 0x02 | ||
| 1467 | #define TNF_SHARED 0x04 | ||
| 1468 | #define TNF_FAULT_LOCAL 0x08 | ||
| 1469 | |||
| 1416 | #ifdef CONFIG_NUMA_BALANCING | 1470 | #ifdef CONFIG_NUMA_BALANCING |
| 1417 | extern void task_numa_fault(int node, int pages, bool migrated); | 1471 | extern void task_numa_fault(int last_node, int node, int pages, int flags); |
| 1472 | extern pid_t task_numa_group_id(struct task_struct *p); | ||
| 1418 | extern void set_numabalancing_state(bool enabled); | 1473 | extern void set_numabalancing_state(bool enabled); |
| 1474 | extern void task_numa_free(struct task_struct *p); | ||
| 1475 | |||
| 1476 | extern unsigned int sysctl_numa_balancing_migrate_deferred; | ||
| 1419 | #else | 1477 | #else |
| 1420 | static inline void task_numa_fault(int node, int pages, bool migrated) | 1478 | static inline void task_numa_fault(int last_node, int node, int pages, |
| 1479 | int flags) | ||
| 1480 | { | ||
| 1481 | } | ||
| 1482 | static inline pid_t task_numa_group_id(struct task_struct *p) | ||
| 1421 | { | 1483 | { |
| 1484 | return 0; | ||
| 1422 | } | 1485 | } |
| 1423 | static inline void set_numabalancing_state(bool enabled) | 1486 | static inline void set_numabalancing_state(bool enabled) |
| 1424 | { | 1487 | { |
| 1425 | } | 1488 | } |
| 1489 | static inline void task_numa_free(struct task_struct *p) | ||
| 1490 | { | ||
| 1491 | } | ||
| 1426 | #endif | 1492 | #endif |
| 1427 | 1493 | ||
| 1428 | static inline struct pid *task_pid(struct task_struct *task) | 1494 | static inline struct pid *task_pid(struct task_struct *task) |
| @@ -1975,7 +2041,7 @@ extern void wake_up_new_task(struct task_struct *tsk); | |||
| 1975 | #else | 2041 | #else |
| 1976 | static inline void kick_process(struct task_struct *tsk) { } | 2042 | static inline void kick_process(struct task_struct *tsk) { } |
| 1977 | #endif | 2043 | #endif |
| 1978 | extern void sched_fork(struct task_struct *p); | 2044 | extern void sched_fork(unsigned long clone_flags, struct task_struct *p); |
| 1979 | extern void sched_dead(struct task_struct *p); | 2045 | extern void sched_dead(struct task_struct *p); |
| 1980 | 2046 | ||
| 1981 | extern void proc_caches_init(void); | 2047 | extern void proc_caches_init(void); |
| @@ -2402,11 +2468,6 @@ static inline int signal_pending_state(long state, struct task_struct *p) | |||
| 2402 | return (state & TASK_INTERRUPTIBLE) || __fatal_signal_pending(p); | 2468 | return (state & TASK_INTERRUPTIBLE) || __fatal_signal_pending(p); |
| 2403 | } | 2469 | } |
| 2404 | 2470 | ||
| 2405 | static inline int need_resched(void) | ||
| 2406 | { | ||
| 2407 | return unlikely(test_thread_flag(TIF_NEED_RESCHED)); | ||
| 2408 | } | ||
| 2409 | |||
| 2410 | /* | 2471 | /* |
| 2411 | * cond_resched() and cond_resched_lock(): latency reduction via | 2472 | * cond_resched() and cond_resched_lock(): latency reduction via |
| 2412 | * explicit rescheduling in places that are safe. The return | 2473 | * explicit rescheduling in places that are safe. The return |
| @@ -2475,36 +2536,105 @@ static inline int tsk_is_polling(struct task_struct *p) | |||
| 2475 | { | 2536 | { |
| 2476 | return task_thread_info(p)->status & TS_POLLING; | 2537 | return task_thread_info(p)->status & TS_POLLING; |
| 2477 | } | 2538 | } |
| 2478 | static inline void current_set_polling(void) | 2539 | static inline void __current_set_polling(void) |
| 2479 | { | 2540 | { |
| 2480 | current_thread_info()->status |= TS_POLLING; | 2541 | current_thread_info()->status |= TS_POLLING; |
| 2481 | } | 2542 | } |
| 2482 | 2543 | ||
| 2483 | static inline void current_clr_polling(void) | 2544 | static inline bool __must_check current_set_polling_and_test(void) |
| 2545 | { | ||
| 2546 | __current_set_polling(); | ||
| 2547 | |||
| 2548 | /* | ||
| 2549 | * Polling state must be visible before we test NEED_RESCHED, | ||
| 2550 | * paired by resched_task() | ||
| 2551 | */ | ||
| 2552 | smp_mb(); | ||
| 2553 | |||
| 2554 | return unlikely(tif_need_resched()); | ||
| 2555 | } | ||
| 2556 | |||
| 2557 | static inline void __current_clr_polling(void) | ||
| 2484 | { | 2558 | { |
| 2485 | current_thread_info()->status &= ~TS_POLLING; | 2559 | current_thread_info()->status &= ~TS_POLLING; |
| 2486 | smp_mb__after_clear_bit(); | 2560 | } |
| 2561 | |||
| 2562 | static inline bool __must_check current_clr_polling_and_test(void) | ||
| 2563 | { | ||
| 2564 | __current_clr_polling(); | ||
| 2565 | |||
| 2566 | /* | ||
| 2567 | * Polling state must be visible before we test NEED_RESCHED, | ||
| 2568 | * paired by resched_task() | ||
| 2569 | */ | ||
| 2570 | smp_mb(); | ||
| 2571 | |||
| 2572 | return unlikely(tif_need_resched()); | ||
| 2487 | } | 2573 | } |
| 2488 | #elif defined(TIF_POLLING_NRFLAG) | 2574 | #elif defined(TIF_POLLING_NRFLAG) |
| 2489 | static inline int tsk_is_polling(struct task_struct *p) | 2575 | static inline int tsk_is_polling(struct task_struct *p) |
| 2490 | { | 2576 | { |
| 2491 | return test_tsk_thread_flag(p, TIF_POLLING_NRFLAG); | 2577 | return test_tsk_thread_flag(p, TIF_POLLING_NRFLAG); |
| 2492 | } | 2578 | } |
| 2493 | static inline void current_set_polling(void) | 2579 | |
| 2580 | static inline void __current_set_polling(void) | ||
| 2494 | { | 2581 | { |
| 2495 | set_thread_flag(TIF_POLLING_NRFLAG); | 2582 | set_thread_flag(TIF_POLLING_NRFLAG); |
| 2496 | } | 2583 | } |
| 2497 | 2584 | ||
| 2498 | static inline void current_clr_polling(void) | 2585 | static inline bool __must_check current_set_polling_and_test(void) |
| 2586 | { | ||
| 2587 | __current_set_polling(); | ||
| 2588 | |||
| 2589 | /* | ||
| 2590 | * Polling state must be visible before we test NEED_RESCHED, | ||
| 2591 | * paired by resched_task() | ||
| 2592 | * | ||
| 2593 | * XXX: assumes set/clear bit are identical barrier wise. | ||
| 2594 | */ | ||
| 2595 | smp_mb__after_clear_bit(); | ||
| 2596 | |||
| 2597 | return unlikely(tif_need_resched()); | ||
| 2598 | } | ||
| 2599 | |||
| 2600 | static inline void __current_clr_polling(void) | ||
| 2499 | { | 2601 | { |
| 2500 | clear_thread_flag(TIF_POLLING_NRFLAG); | 2602 | clear_thread_flag(TIF_POLLING_NRFLAG); |
| 2501 | } | 2603 | } |
| 2604 | |||
| 2605 | static inline bool __must_check current_clr_polling_and_test(void) | ||
| 2606 | { | ||
| 2607 | __current_clr_polling(); | ||
| 2608 | |||
| 2609 | /* | ||
| 2610 | * Polling state must be visible before we test NEED_RESCHED, | ||
| 2611 | * paired by resched_task() | ||
| 2612 | */ | ||
| 2613 | smp_mb__after_clear_bit(); | ||
| 2614 | |||
| 2615 | return unlikely(tif_need_resched()); | ||
| 2616 | } | ||
| 2617 | |||
| 2502 | #else | 2618 | #else |
| 2503 | static inline int tsk_is_polling(struct task_struct *p) { return 0; } | 2619 | static inline int tsk_is_polling(struct task_struct *p) { return 0; } |
| 2504 | static inline void current_set_polling(void) { } | 2620 | static inline void __current_set_polling(void) { } |
| 2505 | static inline void current_clr_polling(void) { } | 2621 | static inline void __current_clr_polling(void) { } |
| 2622 | |||
| 2623 | static inline bool __must_check current_set_polling_and_test(void) | ||
| 2624 | { | ||
| 2625 | return unlikely(tif_need_resched()); | ||
| 2626 | } | ||
| 2627 | static inline bool __must_check current_clr_polling_and_test(void) | ||
| 2628 | { | ||
| 2629 | return unlikely(tif_need_resched()); | ||
| 2630 | } | ||
| 2506 | #endif | 2631 | #endif |
| 2507 | 2632 | ||
| 2633 | static __always_inline bool need_resched(void) | ||
| 2634 | { | ||
| 2635 | return unlikely(tif_need_resched()); | ||
| 2636 | } | ||
| 2637 | |||
| 2508 | /* | 2638 | /* |
| 2509 | * Thread group CPU time accounting. | 2639 | * Thread group CPU time accounting. |
| 2510 | */ | 2640 | */ |
| @@ -2546,6 +2676,11 @@ static inline unsigned int task_cpu(const struct task_struct *p) | |||
| 2546 | return task_thread_info(p)->cpu; | 2676 | return task_thread_info(p)->cpu; |
| 2547 | } | 2677 | } |
| 2548 | 2678 | ||
| 2679 | static inline int task_node(const struct task_struct *p) | ||
| 2680 | { | ||
| 2681 | return cpu_to_node(task_cpu(p)); | ||
| 2682 | } | ||
| 2683 | |||
| 2549 | extern void set_task_cpu(struct task_struct *p, unsigned int cpu); | 2684 | extern void set_task_cpu(struct task_struct *p, unsigned int cpu); |
| 2550 | 2685 | ||
| 2551 | #else | 2686 | #else |
