aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/sched.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/sched.h')
-rw-r--r--include/linux/sched.h144
1 files changed, 109 insertions, 35 deletions
diff --git a/include/linux/sched.h b/include/linux/sched.h
index b4c38bc8049c..3ab08e4bb6b8 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -77,6 +77,7 @@ struct sched_param {
77#include <linux/proportions.h> 77#include <linux/proportions.h>
78#include <linux/seccomp.h> 78#include <linux/seccomp.h>
79#include <linux/rcupdate.h> 79#include <linux/rcupdate.h>
80#include <linux/rculist.h>
80#include <linux/rtmutex.h> 81#include <linux/rtmutex.h>
81 82
82#include <linux/time.h> 83#include <linux/time.h>
@@ -91,13 +92,13 @@ struct sched_param {
91 92
92#include <asm/processor.h> 93#include <asm/processor.h>
93 94
94struct mem_cgroup;
95struct exec_domain; 95struct exec_domain;
96struct futex_pi_state; 96struct futex_pi_state;
97struct robust_list_head; 97struct robust_list_head;
98struct bio; 98struct bio;
99struct bts_tracer;
100struct fs_struct; 99struct fs_struct;
100struct bts_context;
101struct perf_counter_context;
101 102
102/* 103/*
103 * List of flags we want to share for kernel threads, 104 * List of flags we want to share for kernel threads,
@@ -116,6 +117,7 @@ struct fs_struct;
116 * 11 bit fractions. 117 * 11 bit fractions.
117 */ 118 */
118extern unsigned long avenrun[]; /* Load averages */ 119extern unsigned long avenrun[]; /* Load averages */
120extern void get_avenrun(unsigned long *loads, unsigned long offset, int shift);
119 121
120#define FSHIFT 11 /* nr of bits of precision */ 122#define FSHIFT 11 /* nr of bits of precision */
121#define FIXED_1 (1<<FSHIFT) /* 1.0 as fixed-point */ 123#define FIXED_1 (1<<FSHIFT) /* 1.0 as fixed-point */
@@ -135,8 +137,9 @@ DECLARE_PER_CPU(unsigned long, process_counts);
135extern int nr_processes(void); 137extern int nr_processes(void);
136extern unsigned long nr_running(void); 138extern unsigned long nr_running(void);
137extern unsigned long nr_uninterruptible(void); 139extern unsigned long nr_uninterruptible(void);
138extern unsigned long nr_active(void);
139extern unsigned long nr_iowait(void); 140extern unsigned long nr_iowait(void);
141extern void calc_global_load(void);
142extern u64 cpu_nr_migrations(int cpu);
140 143
141extern unsigned long get_parent_ip(unsigned long addr); 144extern unsigned long get_parent_ip(unsigned long addr);
142 145
@@ -206,7 +209,7 @@ extern unsigned long long time_sync_thresh;
206 ((task->state & (__TASK_STOPPED | __TASK_TRACED)) != 0) 209 ((task->state & (__TASK_STOPPED | __TASK_TRACED)) != 0)
207#define task_contributes_to_load(task) \ 210#define task_contributes_to_load(task) \
208 ((task->state & TASK_UNINTERRUPTIBLE) != 0 && \ 211 ((task->state & TASK_UNINTERRUPTIBLE) != 0 && \
209 (task->flags & PF_FROZEN) == 0) 212 (task->flags & PF_FREEZING) == 0)
210 213
211#define __set_task_state(tsk, state_value) \ 214#define __set_task_state(tsk, state_value) \
212 do { (tsk)->state = (state_value); } while (0) 215 do { (tsk)->state = (state_value); } while (0)
@@ -257,6 +260,7 @@ extern void task_rq_unlock_wait(struct task_struct *p);
257extern cpumask_var_t nohz_cpu_mask; 260extern cpumask_var_t nohz_cpu_mask;
258#if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ) 261#if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ)
259extern int select_nohz_load_balancer(int cpu); 262extern int select_nohz_load_balancer(int cpu);
263extern int get_nohz_load_balancer(void);
260#else 264#else
261static inline int select_nohz_load_balancer(int cpu) 265static inline int select_nohz_load_balancer(int cpu)
262{ 266{
@@ -345,8 +349,20 @@ extern int mutex_spin_on_owner(struct mutex *lock, struct thread_info *owner);
345struct nsproxy; 349struct nsproxy;
346struct user_namespace; 350struct user_namespace;
347 351
348/* Maximum number of active map areas.. This is a random (large) number */ 352/*
349#define DEFAULT_MAX_MAP_COUNT 65536 353 * Default maximum number of active map areas, this limits the number of vmas
354 * per mm struct. Users can overwrite this number by sysctl but there is a
355 * problem.
356 *
357 * When a program's coredump is generated as ELF format, a section is created
358 * per a vma. In ELF, the number of sections is represented in unsigned short.
359 * This means the number of sections should be smaller than 65535 at coredump.
360 * Because the kernel adds some informative sections to a image of program at
361 * generating coredump, we need some margin. The number of extra sections is
362 * 1-3 now and depends on arch. We use "5" as safe margin, here.
363 */
364#define MAPCOUNT_ELF_CORE_MARGIN (5)
365#define DEFAULT_MAX_MAP_COUNT (USHORT_MAX - MAPCOUNT_ELF_CORE_MARGIN)
350 366
351extern int sysctl_max_map_count; 367extern int sysctl_max_map_count;
352 368
@@ -482,6 +498,15 @@ struct task_cputime {
482 .sum_exec_runtime = 0, \ 498 .sum_exec_runtime = 0, \
483 } 499 }
484 500
501/*
502 * Disable preemption until the scheduler is running.
503 * Reset by start_kernel()->sched_init()->init_idle().
504 *
505 * We include PREEMPT_ACTIVE to avoid cond_resched() from working
506 * before the scheduler is active -- see should_resched().
507 */
508#define INIT_PREEMPT_COUNT (1 + PREEMPT_ACTIVE)
509
485/** 510/**
486 * struct thread_group_cputimer - thread group interval timer counts 511 * struct thread_group_cputimer - thread group interval timer counts
487 * @cputime: thread group interval timers. 512 * @cputime: thread group interval timers.
@@ -669,8 +694,12 @@ struct user_struct {
669 struct task_group *tg; 694 struct task_group *tg;
670#ifdef CONFIG_SYSFS 695#ifdef CONFIG_SYSFS
671 struct kobject kobj; 696 struct kobject kobj;
672 struct work_struct work; 697 struct delayed_work work;
698#endif
673#endif 699#endif
700
701#ifdef CONFIG_PERF_COUNTERS
702 atomic_long_t locked_vm;
674#endif 703#endif
675}; 704};
676 705
@@ -838,7 +867,17 @@ struct sched_group {
838 */ 867 */
839 u32 reciprocal_cpu_power; 868 u32 reciprocal_cpu_power;
840 869
841 unsigned long cpumask[]; 870 /*
871 * The CPUs this group covers.
872 *
873 * NOTE: this field is variable length. (Allocated dynamically
874 * by attaching extra space to the end of the structure,
875 * depending on how many CPUs the kernel has booted up with)
876 *
877 * It is also be embedded into static data structures at build
878 * time. (See 'struct static_sched_group' in kernel/sched.c)
879 */
880 unsigned long cpumask[0];
842}; 881};
843 882
844static inline struct cpumask *sched_group_cpus(struct sched_group *sg) 883static inline struct cpumask *sched_group_cpus(struct sched_group *sg)
@@ -924,8 +963,17 @@ struct sched_domain {
924 char *name; 963 char *name;
925#endif 964#endif
926 965
927 /* span of all CPUs in this domain */ 966 /*
928 unsigned long span[]; 967 * Span of all CPUs in this domain.
968 *
969 * NOTE: this field is variable length. (Allocated dynamically
970 * by attaching extra space to the end of the structure,
971 * depending on how many CPUs the kernel has booted up with)
972 *
973 * It is also be embedded into static data structures at build
974 * time. (See 'struct static_sched_domain' in kernel/sched.c)
975 */
976 unsigned long span[0];
929}; 977};
930 978
931static inline struct cpumask *sched_domain_span(struct sched_domain *sd) 979static inline struct cpumask *sched_domain_span(struct sched_domain *sd)
@@ -1052,9 +1100,10 @@ struct sched_entity {
1052 u64 last_wakeup; 1100 u64 last_wakeup;
1053 u64 avg_overlap; 1101 u64 avg_overlap;
1054 1102
1103 u64 nr_migrations;
1104
1055 u64 start_runtime; 1105 u64 start_runtime;
1056 u64 avg_wakeup; 1106 u64 avg_wakeup;
1057 u64 nr_migrations;
1058 1107
1059#ifdef CONFIG_SCHEDSTATS 1108#ifdef CONFIG_SCHEDSTATS
1060 u64 wait_start; 1109 u64 wait_start;
@@ -1149,7 +1198,6 @@ struct task_struct {
1149 * a short time 1198 * a short time
1150 */ 1199 */
1151 unsigned char fpu_counter; 1200 unsigned char fpu_counter;
1152 s8 oomkilladj; /* OOM kill score adjustment (bit shift). */
1153#ifdef CONFIG_BLK_DEV_IO_TRACE 1201#ifdef CONFIG_BLK_DEV_IO_TRACE
1154 unsigned int btrace_seq; 1202 unsigned int btrace_seq;
1155#endif 1203#endif
@@ -1209,18 +1257,11 @@ struct task_struct {
1209 struct list_head ptraced; 1257 struct list_head ptraced;
1210 struct list_head ptrace_entry; 1258 struct list_head ptrace_entry;
1211 1259
1212#ifdef CONFIG_X86_PTRACE_BTS
1213 /* 1260 /*
1214 * This is the tracer handle for the ptrace BTS extension. 1261 * This is the tracer handle for the ptrace BTS extension.
1215 * This field actually belongs to the ptracer task. 1262 * This field actually belongs to the ptracer task.
1216 */ 1263 */
1217 struct bts_tracer *bts; 1264 struct bts_context *bts;
1218 /*
1219 * The buffer to hold the BTS data.
1220 */
1221 void *bts_buffer;
1222 size_t bts_size;
1223#endif /* CONFIG_X86_PTRACE_BTS */
1224 1265
1225 /* PID/PID hash table linkage. */ 1266 /* PID/PID hash table linkage. */
1226 struct pid_link pids[PIDTYPE_MAX]; 1267 struct pid_link pids[PIDTYPE_MAX];
@@ -1247,7 +1288,9 @@ struct task_struct {
1247 * credentials (COW) */ 1288 * credentials (COW) */
1248 const struct cred *cred; /* effective (overridable) subjective task 1289 const struct cred *cred; /* effective (overridable) subjective task
1249 * credentials (COW) */ 1290 * credentials (COW) */
1250 struct mutex cred_exec_mutex; /* execve vs ptrace cred calculation mutex */ 1291 struct mutex cred_guard_mutex; /* guard against foreign influences on
1292 * credential calculations
1293 * (notably. ptrace) */
1251 1294
1252 char comm[TASK_COMM_LEN]; /* executable name excluding path 1295 char comm[TASK_COMM_LEN]; /* executable name excluding path
1253 - access with [gs]et_task_comm (which lock 1296 - access with [gs]et_task_comm (which lock
@@ -1294,7 +1337,8 @@ struct task_struct {
1294/* Thread group tracking */ 1337/* Thread group tracking */
1295 u32 parent_exec_id; 1338 u32 parent_exec_id;
1296 u32 self_exec_id; 1339 u32 self_exec_id;
1297/* Protection of (de-)allocation: mm, files, fs, tty, keyrings */ 1340/* Protection of (de-)allocation: mm, files, fs, tty, keyrings, mems_allowed,
1341 * mempolicy */
1298 spinlock_t alloc_lock; 1342 spinlock_t alloc_lock;
1299 1343
1300#ifdef CONFIG_GENERIC_HARDIRQS 1344#ifdef CONFIG_GENERIC_HARDIRQS
@@ -1362,8 +1406,7 @@ struct task_struct {
1362 cputime_t acct_timexpd; /* stime + utime since last update */ 1406 cputime_t acct_timexpd; /* stime + utime since last update */
1363#endif 1407#endif
1364#ifdef CONFIG_CPUSETS 1408#ifdef CONFIG_CPUSETS
1365 nodemask_t mems_allowed; 1409 nodemask_t mems_allowed; /* Protected by alloc_lock */
1366 int cpuset_mems_generation;
1367 int cpuset_mem_spread_rotor; 1410 int cpuset_mem_spread_rotor;
1368#endif 1411#endif
1369#ifdef CONFIG_CGROUPS 1412#ifdef CONFIG_CGROUPS
@@ -1380,8 +1423,13 @@ struct task_struct {
1380 struct list_head pi_state_list; 1423 struct list_head pi_state_list;
1381 struct futex_pi_state *pi_state_cache; 1424 struct futex_pi_state *pi_state_cache;
1382#endif 1425#endif
1426#ifdef CONFIG_PERF_COUNTERS
1427 struct perf_counter_context *perf_counter_ctxp;
1428 struct mutex perf_counter_mutex;
1429 struct list_head perf_counter_list;
1430#endif
1383#ifdef CONFIG_NUMA 1431#ifdef CONFIG_NUMA
1384 struct mempolicy *mempolicy; 1432 struct mempolicy *mempolicy; /* Protected by alloc_lock */
1385 short il_next; 1433 short il_next;
1386#endif 1434#endif
1387 atomic_t fs_excl; /* holding fs exclusive resources */ 1435 atomic_t fs_excl; /* holding fs exclusive resources */
@@ -1428,7 +1476,9 @@ struct task_struct {
1428#ifdef CONFIG_TRACING 1476#ifdef CONFIG_TRACING
1429 /* state flags for use by tracers */ 1477 /* state flags for use by tracers */
1430 unsigned long trace; 1478 unsigned long trace;
1431#endif 1479 /* bitmask of trace recursion */
1480 unsigned long trace_recursion;
1481#endif /* CONFIG_TRACING */
1432}; 1482};
1433 1483
1434/* Future-safe accessor for struct task_struct's cpus_allowed. */ 1484/* Future-safe accessor for struct task_struct's cpus_allowed. */
@@ -1630,6 +1680,7 @@ extern cputime_t task_gtime(struct task_struct *p);
1630#define PF_MEMALLOC 0x00000800 /* Allocating memory */ 1680#define PF_MEMALLOC 0x00000800 /* Allocating memory */
1631#define PF_FLUSHER 0x00001000 /* responsible for disk writeback */ 1681#define PF_FLUSHER 0x00001000 /* responsible for disk writeback */
1632#define PF_USED_MATH 0x00002000 /* if unset the fpu must be initialized before use */ 1682#define PF_USED_MATH 0x00002000 /* if unset the fpu must be initialized before use */
1683#define PF_FREEZING 0x00004000 /* freeze in progress. do not account to load */
1633#define PF_NOFREEZE 0x00008000 /* this thread should not be frozen */ 1684#define PF_NOFREEZE 0x00008000 /* this thread should not be frozen */
1634#define PF_FROZEN 0x00010000 /* frozen for system suspend */ 1685#define PF_FROZEN 0x00010000 /* frozen for system suspend */
1635#define PF_FSTRANS 0x00020000 /* inside a filesystem transaction */ 1686#define PF_FSTRANS 0x00020000 /* inside a filesystem transaction */
@@ -1766,11 +1817,23 @@ extern unsigned int sysctl_sched_child_runs_first;
1766extern unsigned int sysctl_sched_features; 1817extern unsigned int sysctl_sched_features;
1767extern unsigned int sysctl_sched_migration_cost; 1818extern unsigned int sysctl_sched_migration_cost;
1768extern unsigned int sysctl_sched_nr_migrate; 1819extern unsigned int sysctl_sched_nr_migrate;
1820extern unsigned int sysctl_timer_migration;
1769 1821
1770int sched_nr_latency_handler(struct ctl_table *table, int write, 1822int sched_nr_latency_handler(struct ctl_table *table, int write,
1771 struct file *file, void __user *buffer, size_t *length, 1823 struct file *file, void __user *buffer, size_t *length,
1772 loff_t *ppos); 1824 loff_t *ppos);
1773#endif 1825#endif
1826#ifdef CONFIG_SCHED_DEBUG
1827static inline unsigned int get_sysctl_timer_migration(void)
1828{
1829 return sysctl_timer_migration;
1830}
1831#else
1832static inline unsigned int get_sysctl_timer_migration(void)
1833{
1834 return 1;
1835}
1836#endif
1774extern unsigned int sysctl_sched_rt_period; 1837extern unsigned int sysctl_sched_rt_period;
1775extern int sysctl_sched_rt_runtime; 1838extern int sysctl_sched_rt_runtime;
1776 1839
@@ -1837,9 +1900,6 @@ extern struct pid_namespace init_pid_ns;
1837/* 1900/*
1838 * find a task by one of its numerical ids 1901 * find a task by one of its numerical ids
1839 * 1902 *
1840 * find_task_by_pid_type_ns():
1841 * it is the most generic call - it finds a task by all id,
1842 * type and namespace specified
1843 * find_task_by_pid_ns(): 1903 * find_task_by_pid_ns():
1844 * finds a task by its pid in the specified namespace 1904 * finds a task by its pid in the specified namespace
1845 * find_task_by_vpid(): 1905 * find_task_by_vpid():
@@ -1848,9 +1908,6 @@ extern struct pid_namespace init_pid_ns;
1848 * see also find_vpid() etc in include/linux/pid.h 1908 * see also find_vpid() etc in include/linux/pid.h
1849 */ 1909 */
1850 1910
1851extern struct task_struct *find_task_by_pid_type_ns(int type, int pid,
1852 struct pid_namespace *ns);
1853
1854extern struct task_struct *find_task_by_vpid(pid_t nr); 1911extern struct task_struct *find_task_by_vpid(pid_t nr);
1855extern struct task_struct *find_task_by_pid_ns(pid_t nr, 1912extern struct task_struct *find_task_by_pid_ns(pid_t nr,
1856 struct pid_namespace *ns); 1913 struct pid_namespace *ns);
@@ -1885,6 +1942,7 @@ extern void sched_dead(struct task_struct *p);
1885 1942
1886extern void proc_caches_init(void); 1943extern void proc_caches_init(void);
1887extern void flush_signals(struct task_struct *); 1944extern void flush_signals(struct task_struct *);
1945extern void __flush_signals(struct task_struct *);
1888extern void ignore_signals(struct task_struct *); 1946extern void ignore_signals(struct task_struct *);
1889extern void flush_signal_handlers(struct task_struct *, int force_default); 1947extern void flush_signal_handlers(struct task_struct *, int force_default);
1890extern int dequeue_signal(struct task_struct *tsk, sigset_t *mask, siginfo_t *info); 1948extern int dequeue_signal(struct task_struct *tsk, sigset_t *mask, siginfo_t *info);
@@ -2001,8 +2059,10 @@ extern void set_task_comm(struct task_struct *tsk, char *from);
2001extern char *get_task_comm(char *to, struct task_struct *tsk); 2059extern char *get_task_comm(char *to, struct task_struct *tsk);
2002 2060
2003#ifdef CONFIG_SMP 2061#ifdef CONFIG_SMP
2062extern void wait_task_context_switch(struct task_struct *p);
2004extern unsigned long wait_task_inactive(struct task_struct *, long match_state); 2063extern unsigned long wait_task_inactive(struct task_struct *, long match_state);
2005#else 2064#else
2065static inline void wait_task_context_switch(struct task_struct *p) {}
2006static inline unsigned long wait_task_inactive(struct task_struct *p, 2066static inline unsigned long wait_task_inactive(struct task_struct *p,
2007 long match_state) 2067 long match_state)
2008{ 2068{
@@ -2010,7 +2070,8 @@ static inline unsigned long wait_task_inactive(struct task_struct *p,
2010} 2070}
2011#endif 2071#endif
2012 2072
2013#define next_task(p) list_entry(rcu_dereference((p)->tasks.next), struct task_struct, tasks) 2073#define next_task(p) \
2074 list_entry_rcu((p)->tasks.next, struct task_struct, tasks)
2014 2075
2015#define for_each_process(p) \ 2076#define for_each_process(p) \
2016 for (p = &init_task ; (p = next_task(p)) != &init_task ; ) 2077 for (p = &init_task ; (p = next_task(p)) != &init_task ; )
@@ -2049,8 +2110,8 @@ int same_thread_group(struct task_struct *p1, struct task_struct *p2)
2049 2110
2050static inline struct task_struct *next_thread(const struct task_struct *p) 2111static inline struct task_struct *next_thread(const struct task_struct *p)
2051{ 2112{
2052 return list_entry(rcu_dereference(p->thread_group.next), 2113 return list_entry_rcu(p->thread_group.next,
2053 struct task_struct, thread_group); 2114 struct task_struct, thread_group);
2054} 2115}
2055 2116
2056static inline int thread_group_empty(struct task_struct *p) 2117static inline int thread_group_empty(struct task_struct *p)
@@ -2178,6 +2239,12 @@ static inline int test_tsk_need_resched(struct task_struct *tsk)
2178 return unlikely(test_tsk_thread_flag(tsk,TIF_NEED_RESCHED)); 2239 return unlikely(test_tsk_thread_flag(tsk,TIF_NEED_RESCHED));
2179} 2240}
2180 2241
2242static inline int restart_syscall(void)
2243{
2244 set_tsk_thread_flag(current, TIF_SIGPENDING);
2245 return -ERESTARTNOINTR;
2246}
2247
2181static inline int signal_pending(struct task_struct *p) 2248static inline int signal_pending(struct task_struct *p)
2182{ 2249{
2183 return unlikely(test_tsk_thread_flag(p,TIF_SIGPENDING)); 2250 return unlikely(test_tsk_thread_flag(p,TIF_SIGPENDING));
@@ -2388,6 +2455,13 @@ static inline void inc_syscw(struct task_struct *tsk)
2388#define TASK_SIZE_OF(tsk) TASK_SIZE 2455#define TASK_SIZE_OF(tsk) TASK_SIZE
2389#endif 2456#endif
2390 2457
2458/*
2459 * Call the function if the target task is executing on a CPU right now:
2460 */
2461extern void task_oncpu_function_call(struct task_struct *p,
2462 void (*func) (void *info), void *info);
2463
2464
2391#ifdef CONFIG_MM_OWNER 2465#ifdef CONFIG_MM_OWNER
2392extern void mm_update_next_owner(struct mm_struct *mm); 2466extern void mm_update_next_owner(struct mm_struct *mm);
2393extern void mm_init_owner(struct mm_struct *mm, struct task_struct *p); 2467extern void mm_init_owner(struct mm_struct *mm, struct task_struct *p);