diff options
Diffstat (limited to 'include/linux/sched.h')
-rw-r--r-- | include/linux/sched.h | 115 |
1 files changed, 88 insertions, 27 deletions
diff --git a/include/linux/sched.h b/include/linux/sched.h index 0dd42a02df2e..f712465b05c5 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h | |||
@@ -107,8 +107,18 @@ extern unsigned long this_cpu_load(void); | |||
107 | extern void calc_global_load(unsigned long ticks); | 107 | extern void calc_global_load(unsigned long ticks); |
108 | extern void update_cpu_load_nohz(void); | 108 | extern void update_cpu_load_nohz(void); |
109 | 109 | ||
110 | /* Notifier for when a task gets migrated to a new CPU */ | ||
111 | struct task_migration_notifier { | ||
112 | struct task_struct *task; | ||
113 | int from_cpu; | ||
114 | int to_cpu; | ||
115 | }; | ||
116 | extern void register_task_migration_notifier(struct notifier_block *n); | ||
117 | |||
110 | extern unsigned long get_parent_ip(unsigned long addr); | 118 | extern unsigned long get_parent_ip(unsigned long addr); |
111 | 119 | ||
120 | extern void dump_cpu_task(int cpu); | ||
121 | |||
112 | struct seq_file; | 122 | struct seq_file; |
113 | struct cfs_rq; | 123 | struct cfs_rq; |
114 | struct task_group; | 124 | struct task_group; |
@@ -434,13 +444,28 @@ struct cpu_itimer { | |||
434 | }; | 444 | }; |
435 | 445 | ||
436 | /** | 446 | /** |
447 | * struct cputime - snaphsot of system and user cputime | ||
448 | * @utime: time spent in user mode | ||
449 | * @stime: time spent in system mode | ||
450 | * | ||
451 | * Gathers a generic snapshot of user and system time. | ||
452 | */ | ||
453 | struct cputime { | ||
454 | cputime_t utime; | ||
455 | cputime_t stime; | ||
456 | }; | ||
457 | |||
458 | /** | ||
437 | * struct task_cputime - collected CPU time counts | 459 | * struct task_cputime - collected CPU time counts |
438 | * @utime: time spent in user mode, in &cputime_t units | 460 | * @utime: time spent in user mode, in &cputime_t units |
439 | * @stime: time spent in kernel mode, in &cputime_t units | 461 | * @stime: time spent in kernel mode, in &cputime_t units |
440 | * @sum_exec_runtime: total time spent on the CPU, in nanoseconds | 462 | * @sum_exec_runtime: total time spent on the CPU, in nanoseconds |
441 | * | 463 | * |
442 | * This structure groups together three kinds of CPU time that are | 464 | * This is an extension of struct cputime that includes the total runtime |
443 | * tracked for threads and thread groups. Most things considering | 465 | * spent by the task from the scheduler point of view. |
466 | * | ||
467 | * As a result, this structure groups together three kinds of CPU time | ||
468 | * that are tracked for threads and thread groups. Most things considering | ||
444 | * CPU time want to group these counts together and treat all three | 469 | * CPU time want to group these counts together and treat all three |
445 | * of them in parallel. | 470 | * of them in parallel. |
446 | */ | 471 | */ |
@@ -581,7 +606,7 @@ struct signal_struct { | |||
581 | cputime_t gtime; | 606 | cputime_t gtime; |
582 | cputime_t cgtime; | 607 | cputime_t cgtime; |
583 | #ifndef CONFIG_VIRT_CPU_ACCOUNTING | 608 | #ifndef CONFIG_VIRT_CPU_ACCOUNTING |
584 | cputime_t prev_utime, prev_stime; | 609 | struct cputime prev_cputime; |
585 | #endif | 610 | #endif |
586 | unsigned long nvcsw, nivcsw, cnvcsw, cnivcsw; | 611 | unsigned long nvcsw, nivcsw, cnvcsw, cnivcsw; |
587 | unsigned long min_flt, maj_flt, cmin_flt, cmaj_flt; | 612 | unsigned long min_flt, maj_flt, cmin_flt, cmaj_flt; |
@@ -631,9 +656,10 @@ struct signal_struct { | |||
631 | struct rw_semaphore group_rwsem; | 656 | struct rw_semaphore group_rwsem; |
632 | #endif | 657 | #endif |
633 | 658 | ||
634 | int oom_score_adj; /* OOM kill score adjustment */ | 659 | oom_flags_t oom_flags; |
635 | int oom_score_adj_min; /* OOM kill score adjustment minimum value. | 660 | short oom_score_adj; /* OOM kill score adjustment */ |
636 | * Only settable by CAP_SYS_RESOURCE. */ | 661 | short oom_score_adj_min; /* OOM kill score adjustment min value. |
662 | * Only settable by CAP_SYS_RESOURCE. */ | ||
637 | 663 | ||
638 | struct mutex cred_guard_mutex; /* guard against foreign influences on | 664 | struct mutex cred_guard_mutex; /* guard against foreign influences on |
639 | * credential calculations | 665 | * credential calculations |
@@ -1061,6 +1087,7 @@ struct sched_class { | |||
1061 | 1087 | ||
1062 | #ifdef CONFIG_SMP | 1088 | #ifdef CONFIG_SMP |
1063 | int (*select_task_rq)(struct task_struct *p, int sd_flag, int flags); | 1089 | int (*select_task_rq)(struct task_struct *p, int sd_flag, int flags); |
1090 | void (*migrate_task_rq)(struct task_struct *p, int next_cpu); | ||
1064 | 1091 | ||
1065 | void (*pre_schedule) (struct rq *this_rq, struct task_struct *task); | 1092 | void (*pre_schedule) (struct rq *this_rq, struct task_struct *task); |
1066 | void (*post_schedule) (struct rq *this_rq); | 1093 | void (*post_schedule) (struct rq *this_rq); |
@@ -1095,6 +1122,18 @@ struct load_weight { | |||
1095 | unsigned long weight, inv_weight; | 1122 | unsigned long weight, inv_weight; |
1096 | }; | 1123 | }; |
1097 | 1124 | ||
1125 | struct sched_avg { | ||
1126 | /* | ||
1127 | * These sums represent an infinite geometric series and so are bound | ||
1128 | * above by 1024/(1-y). Thus we only need a u32 to store them for for all | ||
1129 | * choices of y < 1-2^(-32)*1024. | ||
1130 | */ | ||
1131 | u32 runnable_avg_sum, runnable_avg_period; | ||
1132 | u64 last_runnable_update; | ||
1133 | s64 decay_count; | ||
1134 | unsigned long load_avg_contrib; | ||
1135 | }; | ||
1136 | |||
1098 | #ifdef CONFIG_SCHEDSTATS | 1137 | #ifdef CONFIG_SCHEDSTATS |
1099 | struct sched_statistics { | 1138 | struct sched_statistics { |
1100 | u64 wait_start; | 1139 | u64 wait_start; |
@@ -1155,6 +1194,15 @@ struct sched_entity { | |||
1155 | /* rq "owned" by this entity/group: */ | 1194 | /* rq "owned" by this entity/group: */ |
1156 | struct cfs_rq *my_q; | 1195 | struct cfs_rq *my_q; |
1157 | #endif | 1196 | #endif |
1197 | /* | ||
1198 | * Load-tracking only depends on SMP, FAIR_GROUP_SCHED dependency below may be | ||
1199 | * removed when useful for applications beyond shares distribution (e.g. | ||
1200 | * load-balance). | ||
1201 | */ | ||
1202 | #if defined(CONFIG_SMP) && defined(CONFIG_FAIR_GROUP_SCHED) | ||
1203 | /* Per-entity load-tracking */ | ||
1204 | struct sched_avg avg; | ||
1205 | #endif | ||
1158 | }; | 1206 | }; |
1159 | 1207 | ||
1160 | struct sched_rt_entity { | 1208 | struct sched_rt_entity { |
@@ -1318,7 +1366,7 @@ struct task_struct { | |||
1318 | cputime_t utime, stime, utimescaled, stimescaled; | 1366 | cputime_t utime, stime, utimescaled, stimescaled; |
1319 | cputime_t gtime; | 1367 | cputime_t gtime; |
1320 | #ifndef CONFIG_VIRT_CPU_ACCOUNTING | 1368 | #ifndef CONFIG_VIRT_CPU_ACCOUNTING |
1321 | cputime_t prev_utime, prev_stime; | 1369 | struct cputime prev_cputime; |
1322 | #endif | 1370 | #endif |
1323 | unsigned long nvcsw, nivcsw; /* context switch counts */ | 1371 | unsigned long nvcsw, nivcsw; /* context switch counts */ |
1324 | struct timespec start_time; /* monotonic time */ | 1372 | struct timespec start_time; /* monotonic time */ |
@@ -1479,6 +1527,14 @@ struct task_struct { | |||
1479 | short il_next; | 1527 | short il_next; |
1480 | short pref_node_fork; | 1528 | short pref_node_fork; |
1481 | #endif | 1529 | #endif |
1530 | #ifdef CONFIG_NUMA_BALANCING | ||
1531 | int numa_scan_seq; | ||
1532 | int numa_migrate_seq; | ||
1533 | unsigned int numa_scan_period; | ||
1534 | u64 node_stamp; /* migration stamp */ | ||
1535 | struct callback_head numa_work; | ||
1536 | #endif /* CONFIG_NUMA_BALANCING */ | ||
1537 | |||
1482 | struct rcu_head rcu; | 1538 | struct rcu_head rcu; |
1483 | 1539 | ||
1484 | /* | 1540 | /* |
@@ -1541,6 +1597,7 @@ struct task_struct { | |||
1541 | unsigned long nr_pages; /* uncharged usage */ | 1597 | unsigned long nr_pages; /* uncharged usage */ |
1542 | unsigned long memsw_nr_pages; /* uncharged mem+swap usage */ | 1598 | unsigned long memsw_nr_pages; /* uncharged mem+swap usage */ |
1543 | } memcg_batch; | 1599 | } memcg_batch; |
1600 | unsigned int memcg_kmem_skip_account; | ||
1544 | #endif | 1601 | #endif |
1545 | #ifdef CONFIG_HAVE_HW_BREAKPOINT | 1602 | #ifdef CONFIG_HAVE_HW_BREAKPOINT |
1546 | atomic_t ptrace_bp_refcnt; | 1603 | atomic_t ptrace_bp_refcnt; |
@@ -1553,6 +1610,18 @@ struct task_struct { | |||
1553 | /* Future-safe accessor for struct task_struct's cpus_allowed. */ | 1610 | /* Future-safe accessor for struct task_struct's cpus_allowed. */ |
1554 | #define tsk_cpus_allowed(tsk) (&(tsk)->cpus_allowed) | 1611 | #define tsk_cpus_allowed(tsk) (&(tsk)->cpus_allowed) |
1555 | 1612 | ||
1613 | #ifdef CONFIG_NUMA_BALANCING | ||
1614 | extern void task_numa_fault(int node, int pages, bool migrated); | ||
1615 | extern void set_numabalancing_state(bool enabled); | ||
1616 | #else | ||
1617 | static inline void task_numa_fault(int node, int pages, bool migrated) | ||
1618 | { | ||
1619 | } | ||
1620 | static inline void set_numabalancing_state(bool enabled) | ||
1621 | { | ||
1622 | } | ||
1623 | #endif | ||
1624 | |||
1556 | /* | 1625 | /* |
1557 | * Priority of a process goes from 0..MAX_PRIO-1, valid RT | 1626 | * Priority of a process goes from 0..MAX_PRIO-1, valid RT |
1558 | * priority is 0..MAX_RT_PRIO-1, and SCHED_NORMAL/SCHED_BATCH | 1627 | * priority is 0..MAX_RT_PRIO-1, and SCHED_NORMAL/SCHED_BATCH |
@@ -1710,12 +1779,6 @@ static inline int is_global_init(struct task_struct *tsk) | |||
1710 | return tsk->pid == 1; | 1779 | return tsk->pid == 1; |
1711 | } | 1780 | } |
1712 | 1781 | ||
1713 | /* | ||
1714 | * is_container_init: | ||
1715 | * check whether in the task is init in its own pid namespace. | ||
1716 | */ | ||
1717 | extern int is_container_init(struct task_struct *tsk); | ||
1718 | |||
1719 | extern struct pid *cad_pid; | 1782 | extern struct pid *cad_pid; |
1720 | 1783 | ||
1721 | extern void free_task(struct task_struct *tsk); | 1784 | extern void free_task(struct task_struct *tsk); |
@@ -1729,8 +1792,8 @@ static inline void put_task_struct(struct task_struct *t) | |||
1729 | __put_task_struct(t); | 1792 | __put_task_struct(t); |
1730 | } | 1793 | } |
1731 | 1794 | ||
1732 | extern void task_times(struct task_struct *p, cputime_t *ut, cputime_t *st); | 1795 | extern void task_cputime_adjusted(struct task_struct *p, cputime_t *ut, cputime_t *st); |
1733 | extern void thread_group_times(struct task_struct *p, cputime_t *ut, cputime_t *st); | 1796 | extern void thread_group_cputime_adjusted(struct task_struct *p, cputime_t *ut, cputime_t *st); |
1734 | 1797 | ||
1735 | /* | 1798 | /* |
1736 | * Per process flags | 1799 | * Per process flags |
@@ -1844,14 +1907,6 @@ static inline void rcu_copy_process(struct task_struct *p) | |||
1844 | 1907 | ||
1845 | #endif | 1908 | #endif |
1846 | 1909 | ||
1847 | static inline void rcu_switch(struct task_struct *prev, | ||
1848 | struct task_struct *next) | ||
1849 | { | ||
1850 | #ifdef CONFIG_RCU_USER_QS | ||
1851 | rcu_user_hooks_switch(prev, next); | ||
1852 | #endif | ||
1853 | } | ||
1854 | |||
1855 | static inline void tsk_restore_flags(struct task_struct *task, | 1910 | static inline void tsk_restore_flags(struct task_struct *task, |
1856 | unsigned long orig_flags, unsigned long flags) | 1911 | unsigned long orig_flags, unsigned long flags) |
1857 | { | 1912 | { |
@@ -1990,6 +2045,13 @@ enum sched_tunable_scaling { | |||
1990 | }; | 2045 | }; |
1991 | extern enum sched_tunable_scaling sysctl_sched_tunable_scaling; | 2046 | extern enum sched_tunable_scaling sysctl_sched_tunable_scaling; |
1992 | 2047 | ||
2048 | extern unsigned int sysctl_numa_balancing_scan_delay; | ||
2049 | extern unsigned int sysctl_numa_balancing_scan_period_min; | ||
2050 | extern unsigned int sysctl_numa_balancing_scan_period_max; | ||
2051 | extern unsigned int sysctl_numa_balancing_scan_period_reset; | ||
2052 | extern unsigned int sysctl_numa_balancing_scan_size; | ||
2053 | extern unsigned int sysctl_numa_balancing_settle_count; | ||
2054 | |||
1993 | #ifdef CONFIG_SCHED_DEBUG | 2055 | #ifdef CONFIG_SCHED_DEBUG |
1994 | extern unsigned int sysctl_sched_migration_cost; | 2056 | extern unsigned int sysctl_sched_migration_cost; |
1995 | extern unsigned int sysctl_sched_nr_migrate; | 2057 | extern unsigned int sysctl_sched_nr_migrate; |
@@ -2271,7 +2333,7 @@ extern void mm_release(struct task_struct *, struct mm_struct *); | |||
2271 | extern struct mm_struct *dup_mm(struct task_struct *tsk); | 2333 | extern struct mm_struct *dup_mm(struct task_struct *tsk); |
2272 | 2334 | ||
2273 | extern int copy_thread(unsigned long, unsigned long, unsigned long, | 2335 | extern int copy_thread(unsigned long, unsigned long, unsigned long, |
2274 | struct task_struct *, struct pt_regs *); | 2336 | struct task_struct *); |
2275 | extern void flush_thread(void); | 2337 | extern void flush_thread(void); |
2276 | extern void exit_thread(void); | 2338 | extern void exit_thread(void); |
2277 | 2339 | ||
@@ -2283,14 +2345,13 @@ extern void flush_itimer_signals(void); | |||
2283 | 2345 | ||
2284 | extern void do_group_exit(int); | 2346 | extern void do_group_exit(int); |
2285 | 2347 | ||
2286 | extern void daemonize(const char *, ...); | ||
2287 | extern int allow_signal(int); | 2348 | extern int allow_signal(int); |
2288 | extern int disallow_signal(int); | 2349 | extern int disallow_signal(int); |
2289 | 2350 | ||
2290 | extern int do_execve(const char *, | 2351 | extern int do_execve(const char *, |
2291 | const char __user * const __user *, | 2352 | const char __user * const __user *, |
2292 | const char __user * const __user *, struct pt_regs *); | 2353 | const char __user * const __user *); |
2293 | extern long do_fork(unsigned long, unsigned long, struct pt_regs *, unsigned long, int __user *, int __user *); | 2354 | extern long do_fork(unsigned long, unsigned long, unsigned long, int __user *, int __user *); |
2294 | struct task_struct *fork_idle(int); | 2355 | struct task_struct *fork_idle(int); |
2295 | #ifdef CONFIG_GENERIC_KERNEL_THREAD | 2356 | #ifdef CONFIG_GENERIC_KERNEL_THREAD |
2296 | extern pid_t kernel_thread(int (*fn)(void *), void *arg, unsigned long flags); | 2357 | extern pid_t kernel_thread(int (*fn)(void *), void *arg, unsigned long flags); |