xref: /linux/include/linux/sched.h (revision 9ec52099e4b8678a60e9f93e41ad87885d64f3e6)
11da177e4SLinus Torvalds #ifndef _LINUX_SCHED_H
21da177e4SLinus Torvalds #define _LINUX_SCHED_H
31da177e4SLinus Torvalds 
4b7b3c76aSDavid Woodhouse #include <linux/auxvec.h>	/* For AT_VECTOR_SIZE */
5b7b3c76aSDavid Woodhouse 
6b7b3c76aSDavid Woodhouse /*
7b7b3c76aSDavid Woodhouse  * cloning flags:
8b7b3c76aSDavid Woodhouse  */
9b7b3c76aSDavid Woodhouse #define CSIGNAL		0x000000ff	/* signal mask to be sent at exit */
10b7b3c76aSDavid Woodhouse #define CLONE_VM	0x00000100	/* set if VM shared between processes */
11b7b3c76aSDavid Woodhouse #define CLONE_FS	0x00000200	/* set if fs info shared between processes */
12b7b3c76aSDavid Woodhouse #define CLONE_FILES	0x00000400	/* set if open files shared between processes */
13b7b3c76aSDavid Woodhouse #define CLONE_SIGHAND	0x00000800	/* set if signal handlers and blocked signals shared */
14b7b3c76aSDavid Woodhouse #define CLONE_PTRACE	0x00002000	/* set if we want to let tracing continue on the child too */
15b7b3c76aSDavid Woodhouse #define CLONE_VFORK	0x00004000	/* set if the parent wants the child to wake it up on mm_release */
16b7b3c76aSDavid Woodhouse #define CLONE_PARENT	0x00008000	/* set if we want to have the same parent as the cloner */
17b7b3c76aSDavid Woodhouse #define CLONE_THREAD	0x00010000	/* Same thread group? */
18b7b3c76aSDavid Woodhouse #define CLONE_NEWNS	0x00020000	/* New namespace group? */
19b7b3c76aSDavid Woodhouse #define CLONE_SYSVSEM	0x00040000	/* share system V SEM_UNDO semantics */
20b7b3c76aSDavid Woodhouse #define CLONE_SETTLS	0x00080000	/* create a new TLS for the child */
21b7b3c76aSDavid Woodhouse #define CLONE_PARENT_SETTID	0x00100000	/* set the TID in the parent */
22b7b3c76aSDavid Woodhouse #define CLONE_CHILD_CLEARTID	0x00200000	/* clear the TID in the child */
23b7b3c76aSDavid Woodhouse #define CLONE_DETACHED		0x00400000	/* Unused, ignored */
24b7b3c76aSDavid Woodhouse #define CLONE_UNTRACED		0x00800000	/* set if the tracing process can't force CLONE_PTRACE on this clone */
25b7b3c76aSDavid Woodhouse #define CLONE_CHILD_SETTID	0x01000000	/* set the TID in the child */
26b7b3c76aSDavid Woodhouse #define CLONE_STOPPED		0x02000000	/* Start in stopped state */
27071df104SSerge E. Hallyn #define CLONE_NEWUTS		0x04000000	/* New utsname group? */
2825b21cb2SKirill Korotaev #define CLONE_NEWIPC		0x08000000	/* New ipcs */
29b7b3c76aSDavid Woodhouse 
30b7b3c76aSDavid Woodhouse /*
31b7b3c76aSDavid Woodhouse  * Scheduling policies
32b7b3c76aSDavid Woodhouse  */
33b7b3c76aSDavid Woodhouse #define SCHED_NORMAL		0
34b7b3c76aSDavid Woodhouse #define SCHED_FIFO		1
35b7b3c76aSDavid Woodhouse #define SCHED_RR		2
36b7b3c76aSDavid Woodhouse #define SCHED_BATCH		3
37b7b3c76aSDavid Woodhouse 
38a3b6714eSDavid Woodhouse #ifdef __KERNEL__
39b7b3c76aSDavid Woodhouse 
40b7b3c76aSDavid Woodhouse struct sched_param {
41b7b3c76aSDavid Woodhouse 	int sched_priority;
42b7b3c76aSDavid Woodhouse };
43b7b3c76aSDavid Woodhouse 
441da177e4SLinus Torvalds #include <asm/param.h>	/* for HZ */
451da177e4SLinus Torvalds 
461da177e4SLinus Torvalds #include <linux/capability.h>
471da177e4SLinus Torvalds #include <linux/threads.h>
481da177e4SLinus Torvalds #include <linux/kernel.h>
491da177e4SLinus Torvalds #include <linux/types.h>
501da177e4SLinus Torvalds #include <linux/timex.h>
511da177e4SLinus Torvalds #include <linux/jiffies.h>
521da177e4SLinus Torvalds #include <linux/rbtree.h>
531da177e4SLinus Torvalds #include <linux/thread_info.h>
541da177e4SLinus Torvalds #include <linux/cpumask.h>
551da177e4SLinus Torvalds #include <linux/errno.h>
561da177e4SLinus Torvalds #include <linux/nodemask.h>
571da177e4SLinus Torvalds 
581da177e4SLinus Torvalds #include <asm/system.h>
591da177e4SLinus Torvalds #include <asm/semaphore.h>
601da177e4SLinus Torvalds #include <asm/page.h>
611da177e4SLinus Torvalds #include <asm/ptrace.h>
621da177e4SLinus Torvalds #include <asm/mmu.h>
631da177e4SLinus Torvalds #include <asm/cputime.h>
641da177e4SLinus Torvalds 
651da177e4SLinus Torvalds #include <linux/smp.h>
661da177e4SLinus Torvalds #include <linux/sem.h>
671da177e4SLinus Torvalds #include <linux/signal.h>
681da177e4SLinus Torvalds #include <linux/securebits.h>
691da177e4SLinus Torvalds #include <linux/fs_struct.h>
701da177e4SLinus Torvalds #include <linux/compiler.h>
711da177e4SLinus Torvalds #include <linux/completion.h>
721da177e4SLinus Torvalds #include <linux/pid.h>
731da177e4SLinus Torvalds #include <linux/percpu.h>
741da177e4SLinus Torvalds #include <linux/topology.h>
751da177e4SLinus Torvalds #include <linux/seccomp.h>
76e56d0903SIngo Molnar #include <linux/rcupdate.h>
770771dfefSIngo Molnar #include <linux/futex.h>
7823f78d4aSIngo Molnar #include <linux/rtmutex.h>
791da177e4SLinus Torvalds 
80a3b6714eSDavid Woodhouse #include <linux/time.h>
81a3b6714eSDavid Woodhouse #include <linux/param.h>
82a3b6714eSDavid Woodhouse #include <linux/resource.h>
83a3b6714eSDavid Woodhouse #include <linux/timer.h>
84a3b6714eSDavid Woodhouse #include <linux/hrtimer.h>
85a3b6714eSDavid Woodhouse 
86a3b6714eSDavid Woodhouse #include <asm/processor.h>
8736d57ac4SH. J. Lu 
881da177e4SLinus Torvalds struct exec_domain;
89c87e2837SIngo Molnar struct futex_pi_state;
901da177e4SLinus Torvalds 
911da177e4SLinus Torvalds /*
921da177e4SLinus Torvalds  * List of flags we want to share for kernel threads,
931da177e4SLinus Torvalds  * if only because they are not used by them anyway.
941da177e4SLinus Torvalds  */
951da177e4SLinus Torvalds #define CLONE_KERNEL	(CLONE_FS | CLONE_FILES | CLONE_SIGHAND)
961da177e4SLinus Torvalds 
971da177e4SLinus Torvalds /*
981da177e4SLinus Torvalds  * These are the constant used to fake the fixed-point load-average
991da177e4SLinus Torvalds  * counting. Some notes:
1001da177e4SLinus Torvalds  *  - 11 bit fractions expand to 22 bits by the multiplies: this gives
1011da177e4SLinus Torvalds  *    a load-average precision of 10 bits integer + 11 bits fractional
1021da177e4SLinus Torvalds  *  - if you want to count load-averages more often, you need more
1031da177e4SLinus Torvalds  *    precision, or rounding will get you. With 2-second counting freq,
1041da177e4SLinus Torvalds  *    the EXP_n values would be 1981, 2034 and 2043 if still using only
1051da177e4SLinus Torvalds  *    11 bit fractions.
1061da177e4SLinus Torvalds  */
1071da177e4SLinus Torvalds extern unsigned long avenrun[];		/* Load averages */
1081da177e4SLinus Torvalds 
1091da177e4SLinus Torvalds #define FSHIFT		11		/* nr of bits of precision */
1101da177e4SLinus Torvalds #define FIXED_1		(1<<FSHIFT)	/* 1.0 as fixed-point */
1111da177e4SLinus Torvalds #define LOAD_FREQ	(5*HZ)		/* 5 sec intervals */
1121da177e4SLinus Torvalds #define EXP_1		1884		/* 1/exp(5sec/1min) as fixed-point */
1131da177e4SLinus Torvalds #define EXP_5		2014		/* 1/exp(5sec/5min) */
1141da177e4SLinus Torvalds #define EXP_15		2037		/* 1/exp(5sec/15min) */
1151da177e4SLinus Torvalds 
1161da177e4SLinus Torvalds #define CALC_LOAD(load,exp,n) \
1171da177e4SLinus Torvalds 	load *= exp; \
1181da177e4SLinus Torvalds 	load += n*(FIXED_1-exp); \
1191da177e4SLinus Torvalds 	load >>= FSHIFT;
1201da177e4SLinus Torvalds 
1211da177e4SLinus Torvalds extern unsigned long total_forks;
1221da177e4SLinus Torvalds extern int nr_threads;
1231da177e4SLinus Torvalds DECLARE_PER_CPU(unsigned long, process_counts);
1241da177e4SLinus Torvalds extern int nr_processes(void);
1251da177e4SLinus Torvalds extern unsigned long nr_running(void);
1261da177e4SLinus Torvalds extern unsigned long nr_uninterruptible(void);
127db1b1fefSJack Steiner extern unsigned long nr_active(void);
1281da177e4SLinus Torvalds extern unsigned long nr_iowait(void);
1292dd73a4fSPeter Williams extern unsigned long weighted_cpuload(const int cpu);
1301da177e4SLinus Torvalds 
1311da177e4SLinus Torvalds 
1324a8342d2SLinus Torvalds /*
1334a8342d2SLinus Torvalds  * Task state bitmask. NOTE! These bits are also
1344a8342d2SLinus Torvalds  * encoded in fs/proc/array.c: get_task_state().
1354a8342d2SLinus Torvalds  *
1364a8342d2SLinus Torvalds  * We have two separate sets of flags: task->state
1374a8342d2SLinus Torvalds  * is about runnability, while task->exit_state are
1384a8342d2SLinus Torvalds  * about the task exiting. Confusing, but this way
1394a8342d2SLinus Torvalds  * modifying one set can't modify the other one by
1404a8342d2SLinus Torvalds  * mistake.
1414a8342d2SLinus Torvalds  */
1421da177e4SLinus Torvalds #define TASK_RUNNING		0
1431da177e4SLinus Torvalds #define TASK_INTERRUPTIBLE	1
1441da177e4SLinus Torvalds #define TASK_UNINTERRUPTIBLE	2
1454a8342d2SLinus Torvalds #define TASK_STOPPED		4
1464a8342d2SLinus Torvalds #define TASK_TRACED		8
1474a8342d2SLinus Torvalds /* in tsk->exit_state */
1484a8342d2SLinus Torvalds #define EXIT_ZOMBIE		16
1494a8342d2SLinus Torvalds #define EXIT_DEAD		32
1504a8342d2SLinus Torvalds /* in tsk->state again */
1514a8342d2SLinus Torvalds #define TASK_NONINTERACTIVE	64
152c394cc9fSOleg Nesterov #define TASK_DEAD		128
1531da177e4SLinus Torvalds 
1541da177e4SLinus Torvalds #define __set_task_state(tsk, state_value)		\
1551da177e4SLinus Torvalds 	do { (tsk)->state = (state_value); } while (0)
1561da177e4SLinus Torvalds #define set_task_state(tsk, state_value)		\
1571da177e4SLinus Torvalds 	set_mb((tsk)->state, (state_value))
1581da177e4SLinus Torvalds 
159498d0c57SAndrew Morton /*
160498d0c57SAndrew Morton  * set_current_state() includes a barrier so that the write of current->state
161498d0c57SAndrew Morton  * is correctly serialised wrt the caller's subsequent test of whether to
162498d0c57SAndrew Morton  * actually sleep:
163498d0c57SAndrew Morton  *
164498d0c57SAndrew Morton  *	set_current_state(TASK_UNINTERRUPTIBLE);
165498d0c57SAndrew Morton  *	if (do_i_need_to_sleep())
166498d0c57SAndrew Morton  *		schedule();
167498d0c57SAndrew Morton  *
168498d0c57SAndrew Morton  * If the caller does not need such serialisation then use __set_current_state()
169498d0c57SAndrew Morton  */
1701da177e4SLinus Torvalds #define __set_current_state(state_value)			\
1711da177e4SLinus Torvalds 	do { current->state = (state_value); } while (0)
1721da177e4SLinus Torvalds #define set_current_state(state_value)		\
1731da177e4SLinus Torvalds 	set_mb(current->state, (state_value))
1741da177e4SLinus Torvalds 
1751da177e4SLinus Torvalds /* Task command name length */
1761da177e4SLinus Torvalds #define TASK_COMM_LEN 16
1771da177e4SLinus Torvalds 
1781da177e4SLinus Torvalds #include <linux/spinlock.h>
1791da177e4SLinus Torvalds 
1801da177e4SLinus Torvalds /*
1811da177e4SLinus Torvalds  * This serializes "schedule()" and also protects
1821da177e4SLinus Torvalds  * the run-queue from deletions/modifications (but
1831da177e4SLinus Torvalds  * _adding_ to the beginning of the run-queue has
1841da177e4SLinus Torvalds  * a separate lock).
1851da177e4SLinus Torvalds  */
1861da177e4SLinus Torvalds extern rwlock_t tasklist_lock;
1871da177e4SLinus Torvalds extern spinlock_t mmlist_lock;
1881da177e4SLinus Torvalds 
18936c8b586SIngo Molnar struct task_struct;
1901da177e4SLinus Torvalds 
1911da177e4SLinus Torvalds extern void sched_init(void);
1921da177e4SLinus Torvalds extern void sched_init_smp(void);
19336c8b586SIngo Molnar extern void init_idle(struct task_struct *idle, int cpu);
1941da177e4SLinus Torvalds 
1951da177e4SLinus Torvalds extern cpumask_t nohz_cpu_mask;
1961da177e4SLinus Torvalds 
1971da177e4SLinus Torvalds extern void show_state(void);
1981da177e4SLinus Torvalds extern void show_regs(struct pt_regs *);
1991da177e4SLinus Torvalds 
2001da177e4SLinus Torvalds /*
2011da177e4SLinus Torvalds  * TASK is a pointer to the task whose backtrace we want to see (or NULL for current
2021da177e4SLinus Torvalds  * task), SP is the stack pointer of the first frame that should be shown in the back
2031da177e4SLinus Torvalds  * trace (or NULL if the entire call-chain of the task should be shown).
2041da177e4SLinus Torvalds  */
2051da177e4SLinus Torvalds extern void show_stack(struct task_struct *task, unsigned long *sp);
2061da177e4SLinus Torvalds 
2071da177e4SLinus Torvalds void io_schedule(void);
2081da177e4SLinus Torvalds long io_schedule_timeout(long timeout);
2091da177e4SLinus Torvalds 
2101da177e4SLinus Torvalds extern void cpu_init (void);
2111da177e4SLinus Torvalds extern void trap_init(void);
2121da177e4SLinus Torvalds extern void update_process_times(int user);
2131da177e4SLinus Torvalds extern void scheduler_tick(void);
2141da177e4SLinus Torvalds 
2158446f1d3SIngo Molnar #ifdef CONFIG_DETECT_SOFTLOCKUP
2166687a97dSIngo Molnar extern void softlockup_tick(void);
2178446f1d3SIngo Molnar extern void spawn_softlockup_task(void);
2188446f1d3SIngo Molnar extern void touch_softlockup_watchdog(void);
2198446f1d3SIngo Molnar #else
2206687a97dSIngo Molnar static inline void softlockup_tick(void)
2218446f1d3SIngo Molnar {
2228446f1d3SIngo Molnar }
2238446f1d3SIngo Molnar static inline void spawn_softlockup_task(void)
2248446f1d3SIngo Molnar {
2258446f1d3SIngo Molnar }
2268446f1d3SIngo Molnar static inline void touch_softlockup_watchdog(void)
2278446f1d3SIngo Molnar {
2288446f1d3SIngo Molnar }
2298446f1d3SIngo Molnar #endif
2308446f1d3SIngo Molnar 
2318446f1d3SIngo Molnar 
2321da177e4SLinus Torvalds /* Attach to any functions which should be ignored in wchan output. */
2331da177e4SLinus Torvalds #define __sched		__attribute__((__section__(".sched.text")))
2341da177e4SLinus Torvalds /* Is this address in the __sched functions? */
2351da177e4SLinus Torvalds extern int in_sched_functions(unsigned long addr);
2361da177e4SLinus Torvalds 
2371da177e4SLinus Torvalds #define	MAX_SCHEDULE_TIMEOUT	LONG_MAX
2381da177e4SLinus Torvalds extern signed long FASTCALL(schedule_timeout(signed long timeout));
23964ed93a2SNishanth Aravamudan extern signed long schedule_timeout_interruptible(signed long timeout);
24064ed93a2SNishanth Aravamudan extern signed long schedule_timeout_uninterruptible(signed long timeout);
2411da177e4SLinus Torvalds asmlinkage void schedule(void);
2421da177e4SLinus Torvalds 
243ab516013SSerge E. Hallyn struct nsproxy;
2441da177e4SLinus Torvalds 
2451da177e4SLinus Torvalds /* Maximum number of active map areas.. This is a random (large) number */
2461da177e4SLinus Torvalds #define DEFAULT_MAX_MAP_COUNT	65536
2471da177e4SLinus Torvalds 
2481da177e4SLinus Torvalds extern int sysctl_max_map_count;
2491da177e4SLinus Torvalds 
2501da177e4SLinus Torvalds #include <linux/aio.h>
2511da177e4SLinus Torvalds 
2521da177e4SLinus Torvalds extern unsigned long
2531da177e4SLinus Torvalds arch_get_unmapped_area(struct file *, unsigned long, unsigned long,
2541da177e4SLinus Torvalds 		       unsigned long, unsigned long);
2551da177e4SLinus Torvalds extern unsigned long
2561da177e4SLinus Torvalds arch_get_unmapped_area_topdown(struct file *filp, unsigned long addr,
2571da177e4SLinus Torvalds 			  unsigned long len, unsigned long pgoff,
2581da177e4SLinus Torvalds 			  unsigned long flags);
2591363c3cdSWolfgang Wander extern void arch_unmap_area(struct mm_struct *, unsigned long);
2601363c3cdSWolfgang Wander extern void arch_unmap_area_topdown(struct mm_struct *, unsigned long);
2611da177e4SLinus Torvalds 
262f412ac08SHugh Dickins #if NR_CPUS >= CONFIG_SPLIT_PTLOCK_CPUS
263f412ac08SHugh Dickins /*
264f412ac08SHugh Dickins  * The mm counters are not protected by its page_table_lock,
265f412ac08SHugh Dickins  * so must be incremented atomically.
266f412ac08SHugh Dickins  */
267d3cb4871SChristoph Lameter #define set_mm_counter(mm, member, value) atomic_long_set(&(mm)->_##member, value)
268d3cb4871SChristoph Lameter #define get_mm_counter(mm, member) ((unsigned long)atomic_long_read(&(mm)->_##member))
269d3cb4871SChristoph Lameter #define add_mm_counter(mm, member, value) atomic_long_add(value, &(mm)->_##member)
270d3cb4871SChristoph Lameter #define inc_mm_counter(mm, member) atomic_long_inc(&(mm)->_##member)
271d3cb4871SChristoph Lameter #define dec_mm_counter(mm, member) atomic_long_dec(&(mm)->_##member)
272d3cb4871SChristoph Lameter typedef atomic_long_t mm_counter_t;
273f412ac08SHugh Dickins 
274f412ac08SHugh Dickins #else  /* NR_CPUS < CONFIG_SPLIT_PTLOCK_CPUS */
275f412ac08SHugh Dickins /*
276f412ac08SHugh Dickins  * The mm counters are protected by its page_table_lock,
277f412ac08SHugh Dickins  * so can be incremented directly.
278f412ac08SHugh Dickins  */
2791da177e4SLinus Torvalds #define set_mm_counter(mm, member, value) (mm)->_##member = (value)
2801da177e4SLinus Torvalds #define get_mm_counter(mm, member) ((mm)->_##member)
2811da177e4SLinus Torvalds #define add_mm_counter(mm, member, value) (mm)->_##member += (value)
2821da177e4SLinus Torvalds #define inc_mm_counter(mm, member) (mm)->_##member++
2831da177e4SLinus Torvalds #define dec_mm_counter(mm, member) (mm)->_##member--
284f412ac08SHugh Dickins typedef unsigned long mm_counter_t;
2854294621fSHugh Dickins 
286f412ac08SHugh Dickins #endif /* NR_CPUS < CONFIG_SPLIT_PTLOCK_CPUS */
287f412ac08SHugh Dickins 
288f412ac08SHugh Dickins #define get_mm_rss(mm)					\
289f412ac08SHugh Dickins 	(get_mm_counter(mm, file_rss) + get_mm_counter(mm, anon_rss))
290365e9c87SHugh Dickins #define update_hiwater_rss(mm)	do {			\
291365e9c87SHugh Dickins 	unsigned long _rss = get_mm_rss(mm);		\
292365e9c87SHugh Dickins 	if ((mm)->hiwater_rss < _rss)			\
293365e9c87SHugh Dickins 		(mm)->hiwater_rss = _rss;		\
294365e9c87SHugh Dickins } while (0)
295365e9c87SHugh Dickins #define update_hiwater_vm(mm)	do {			\
296365e9c87SHugh Dickins 	if ((mm)->hiwater_vm < (mm)->total_vm)		\
297365e9c87SHugh Dickins 		(mm)->hiwater_vm = (mm)->total_vm;	\
298365e9c87SHugh Dickins } while (0)
299365e9c87SHugh Dickins 
3001da177e4SLinus Torvalds struct mm_struct {
3011da177e4SLinus Torvalds 	struct vm_area_struct * mmap;		/* list of VMAs */
3021da177e4SLinus Torvalds 	struct rb_root mm_rb;
3031da177e4SLinus Torvalds 	struct vm_area_struct * mmap_cache;	/* last find_vma result */
3041da177e4SLinus Torvalds 	unsigned long (*get_unmapped_area) (struct file *filp,
3051da177e4SLinus Torvalds 				unsigned long addr, unsigned long len,
3061da177e4SLinus Torvalds 				unsigned long pgoff, unsigned long flags);
3071363c3cdSWolfgang Wander 	void (*unmap_area) (struct mm_struct *mm, unsigned long addr);
3081da177e4SLinus Torvalds 	unsigned long mmap_base;		/* base of mmap area */
3090551fbd2SBenjamin Herrenschmidt 	unsigned long task_size;		/* size of task vm space */
3101363c3cdSWolfgang Wander 	unsigned long cached_hole_size;         /* if non-zero, the largest hole below free_area_cache */
3111363c3cdSWolfgang Wander 	unsigned long free_area_cache;		/* first hole of size cached_hole_size or larger */
3121da177e4SLinus Torvalds 	pgd_t * pgd;
3131da177e4SLinus Torvalds 	atomic_t mm_users;			/* How many users with user space? */
3141da177e4SLinus Torvalds 	atomic_t mm_count;			/* How many references to "struct mm_struct" (users count as 1) */
3151da177e4SLinus Torvalds 	int map_count;				/* number of VMAs */
3161da177e4SLinus Torvalds 	struct rw_semaphore mmap_sem;
3171da177e4SLinus Torvalds 	spinlock_t page_table_lock;		/* Protects page tables and some counters */
3181da177e4SLinus Torvalds 
3191da177e4SLinus Torvalds 	struct list_head mmlist;		/* List of maybe swapped mm's.  These are globally strung
3201da177e4SLinus Torvalds 						 * together off init_mm.mmlist, and are protected
3211da177e4SLinus Torvalds 						 * by mmlist_lock
3221da177e4SLinus Torvalds 						 */
3231da177e4SLinus Torvalds 
324f412ac08SHugh Dickins 	/* Special counters, in some configurations protected by the
325f412ac08SHugh Dickins 	 * page_table_lock, in other configurations by being atomic.
326f412ac08SHugh Dickins 	 */
3274294621fSHugh Dickins 	mm_counter_t _file_rss;
3281da177e4SLinus Torvalds 	mm_counter_t _anon_rss;
3291da177e4SLinus Torvalds 
330f449952bSHugh Dickins 	unsigned long hiwater_rss;	/* High-watermark of RSS usage */
331f449952bSHugh Dickins 	unsigned long hiwater_vm;	/* High-water virtual memory usage */
332f449952bSHugh Dickins 
333f449952bSHugh Dickins 	unsigned long total_vm, locked_vm, shared_vm, exec_vm;
334f449952bSHugh Dickins 	unsigned long stack_vm, reserved_vm, def_flags, nr_ptes;
335f449952bSHugh Dickins 	unsigned long start_code, end_code, start_data, end_data;
336f449952bSHugh Dickins 	unsigned long start_brk, brk, start_stack;
337f449952bSHugh Dickins 	unsigned long arg_start, arg_end, env_start, env_end;
338f449952bSHugh Dickins 
33936d57ac4SH. J. Lu 	unsigned long saved_auxv[AT_VECTOR_SIZE]; /* for /proc/PID/auxv */
3401da177e4SLinus Torvalds 
341d6e71144SAlan Cox 	unsigned dumpable:2;
3421da177e4SLinus Torvalds 	cpumask_t cpu_vm_mask;
3431da177e4SLinus Torvalds 
3441da177e4SLinus Torvalds 	/* Architecture-specific MM context */
3451da177e4SLinus Torvalds 	mm_context_t context;
3461da177e4SLinus Torvalds 
3471da177e4SLinus Torvalds 	/* Token based thrashing protection. */
3481da177e4SLinus Torvalds 	unsigned long swap_token_time;
3491da177e4SLinus Torvalds 	char recent_pagein;
3501da177e4SLinus Torvalds 
3511da177e4SLinus Torvalds 	/* coredumping support */
3521da177e4SLinus Torvalds 	int core_waiters;
3531da177e4SLinus Torvalds 	struct completion *core_startup_done, core_done;
3541da177e4SLinus Torvalds 
3551da177e4SLinus Torvalds 	/* aio bits */
3561da177e4SLinus Torvalds 	rwlock_t		ioctx_list_lock;
3571da177e4SLinus Torvalds 	struct kioctx		*ioctx_list;
3581da177e4SLinus Torvalds };
3591da177e4SLinus Torvalds 
3601da177e4SLinus Torvalds struct sighand_struct {
3611da177e4SLinus Torvalds 	atomic_t		count;
3621da177e4SLinus Torvalds 	struct k_sigaction	action[_NSIG];
3631da177e4SLinus Torvalds 	spinlock_t		siglock;
3641da177e4SLinus Torvalds };
3651da177e4SLinus Torvalds 
3660e464814SKaiGai Kohei struct pacct_struct {
367f6ec29a4SKaiGai Kohei 	int			ac_flag;
368f6ec29a4SKaiGai Kohei 	long			ac_exitcode;
3690e464814SKaiGai Kohei 	unsigned long		ac_mem;
37077787bfbSKaiGai Kohei 	cputime_t		ac_utime, ac_stime;
37177787bfbSKaiGai Kohei 	unsigned long		ac_minflt, ac_majflt;
3720e464814SKaiGai Kohei };
3730e464814SKaiGai Kohei 
3741da177e4SLinus Torvalds /*
3751da177e4SLinus Torvalds  * NOTE! "signal_struct" does not have it's own
3761da177e4SLinus Torvalds  * locking, because a shared signal_struct always
3771da177e4SLinus Torvalds  * implies a shared sighand_struct, so locking
3781da177e4SLinus Torvalds  * sighand_struct is always a proper superset of
3791da177e4SLinus Torvalds  * the locking of signal_struct.
3801da177e4SLinus Torvalds  */
3811da177e4SLinus Torvalds struct signal_struct {
3821da177e4SLinus Torvalds 	atomic_t		count;
3831da177e4SLinus Torvalds 	atomic_t		live;
3841da177e4SLinus Torvalds 
3851da177e4SLinus Torvalds 	wait_queue_head_t	wait_chldexit;	/* for wait4() */
3861da177e4SLinus Torvalds 
3871da177e4SLinus Torvalds 	/* current thread group signal load-balancing target: */
38836c8b586SIngo Molnar 	struct task_struct	*curr_target;
3891da177e4SLinus Torvalds 
3901da177e4SLinus Torvalds 	/* shared signal handling: */
3911da177e4SLinus Torvalds 	struct sigpending	shared_pending;
3921da177e4SLinus Torvalds 
3931da177e4SLinus Torvalds 	/* thread group exit support */
3941da177e4SLinus Torvalds 	int			group_exit_code;
3951da177e4SLinus Torvalds 	/* overloaded:
3961da177e4SLinus Torvalds 	 * - notify group_exit_task when ->count is equal to notify_count
3971da177e4SLinus Torvalds 	 * - everyone except group_exit_task is stopped during signal delivery
3981da177e4SLinus Torvalds 	 *   of fatal signals, group_exit_task processes the signal.
3991da177e4SLinus Torvalds 	 */
4001da177e4SLinus Torvalds 	struct task_struct	*group_exit_task;
4011da177e4SLinus Torvalds 	int			notify_count;
4021da177e4SLinus Torvalds 
4031da177e4SLinus Torvalds 	/* thread group stop support, overloads group_exit_code too */
4041da177e4SLinus Torvalds 	int			group_stop_count;
4051da177e4SLinus Torvalds 	unsigned int		flags; /* see SIGNAL_* flags below */
4061da177e4SLinus Torvalds 
4071da177e4SLinus Torvalds 	/* POSIX.1b Interval Timers */
4081da177e4SLinus Torvalds 	struct list_head posix_timers;
4091da177e4SLinus Torvalds 
4101da177e4SLinus Torvalds 	/* ITIMER_REAL timer for the process */
4112ff678b8SThomas Gleixner 	struct hrtimer real_timer;
41205cfb614SRoman Zippel 	struct task_struct *tsk;
4132ff678b8SThomas Gleixner 	ktime_t it_real_incr;
4141da177e4SLinus Torvalds 
4151da177e4SLinus Torvalds 	/* ITIMER_PROF and ITIMER_VIRTUAL timers for the process */
4161da177e4SLinus Torvalds 	cputime_t it_prof_expires, it_virt_expires;
4171da177e4SLinus Torvalds 	cputime_t it_prof_incr, it_virt_incr;
4181da177e4SLinus Torvalds 
4191da177e4SLinus Torvalds 	/* job control IDs */
4201da177e4SLinus Torvalds 	pid_t pgrp;
4211da177e4SLinus Torvalds 	pid_t tty_old_pgrp;
4221da177e4SLinus Torvalds 	pid_t session;
4231da177e4SLinus Torvalds 	/* boolean value for session group leader */
4241da177e4SLinus Torvalds 	int leader;
4251da177e4SLinus Torvalds 
4261da177e4SLinus Torvalds 	struct tty_struct *tty; /* NULL if no tty */
4271da177e4SLinus Torvalds 
4281da177e4SLinus Torvalds 	/*
4291da177e4SLinus Torvalds 	 * Cumulative resource counters for dead threads in the group,
4301da177e4SLinus Torvalds 	 * and for reaped dead child processes forked by this group.
4311da177e4SLinus Torvalds 	 * Live threads maintain their own counters and add to these
4321da177e4SLinus Torvalds 	 * in __exit_signal, except for the group leader.
4331da177e4SLinus Torvalds 	 */
4341da177e4SLinus Torvalds 	cputime_t utime, stime, cutime, cstime;
4351da177e4SLinus Torvalds 	unsigned long nvcsw, nivcsw, cnvcsw, cnivcsw;
4361da177e4SLinus Torvalds 	unsigned long min_flt, maj_flt, cmin_flt, cmaj_flt;
4371da177e4SLinus Torvalds 
4381da177e4SLinus Torvalds 	/*
4391da177e4SLinus Torvalds 	 * Cumulative ns of scheduled CPU time for dead threads in the
4401da177e4SLinus Torvalds 	 * group, not including a zombie group leader.  (This only differs
4411da177e4SLinus Torvalds 	 * from jiffies_to_ns(utime + stime) if sched_clock uses something
4421da177e4SLinus Torvalds 	 * other than jiffies.)
4431da177e4SLinus Torvalds 	 */
4441da177e4SLinus Torvalds 	unsigned long long sched_time;
4451da177e4SLinus Torvalds 
4461da177e4SLinus Torvalds 	/*
4471da177e4SLinus Torvalds 	 * We don't bother to synchronize most readers of this at all,
4481da177e4SLinus Torvalds 	 * because there is no reader checking a limit that actually needs
4491da177e4SLinus Torvalds 	 * to get both rlim_cur and rlim_max atomically, and either one
4501da177e4SLinus Torvalds 	 * alone is a single word that can safely be read normally.
4511da177e4SLinus Torvalds 	 * getrlimit/setrlimit use task_lock(current->group_leader) to
4521da177e4SLinus Torvalds 	 * protect this instead of the siglock, because they really
4531da177e4SLinus Torvalds 	 * have no need to disable irqs.
4541da177e4SLinus Torvalds 	 */
4551da177e4SLinus Torvalds 	struct rlimit rlim[RLIM_NLIMITS];
4561da177e4SLinus Torvalds 
4571da177e4SLinus Torvalds 	struct list_head cpu_timers[3];
4581da177e4SLinus Torvalds 
4591da177e4SLinus Torvalds 	/* keep the process-shared keyrings here so that they do the right
4601da177e4SLinus Torvalds 	 * thing in threads created with CLONE_THREAD */
4611da177e4SLinus Torvalds #ifdef CONFIG_KEYS
4621da177e4SLinus Torvalds 	struct key *session_keyring;	/* keyring inherited over fork */
4631da177e4SLinus Torvalds 	struct key *process_keyring;	/* keyring private to this process */
4641da177e4SLinus Torvalds #endif
4650e464814SKaiGai Kohei #ifdef CONFIG_BSD_PROCESS_ACCT
4660e464814SKaiGai Kohei 	struct pacct_struct pacct;	/* per-process accounting information */
4670e464814SKaiGai Kohei #endif
468ad4ecbcbSShailabh Nagar #ifdef CONFIG_TASKSTATS
469ad4ecbcbSShailabh Nagar 	spinlock_t stats_lock;
470ad4ecbcbSShailabh Nagar 	struct taskstats *stats;
471ad4ecbcbSShailabh Nagar #endif
4721da177e4SLinus Torvalds };
4731da177e4SLinus Torvalds 
4744866cde0SNick Piggin /* Context switch must be unlocked if interrupts are to be enabled */
4754866cde0SNick Piggin #ifdef __ARCH_WANT_INTERRUPTS_ON_CTXSW
4764866cde0SNick Piggin # define __ARCH_WANT_UNLOCKED_CTXSW
4774866cde0SNick Piggin #endif
4784866cde0SNick Piggin 
4791da177e4SLinus Torvalds /*
4801da177e4SLinus Torvalds  * Bits in flags field of signal_struct.
4811da177e4SLinus Torvalds  */
4821da177e4SLinus Torvalds #define SIGNAL_STOP_STOPPED	0x00000001 /* job control stop in effect */
4831da177e4SLinus Torvalds #define SIGNAL_STOP_DEQUEUED	0x00000002 /* stop signal dequeued */
4841da177e4SLinus Torvalds #define SIGNAL_STOP_CONTINUED	0x00000004 /* SIGCONT since WCONTINUED reap */
4851da177e4SLinus Torvalds #define SIGNAL_GROUP_EXIT	0x00000008 /* group exit in progress */
4861da177e4SLinus Torvalds 
4871da177e4SLinus Torvalds 
4881da177e4SLinus Torvalds /*
4891da177e4SLinus Torvalds  * Priority of a process goes from 0..MAX_PRIO-1, valid RT
490b0a9499cSIngo Molnar  * priority is 0..MAX_RT_PRIO-1, and SCHED_NORMAL/SCHED_BATCH
491b0a9499cSIngo Molnar  * tasks are in the range MAX_RT_PRIO..MAX_PRIO-1. Priority
492b0a9499cSIngo Molnar  * values are inverted: lower p->prio value means higher priority.
4931da177e4SLinus Torvalds  *
4941da177e4SLinus Torvalds  * The MAX_USER_RT_PRIO value allows the actual maximum
4951da177e4SLinus Torvalds  * RT priority to be separate from the value exported to
4961da177e4SLinus Torvalds  * user-space.  This allows kernel threads to set their
4971da177e4SLinus Torvalds  * priority to a value higher than any user task. Note:
4981da177e4SLinus Torvalds  * MAX_RT_PRIO must not be smaller than MAX_USER_RT_PRIO.
4991da177e4SLinus Torvalds  */
5001da177e4SLinus Torvalds 
5011da177e4SLinus Torvalds #define MAX_USER_RT_PRIO	100
5021da177e4SLinus Torvalds #define MAX_RT_PRIO		MAX_USER_RT_PRIO
5031da177e4SLinus Torvalds 
5041da177e4SLinus Torvalds #define MAX_PRIO		(MAX_RT_PRIO + 40)
5051da177e4SLinus Torvalds 
506b29739f9SIngo Molnar #define rt_prio(prio)		unlikely((prio) < MAX_RT_PRIO)
507b29739f9SIngo Molnar #define rt_task(p)		rt_prio((p)->prio)
508d425b274SCon Kolivas #define batch_task(p)		(unlikely((p)->policy == SCHED_BATCH))
50957a6f51cSOleg Nesterov #define is_rt_policy(p)		((p) != SCHED_NORMAL && (p) != SCHED_BATCH)
51057a6f51cSOleg Nesterov #define has_rt_policy(p)	unlikely(is_rt_policy((p)->policy))
5111da177e4SLinus Torvalds 
5121da177e4SLinus Torvalds /*
5131da177e4SLinus Torvalds  * Some day this will be a full-fledged user tracking system..
5141da177e4SLinus Torvalds  */
5151da177e4SLinus Torvalds struct user_struct {
5161da177e4SLinus Torvalds 	atomic_t __count;	/* reference count */
5171da177e4SLinus Torvalds 	atomic_t processes;	/* How many processes does this user have? */
5181da177e4SLinus Torvalds 	atomic_t files;		/* How many open files does this user have? */
5191da177e4SLinus Torvalds 	atomic_t sigpending;	/* How many pending signals does this user have? */
5202d9048e2SAmy Griffis #ifdef CONFIG_INOTIFY_USER
5210eeca283SRobert Love 	atomic_t inotify_watches; /* How many inotify watches does this user have? */
5220eeca283SRobert Love 	atomic_t inotify_devs;	/* How many inotify devs does this user have opened? */
5230eeca283SRobert Love #endif
5241da177e4SLinus Torvalds 	/* protected by mq_lock	*/
5251da177e4SLinus Torvalds 	unsigned long mq_bytes;	/* How many bytes can be allocated to mqueue? */
5261da177e4SLinus Torvalds 	unsigned long locked_shm; /* How many pages of mlocked shm ? */
5271da177e4SLinus Torvalds 
5281da177e4SLinus Torvalds #ifdef CONFIG_KEYS
5291da177e4SLinus Torvalds 	struct key *uid_keyring;	/* UID specific keyring */
5301da177e4SLinus Torvalds 	struct key *session_keyring;	/* UID's default session keyring */
5311da177e4SLinus Torvalds #endif
5321da177e4SLinus Torvalds 
5331da177e4SLinus Torvalds 	/* Hash table maintenance information */
5341da177e4SLinus Torvalds 	struct list_head uidhash_list;
5351da177e4SLinus Torvalds 	uid_t uid;
5361da177e4SLinus Torvalds };
5371da177e4SLinus Torvalds 
5381da177e4SLinus Torvalds extern struct user_struct *find_user(uid_t);
5391da177e4SLinus Torvalds 
5401da177e4SLinus Torvalds extern struct user_struct root_user;
5411da177e4SLinus Torvalds #define INIT_USER (&root_user)
5421da177e4SLinus Torvalds 
5431da177e4SLinus Torvalds struct backing_dev_info;
5441da177e4SLinus Torvalds struct reclaim_state;
5451da177e4SLinus Torvalds 
54652f17b6cSChandra Seetharaman #if defined(CONFIG_SCHEDSTATS) || defined(CONFIG_TASK_DELAY_ACCT)
5471da177e4SLinus Torvalds struct sched_info {
5481da177e4SLinus Torvalds 	/* cumulative counters */
5491da177e4SLinus Torvalds 	unsigned long	cpu_time,	/* time spent on the cpu */
5501da177e4SLinus Torvalds 			run_delay,	/* time spent waiting on a runqueue */
5511da177e4SLinus Torvalds 			pcnt;		/* # of timeslices run on this cpu */
5521da177e4SLinus Torvalds 
5531da177e4SLinus Torvalds 	/* timestamps */
5541da177e4SLinus Torvalds 	unsigned long	last_arrival,	/* when we last ran on a cpu */
5551da177e4SLinus Torvalds 			last_queued;	/* when we were last queued to run */
5561da177e4SLinus Torvalds };
55752f17b6cSChandra Seetharaman #endif /* defined(CONFIG_SCHEDSTATS) || defined(CONFIG_TASK_DELAY_ACCT) */
5581da177e4SLinus Torvalds 
55952f17b6cSChandra Seetharaman #ifdef CONFIG_SCHEDSTATS
5601da177e4SLinus Torvalds extern struct file_operations proc_schedstat_operations;
56152f17b6cSChandra Seetharaman #endif /* CONFIG_SCHEDSTATS */
5621da177e4SLinus Torvalds 
563ca74e92bSShailabh Nagar #ifdef CONFIG_TASK_DELAY_ACCT
564ca74e92bSShailabh Nagar struct task_delay_info {
565ca74e92bSShailabh Nagar 	spinlock_t	lock;
566ca74e92bSShailabh Nagar 	unsigned int	flags;	/* Private per-task flags */
567ca74e92bSShailabh Nagar 
568ca74e92bSShailabh Nagar 	/* For each stat XXX, add following, aligned appropriately
569ca74e92bSShailabh Nagar 	 *
570ca74e92bSShailabh Nagar 	 * struct timespec XXX_start, XXX_end;
571ca74e92bSShailabh Nagar 	 * u64 XXX_delay;
572ca74e92bSShailabh Nagar 	 * u32 XXX_count;
573ca74e92bSShailabh Nagar 	 *
574ca74e92bSShailabh Nagar 	 * Atomicity of updates to XXX_delay, XXX_count protected by
575ca74e92bSShailabh Nagar 	 * single lock above (split into XXX_lock if contention is an issue).
576ca74e92bSShailabh Nagar 	 */
5770ff92245SShailabh Nagar 
5780ff92245SShailabh Nagar 	/*
5790ff92245SShailabh Nagar 	 * XXX_count is incremented on every XXX operation, the delay
5800ff92245SShailabh Nagar 	 * associated with the operation is added to XXX_delay.
5810ff92245SShailabh Nagar 	 * XXX_delay contains the accumulated delay time in nanoseconds.
5820ff92245SShailabh Nagar 	 */
5830ff92245SShailabh Nagar 	struct timespec blkio_start, blkio_end;	/* Shared by blkio, swapin */
5840ff92245SShailabh Nagar 	u64 blkio_delay;	/* wait for sync block io completion */
5850ff92245SShailabh Nagar 	u64 swapin_delay;	/* wait for swapin block io completion */
5860ff92245SShailabh Nagar 	u32 blkio_count;	/* total count of the number of sync block */
5870ff92245SShailabh Nagar 				/* io operations performed */
5880ff92245SShailabh Nagar 	u32 swapin_count;	/* total count of the number of swapin block */
5890ff92245SShailabh Nagar 				/* io operations performed */
590ca74e92bSShailabh Nagar };
59152f17b6cSChandra Seetharaman #endif	/* CONFIG_TASK_DELAY_ACCT */
59252f17b6cSChandra Seetharaman 
59352f17b6cSChandra Seetharaman static inline int sched_info_on(void)
59452f17b6cSChandra Seetharaman {
59552f17b6cSChandra Seetharaman #ifdef CONFIG_SCHEDSTATS
59652f17b6cSChandra Seetharaman 	return 1;
59752f17b6cSChandra Seetharaman #elif defined(CONFIG_TASK_DELAY_ACCT)
59852f17b6cSChandra Seetharaman 	extern int delayacct_on;
59952f17b6cSChandra Seetharaman 	return delayacct_on;
60052f17b6cSChandra Seetharaman #else
60152f17b6cSChandra Seetharaman 	return 0;
602ca74e92bSShailabh Nagar #endif
60352f17b6cSChandra Seetharaman }
604ca74e92bSShailabh Nagar 
6051da177e4SLinus Torvalds enum idle_type
6061da177e4SLinus Torvalds {
6071da177e4SLinus Torvalds 	SCHED_IDLE,
6081da177e4SLinus Torvalds 	NOT_IDLE,
6091da177e4SLinus Torvalds 	NEWLY_IDLE,
6101da177e4SLinus Torvalds 	MAX_IDLE_TYPES
6111da177e4SLinus Torvalds };
6121da177e4SLinus Torvalds 
6131da177e4SLinus Torvalds /*
6141da177e4SLinus Torvalds  * sched-domains (multiprocessor balancing) declarations:
6151da177e4SLinus Torvalds  */
6161da177e4SLinus Torvalds #define SCHED_LOAD_SCALE	128UL	/* increase resolution of load */
6171da177e4SLinus Torvalds 
6182dd73a4fSPeter Williams #ifdef CONFIG_SMP
6191da177e4SLinus Torvalds #define SD_LOAD_BALANCE		1	/* Do load balancing on this domain. */
6201da177e4SLinus Torvalds #define SD_BALANCE_NEWIDLE	2	/* Balance when about to become idle */
6211da177e4SLinus Torvalds #define SD_BALANCE_EXEC		4	/* Balance on exec */
622147cbb4bSNick Piggin #define SD_BALANCE_FORK		8	/* Balance on fork, clone */
623147cbb4bSNick Piggin #define SD_WAKE_IDLE		16	/* Wake to idle CPU on task wakeup */
624147cbb4bSNick Piggin #define SD_WAKE_AFFINE		32	/* Wake task to waking CPU */
625147cbb4bSNick Piggin #define SD_WAKE_BALANCE		64	/* Perform balancing at task wakeup */
626147cbb4bSNick Piggin #define SD_SHARE_CPUPOWER	128	/* Domain members share cpu power */
6275c45bf27SSiddha, Suresh B #define SD_POWERSAVINGS_BALANCE	256	/* Balance for power savings */
6285c45bf27SSiddha, Suresh B 
6295c45bf27SSiddha, Suresh B #define BALANCE_FOR_POWER	((sched_mc_power_savings || sched_smt_power_savings) \
6305c45bf27SSiddha, Suresh B 				 ? SD_POWERSAVINGS_BALANCE : 0)
6315c45bf27SSiddha, Suresh B 
6321da177e4SLinus Torvalds 
6331da177e4SLinus Torvalds struct sched_group {
6341da177e4SLinus Torvalds 	struct sched_group *next;	/* Must be a circular list */
6351da177e4SLinus Torvalds 	cpumask_t cpumask;
6361da177e4SLinus Torvalds 
6371da177e4SLinus Torvalds 	/*
6381da177e4SLinus Torvalds 	 * CPU power of this group, SCHED_LOAD_SCALE being max power for a
6391da177e4SLinus Torvalds 	 * single CPU. This is read only (except for setup, hotplug CPU).
6401da177e4SLinus Torvalds 	 */
6411da177e4SLinus Torvalds 	unsigned long cpu_power;
6421da177e4SLinus Torvalds };
6431da177e4SLinus Torvalds 
6441da177e4SLinus Torvalds struct sched_domain {
6451da177e4SLinus Torvalds 	/* These fields must be setup */
6461da177e4SLinus Torvalds 	struct sched_domain *parent;	/* top domain must be null terminated */
6471da177e4SLinus Torvalds 	struct sched_group *groups;	/* the balancing groups of the domain */
6481da177e4SLinus Torvalds 	cpumask_t span;			/* span of all CPUs in this domain */
6491da177e4SLinus Torvalds 	unsigned long min_interval;	/* Minimum balance interval ms */
6501da177e4SLinus Torvalds 	unsigned long max_interval;	/* Maximum balance interval ms */
6511da177e4SLinus Torvalds 	unsigned int busy_factor;	/* less balancing by factor if busy */
6521da177e4SLinus Torvalds 	unsigned int imbalance_pct;	/* No balance until over watermark */
6531da177e4SLinus Torvalds 	unsigned long long cache_hot_time; /* Task considered cache hot (ns) */
6541da177e4SLinus Torvalds 	unsigned int cache_nice_tries;	/* Leave cache hot tasks for # tries */
6551da177e4SLinus Torvalds 	unsigned int per_cpu_gain;	/* CPU % gained by adding domain cpus */
6567897986bSNick Piggin 	unsigned int busy_idx;
6577897986bSNick Piggin 	unsigned int idle_idx;
6587897986bSNick Piggin 	unsigned int newidle_idx;
6597897986bSNick Piggin 	unsigned int wake_idx;
660147cbb4bSNick Piggin 	unsigned int forkexec_idx;
6611da177e4SLinus Torvalds 	int flags;			/* See SD_* */
6621da177e4SLinus Torvalds 
6631da177e4SLinus Torvalds 	/* Runtime fields. */
6641da177e4SLinus Torvalds 	unsigned long last_balance;	/* init to jiffies. units in jiffies */
6651da177e4SLinus Torvalds 	unsigned int balance_interval;	/* initialise to 1. units in ms. */
6661da177e4SLinus Torvalds 	unsigned int nr_balance_failed; /* initialise to 0 */
6671da177e4SLinus Torvalds 
6681da177e4SLinus Torvalds #ifdef CONFIG_SCHEDSTATS
6691da177e4SLinus Torvalds 	/* load_balance() stats */
6701da177e4SLinus Torvalds 	unsigned long lb_cnt[MAX_IDLE_TYPES];
6711da177e4SLinus Torvalds 	unsigned long lb_failed[MAX_IDLE_TYPES];
6721da177e4SLinus Torvalds 	unsigned long lb_balanced[MAX_IDLE_TYPES];
6731da177e4SLinus Torvalds 	unsigned long lb_imbalance[MAX_IDLE_TYPES];
6741da177e4SLinus Torvalds 	unsigned long lb_gained[MAX_IDLE_TYPES];
6751da177e4SLinus Torvalds 	unsigned long lb_hot_gained[MAX_IDLE_TYPES];
6761da177e4SLinus Torvalds 	unsigned long lb_nobusyg[MAX_IDLE_TYPES];
6771da177e4SLinus Torvalds 	unsigned long lb_nobusyq[MAX_IDLE_TYPES];
6781da177e4SLinus Torvalds 
6791da177e4SLinus Torvalds 	/* Active load balancing */
6801da177e4SLinus Torvalds 	unsigned long alb_cnt;
6811da177e4SLinus Torvalds 	unsigned long alb_failed;
6821da177e4SLinus Torvalds 	unsigned long alb_pushed;
6831da177e4SLinus Torvalds 
68468767a0aSNick Piggin 	/* SD_BALANCE_EXEC stats */
68568767a0aSNick Piggin 	unsigned long sbe_cnt;
68668767a0aSNick Piggin 	unsigned long sbe_balanced;
6871da177e4SLinus Torvalds 	unsigned long sbe_pushed;
6881da177e4SLinus Torvalds 
68968767a0aSNick Piggin 	/* SD_BALANCE_FORK stats */
69068767a0aSNick Piggin 	unsigned long sbf_cnt;
69168767a0aSNick Piggin 	unsigned long sbf_balanced;
69268767a0aSNick Piggin 	unsigned long sbf_pushed;
69368767a0aSNick Piggin 
6941da177e4SLinus Torvalds 	/* try_to_wake_up() stats */
6951da177e4SLinus Torvalds 	unsigned long ttwu_wake_remote;
6961da177e4SLinus Torvalds 	unsigned long ttwu_move_affine;
6971da177e4SLinus Torvalds 	unsigned long ttwu_move_balance;
6981da177e4SLinus Torvalds #endif
6991da177e4SLinus Torvalds };
7001da177e4SLinus Torvalds 
70151888ca2SSrivatsa Vaddagiri extern int partition_sched_domains(cpumask_t *partition1,
7021a20ff27SDinakar Guniguntala 				    cpumask_t *partition2);
703198e2f18Sakpm@osdl.org 
704198e2f18Sakpm@osdl.org /*
705198e2f18Sakpm@osdl.org  * Maximum cache size the migration-costs auto-tuning code will
706198e2f18Sakpm@osdl.org  * search from:
707198e2f18Sakpm@osdl.org  */
708198e2f18Sakpm@osdl.org extern unsigned int max_cache_size;
709198e2f18Sakpm@osdl.org 
7101da177e4SLinus Torvalds #endif	/* CONFIG_SMP */
7111da177e4SLinus Torvalds 
7121da177e4SLinus Torvalds 
7131da177e4SLinus Torvalds struct io_context;			/* See blkdev.h */
7141da177e4SLinus Torvalds struct cpuset;
7151da177e4SLinus Torvalds 
7161da177e4SLinus Torvalds #define NGROUPS_SMALL		32
7171da177e4SLinus Torvalds #define NGROUPS_PER_BLOCK	((int)(PAGE_SIZE / sizeof(gid_t)))
7181da177e4SLinus Torvalds struct group_info {
7191da177e4SLinus Torvalds 	int ngroups;
7201da177e4SLinus Torvalds 	atomic_t usage;
7211da177e4SLinus Torvalds 	gid_t small_block[NGROUPS_SMALL];
7221da177e4SLinus Torvalds 	int nblocks;
7231da177e4SLinus Torvalds 	gid_t *blocks[0];
7241da177e4SLinus Torvalds };
7251da177e4SLinus Torvalds 
7261da177e4SLinus Torvalds /*
7271da177e4SLinus Torvalds  * get_group_info() must be called with the owning task locked (via task_lock())
7281da177e4SLinus Torvalds  * when task != current.  The reason being that the vast majority of callers are
7291da177e4SLinus Torvalds  * looking at current->group_info, which can not be changed except by the
7301da177e4SLinus Torvalds  * current task.  Changing current->group_info requires the task lock, too.
7311da177e4SLinus Torvalds  */
7321da177e4SLinus Torvalds #define get_group_info(group_info) do { \
7331da177e4SLinus Torvalds 	atomic_inc(&(group_info)->usage); \
7341da177e4SLinus Torvalds } while (0)
7351da177e4SLinus Torvalds 
7361da177e4SLinus Torvalds #define put_group_info(group_info) do { \
7371da177e4SLinus Torvalds 	if (atomic_dec_and_test(&(group_info)->usage)) \
7381da177e4SLinus Torvalds 		groups_free(group_info); \
7391da177e4SLinus Torvalds } while (0)
7401da177e4SLinus Torvalds 
7413e30148cSDavid Howells extern struct group_info *groups_alloc(int gidsetsize);
7423e30148cSDavid Howells extern void groups_free(struct group_info *group_info);
7433e30148cSDavid Howells extern int set_current_groups(struct group_info *group_info);
7443e30148cSDavid Howells extern int groups_search(struct group_info *group_info, gid_t grp);
7451da177e4SLinus Torvalds /* access the groups "array" with this macro */
7461da177e4SLinus Torvalds #define GROUP_AT(gi, i) \
7471da177e4SLinus Torvalds     ((gi)->blocks[(i)/NGROUPS_PER_BLOCK][(i)%NGROUPS_PER_BLOCK])
7481da177e4SLinus Torvalds 
749383f2835SChen, Kenneth W #ifdef ARCH_HAS_PREFETCH_SWITCH_STACK
75036c8b586SIngo Molnar extern void prefetch_stack(struct task_struct *t);
751383f2835SChen, Kenneth W #else
752383f2835SChen, Kenneth W static inline void prefetch_stack(struct task_struct *t) { }
753383f2835SChen, Kenneth W #endif
7541da177e4SLinus Torvalds 
7551da177e4SLinus Torvalds struct audit_context;		/* See audit.c */
7561da177e4SLinus Torvalds struct mempolicy;
757b92ce558SJens Axboe struct pipe_inode_info;
7584865ecf1SSerge E. Hallyn struct uts_namespace;
7591da177e4SLinus Torvalds 
7603dee386eSCon Kolivas enum sleep_type {
7613dee386eSCon Kolivas 	SLEEP_NORMAL,
7623dee386eSCon Kolivas 	SLEEP_NONINTERACTIVE,
7633dee386eSCon Kolivas 	SLEEP_INTERACTIVE,
7643dee386eSCon Kolivas 	SLEEP_INTERRUPTED,
7653dee386eSCon Kolivas };
7663dee386eSCon Kolivas 
76770b97a7fSIngo Molnar struct prio_array;
76870b97a7fSIngo Molnar 
7691da177e4SLinus Torvalds struct task_struct {
7701da177e4SLinus Torvalds 	volatile long state;	/* -1 unrunnable, 0 runnable, >0 stopped */
7711da177e4SLinus Torvalds 	struct thread_info *thread_info;
7721da177e4SLinus Torvalds 	atomic_t usage;
7731da177e4SLinus Torvalds 	unsigned long flags;	/* per process flags, defined below */
7741da177e4SLinus Torvalds 	unsigned long ptrace;
7751da177e4SLinus Torvalds 
77636772092SPaolo 'Blaisorblade' Giarrusso 	int lock_depth;		/* BKL lock depth */
7771da177e4SLinus Torvalds 
7782dd73a4fSPeter Williams #ifdef CONFIG_SMP
7792dd73a4fSPeter Williams #ifdef __ARCH_WANT_UNLOCKED_CTXSW
7804866cde0SNick Piggin 	int oncpu;
7814866cde0SNick Piggin #endif
7822dd73a4fSPeter Williams #endif
7832dd73a4fSPeter Williams 	int load_weight;	/* for niceness load balancing purposes */
784b29739f9SIngo Molnar 	int prio, static_prio, normal_prio;
7851da177e4SLinus Torvalds 	struct list_head run_list;
78670b97a7fSIngo Molnar 	struct prio_array *array;
7871da177e4SLinus Torvalds 
78822e2c507SJens Axboe 	unsigned short ioprio;
7896c5c9341SAlexey Dobriyan #ifdef CONFIG_BLK_DEV_IO_TRACE
7902056a782SJens Axboe 	unsigned int btrace_seq;
7916c5c9341SAlexey Dobriyan #endif
7921da177e4SLinus Torvalds 	unsigned long sleep_avg;
7931da177e4SLinus Torvalds 	unsigned long long timestamp, last_ran;
7941da177e4SLinus Torvalds 	unsigned long long sched_time; /* sched_clock time spent running */
7953dee386eSCon Kolivas 	enum sleep_type sleep_type;
7961da177e4SLinus Torvalds 
7971da177e4SLinus Torvalds 	unsigned long policy;
7981da177e4SLinus Torvalds 	cpumask_t cpus_allowed;
7991da177e4SLinus Torvalds 	unsigned int time_slice, first_time_slice;
8001da177e4SLinus Torvalds 
80152f17b6cSChandra Seetharaman #if defined(CONFIG_SCHEDSTATS) || defined(CONFIG_TASK_DELAY_ACCT)
8021da177e4SLinus Torvalds 	struct sched_info sched_info;
8031da177e4SLinus Torvalds #endif
8041da177e4SLinus Torvalds 
8051da177e4SLinus Torvalds 	struct list_head tasks;
8061da177e4SLinus Torvalds 	/*
8071da177e4SLinus Torvalds 	 * ptrace_list/ptrace_children forms the list of my children
8081da177e4SLinus Torvalds 	 * that were stolen by a ptracer.
8091da177e4SLinus Torvalds 	 */
8101da177e4SLinus Torvalds 	struct list_head ptrace_children;
8111da177e4SLinus Torvalds 	struct list_head ptrace_list;
8121da177e4SLinus Torvalds 
8131da177e4SLinus Torvalds 	struct mm_struct *mm, *active_mm;
8141da177e4SLinus Torvalds 
8151da177e4SLinus Torvalds /* task state */
8161da177e4SLinus Torvalds 	struct linux_binfmt *binfmt;
8171da177e4SLinus Torvalds 	long exit_state;
8181da177e4SLinus Torvalds 	int exit_code, exit_signal;
8191da177e4SLinus Torvalds 	int pdeath_signal;  /*  The signal sent when the parent dies  */
8201da177e4SLinus Torvalds 	/* ??? */
8211da177e4SLinus Torvalds 	unsigned long personality;
8221da177e4SLinus Torvalds 	unsigned did_exec:1;
8231da177e4SLinus Torvalds 	pid_t pid;
8241da177e4SLinus Torvalds 	pid_t tgid;
8250a425405SArjan van de Ven 
8260a425405SArjan van de Ven #ifdef CONFIG_CC_STACKPROTECTOR
8270a425405SArjan van de Ven 	/* Canary value for the -fstack-protector gcc feature */
8280a425405SArjan van de Ven 	unsigned long stack_canary;
8290a425405SArjan van de Ven #endif
8301da177e4SLinus Torvalds 	/*
8311da177e4SLinus Torvalds 	 * pointers to (original) parent process, youngest child, younger sibling,
8321da177e4SLinus Torvalds 	 * older sibling, respectively.  (p->father can be replaced with
8331da177e4SLinus Torvalds 	 * p->parent->pid)
8341da177e4SLinus Torvalds 	 */
8351da177e4SLinus Torvalds 	struct task_struct *real_parent; /* real parent process (when being debugged) */
8361da177e4SLinus Torvalds 	struct task_struct *parent;	/* parent process */
8371da177e4SLinus Torvalds 	/*
8381da177e4SLinus Torvalds 	 * children/sibling forms the list of my children plus the
8391da177e4SLinus Torvalds 	 * tasks I'm ptracing.
8401da177e4SLinus Torvalds 	 */
8411da177e4SLinus Torvalds 	struct list_head children;	/* list of my children */
8421da177e4SLinus Torvalds 	struct list_head sibling;	/* linkage in my parent's children list */
8431da177e4SLinus Torvalds 	struct task_struct *group_leader;	/* threadgroup leader */
8441da177e4SLinus Torvalds 
8451da177e4SLinus Torvalds 	/* PID/PID hash table linkage. */
84692476d7fSEric W. Biederman 	struct pid_link pids[PIDTYPE_MAX];
84747e65328SOleg Nesterov 	struct list_head thread_group;
8481da177e4SLinus Torvalds 
8491da177e4SLinus Torvalds 	struct completion *vfork_done;		/* for vfork() */
8501da177e4SLinus Torvalds 	int __user *set_child_tid;		/* CLONE_CHILD_SETTID */
8511da177e4SLinus Torvalds 	int __user *clear_child_tid;		/* CLONE_CHILD_CLEARTID */
8521da177e4SLinus Torvalds 
8531da177e4SLinus Torvalds 	unsigned long rt_priority;
8541da177e4SLinus Torvalds 	cputime_t utime, stime;
8551da177e4SLinus Torvalds 	unsigned long nvcsw, nivcsw; /* context switch counts */
8561da177e4SLinus Torvalds 	struct timespec start_time;
8571da177e4SLinus Torvalds /* mm fault and swap info: this can arguably be seen as either mm-specific or thread-specific */
8581da177e4SLinus Torvalds 	unsigned long min_flt, maj_flt;
8591da177e4SLinus Torvalds 
8601da177e4SLinus Torvalds   	cputime_t it_prof_expires, it_virt_expires;
8611da177e4SLinus Torvalds 	unsigned long long it_sched_expires;
8621da177e4SLinus Torvalds 	struct list_head cpu_timers[3];
8631da177e4SLinus Torvalds 
8641da177e4SLinus Torvalds /* process credentials */
8651da177e4SLinus Torvalds 	uid_t uid,euid,suid,fsuid;
8661da177e4SLinus Torvalds 	gid_t gid,egid,sgid,fsgid;
8671da177e4SLinus Torvalds 	struct group_info *group_info;
8681da177e4SLinus Torvalds 	kernel_cap_t   cap_effective, cap_inheritable, cap_permitted;
8691da177e4SLinus Torvalds 	unsigned keep_capabilities:1;
8701da177e4SLinus Torvalds 	struct user_struct *user;
8711da177e4SLinus Torvalds #ifdef CONFIG_KEYS
872b5f545c8SDavid Howells 	struct key *request_key_auth;	/* assumed request_key authority */
8731da177e4SLinus Torvalds 	struct key *thread_keyring;	/* keyring private to this thread */
8743e30148cSDavid Howells 	unsigned char jit_keyring;	/* default keyring to attach requested keys to */
8751da177e4SLinus Torvalds #endif
876e07e23e1SArjan van de Ven 	/*
877e07e23e1SArjan van de Ven 	 * fpu_counter contains the number of consecutive context switches
878e07e23e1SArjan van de Ven 	 * that the FPU is used. If this is over a threshold, the lazy fpu
879e07e23e1SArjan van de Ven 	 * saving becomes unlazy to save the trap. This is an unsigned char
880e07e23e1SArjan van de Ven 	 * so that after 256 times the counter wraps and the behavior turns
881e07e23e1SArjan van de Ven 	 * lazy again; this to deal with bursty apps that only use FPU for
882e07e23e1SArjan van de Ven 	 * a short time
883e07e23e1SArjan van de Ven 	 */
884e07e23e1SArjan van de Ven 	unsigned char fpu_counter;
8851da177e4SLinus Torvalds 	int oomkilladj; /* OOM kill score adjustment (bit shift). */
88636772092SPaolo 'Blaisorblade' Giarrusso 	char comm[TASK_COMM_LEN]; /* executable name excluding path
88736772092SPaolo 'Blaisorblade' Giarrusso 				     - access with [gs]et_task_comm (which lock
88836772092SPaolo 'Blaisorblade' Giarrusso 				       it with task_lock())
88936772092SPaolo 'Blaisorblade' Giarrusso 				     - initialized normally by flush_old_exec */
8901da177e4SLinus Torvalds /* file system info */
8911da177e4SLinus Torvalds 	int link_count, total_link_count;
8923d5b6fccSAlexey Dobriyan #ifdef CONFIG_SYSVIPC
8931da177e4SLinus Torvalds /* ipc stuff */
8941da177e4SLinus Torvalds 	struct sysv_sem sysvsem;
8953d5b6fccSAlexey Dobriyan #endif
8961da177e4SLinus Torvalds /* CPU-specific state of this task */
8971da177e4SLinus Torvalds 	struct thread_struct thread;
8981da177e4SLinus Torvalds /* filesystem information */
8991da177e4SLinus Torvalds 	struct fs_struct *fs;
9001da177e4SLinus Torvalds /* open file information */
9011da177e4SLinus Torvalds 	struct files_struct *files;
9021651e14eSSerge E. Hallyn /* namespaces */
903ab516013SSerge E. Hallyn 	struct nsproxy *nsproxy;
9041da177e4SLinus Torvalds /* signal handlers */
9051da177e4SLinus Torvalds 	struct signal_struct *signal;
9061da177e4SLinus Torvalds 	struct sighand_struct *sighand;
9071da177e4SLinus Torvalds 
9081da177e4SLinus Torvalds 	sigset_t blocked, real_blocked;
909150256d8SDavid Woodhouse 	sigset_t saved_sigmask;		/* To be restored with TIF_RESTORE_SIGMASK */
9101da177e4SLinus Torvalds 	struct sigpending pending;
9111da177e4SLinus Torvalds 
9121da177e4SLinus Torvalds 	unsigned long sas_ss_sp;
9131da177e4SLinus Torvalds 	size_t sas_ss_size;
9141da177e4SLinus Torvalds 	int (*notifier)(void *priv);
9151da177e4SLinus Torvalds 	void *notifier_data;
9161da177e4SLinus Torvalds 	sigset_t *notifier_mask;
9171da177e4SLinus Torvalds 
9181da177e4SLinus Torvalds 	void *security;
9191da177e4SLinus Torvalds 	struct audit_context *audit_context;
9201da177e4SLinus Torvalds 	seccomp_t seccomp;
9211da177e4SLinus Torvalds 
9221da177e4SLinus Torvalds /* Thread group tracking */
9231da177e4SLinus Torvalds    	u32 parent_exec_id;
9241da177e4SLinus Torvalds    	u32 self_exec_id;
9251da177e4SLinus Torvalds /* Protection of (de-)allocation: mm, files, fs, tty, keyrings */
9261da177e4SLinus Torvalds 	spinlock_t alloc_lock;
9271da177e4SLinus Torvalds 
928b29739f9SIngo Molnar 	/* Protection of the PI data structures: */
929b29739f9SIngo Molnar 	spinlock_t pi_lock;
930b29739f9SIngo Molnar 
93123f78d4aSIngo Molnar #ifdef CONFIG_RT_MUTEXES
93223f78d4aSIngo Molnar 	/* PI waiters blocked on a rt_mutex held by this task */
93323f78d4aSIngo Molnar 	struct plist_head pi_waiters;
93423f78d4aSIngo Molnar 	/* Deadlock detection and priority inheritance handling */
93523f78d4aSIngo Molnar 	struct rt_mutex_waiter *pi_blocked_on;
93623f78d4aSIngo Molnar #endif
93723f78d4aSIngo Molnar 
938408894eeSIngo Molnar #ifdef CONFIG_DEBUG_MUTEXES
939408894eeSIngo Molnar 	/* mutex deadlock detection */
940408894eeSIngo Molnar 	struct mutex_waiter *blocked_on;
941408894eeSIngo Molnar #endif
942de30a2b3SIngo Molnar #ifdef CONFIG_TRACE_IRQFLAGS
943de30a2b3SIngo Molnar 	unsigned int irq_events;
944de30a2b3SIngo Molnar 	int hardirqs_enabled;
945de30a2b3SIngo Molnar 	unsigned long hardirq_enable_ip;
946de30a2b3SIngo Molnar 	unsigned int hardirq_enable_event;
947de30a2b3SIngo Molnar 	unsigned long hardirq_disable_ip;
948de30a2b3SIngo Molnar 	unsigned int hardirq_disable_event;
949de30a2b3SIngo Molnar 	int softirqs_enabled;
950de30a2b3SIngo Molnar 	unsigned long softirq_disable_ip;
951de30a2b3SIngo Molnar 	unsigned int softirq_disable_event;
952de30a2b3SIngo Molnar 	unsigned long softirq_enable_ip;
953de30a2b3SIngo Molnar 	unsigned int softirq_enable_event;
954de30a2b3SIngo Molnar 	int hardirq_context;
955de30a2b3SIngo Molnar 	int softirq_context;
956de30a2b3SIngo Molnar #endif
957fbb9ce95SIngo Molnar #ifdef CONFIG_LOCKDEP
958fbb9ce95SIngo Molnar # define MAX_LOCK_DEPTH 30UL
959fbb9ce95SIngo Molnar 	u64 curr_chain_key;
960fbb9ce95SIngo Molnar 	int lockdep_depth;
961fbb9ce95SIngo Molnar 	struct held_lock held_locks[MAX_LOCK_DEPTH];
962fbb9ce95SIngo Molnar 	unsigned int lockdep_recursion;
963fbb9ce95SIngo Molnar #endif
964408894eeSIngo Molnar 
9651da177e4SLinus Torvalds /* journalling filesystem info */
9661da177e4SLinus Torvalds 	void *journal_info;
9671da177e4SLinus Torvalds 
9681da177e4SLinus Torvalds /* VM state */
9691da177e4SLinus Torvalds 	struct reclaim_state *reclaim_state;
9701da177e4SLinus Torvalds 
9711da177e4SLinus Torvalds 	struct backing_dev_info *backing_dev_info;
9721da177e4SLinus Torvalds 
9731da177e4SLinus Torvalds 	struct io_context *io_context;
9741da177e4SLinus Torvalds 
9751da177e4SLinus Torvalds 	unsigned long ptrace_message;
9761da177e4SLinus Torvalds 	siginfo_t *last_siginfo; /* For ptrace use.  */
9771da177e4SLinus Torvalds /*
9781da177e4SLinus Torvalds  * current io wait handle: wait queue entry to use for io waits
9791da177e4SLinus Torvalds  * If this thread is processing aio, this points at the waitqueue
9801da177e4SLinus Torvalds  * inside the currently handled kiocb. It may be NULL (i.e. default
9811da177e4SLinus Torvalds  * to a stack based synchronous wait) if its doing sync IO.
9821da177e4SLinus Torvalds  */
9831da177e4SLinus Torvalds 	wait_queue_t *io_wait;
9841da177e4SLinus Torvalds /* i/o counters(bytes read/written, #syscalls */
9851da177e4SLinus Torvalds 	u64 rchar, wchar, syscr, syscw;
9868f0ab514SJay Lan #if defined(CONFIG_TASK_XACCT)
9871da177e4SLinus Torvalds 	u64 acct_rss_mem1;	/* accumulated rss usage */
9881da177e4SLinus Torvalds 	u64 acct_vm_mem1;	/* accumulated virtual memory usage */
989db5fed26SJay Lan 	cputime_t acct_stimexpd;/* stime since last update */
9901da177e4SLinus Torvalds #endif
9911da177e4SLinus Torvalds #ifdef CONFIG_NUMA
9921da177e4SLinus Torvalds   	struct mempolicy *mempolicy;
9931da177e4SLinus Torvalds 	short il_next;
9941da177e4SLinus Torvalds #endif
9951da177e4SLinus Torvalds #ifdef CONFIG_CPUSETS
9961da177e4SLinus Torvalds 	struct cpuset *cpuset;
9971da177e4SLinus Torvalds 	nodemask_t mems_allowed;
9981da177e4SLinus Torvalds 	int cpuset_mems_generation;
999825a46afSPaul Jackson 	int cpuset_mem_spread_rotor;
10001da177e4SLinus Torvalds #endif
10010771dfefSIngo Molnar 	struct robust_list_head __user *robust_list;
100234f192c6SIngo Molnar #ifdef CONFIG_COMPAT
100334f192c6SIngo Molnar 	struct compat_robust_list_head __user *compat_robust_list;
100434f192c6SIngo Molnar #endif
1005c87e2837SIngo Molnar 	struct list_head pi_state_list;
1006c87e2837SIngo Molnar 	struct futex_pi_state *pi_state_cache;
10070771dfefSIngo Molnar 
100822e2c507SJens Axboe 	atomic_t fs_excl;	/* holding fs exclusive resources */
1009e56d0903SIngo Molnar 	struct rcu_head rcu;
1010b92ce558SJens Axboe 
1011b92ce558SJens Axboe 	/*
1012b92ce558SJens Axboe 	 * cache last used pipe for splice
1013b92ce558SJens Axboe 	 */
1014b92ce558SJens Axboe 	struct pipe_inode_info *splice_pipe;
1015ca74e92bSShailabh Nagar #ifdef	CONFIG_TASK_DELAY_ACCT
1016ca74e92bSShailabh Nagar 	struct task_delay_info *delays;
1017ca74e92bSShailabh Nagar #endif
10181da177e4SLinus Torvalds };
10191da177e4SLinus Torvalds 
10201da177e4SLinus Torvalds static inline pid_t process_group(struct task_struct *tsk)
10211da177e4SLinus Torvalds {
10221da177e4SLinus Torvalds 	return tsk->signal->pgrp;
10231da177e4SLinus Torvalds }
10241da177e4SLinus Torvalds 
102522c935f4SEric W. Biederman static inline struct pid *task_pid(struct task_struct *task)
102622c935f4SEric W. Biederman {
102722c935f4SEric W. Biederman 	return task->pids[PIDTYPE_PID].pid;
102822c935f4SEric W. Biederman }
102922c935f4SEric W. Biederman 
103022c935f4SEric W. Biederman static inline struct pid *task_tgid(struct task_struct *task)
103122c935f4SEric W. Biederman {
103222c935f4SEric W. Biederman 	return task->group_leader->pids[PIDTYPE_PID].pid;
103322c935f4SEric W. Biederman }
103422c935f4SEric W. Biederman 
103522c935f4SEric W. Biederman static inline struct pid *task_pgrp(struct task_struct *task)
103622c935f4SEric W. Biederman {
103722c935f4SEric W. Biederman 	return task->group_leader->pids[PIDTYPE_PGID].pid;
103822c935f4SEric W. Biederman }
103922c935f4SEric W. Biederman 
104022c935f4SEric W. Biederman static inline struct pid *task_session(struct task_struct *task)
104122c935f4SEric W. Biederman {
104222c935f4SEric W. Biederman 	return task->group_leader->pids[PIDTYPE_SID].pid;
104322c935f4SEric W. Biederman }
104422c935f4SEric W. Biederman 
10451da177e4SLinus Torvalds /**
10461da177e4SLinus Torvalds  * pid_alive - check that a task structure is not stale
10471da177e4SLinus Torvalds  * @p: Task structure to be checked.
10481da177e4SLinus Torvalds  *
10491da177e4SLinus Torvalds  * Test if a process is not yet dead (at most zombie state)
10501da177e4SLinus Torvalds  * If pid_alive fails, then pointers within the task structure
10511da177e4SLinus Torvalds  * can be stale and must not be dereferenced.
10521da177e4SLinus Torvalds  */
10531da177e4SLinus Torvalds static inline int pid_alive(struct task_struct *p)
10541da177e4SLinus Torvalds {
105592476d7fSEric W. Biederman 	return p->pids[PIDTYPE_PID].pid != NULL;
10561da177e4SLinus Torvalds }
10571da177e4SLinus Torvalds 
1058f400e198SSukadev Bhattiprolu /**
1059f400e198SSukadev Bhattiprolu  * is_init - check if a task structure is the first user space
1060f400e198SSukadev Bhattiprolu  *	     task the kernel created.
1061f400e198SSukadev Bhattiprolu  * @p: Task structure to be checked.
1062f400e198SSukadev Bhattiprolu  */
1063f400e198SSukadev Bhattiprolu static inline int is_init(struct task_struct *tsk)
1064f400e198SSukadev Bhattiprolu {
1065f400e198SSukadev Bhattiprolu 	return tsk->pid == 1;
1066f400e198SSukadev Bhattiprolu }
1067f400e198SSukadev Bhattiprolu 
1068*9ec52099SCedric Le Goater extern struct pid *cad_pid;
1069*9ec52099SCedric Le Goater 
10701da177e4SLinus Torvalds extern void free_task(struct task_struct *tsk);
10711da177e4SLinus Torvalds #define get_task_struct(tsk) do { atomic_inc(&(tsk)->usage); } while(0)
1072e56d0903SIngo Molnar 
1073158d9ebdSAndrew Morton extern void __put_task_struct(struct task_struct *t);
1074e56d0903SIngo Molnar 
1075e56d0903SIngo Molnar static inline void put_task_struct(struct task_struct *t)
1076e56d0903SIngo Molnar {
1077e56d0903SIngo Molnar 	if (atomic_dec_and_test(&t->usage))
10788c7904a0SEric W. Biederman 		__put_task_struct(t);
1079e56d0903SIngo Molnar }
10801da177e4SLinus Torvalds 
10811da177e4SLinus Torvalds /*
10821da177e4SLinus Torvalds  * Per process flags
10831da177e4SLinus Torvalds  */
10841da177e4SLinus Torvalds #define PF_ALIGNWARN	0x00000001	/* Print alignment warning msgs */
10851da177e4SLinus Torvalds 					/* Not implemented yet, only for 486*/
10861da177e4SLinus Torvalds #define PF_STARTING	0x00000002	/* being created */
10871da177e4SLinus Torvalds #define PF_EXITING	0x00000004	/* getting shut down */
10881da177e4SLinus Torvalds #define PF_FORKNOEXEC	0x00000040	/* forked but didn't exec */
10891da177e4SLinus Torvalds #define PF_SUPERPRIV	0x00000100	/* used super-user privileges */
10901da177e4SLinus Torvalds #define PF_DUMPCORE	0x00000200	/* dumped core */
10911da177e4SLinus Torvalds #define PF_SIGNALED	0x00000400	/* killed by a signal */
10921da177e4SLinus Torvalds #define PF_MEMALLOC	0x00000800	/* Allocating memory */
10931da177e4SLinus Torvalds #define PF_FLUSHER	0x00001000	/* responsible for disk writeback */
10941da177e4SLinus Torvalds #define PF_USED_MATH	0x00002000	/* if unset the fpu must be initialized before use */
10951da177e4SLinus Torvalds #define PF_FREEZE	0x00004000	/* this task is being frozen for suspend now */
10961da177e4SLinus Torvalds #define PF_NOFREEZE	0x00008000	/* this thread should not be frozen */
10971da177e4SLinus Torvalds #define PF_FROZEN	0x00010000	/* frozen for system suspend */
10981da177e4SLinus Torvalds #define PF_FSTRANS	0x00020000	/* inside a filesystem transaction */
10991da177e4SLinus Torvalds #define PF_KSWAPD	0x00040000	/* I am kswapd */
11001da177e4SLinus Torvalds #define PF_SWAPOFF	0x00080000	/* I am in swapoff */
11011da177e4SLinus Torvalds #define PF_LESS_THROTTLE 0x00100000	/* Throttle me less: I clean memory */
1102b31dc66aSJens Axboe #define PF_BORROWED_MM	0x00200000	/* I am a kthread doing use_mm */
1103b31dc66aSJens Axboe #define PF_RANDOMIZE	0x00400000	/* randomize virtual address space */
1104b31dc66aSJens Axboe #define PF_SWAPWRITE	0x00800000	/* Allowed to write to swap */
1105b31dc66aSJens Axboe #define PF_SPREAD_PAGE	0x01000000	/* Spread page cache over cpuset */
1106b31dc66aSJens Axboe #define PF_SPREAD_SLAB	0x02000000	/* Spread some slab caches over cpuset */
1107c61afb18SPaul Jackson #define PF_MEMPOLICY	0x10000000	/* Non-default NUMA mempolicy */
110861a87122SThomas Gleixner #define PF_MUTEX_TESTER	0x20000000	/* Thread belongs to the rt mutex tester */
11091da177e4SLinus Torvalds 
11101da177e4SLinus Torvalds /*
11111da177e4SLinus Torvalds  * Only the _current_ task can read/write to tsk->flags, but other
11121da177e4SLinus Torvalds  * tasks can access tsk->flags in readonly mode for example
11131da177e4SLinus Torvalds  * with tsk_used_math (like during threaded core dumping).
11141da177e4SLinus Torvalds  * There is however an exception to this rule during ptrace
11151da177e4SLinus Torvalds  * or during fork: the ptracer task is allowed to write to the
11161da177e4SLinus Torvalds  * child->flags of its traced child (same goes for fork, the parent
11171da177e4SLinus Torvalds  * can write to the child->flags), because we're guaranteed the
11181da177e4SLinus Torvalds  * child is not running and in turn not changing child->flags
11191da177e4SLinus Torvalds  * at the same time the parent does it.
11201da177e4SLinus Torvalds  */
11211da177e4SLinus Torvalds #define clear_stopped_child_used_math(child) do { (child)->flags &= ~PF_USED_MATH; } while (0)
11221da177e4SLinus Torvalds #define set_stopped_child_used_math(child) do { (child)->flags |= PF_USED_MATH; } while (0)
11231da177e4SLinus Torvalds #define clear_used_math() clear_stopped_child_used_math(current)
11241da177e4SLinus Torvalds #define set_used_math() set_stopped_child_used_math(current)
11251da177e4SLinus Torvalds #define conditional_stopped_child_used_math(condition, child) \
11261da177e4SLinus Torvalds 	do { (child)->flags &= ~PF_USED_MATH, (child)->flags |= (condition) ? PF_USED_MATH : 0; } while (0)
11271da177e4SLinus Torvalds #define conditional_used_math(condition) \
11281da177e4SLinus Torvalds 	conditional_stopped_child_used_math(condition, current)
11291da177e4SLinus Torvalds #define copy_to_stopped_child_used_math(child) \
11301da177e4SLinus Torvalds 	do { (child)->flags &= ~PF_USED_MATH, (child)->flags |= current->flags & PF_USED_MATH; } while (0)
11311da177e4SLinus Torvalds /* NOTE: this will return 0 or PF_USED_MATH, it will never return 1 */
11321da177e4SLinus Torvalds #define tsk_used_math(p) ((p)->flags & PF_USED_MATH)
11331da177e4SLinus Torvalds #define used_math() tsk_used_math(current)
11341da177e4SLinus Torvalds 
11351da177e4SLinus Torvalds #ifdef CONFIG_SMP
113636c8b586SIngo Molnar extern int set_cpus_allowed(struct task_struct *p, cpumask_t new_mask);
11371da177e4SLinus Torvalds #else
113836c8b586SIngo Molnar static inline int set_cpus_allowed(struct task_struct *p, cpumask_t new_mask)
11391da177e4SLinus Torvalds {
11404098f991SPaul Jackson 	if (!cpu_isset(0, new_mask))
11411da177e4SLinus Torvalds 		return -EINVAL;
11421da177e4SLinus Torvalds 	return 0;
11431da177e4SLinus Torvalds }
11441da177e4SLinus Torvalds #endif
11451da177e4SLinus Torvalds 
11461da177e4SLinus Torvalds extern unsigned long long sched_clock(void);
114736c8b586SIngo Molnar extern unsigned long long
114836c8b586SIngo Molnar current_sched_time(const struct task_struct *current_task);
11491da177e4SLinus Torvalds 
11501da177e4SLinus Torvalds /* sched_exec is called by processes performing an exec */
11511da177e4SLinus Torvalds #ifdef CONFIG_SMP
11521da177e4SLinus Torvalds extern void sched_exec(void);
11531da177e4SLinus Torvalds #else
11541da177e4SLinus Torvalds #define sched_exec()   {}
11551da177e4SLinus Torvalds #endif
11561da177e4SLinus Torvalds 
11571da177e4SLinus Torvalds #ifdef CONFIG_HOTPLUG_CPU
11581da177e4SLinus Torvalds extern void idle_task_exit(void);
11591da177e4SLinus Torvalds #else
11601da177e4SLinus Torvalds static inline void idle_task_exit(void) {}
11611da177e4SLinus Torvalds #endif
11621da177e4SLinus Torvalds 
11631da177e4SLinus Torvalds extern void sched_idle_next(void);
1164b29739f9SIngo Molnar 
1165b29739f9SIngo Molnar #ifdef CONFIG_RT_MUTEXES
116636c8b586SIngo Molnar extern int rt_mutex_getprio(struct task_struct *p);
116736c8b586SIngo Molnar extern void rt_mutex_setprio(struct task_struct *p, int prio);
116836c8b586SIngo Molnar extern void rt_mutex_adjust_pi(struct task_struct *p);
1169b29739f9SIngo Molnar #else
117036c8b586SIngo Molnar static inline int rt_mutex_getprio(struct task_struct *p)
1171b29739f9SIngo Molnar {
1172b29739f9SIngo Molnar 	return p->normal_prio;
1173b29739f9SIngo Molnar }
117495e02ca9SThomas Gleixner # define rt_mutex_adjust_pi(p)		do { } while (0)
1175b29739f9SIngo Molnar #endif
1176b29739f9SIngo Molnar 
117736c8b586SIngo Molnar extern void set_user_nice(struct task_struct *p, long nice);
117836c8b586SIngo Molnar extern int task_prio(const struct task_struct *p);
117936c8b586SIngo Molnar extern int task_nice(const struct task_struct *p);
118036c8b586SIngo Molnar extern int can_nice(const struct task_struct *p, const int nice);
118136c8b586SIngo Molnar extern int task_curr(const struct task_struct *p);
11821da177e4SLinus Torvalds extern int idle_cpu(int cpu);
11831da177e4SLinus Torvalds extern int sched_setscheduler(struct task_struct *, int, struct sched_param *);
118436c8b586SIngo Molnar extern struct task_struct *idle_task(int cpu);
118536c8b586SIngo Molnar extern struct task_struct *curr_task(int cpu);
118636c8b586SIngo Molnar extern void set_curr_task(int cpu, struct task_struct *p);
11871da177e4SLinus Torvalds 
11881da177e4SLinus Torvalds void yield(void);
11891da177e4SLinus Torvalds 
11901da177e4SLinus Torvalds /*
11911da177e4SLinus Torvalds  * The default (Linux) execution domain.
11921da177e4SLinus Torvalds  */
11931da177e4SLinus Torvalds extern struct exec_domain	default_exec_domain;
11941da177e4SLinus Torvalds 
11951da177e4SLinus Torvalds union thread_union {
11961da177e4SLinus Torvalds 	struct thread_info thread_info;
11971da177e4SLinus Torvalds 	unsigned long stack[THREAD_SIZE/sizeof(long)];
11981da177e4SLinus Torvalds };
11991da177e4SLinus Torvalds 
12001da177e4SLinus Torvalds #ifndef __HAVE_ARCH_KSTACK_END
12011da177e4SLinus Torvalds static inline int kstack_end(void *addr)
12021da177e4SLinus Torvalds {
12031da177e4SLinus Torvalds 	/* Reliable end of stack detection:
12041da177e4SLinus Torvalds 	 * Some APM bios versions misalign the stack
12051da177e4SLinus Torvalds 	 */
12061da177e4SLinus Torvalds 	return !(((unsigned long)addr+sizeof(void*)-1) & (THREAD_SIZE-sizeof(void*)));
12071da177e4SLinus Torvalds }
12081da177e4SLinus Torvalds #endif
12091da177e4SLinus Torvalds 
12101da177e4SLinus Torvalds extern union thread_union init_thread_union;
12111da177e4SLinus Torvalds extern struct task_struct init_task;
12121da177e4SLinus Torvalds 
12131da177e4SLinus Torvalds extern struct   mm_struct init_mm;
12141da177e4SLinus Torvalds 
12151da177e4SLinus Torvalds #define find_task_by_pid(nr)	find_task_by_pid_type(PIDTYPE_PID, nr)
12161da177e4SLinus Torvalds extern struct task_struct *find_task_by_pid_type(int type, int pid);
12171da177e4SLinus Torvalds extern void set_special_pids(pid_t session, pid_t pgrp);
12181da177e4SLinus Torvalds extern void __set_special_pids(pid_t session, pid_t pgrp);
12191da177e4SLinus Torvalds 
12201da177e4SLinus Torvalds /* per-UID process charging. */
12211da177e4SLinus Torvalds extern struct user_struct * alloc_uid(uid_t);
12221da177e4SLinus Torvalds static inline struct user_struct *get_uid(struct user_struct *u)
12231da177e4SLinus Torvalds {
12241da177e4SLinus Torvalds 	atomic_inc(&u->__count);
12251da177e4SLinus Torvalds 	return u;
12261da177e4SLinus Torvalds }
12271da177e4SLinus Torvalds extern void free_uid(struct user_struct *);
12281da177e4SLinus Torvalds extern void switch_uid(struct user_struct *);
12291da177e4SLinus Torvalds 
12301da177e4SLinus Torvalds #include <asm/current.h>
12311da177e4SLinus Torvalds 
12323171a030SAtsushi Nemoto extern void do_timer(unsigned long ticks);
12331da177e4SLinus Torvalds 
12341da177e4SLinus Torvalds extern int FASTCALL(wake_up_state(struct task_struct * tsk, unsigned int state));
12351da177e4SLinus Torvalds extern int FASTCALL(wake_up_process(struct task_struct * tsk));
12361da177e4SLinus Torvalds extern void FASTCALL(wake_up_new_task(struct task_struct * tsk,
12371da177e4SLinus Torvalds 						unsigned long clone_flags));
12381da177e4SLinus Torvalds #ifdef CONFIG_SMP
12391da177e4SLinus Torvalds  extern void kick_process(struct task_struct *tsk);
12401da177e4SLinus Torvalds #else
12411da177e4SLinus Torvalds  static inline void kick_process(struct task_struct *tsk) { }
12421da177e4SLinus Torvalds #endif
124336c8b586SIngo Molnar extern void FASTCALL(sched_fork(struct task_struct * p, int clone_flags));
124436c8b586SIngo Molnar extern void FASTCALL(sched_exit(struct task_struct * p));
12451da177e4SLinus Torvalds 
12461da177e4SLinus Torvalds extern int in_group_p(gid_t);
12471da177e4SLinus Torvalds extern int in_egroup_p(gid_t);
12481da177e4SLinus Torvalds 
12491da177e4SLinus Torvalds extern void proc_caches_init(void);
12501da177e4SLinus Torvalds extern void flush_signals(struct task_struct *);
12511da177e4SLinus Torvalds extern void flush_signal_handlers(struct task_struct *, int force_default);
12521da177e4SLinus Torvalds extern int dequeue_signal(struct task_struct *tsk, sigset_t *mask, siginfo_t *info);
12531da177e4SLinus Torvalds 
12541da177e4SLinus Torvalds static inline int dequeue_signal_lock(struct task_struct *tsk, sigset_t *mask, siginfo_t *info)
12551da177e4SLinus Torvalds {
12561da177e4SLinus Torvalds 	unsigned long flags;
12571da177e4SLinus Torvalds 	int ret;
12581da177e4SLinus Torvalds 
12591da177e4SLinus Torvalds 	spin_lock_irqsave(&tsk->sighand->siglock, flags);
12601da177e4SLinus Torvalds 	ret = dequeue_signal(tsk, mask, info);
12611da177e4SLinus Torvalds 	spin_unlock_irqrestore(&tsk->sighand->siglock, flags);
12621da177e4SLinus Torvalds 
12631da177e4SLinus Torvalds 	return ret;
12641da177e4SLinus Torvalds }
12651da177e4SLinus Torvalds 
12661da177e4SLinus Torvalds extern void block_all_signals(int (*notifier)(void *priv), void *priv,
12671da177e4SLinus Torvalds 			      sigset_t *mask);
12681da177e4SLinus Torvalds extern void unblock_all_signals(void);
12691da177e4SLinus Torvalds extern void release_task(struct task_struct * p);
12701da177e4SLinus Torvalds extern int send_sig_info(int, struct siginfo *, struct task_struct *);
12711da177e4SLinus Torvalds extern int send_group_sig_info(int, struct siginfo *, struct task_struct *);
12721da177e4SLinus Torvalds extern int force_sigsegv(int, struct task_struct *);
12731da177e4SLinus Torvalds extern int force_sig_info(int, struct siginfo *, struct task_struct *);
1274c4b92fc1SEric W. Biederman extern int __kill_pgrp_info(int sig, struct siginfo *info, struct pid *pgrp);
1275c4b92fc1SEric W. Biederman extern int kill_pgrp_info(int sig, struct siginfo *info, struct pid *pgrp);
1276c4b92fc1SEric W. Biederman extern int kill_pid_info(int sig, struct siginfo *info, struct pid *pid);
12772425c08bSEric W. Biederman extern int kill_pid_info_as_uid(int, struct siginfo *, struct pid *, uid_t, uid_t, u32);
1278c4b92fc1SEric W. Biederman extern int kill_pgrp(struct pid *pid, int sig, int priv);
1279c4b92fc1SEric W. Biederman extern int kill_pid(struct pid *pid, int sig, int priv);
12801da177e4SLinus Torvalds extern int __kill_pg_info(int sig, struct siginfo *info, pid_t pgrp);
12811da177e4SLinus Torvalds extern int kill_pg_info(int, struct siginfo *, pid_t);
12821da177e4SLinus Torvalds extern int kill_proc_info(int, struct siginfo *, pid_t);
12831da177e4SLinus Torvalds extern void do_notify_parent(struct task_struct *, int);
12841da177e4SLinus Torvalds extern void force_sig(int, struct task_struct *);
12851da177e4SLinus Torvalds extern void force_sig_specific(int, struct task_struct *);
12861da177e4SLinus Torvalds extern int send_sig(int, struct task_struct *, int);
12871da177e4SLinus Torvalds extern void zap_other_threads(struct task_struct *p);
12881da177e4SLinus Torvalds extern int kill_pg(pid_t, int, int);
12891da177e4SLinus Torvalds extern int kill_proc(pid_t, int, int);
12901da177e4SLinus Torvalds extern struct sigqueue *sigqueue_alloc(void);
12911da177e4SLinus Torvalds extern void sigqueue_free(struct sigqueue *);
12921da177e4SLinus Torvalds extern int send_sigqueue(int, struct sigqueue *,  struct task_struct *);
12931da177e4SLinus Torvalds extern int send_group_sigqueue(int, struct sigqueue *,  struct task_struct *);
12949ac95f2fSOleg Nesterov extern int do_sigaction(int, struct k_sigaction *, struct k_sigaction *);
12951da177e4SLinus Torvalds extern int do_sigaltstack(const stack_t __user *, stack_t __user *, unsigned long);
12961da177e4SLinus Torvalds 
1297*9ec52099SCedric Le Goater static inline int kill_cad_pid(int sig, int priv)
1298*9ec52099SCedric Le Goater {
1299*9ec52099SCedric Le Goater 	return kill_pid(cad_pid, sig, priv);
1300*9ec52099SCedric Le Goater }
1301*9ec52099SCedric Le Goater 
13021da177e4SLinus Torvalds /* These can be the second arg to send_sig_info/send_group_sig_info.  */
13031da177e4SLinus Torvalds #define SEND_SIG_NOINFO ((struct siginfo *) 0)
13041da177e4SLinus Torvalds #define SEND_SIG_PRIV	((struct siginfo *) 1)
13051da177e4SLinus Torvalds #define SEND_SIG_FORCED	((struct siginfo *) 2)
13061da177e4SLinus Torvalds 
1307621d3121SOleg Nesterov static inline int is_si_special(const struct siginfo *info)
1308621d3121SOleg Nesterov {
1309621d3121SOleg Nesterov 	return info <= SEND_SIG_FORCED;
1310621d3121SOleg Nesterov }
1311621d3121SOleg Nesterov 
13121da177e4SLinus Torvalds /* True if we are on the alternate signal stack.  */
13131da177e4SLinus Torvalds 
13141da177e4SLinus Torvalds static inline int on_sig_stack(unsigned long sp)
13151da177e4SLinus Torvalds {
13161da177e4SLinus Torvalds 	return (sp - current->sas_ss_sp < current->sas_ss_size);
13171da177e4SLinus Torvalds }
13181da177e4SLinus Torvalds 
13191da177e4SLinus Torvalds static inline int sas_ss_flags(unsigned long sp)
13201da177e4SLinus Torvalds {
13211da177e4SLinus Torvalds 	return (current->sas_ss_size == 0 ? SS_DISABLE
13221da177e4SLinus Torvalds 		: on_sig_stack(sp) ? SS_ONSTACK : 0);
13231da177e4SLinus Torvalds }
13241da177e4SLinus Torvalds 
13251da177e4SLinus Torvalds /*
13261da177e4SLinus Torvalds  * Routines for handling mm_structs
13271da177e4SLinus Torvalds  */
13281da177e4SLinus Torvalds extern struct mm_struct * mm_alloc(void);
13291da177e4SLinus Torvalds 
13301da177e4SLinus Torvalds /* mmdrop drops the mm and the page tables */
13311da177e4SLinus Torvalds extern void FASTCALL(__mmdrop(struct mm_struct *));
13321da177e4SLinus Torvalds static inline void mmdrop(struct mm_struct * mm)
13331da177e4SLinus Torvalds {
13341da177e4SLinus Torvalds 	if (atomic_dec_and_test(&mm->mm_count))
13351da177e4SLinus Torvalds 		__mmdrop(mm);
13361da177e4SLinus Torvalds }
13371da177e4SLinus Torvalds 
13381da177e4SLinus Torvalds /* mmput gets rid of the mappings and all user-space */
13391da177e4SLinus Torvalds extern void mmput(struct mm_struct *);
13401da177e4SLinus Torvalds /* Grab a reference to a task's mm, if it is not already going away */
13411da177e4SLinus Torvalds extern struct mm_struct *get_task_mm(struct task_struct *task);
13421da177e4SLinus Torvalds /* Remove the current tasks stale references to the old mm_struct */
13431da177e4SLinus Torvalds extern void mm_release(struct task_struct *, struct mm_struct *);
13441da177e4SLinus Torvalds 
13451da177e4SLinus Torvalds extern int  copy_thread(int, unsigned long, unsigned long, unsigned long, struct task_struct *, struct pt_regs *);
13461da177e4SLinus Torvalds extern void flush_thread(void);
13471da177e4SLinus Torvalds extern void exit_thread(void);
13481da177e4SLinus Torvalds 
13491da177e4SLinus Torvalds extern void exit_files(struct task_struct *);
13506b3934efSOleg Nesterov extern void __cleanup_signal(struct signal_struct *);
1351a7e5328aSOleg Nesterov extern void __cleanup_sighand(struct sighand_struct *);
13521da177e4SLinus Torvalds extern void exit_itimers(struct signal_struct *);
13531da177e4SLinus Torvalds 
13541da177e4SLinus Torvalds extern NORET_TYPE void do_group_exit(int);
13551da177e4SLinus Torvalds 
13561da177e4SLinus Torvalds extern void daemonize(const char *, ...);
13571da177e4SLinus Torvalds extern int allow_signal(int);
13581da177e4SLinus Torvalds extern int disallow_signal(int);
135936c8b586SIngo Molnar extern struct task_struct *child_reaper;
13601da177e4SLinus Torvalds 
13611da177e4SLinus Torvalds extern int do_execve(char *, char __user * __user *, char __user * __user *, struct pt_regs *);
13621da177e4SLinus Torvalds extern long do_fork(unsigned long, unsigned long, struct pt_regs *, unsigned long, int __user *, int __user *);
136336c8b586SIngo Molnar struct task_struct *fork_idle(int);
13641da177e4SLinus Torvalds 
13651da177e4SLinus Torvalds extern void set_task_comm(struct task_struct *tsk, char *from);
13661da177e4SLinus Torvalds extern void get_task_comm(char *to, struct task_struct *tsk);
13671da177e4SLinus Torvalds 
13681da177e4SLinus Torvalds #ifdef CONFIG_SMP
136936c8b586SIngo Molnar extern void wait_task_inactive(struct task_struct * p);
13701da177e4SLinus Torvalds #else
13711da177e4SLinus Torvalds #define wait_task_inactive(p)	do { } while (0)
13721da177e4SLinus Torvalds #endif
13731da177e4SLinus Torvalds 
13741da177e4SLinus Torvalds #define remove_parent(p)	list_del_init(&(p)->sibling)
13758fafabd8SOleg Nesterov #define add_parent(p)		list_add_tail(&(p)->sibling,&(p)->parent->children)
13761da177e4SLinus Torvalds 
13775e85d4abSEric W. Biederman #define next_task(p)	list_entry(rcu_dereference((p)->tasks.next), struct task_struct, tasks)
13781da177e4SLinus Torvalds 
13791da177e4SLinus Torvalds #define for_each_process(p) \
13801da177e4SLinus Torvalds 	for (p = &init_task ; (p = next_task(p)) != &init_task ; )
13811da177e4SLinus Torvalds 
13821da177e4SLinus Torvalds /*
13831da177e4SLinus Torvalds  * Careful: do_each_thread/while_each_thread is a double loop so
13841da177e4SLinus Torvalds  *          'break' will not work as expected - use goto instead.
13851da177e4SLinus Torvalds  */
13861da177e4SLinus Torvalds #define do_each_thread(g, t) \
13871da177e4SLinus Torvalds 	for (g = t = &init_task ; (g = t = next_task(g)) != &init_task ; ) do
13881da177e4SLinus Torvalds 
13891da177e4SLinus Torvalds #define while_each_thread(g, t) \
13901da177e4SLinus Torvalds 	while ((t = next_thread(t)) != g)
13911da177e4SLinus Torvalds 
1392de12a787SEric W. Biederman /* de_thread depends on thread_group_leader not being a pid based check */
1393de12a787SEric W. Biederman #define thread_group_leader(p)	(p == p->group_leader)
13941da177e4SLinus Torvalds 
13950804ef4bSEric W. Biederman /* Do to the insanities of de_thread it is possible for a process
13960804ef4bSEric W. Biederman  * to have the pid of the thread group leader without actually being
13970804ef4bSEric W. Biederman  * the thread group leader.  For iteration through the pids in proc
13980804ef4bSEric W. Biederman  * all we care about is that we have a task with the appropriate
13990804ef4bSEric W. Biederman  * pid, we don't actually care if we have the right task.
14000804ef4bSEric W. Biederman  */
14010804ef4bSEric W. Biederman static inline int has_group_leader_pid(struct task_struct *p)
14020804ef4bSEric W. Biederman {
14030804ef4bSEric W. Biederman 	return p->pid == p->tgid;
14040804ef4bSEric W. Biederman }
14050804ef4bSEric W. Biederman 
140636c8b586SIngo Molnar static inline struct task_struct *next_thread(const struct task_struct *p)
140747e65328SOleg Nesterov {
140847e65328SOleg Nesterov 	return list_entry(rcu_dereference(p->thread_group.next),
140936c8b586SIngo Molnar 			  struct task_struct, thread_group);
141047e65328SOleg Nesterov }
141147e65328SOleg Nesterov 
141236c8b586SIngo Molnar static inline int thread_group_empty(struct task_struct *p)
14131da177e4SLinus Torvalds {
141447e65328SOleg Nesterov 	return list_empty(&p->thread_group);
14151da177e4SLinus Torvalds }
14161da177e4SLinus Torvalds 
14171da177e4SLinus Torvalds #define delay_group_leader(p) \
14181da177e4SLinus Torvalds 		(thread_group_leader(p) && !thread_group_empty(p))
14191da177e4SLinus Torvalds 
14201da177e4SLinus Torvalds /*
1421260ea101SEric W. Biederman  * Protects ->fs, ->files, ->mm, ->group_info, ->comm, keyring
142222e2c507SJens Axboe  * subscriptions and synchronises with wait4().  Also used in procfs.  Also
1423053199edSPaul Jackson  * pins the final release of task.io_context.  Also protects ->cpuset.
14241da177e4SLinus Torvalds  *
14251da177e4SLinus Torvalds  * Nests both inside and outside of read_lock(&tasklist_lock).
14261da177e4SLinus Torvalds  * It must not be nested with write_lock_irq(&tasklist_lock),
14271da177e4SLinus Torvalds  * neither inside nor outside.
14281da177e4SLinus Torvalds  */
14291da177e4SLinus Torvalds static inline void task_lock(struct task_struct *p)
14301da177e4SLinus Torvalds {
14311da177e4SLinus Torvalds 	spin_lock(&p->alloc_lock);
14321da177e4SLinus Torvalds }
14331da177e4SLinus Torvalds 
14341da177e4SLinus Torvalds static inline void task_unlock(struct task_struct *p)
14351da177e4SLinus Torvalds {
14361da177e4SLinus Torvalds 	spin_unlock(&p->alloc_lock);
14371da177e4SLinus Torvalds }
14381da177e4SLinus Torvalds 
1439f63ee72eSOleg Nesterov extern struct sighand_struct *lock_task_sighand(struct task_struct *tsk,
1440f63ee72eSOleg Nesterov 							unsigned long *flags);
1441f63ee72eSOleg Nesterov 
1442f63ee72eSOleg Nesterov static inline void unlock_task_sighand(struct task_struct *tsk,
1443f63ee72eSOleg Nesterov 						unsigned long *flags)
1444f63ee72eSOleg Nesterov {
1445f63ee72eSOleg Nesterov 	spin_unlock_irqrestore(&tsk->sighand->siglock, *flags);
1446f63ee72eSOleg Nesterov }
1447f63ee72eSOleg Nesterov 
1448f037360fSAl Viro #ifndef __HAVE_THREAD_FUNCTIONS
1449f037360fSAl Viro 
1450a1261f54SAl Viro #define task_thread_info(task) (task)->thread_info
14519fc65876SAl Viro #define task_stack_page(task) ((void*)((task)->thread_info))
1452a1261f54SAl Viro 
145310ebffdeSAl Viro static inline void setup_thread_stack(struct task_struct *p, struct task_struct *org)
145410ebffdeSAl Viro {
145510ebffdeSAl Viro 	*task_thread_info(p) = *task_thread_info(org);
145610ebffdeSAl Viro 	task_thread_info(p)->task = p;
145710ebffdeSAl Viro }
145810ebffdeSAl Viro 
145910ebffdeSAl Viro static inline unsigned long *end_of_stack(struct task_struct *p)
146010ebffdeSAl Viro {
146110ebffdeSAl Viro 	return (unsigned long *)(p->thread_info + 1);
146210ebffdeSAl Viro }
146310ebffdeSAl Viro 
1464f037360fSAl Viro #endif
1465f037360fSAl Viro 
14661da177e4SLinus Torvalds /* set thread flags in other task's structures
14671da177e4SLinus Torvalds  * - see asm/thread_info.h for TIF_xxxx flags available
14681da177e4SLinus Torvalds  */
14691da177e4SLinus Torvalds static inline void set_tsk_thread_flag(struct task_struct *tsk, int flag)
14701da177e4SLinus Torvalds {
1471a1261f54SAl Viro 	set_ti_thread_flag(task_thread_info(tsk), flag);
14721da177e4SLinus Torvalds }
14731da177e4SLinus Torvalds 
14741da177e4SLinus Torvalds static inline void clear_tsk_thread_flag(struct task_struct *tsk, int flag)
14751da177e4SLinus Torvalds {
1476a1261f54SAl Viro 	clear_ti_thread_flag(task_thread_info(tsk), flag);
14771da177e4SLinus Torvalds }
14781da177e4SLinus Torvalds 
14791da177e4SLinus Torvalds static inline int test_and_set_tsk_thread_flag(struct task_struct *tsk, int flag)
14801da177e4SLinus Torvalds {
1481a1261f54SAl Viro 	return test_and_set_ti_thread_flag(task_thread_info(tsk), flag);
14821da177e4SLinus Torvalds }
14831da177e4SLinus Torvalds 
14841da177e4SLinus Torvalds static inline int test_and_clear_tsk_thread_flag(struct task_struct *tsk, int flag)
14851da177e4SLinus Torvalds {
1486a1261f54SAl Viro 	return test_and_clear_ti_thread_flag(task_thread_info(tsk), flag);
14871da177e4SLinus Torvalds }
14881da177e4SLinus Torvalds 
14891da177e4SLinus Torvalds static inline int test_tsk_thread_flag(struct task_struct *tsk, int flag)
14901da177e4SLinus Torvalds {
1491a1261f54SAl Viro 	return test_ti_thread_flag(task_thread_info(tsk), flag);
14921da177e4SLinus Torvalds }
14931da177e4SLinus Torvalds 
14941da177e4SLinus Torvalds static inline void set_tsk_need_resched(struct task_struct *tsk)
14951da177e4SLinus Torvalds {
14961da177e4SLinus Torvalds 	set_tsk_thread_flag(tsk,TIF_NEED_RESCHED);
14971da177e4SLinus Torvalds }
14981da177e4SLinus Torvalds 
14991da177e4SLinus Torvalds static inline void clear_tsk_need_resched(struct task_struct *tsk)
15001da177e4SLinus Torvalds {
15011da177e4SLinus Torvalds 	clear_tsk_thread_flag(tsk,TIF_NEED_RESCHED);
15021da177e4SLinus Torvalds }
15031da177e4SLinus Torvalds 
15041da177e4SLinus Torvalds static inline int signal_pending(struct task_struct *p)
15051da177e4SLinus Torvalds {
15061da177e4SLinus Torvalds 	return unlikely(test_tsk_thread_flag(p,TIF_SIGPENDING));
15071da177e4SLinus Torvalds }
15081da177e4SLinus Torvalds 
15091da177e4SLinus Torvalds static inline int need_resched(void)
15101da177e4SLinus Torvalds {
15111da177e4SLinus Torvalds 	return unlikely(test_thread_flag(TIF_NEED_RESCHED));
15121da177e4SLinus Torvalds }
15131da177e4SLinus Torvalds 
15141da177e4SLinus Torvalds /*
15151da177e4SLinus Torvalds  * cond_resched() and cond_resched_lock(): latency reduction via
15161da177e4SLinus Torvalds  * explicit rescheduling in places that are safe. The return
15171da177e4SLinus Torvalds  * value indicates whether a reschedule was done in fact.
15181da177e4SLinus Torvalds  * cond_resched_lock() will drop the spinlock before scheduling,
15191da177e4SLinus Torvalds  * cond_resched_softirq() will enable bhs before scheduling.
15201da177e4SLinus Torvalds  */
15211da177e4SLinus Torvalds extern int cond_resched(void);
15221da177e4SLinus Torvalds extern int cond_resched_lock(spinlock_t * lock);
15231da177e4SLinus Torvalds extern int cond_resched_softirq(void);
15241da177e4SLinus Torvalds 
15251da177e4SLinus Torvalds /*
15261da177e4SLinus Torvalds  * Does a critical section need to be broken due to another
15271da177e4SLinus Torvalds  * task waiting?:
15281da177e4SLinus Torvalds  */
15291da177e4SLinus Torvalds #if defined(CONFIG_PREEMPT) && defined(CONFIG_SMP)
15301da177e4SLinus Torvalds # define need_lockbreak(lock) ((lock)->break_lock)
15311da177e4SLinus Torvalds #else
15321da177e4SLinus Torvalds # define need_lockbreak(lock) 0
15331da177e4SLinus Torvalds #endif
15341da177e4SLinus Torvalds 
15351da177e4SLinus Torvalds /*
15361da177e4SLinus Torvalds  * Does a critical section need to be broken due to another
15371da177e4SLinus Torvalds  * task waiting or preemption being signalled:
15381da177e4SLinus Torvalds  */
15391da177e4SLinus Torvalds static inline int lock_need_resched(spinlock_t *lock)
15401da177e4SLinus Torvalds {
15411da177e4SLinus Torvalds 	if (need_lockbreak(lock) || need_resched())
15421da177e4SLinus Torvalds 		return 1;
15431da177e4SLinus Torvalds 	return 0;
15441da177e4SLinus Torvalds }
15451da177e4SLinus Torvalds 
15461da177e4SLinus Torvalds /* Reevaluate whether the task has signals pending delivery.
15471da177e4SLinus Torvalds    This is required every time the blocked sigset_t changes.
15481da177e4SLinus Torvalds    callers must hold sighand->siglock.  */
15491da177e4SLinus Torvalds 
15501da177e4SLinus Torvalds extern FASTCALL(void recalc_sigpending_tsk(struct task_struct *t));
15511da177e4SLinus Torvalds extern void recalc_sigpending(void);
15521da177e4SLinus Torvalds 
15531da177e4SLinus Torvalds extern void signal_wake_up(struct task_struct *t, int resume_stopped);
15541da177e4SLinus Torvalds 
15551da177e4SLinus Torvalds /*
15561da177e4SLinus Torvalds  * Wrappers for p->thread_info->cpu access. No-op on UP.
15571da177e4SLinus Torvalds  */
15581da177e4SLinus Torvalds #ifdef CONFIG_SMP
15591da177e4SLinus Torvalds 
15601da177e4SLinus Torvalds static inline unsigned int task_cpu(const struct task_struct *p)
15611da177e4SLinus Torvalds {
1562a1261f54SAl Viro 	return task_thread_info(p)->cpu;
15631da177e4SLinus Torvalds }
15641da177e4SLinus Torvalds 
15651da177e4SLinus Torvalds static inline void set_task_cpu(struct task_struct *p, unsigned int cpu)
15661da177e4SLinus Torvalds {
1567a1261f54SAl Viro 	task_thread_info(p)->cpu = cpu;
15681da177e4SLinus Torvalds }
15691da177e4SLinus Torvalds 
15701da177e4SLinus Torvalds #else
15711da177e4SLinus Torvalds 
15721da177e4SLinus Torvalds static inline unsigned int task_cpu(const struct task_struct *p)
15731da177e4SLinus Torvalds {
15741da177e4SLinus Torvalds 	return 0;
15751da177e4SLinus Torvalds }
15761da177e4SLinus Torvalds 
15771da177e4SLinus Torvalds static inline void set_task_cpu(struct task_struct *p, unsigned int cpu)
15781da177e4SLinus Torvalds {
15791da177e4SLinus Torvalds }
15801da177e4SLinus Torvalds 
15811da177e4SLinus Torvalds #endif /* CONFIG_SMP */
15821da177e4SLinus Torvalds 
15831da177e4SLinus Torvalds #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
15841da177e4SLinus Torvalds extern void arch_pick_mmap_layout(struct mm_struct *mm);
15851da177e4SLinus Torvalds #else
15861da177e4SLinus Torvalds static inline void arch_pick_mmap_layout(struct mm_struct *mm)
15871da177e4SLinus Torvalds {
15881da177e4SLinus Torvalds 	mm->mmap_base = TASK_UNMAPPED_BASE;
15891da177e4SLinus Torvalds 	mm->get_unmapped_area = arch_get_unmapped_area;
15901da177e4SLinus Torvalds 	mm->unmap_area = arch_unmap_area;
15911da177e4SLinus Torvalds }
15921da177e4SLinus Torvalds #endif
15931da177e4SLinus Torvalds 
15941da177e4SLinus Torvalds extern long sched_setaffinity(pid_t pid, cpumask_t new_mask);
15951da177e4SLinus Torvalds extern long sched_getaffinity(pid_t pid, cpumask_t *mask);
15961da177e4SLinus Torvalds 
15975c45bf27SSiddha, Suresh B #include <linux/sysdev.h>
15985c45bf27SSiddha, Suresh B extern int sched_mc_power_savings, sched_smt_power_savings;
15995c45bf27SSiddha, Suresh B extern struct sysdev_attribute attr_sched_mc_power_savings, attr_sched_smt_power_savings;
16005c45bf27SSiddha, Suresh B extern int sched_create_sysfs_power_savings_entries(struct sysdev_class *cls);
16015c45bf27SSiddha, Suresh B 
16021da177e4SLinus Torvalds extern void normalize_rt_tasks(void);
16031da177e4SLinus Torvalds 
16041da177e4SLinus Torvalds #ifdef CONFIG_PM
16053e1d1d28SChristoph Lameter /*
16063e1d1d28SChristoph Lameter  * Check if a process has been frozen
16073e1d1d28SChristoph Lameter  */
16083e1d1d28SChristoph Lameter static inline int frozen(struct task_struct *p)
16093e1d1d28SChristoph Lameter {
16103e1d1d28SChristoph Lameter 	return p->flags & PF_FROZEN;
16113e1d1d28SChristoph Lameter }
16123e1d1d28SChristoph Lameter 
16133e1d1d28SChristoph Lameter /*
16143e1d1d28SChristoph Lameter  * Check if there is a request to freeze a process
16153e1d1d28SChristoph Lameter  */
16163e1d1d28SChristoph Lameter static inline int freezing(struct task_struct *p)
16173e1d1d28SChristoph Lameter {
16183e1d1d28SChristoph Lameter 	return p->flags & PF_FREEZE;
16193e1d1d28SChristoph Lameter }
16203e1d1d28SChristoph Lameter 
16213e1d1d28SChristoph Lameter /*
16223e1d1d28SChristoph Lameter  * Request that a process be frozen
16233e1d1d28SChristoph Lameter  * FIXME: SMP problem. We may not modify other process' flags!
16243e1d1d28SChristoph Lameter  */
16253e1d1d28SChristoph Lameter static inline void freeze(struct task_struct *p)
16263e1d1d28SChristoph Lameter {
16273e1d1d28SChristoph Lameter 	p->flags |= PF_FREEZE;
16283e1d1d28SChristoph Lameter }
16293e1d1d28SChristoph Lameter 
16303e1d1d28SChristoph Lameter /*
1631a7ef7878SRafael J. Wysocki  * Sometimes we may need to cancel the previous 'freeze' request
1632a7ef7878SRafael J. Wysocki  */
1633a7ef7878SRafael J. Wysocki static inline void do_not_freeze(struct task_struct *p)
1634a7ef7878SRafael J. Wysocki {
1635a7ef7878SRafael J. Wysocki 	p->flags &= ~PF_FREEZE;
1636a7ef7878SRafael J. Wysocki }
1637a7ef7878SRafael J. Wysocki 
1638a7ef7878SRafael J. Wysocki /*
16393e1d1d28SChristoph Lameter  * Wake up a frozen process
16403e1d1d28SChristoph Lameter  */
16413e1d1d28SChristoph Lameter static inline int thaw_process(struct task_struct *p)
16423e1d1d28SChristoph Lameter {
16433e1d1d28SChristoph Lameter 	if (frozen(p)) {
16443e1d1d28SChristoph Lameter 		p->flags &= ~PF_FROZEN;
16453e1d1d28SChristoph Lameter 		wake_up_process(p);
16463e1d1d28SChristoph Lameter 		return 1;
16473e1d1d28SChristoph Lameter 	}
16483e1d1d28SChristoph Lameter 	return 0;
16493e1d1d28SChristoph Lameter }
16503e1d1d28SChristoph Lameter 
16513e1d1d28SChristoph Lameter /*
16523e1d1d28SChristoph Lameter  * freezing is complete, mark process as frozen
16533e1d1d28SChristoph Lameter  */
16543e1d1d28SChristoph Lameter static inline void frozen_process(struct task_struct *p)
16553e1d1d28SChristoph Lameter {
16563e1d1d28SChristoph Lameter 	p->flags = (p->flags & ~PF_FREEZE) | PF_FROZEN;
16573e1d1d28SChristoph Lameter }
16583e1d1d28SChristoph Lameter 
16593e1d1d28SChristoph Lameter extern void refrigerator(void);
16601da177e4SLinus Torvalds extern int freeze_processes(void);
16611da177e4SLinus Torvalds extern void thaw_processes(void);
16621da177e4SLinus Torvalds 
16633e1d1d28SChristoph Lameter static inline int try_to_freeze(void)
16641da177e4SLinus Torvalds {
16653e1d1d28SChristoph Lameter 	if (freezing(current)) {
16663e1d1d28SChristoph Lameter 		refrigerator();
16671da177e4SLinus Torvalds 		return 1;
16681da177e4SLinus Torvalds 	} else
16691da177e4SLinus Torvalds 		return 0;
16701da177e4SLinus Torvalds }
16711da177e4SLinus Torvalds #else
16723e1d1d28SChristoph Lameter static inline int frozen(struct task_struct *p) { return 0; }
16733e1d1d28SChristoph Lameter static inline int freezing(struct task_struct *p) { return 0; }
16743e1d1d28SChristoph Lameter static inline void freeze(struct task_struct *p) { BUG(); }
16753e1d1d28SChristoph Lameter static inline int thaw_process(struct task_struct *p) { return 1; }
16763e1d1d28SChristoph Lameter static inline void frozen_process(struct task_struct *p) { BUG(); }
16773e1d1d28SChristoph Lameter 
16783e1d1d28SChristoph Lameter static inline void refrigerator(void) {}
16791da177e4SLinus Torvalds static inline int freeze_processes(void) { BUG(); return 0; }
16801da177e4SLinus Torvalds static inline void thaw_processes(void) {}
16811da177e4SLinus Torvalds 
16823e1d1d28SChristoph Lameter static inline int try_to_freeze(void) { return 0; }
16833e1d1d28SChristoph Lameter 
16841da177e4SLinus Torvalds #endif /* CONFIG_PM */
16851da177e4SLinus Torvalds #endif /* __KERNEL__ */
16861da177e4SLinus Torvalds 
16871da177e4SLinus Torvalds #endif
1688