sched.h 60.4 KB
Newer Older
Linus Torvalds's avatar
Linus Torvalds committed
1 2 3
#ifndef _LINUX_SCHED_H
#define _LINUX_SCHED_H

4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
/*
 * cloning flags:
 */
#define CSIGNAL		0x000000ff	/* signal mask to be sent at exit */
#define CLONE_VM	0x00000100	/* set if VM shared between processes */
#define CLONE_FS	0x00000200	/* set if fs info shared between processes */
#define CLONE_FILES	0x00000400	/* set if open files shared between processes */
#define CLONE_SIGHAND	0x00000800	/* set if signal handlers and blocked signals shared */
#define CLONE_PTRACE	0x00002000	/* set if we want to let tracing continue on the child too */
#define CLONE_VFORK	0x00004000	/* set if the parent wants the child to wake it up on mm_release */
#define CLONE_PARENT	0x00008000	/* set if we want to have the same parent as the cloner */
#define CLONE_THREAD	0x00010000	/* Same thread group? */
#define CLONE_NEWNS	0x00020000	/* New namespace group? */
#define CLONE_SYSVSEM	0x00040000	/* share system V SEM_UNDO semantics */
#define CLONE_SETTLS	0x00080000	/* create a new TLS for the child */
#define CLONE_PARENT_SETTID	0x00100000	/* set the TID in the parent */
#define CLONE_CHILD_CLEARTID	0x00200000	/* clear the TID in the child */
#define CLONE_DETACHED		0x00400000	/* Unused, ignored */
#define CLONE_UNTRACED		0x00800000	/* set if the tracing process can't force CLONE_PTRACE on this clone */
#define CLONE_CHILD_SETTID	0x01000000	/* set the TID in the child */
#define CLONE_STOPPED		0x02000000	/* Start in stopped state */
25
#define CLONE_NEWUTS		0x04000000	/* New utsname group? */
Kirill Korotaev's avatar
Kirill Korotaev committed
26
#define CLONE_NEWIPC		0x08000000	/* New ipcs */
Serge E. Hallyn's avatar
Serge E. Hallyn committed
27
#define CLONE_NEWUSER		0x10000000	/* New user namespace */
28
#define CLONE_NEWPID		0x20000000	/* New pid namespace */
29
#define CLONE_NEWNET		0x40000000	/* New network namespace */
30 31 32 33 34 35 36 37

/*
 * Scheduling policies
 */
#define SCHED_NORMAL		0
#define SCHED_FIFO		1
#define SCHED_RR		2
#define SCHED_BATCH		3
Ingo Molnar's avatar
Ingo Molnar committed
38 39
/* SCHED_ISO: reserved but not implemented yet */
#define SCHED_IDLE		5
40

41
#ifdef __KERNEL__
42 43 44 45 46

struct sched_param {
	int sched_priority;
};

Linus Torvalds's avatar
Linus Torvalds committed
47 48 49 50 51 52 53 54 55 56 57 58 59
#include <asm/param.h>	/* for HZ */

#include <linux/capability.h>
#include <linux/threads.h>
#include <linux/kernel.h>
#include <linux/types.h>
#include <linux/timex.h>
#include <linux/jiffies.h>
#include <linux/rbtree.h>
#include <linux/thread_info.h>
#include <linux/cpumask.h>
#include <linux/errno.h>
#include <linux/nodemask.h>
60
#include <linux/mm_types.h>
Linus Torvalds's avatar
Linus Torvalds committed
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77

#include <asm/system.h>
#include <asm/semaphore.h>
#include <asm/page.h>
#include <asm/ptrace.h>
#include <asm/cputime.h>

#include <linux/smp.h>
#include <linux/sem.h>
#include <linux/signal.h>
#include <linux/securebits.h>
#include <linux/fs_struct.h>
#include <linux/compiler.h>
#include <linux/completion.h>
#include <linux/pid.h>
#include <linux/percpu.h>
#include <linux/topology.h>
Peter Zijlstra's avatar
Peter Zijlstra committed
78
#include <linux/proportions.h>
Linus Torvalds's avatar
Linus Torvalds committed
79
#include <linux/seccomp.h>
Ingo Molnar's avatar
Ingo Molnar committed
80
#include <linux/rcupdate.h>
81
#include <linux/futex.h>
Ingo Molnar's avatar
Ingo Molnar committed
82
#include <linux/rtmutex.h>
Linus Torvalds's avatar
Linus Torvalds committed
83

84 85 86 87 88
#include <linux/time.h>
#include <linux/param.h>
#include <linux/resource.h>
#include <linux/timer.h>
#include <linux/hrtimer.h>
89
#include <linux/task_io_accounting.h>
90
#include <linux/kobject.h>
Arjan van de Ven's avatar
Arjan van de Ven committed
91
#include <linux/latencytop.h>
92 93

#include <asm/processor.h>
H. J. Lu's avatar
H. J. Lu committed
94

Linus Torvalds's avatar
Linus Torvalds committed
95
struct exec_domain;
96
struct futex_pi_state;
97
struct bio;
Linus Torvalds's avatar
Linus Torvalds committed
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118

/*
 * List of flags we want to share for kernel threads,
 * if only because they are not used by them anyway.
 */
#define CLONE_KERNEL	(CLONE_FS | CLONE_FILES | CLONE_SIGHAND)

/*
 * These are the constant used to fake the fixed-point load-average
 * counting. Some notes:
 *  - 11 bit fractions expand to 22 bits by the multiplies: this gives
 *    a load-average precision of 10 bits integer + 11 bits fractional
 *  - if you want to count load-averages more often, you need more
 *    precision, or rounding will get you. With 2-second counting freq,
 *    the EXP_n values would be 1981, 2034 and 2043 if still using only
 *    11 bit fractions.
 */
extern unsigned long avenrun[];		/* Load averages */

#define FSHIFT		11		/* nr of bits of precision */
#define FIXED_1		(1<<FSHIFT)	/* 1.0 as fixed-point */
119
#define LOAD_FREQ	(5*HZ+1)	/* 5 sec intervals */
Linus Torvalds's avatar
Linus Torvalds committed
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134
#define EXP_1		1884		/* 1/exp(5sec/1min) as fixed-point */
#define EXP_5		2014		/* 1/exp(5sec/5min) */
#define EXP_15		2037		/* 1/exp(5sec/15min) */

#define CALC_LOAD(load,exp,n) \
	load *= exp; \
	load += n*(FIXED_1-exp); \
	load >>= FSHIFT;

extern unsigned long total_forks;
extern int nr_threads;
DECLARE_PER_CPU(unsigned long, process_counts);
extern int nr_processes(void);
extern unsigned long nr_running(void);
extern unsigned long nr_uninterruptible(void);
135
extern unsigned long nr_active(void);
Linus Torvalds's avatar
Linus Torvalds committed
136
extern unsigned long nr_iowait(void);
137
extern unsigned long weighted_cpuload(const int cpu);
Linus Torvalds's avatar
Linus Torvalds committed
138

Ingo Molnar's avatar
Ingo Molnar committed
139 140
struct seq_file;
struct cfs_rq;
141
struct task_group;
Ingo Molnar's avatar
Ingo Molnar committed
142 143 144 145
#ifdef CONFIG_SCHED_DEBUG
extern void proc_sched_show_task(struct task_struct *p, struct seq_file *m);
extern void proc_sched_set_task(struct task_struct *p);
extern void
146
print_cfs_rq(struct seq_file *m, int cpu, struct cfs_rq *cfs_rq);
Ingo Molnar's avatar
Ingo Molnar committed
147 148 149 150 151 152 153 154 155
#else
static inline void
proc_sched_show_task(struct task_struct *p, struct seq_file *m)
{
}
static inline void proc_sched_set_task(struct task_struct *p)
{
}
static inline void
156
print_cfs_rq(struct seq_file *m, int cpu, struct cfs_rq *cfs_rq)
Ingo Molnar's avatar
Ingo Molnar committed
157 158 159
{
}
#endif
Linus Torvalds's avatar
Linus Torvalds committed
160

161 162 163 164 165 166 167 168 169 170
/*
 * Task state bitmask. NOTE! These bits are also
 * encoded in fs/proc/array.c: get_task_state().
 *
 * We have two separate sets of flags: task->state
 * is about runnability, while task->exit_state are
 * about the task exiting. Confusing, but this way
 * modifying one set can't modify the other one by
 * mistake.
 */
Linus Torvalds's avatar
Linus Torvalds committed
171 172 173
#define TASK_RUNNING		0
#define TASK_INTERRUPTIBLE	1
#define TASK_UNINTERRUPTIBLE	2
174 175 176 177 178 179
#define TASK_STOPPED		4
#define TASK_TRACED		8
/* in tsk->exit_state */
#define EXIT_ZOMBIE		16
#define EXIT_DEAD		32
/* in tsk->state again */
180
#define TASK_DEAD		64
Linus Torvalds's avatar
Linus Torvalds committed
181 182 183 184 185 186

#define __set_task_state(tsk, state_value)		\
	do { (tsk)->state = (state_value); } while (0)
#define set_task_state(tsk, state_value)		\
	set_mb((tsk)->state, (state_value))

187 188 189 190 191 192 193 194 195 196 197
/*
 * set_current_state() includes a barrier so that the write of current->state
 * is correctly serialised wrt the caller's subsequent test of whether to
 * actually sleep:
 *
 *	set_current_state(TASK_UNINTERRUPTIBLE);
 *	if (do_i_need_to_sleep())
 *		schedule();
 *
 * If the caller does not need such serialisation then use __set_current_state()
 */
Linus Torvalds's avatar
Linus Torvalds committed
198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216
#define __set_current_state(state_value)			\
	do { current->state = (state_value); } while (0)
#define set_current_state(state_value)		\
	set_mb(current->state, (state_value))

/* Task command name length */
#define TASK_COMM_LEN 16

#include <linux/spinlock.h>

/*
 * This serializes "schedule()" and also protects
 * the run-queue from deletions/modifications (but
 * _adding_ to the beginning of the run-queue has
 * a separate lock).
 */
extern rwlock_t tasklist_lock;
extern spinlock_t mmlist_lock;

217
struct task_struct;
Linus Torvalds's avatar
Linus Torvalds committed
218 219 220

extern void sched_init(void);
extern void sched_init_smp(void);
221
extern void init_idle(struct task_struct *idle, int cpu);
222
extern void init_idle_bootup_task(struct task_struct *idle);
Linus Torvalds's avatar
Linus Torvalds committed
223 224

extern cpumask_t nohz_cpu_mask;
225 226 227 228 229 230 231 232
#if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ)
extern int select_nohz_load_balancer(int cpu);
#else
static inline int select_nohz_load_balancer(int cpu)
{
	return 0;
}
#endif
Linus Torvalds's avatar
Linus Torvalds committed
233

Peter Zijlstra's avatar
Peter Zijlstra committed
234 235
extern unsigned long rt_needs_cpu(int cpu);

236
/*
237
 * Only dump TASK_* tasks. (0 for all tasks)
238 239 240 241 242
 */
extern void show_state_filter(unsigned long state_filter);

static inline void show_state(void)
{
243
	show_state_filter(0);
244 245
}

Linus Torvalds's avatar
Linus Torvalds committed
246 247 248 249 250 251 252 253 254 255 256 257 258 259
extern void show_regs(struct pt_regs *);

/*
 * TASK is a pointer to the task whose backtrace we want to see (or NULL for current
 * task), SP is the stack pointer of the first frame that should be shown in the back
 * trace (or NULL if the entire call-chain of the task should be shown).
 */
extern void show_stack(struct task_struct *task, unsigned long *sp);

void io_schedule(void);
long io_schedule_timeout(long timeout);

extern void cpu_init (void);
extern void trap_init(void);
260
extern void account_process_tick(struct task_struct *task, int user);
Linus Torvalds's avatar
Linus Torvalds committed
261 262
extern void update_process_times(int user);
extern void scheduler_tick(void);
263
extern void hrtick_resched(void);
Linus Torvalds's avatar
Linus Torvalds committed
264

265 266
extern void sched_show_task(struct task_struct *p);

Ingo Molnar's avatar
Ingo Molnar committed
267
#ifdef CONFIG_DETECT_SOFTLOCKUP
268
extern void softlockup_tick(void);
Ingo Molnar's avatar
Ingo Molnar committed
269 270
extern void spawn_softlockup_task(void);
extern void touch_softlockup_watchdog(void);
271
extern void touch_all_softlockup_watchdogs(void);
Ingo Molnar's avatar
Ingo Molnar committed
272
extern unsigned long  softlockup_thresh;
273 274
extern unsigned long sysctl_hung_task_check_count;
extern unsigned long sysctl_hung_task_timeout_secs;
Ingo Molnar's avatar
Ingo Molnar committed
275
extern unsigned long sysctl_hung_task_warnings;
Ingo Molnar's avatar
Ingo Molnar committed
276
#else
277
static inline void softlockup_tick(void)
Ingo Molnar's avatar
Ingo Molnar committed
278 279 280 281 282 283 284 285
{
}
static inline void spawn_softlockup_task(void)
{
}
static inline void touch_softlockup_watchdog(void)
{
}
286 287 288
static inline void touch_all_softlockup_watchdogs(void)
{
}
Ingo Molnar's avatar
Ingo Molnar committed
289 290 291
#endif


Linus Torvalds's avatar
Linus Torvalds committed
292 293
/* Attach to any functions which should be ignored in wchan output. */
#define __sched		__attribute__((__section__(".sched.text")))
294 295 296 297

/* Linker adds these: start and end of __sched functions */
extern char __sched_text_start[], __sched_text_end[];

Linus Torvalds's avatar
Linus Torvalds committed
298 299 300 301 302
/* Is this address in the __sched functions? */
extern int in_sched_functions(unsigned long addr);

#define	MAX_SCHEDULE_TIMEOUT	LONG_MAX
extern signed long FASTCALL(schedule_timeout(signed long timeout));
303 304
extern signed long schedule_timeout_interruptible(signed long timeout);
extern signed long schedule_timeout_uninterruptible(signed long timeout);
Linus Torvalds's avatar
Linus Torvalds committed
305 306
asmlinkage void schedule(void);

307
struct nsproxy;
308
struct user_namespace;
Linus Torvalds's avatar
Linus Torvalds committed
309 310 311 312 313 314 315 316 317 318 319 320 321 322 323

/* Maximum number of active map areas.. This is a random (large) number */
#define DEFAULT_MAX_MAP_COUNT	65536

extern int sysctl_max_map_count;

#include <linux/aio.h>

extern unsigned long
arch_get_unmapped_area(struct file *, unsigned long, unsigned long,
		       unsigned long, unsigned long);
extern unsigned long
arch_get_unmapped_area_topdown(struct file *filp, unsigned long addr,
			  unsigned long len, unsigned long pgoff,
			  unsigned long flags);
324 325
extern void arch_unmap_area(struct mm_struct *, unsigned long);
extern void arch_unmap_area_topdown(struct mm_struct *, unsigned long);
Linus Torvalds's avatar
Linus Torvalds committed
326

327 328 329 330 331
#if NR_CPUS >= CONFIG_SPLIT_PTLOCK_CPUS
/*
 * The mm counters are not protected by its page_table_lock,
 * so must be incremented atomically.
 */
332 333 334 335 336
#define set_mm_counter(mm, member, value) atomic_long_set(&(mm)->_##member, value)
#define get_mm_counter(mm, member) ((unsigned long)atomic_long_read(&(mm)->_##member))
#define add_mm_counter(mm, member, value) atomic_long_add(value, &(mm)->_##member)
#define inc_mm_counter(mm, member) atomic_long_inc(&(mm)->_##member)
#define dec_mm_counter(mm, member) atomic_long_dec(&(mm)->_##member)
337 338 339 340 341 342

#else  /* NR_CPUS < CONFIG_SPLIT_PTLOCK_CPUS */
/*
 * The mm counters are protected by its page_table_lock,
 * so can be incremented directly.
 */
Linus Torvalds's avatar
Linus Torvalds committed
343 344 345 346 347
#define set_mm_counter(mm, member, value) (mm)->_##member = (value)
#define get_mm_counter(mm, member) ((mm)->_##member)
#define add_mm_counter(mm, member, value) (mm)->_##member += (value)
#define inc_mm_counter(mm, member) (mm)->_##member++
#define dec_mm_counter(mm, member) (mm)->_##member--
348 349

#endif /* NR_CPUS < CONFIG_SPLIT_PTLOCK_CPUS */
350

351 352
#define get_mm_rss(mm)					\
	(get_mm_counter(mm, file_rss) + get_mm_counter(mm, anon_rss))
353 354 355 356 357 358 359 360 361 362
#define update_hiwater_rss(mm)	do {			\
	unsigned long _rss = get_mm_rss(mm);		\
	if ((mm)->hiwater_rss < _rss)			\
		(mm)->hiwater_rss = _rss;		\
} while (0)
#define update_hiwater_vm(mm)	do {			\
	if ((mm)->hiwater_vm < (mm)->total_vm)		\
		(mm)->hiwater_vm = (mm)->total_vm;	\
} while (0)

363 364 365 366
extern void set_dumpable(struct mm_struct *mm, int value);
extern int get_dumpable(struct mm_struct *mm);

/* mm flags */
367
/* dumpable bits */
368 369
#define MMF_DUMPABLE      0  /* core dump is permitted */
#define MMF_DUMP_SECURELY 1  /* core file is readable only by root */
370 371 372 373 374 375 376
#define MMF_DUMPABLE_BITS 2

/* coredump filter bits */
#define MMF_DUMP_ANON_PRIVATE	2
#define MMF_DUMP_ANON_SHARED	3
#define MMF_DUMP_MAPPED_PRIVATE	4
#define MMF_DUMP_MAPPED_SHARED	5
Roland McGrath's avatar
Roland McGrath committed
377
#define MMF_DUMP_ELF_HEADERS	6
378
#define MMF_DUMP_FILTER_SHIFT	MMF_DUMPABLE_BITS
Roland McGrath's avatar
Roland McGrath committed
379
#define MMF_DUMP_FILTER_BITS	5
380 381 382 383
#define MMF_DUMP_FILTER_MASK \
	(((1 << MMF_DUMP_FILTER_BITS) - 1) << MMF_DUMP_FILTER_SHIFT)
#define MMF_DUMP_FILTER_DEFAULT \
	((1 << MMF_DUMP_ANON_PRIVATE) |	(1 << MMF_DUMP_ANON_SHARED))
384

Linus Torvalds's avatar
Linus Torvalds committed
385 386 387 388
struct sighand_struct {
	atomic_t		count;
	struct k_sigaction	action[_NSIG];
	spinlock_t		siglock;
Davide Libenzi's avatar
Davide Libenzi committed
389
	wait_queue_head_t	signalfd_wqh;
Linus Torvalds's avatar
Linus Torvalds committed
390 391
};

392
struct pacct_struct {
393 394
	int			ac_flag;
	long			ac_exitcode;
395
	unsigned long		ac_mem;
396 397
	cputime_t		ac_utime, ac_stime;
	unsigned long		ac_minflt, ac_majflt;
398 399
};

Linus Torvalds's avatar
Linus Torvalds committed
400 401 402 403 404 405 406 407 408 409 410 411 412 413
/*
 * NOTE! "signal_struct" does not have it's own
 * locking, because a shared signal_struct always
 * implies a shared sighand_struct, so locking
 * sighand_struct is always a proper superset of
 * the locking of signal_struct.
 */
struct signal_struct {
	atomic_t		count;
	atomic_t		live;

	wait_queue_head_t	wait_chldexit;	/* for wait4() */

	/* current thread group signal load-balancing target: */
414
	struct task_struct	*curr_target;
Linus Torvalds's avatar
Linus Torvalds committed
415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436

	/* shared signal handling: */
	struct sigpending	shared_pending;

	/* thread group exit support */
	int			group_exit_code;
	/* overloaded:
	 * - notify group_exit_task when ->count is equal to notify_count
	 * - everyone except group_exit_task is stopped during signal delivery
	 *   of fatal signals, group_exit_task processes the signal.
	 */
	struct task_struct	*group_exit_task;
	int			notify_count;

	/* thread group stop support, overloads group_exit_code too */
	int			group_stop_count;
	unsigned int		flags; /* see SIGNAL_* flags below */

	/* POSIX.1b Interval Timers */
	struct list_head posix_timers;

	/* ITIMER_REAL timer for the process */
437
	struct hrtimer real_timer;
438
	struct task_struct *tsk;
439
	ktime_t it_real_incr;
Linus Torvalds's avatar
Linus Torvalds committed
440 441 442 443 444 445

	/* ITIMER_PROF and ITIMER_VIRTUAL timers for the process */
	cputime_t it_prof_expires, it_virt_expires;
	cputime_t it_prof_incr, it_virt_incr;

	/* job control IDs */
446 447 448 449 450 451 452 453 454 455 456

	/*
	 * pgrp and session fields are deprecated.
	 * use the task_session_Xnr and task_pgrp_Xnr routines below
	 */

	union {
		pid_t pgrp __deprecated;
		pid_t __pgrp;
	};

457
	struct pid *tty_old_pgrp;
458 459 460 461 462 463

	union {
		pid_t session __deprecated;
		pid_t __session;
	};

Linus Torvalds's avatar
Linus Torvalds committed
464 465 466 467 468 469 470 471 472 473 474 475
	/* boolean value for session group leader */
	int leader;

	struct tty_struct *tty; /* NULL if no tty */

	/*
	 * Cumulative resource counters for dead threads in the group,
	 * and for reaped dead child processes forked by this group.
	 * Live threads maintain their own counters and add to these
	 * in __exit_signal, except for the group leader.
	 */
	cputime_t utime, stime, cutime, cstime;
476 477
	cputime_t gtime;
	cputime_t cgtime;
Linus Torvalds's avatar
Linus Torvalds committed
478 479
	unsigned long nvcsw, nivcsw, cnvcsw, cnivcsw;
	unsigned long min_flt, maj_flt, cmin_flt, cmaj_flt;
480
	unsigned long inblock, oublock, cinblock, coublock;
Linus Torvalds's avatar
Linus Torvalds committed
481 482 483 484 485 486 487

	/*
	 * Cumulative ns of scheduled CPU time for dead threads in the
	 * group, not including a zombie group leader.  (This only differs
	 * from jiffies_to_ns(utime + stime) if sched_clock uses something
	 * other than jiffies.)
	 */
488
	unsigned long long sum_sched_runtime;
Linus Torvalds's avatar
Linus Torvalds committed
489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508

	/*
	 * We don't bother to synchronize most readers of this at all,
	 * because there is no reader checking a limit that actually needs
	 * to get both rlim_cur and rlim_max atomically, and either one
	 * alone is a single word that can safely be read normally.
	 * getrlimit/setrlimit use task_lock(current->group_leader) to
	 * protect this instead of the siglock, because they really
	 * have no need to disable irqs.
	 */
	struct rlimit rlim[RLIM_NLIMITS];

	struct list_head cpu_timers[3];

	/* keep the process-shared keyrings here so that they do the right
	 * thing in threads created with CLONE_THREAD */
#ifdef CONFIG_KEYS
	struct key *session_keyring;	/* keyring inherited over fork */
	struct key *process_keyring;	/* keyring private to this process */
#endif
509 510 511
#ifdef CONFIG_BSD_PROCESS_ACCT
	struct pacct_struct pacct;	/* per-process accounting information */
#endif
512 513 514
#ifdef CONFIG_TASKSTATS
	struct taskstats *stats;
#endif
Miloslav Trmac's avatar
Miloslav Trmac committed
515 516 517 518
#ifdef CONFIG_AUDIT
	unsigned audit_tty;
	struct tty_audit_buf *tty_audit_buf;
#endif
Linus Torvalds's avatar
Linus Torvalds committed
519 520
};

521 522 523 524 525
/* Context switch must be unlocked if interrupts are to be enabled */
#ifdef __ARCH_WANT_INTERRUPTS_ON_CTXSW
# define __ARCH_WANT_UNLOCKED_CTXSW
#endif

Linus Torvalds's avatar
Linus Torvalds committed
526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541
/*
 * Bits in flags field of signal_struct.
 */
#define SIGNAL_STOP_STOPPED	0x00000001 /* job control stop in effect */
#define SIGNAL_STOP_DEQUEUED	0x00000002 /* stop signal dequeued */
#define SIGNAL_STOP_CONTINUED	0x00000004 /* SIGCONT since WCONTINUED reap */
#define SIGNAL_GROUP_EXIT	0x00000008 /* group exit in progress */

/*
 * Some day this will be a full-fledged user tracking system..
 */
struct user_struct {
	atomic_t __count;	/* reference count */
	atomic_t processes;	/* How many processes does this user have? */
	atomic_t files;		/* How many open files does this user have? */
	atomic_t sigpending;	/* How many pending signals does this user have? */
542
#ifdef CONFIG_INOTIFY_USER
Robert Love's avatar
Robert Love committed
543 544 545
	atomic_t inotify_watches; /* How many inotify watches does this user have? */
	atomic_t inotify_devs;	/* How many inotify devs does this user have opened? */
#endif
Alexey Dobriyan's avatar
Alexey Dobriyan committed
546
#ifdef CONFIG_POSIX_MQUEUE
Linus Torvalds's avatar
Linus Torvalds committed
547 548
	/* protected by mq_lock	*/
	unsigned long mq_bytes;	/* How many bytes can be allocated to mqueue? */
Alexey Dobriyan's avatar
Alexey Dobriyan committed
549
#endif
Linus Torvalds's avatar
Linus Torvalds committed
550 551 552 553 554 555 556 557
	unsigned long locked_shm; /* How many pages of mlocked shm ? */

#ifdef CONFIG_KEYS
	struct key *uid_keyring;	/* UID specific keyring */
	struct key *session_keyring;	/* UID's default session keyring */
#endif

	/* Hash table maintenance information */
Pavel Emelyanov's avatar
Pavel Emelyanov committed
558
	struct hlist_node uidhash_node;
Linus Torvalds's avatar
Linus Torvalds committed
559
	uid_t uid;
560 561

#ifdef CONFIG_FAIR_USER_SCHED
562
	struct task_group *tg;
563
#ifdef CONFIG_SYSFS
564
	struct kobject kobj;
565
	struct work_struct work;
566
#endif
567
#endif
Linus Torvalds's avatar
Linus Torvalds committed
568 569
};

570
extern int uids_sysfs_init(void);
571

Linus Torvalds's avatar
Linus Torvalds committed
572 573 574 575 576 577 578 579
extern struct user_struct *find_user(uid_t);

extern struct user_struct root_user;
#define INIT_USER (&root_user)

struct backing_dev_info;
struct reclaim_state;

580
#if defined(CONFIG_SCHEDSTATS) || defined(CONFIG_TASK_DELAY_ACCT)
Linus Torvalds's avatar
Linus Torvalds committed
581 582
struct sched_info {
	/* cumulative counters */
583
	unsigned long pcount;	      /* # of times run on this cpu */
584 585
	unsigned long long cpu_time,  /* time spent on the cpu */
			   run_delay; /* time spent waiting on a runqueue */
Linus Torvalds's avatar
Linus Torvalds committed
586 587

	/* timestamps */
588 589
	unsigned long long last_arrival,/* when we last ran on a cpu */
			   last_queued;	/* when we were last queued to run */
590 591
#ifdef CONFIG_SCHEDSTATS
	/* BKL stats */
592
	unsigned int bkl_count;
593
#endif
Linus Torvalds's avatar
Linus Torvalds committed
594
};
595
#endif /* defined(CONFIG_SCHEDSTATS) || defined(CONFIG_TASK_DELAY_ACCT) */
Linus Torvalds's avatar
Linus Torvalds committed
596

597
#ifdef CONFIG_SCHEDSTATS
598
extern const struct file_operations proc_schedstat_operations;
599
#endif /* CONFIG_SCHEDSTATS */
Linus Torvalds's avatar
Linus Torvalds committed
600

601 602 603 604 605 606 607 608 609 610 611 612 613 614
#ifdef CONFIG_TASK_DELAY_ACCT
struct task_delay_info {
	spinlock_t	lock;
	unsigned int	flags;	/* Private per-task flags */

	/* For each stat XXX, add following, aligned appropriately
	 *
	 * struct timespec XXX_start, XXX_end;
	 * u64 XXX_delay;
	 * u32 XXX_count;
	 *
	 * Atomicity of updates to XXX_delay, XXX_count protected by
	 * single lock above (split into XXX_lock if contention is an issue).
	 */
615 616 617 618 619 620 621 622 623 624 625 626 627

	/*
	 * XXX_count is incremented on every XXX operation, the delay
	 * associated with the operation is added to XXX_delay.
	 * XXX_delay contains the accumulated delay time in nanoseconds.
	 */
	struct timespec blkio_start, blkio_end;	/* Shared by blkio, swapin */
	u64 blkio_delay;	/* wait for sync block io completion */
	u64 swapin_delay;	/* wait for swapin block io completion */
	u32 blkio_count;	/* total count of the number of sync block */
				/* io operations performed */
	u32 swapin_count;	/* total count of the number of swapin block */
				/* io operations performed */
628
};
629 630 631 632 633 634 635 636 637 638 639
#endif	/* CONFIG_TASK_DELAY_ACCT */

static inline int sched_info_on(void)
{
#ifdef CONFIG_SCHEDSTATS
	return 1;
#elif defined(CONFIG_TASK_DELAY_ACCT)
	extern int delayacct_on;
	return delayacct_on;
#else
	return 0;
640
#endif
641
}
642

643 644 645 646 647
enum cpu_idle_type {
	CPU_IDLE,
	CPU_NOT_IDLE,
	CPU_NEWLY_IDLE,
	CPU_MAX_IDLE_TYPES
Linus Torvalds's avatar
Linus Torvalds committed
648 649 650 651 652
};

/*
 * sched-domains (multiprocessor balancing) declarations:
 */
653 654 655 656 657 658 659

/*
 * Increase resolution of nice-level calculations:
 */
#define SCHED_LOAD_SHIFT	10
#define SCHED_LOAD_SCALE	(1L << SCHED_LOAD_SHIFT)

660
#define SCHED_LOAD_SCALE_FUZZ	SCHED_LOAD_SCALE
Linus Torvalds's avatar
Linus Torvalds committed
661

662
#ifdef CONFIG_SMP
Linus Torvalds's avatar
Linus Torvalds committed
663 664 665
#define SD_LOAD_BALANCE		1	/* Do load balancing on this domain. */
#define SD_BALANCE_NEWIDLE	2	/* Balance when about to become idle */
#define SD_BALANCE_EXEC		4	/* Balance on exec */
Nick Piggin's avatar
Nick Piggin committed
666 667 668 669 670
#define SD_BALANCE_FORK		8	/* Balance on fork, clone */
#define SD_WAKE_IDLE		16	/* Wake to idle CPU on task wakeup */
#define SD_WAKE_AFFINE		32	/* Wake task to waking CPU */
#define SD_WAKE_BALANCE		64	/* Perform balancing at task wakeup */
#define SD_SHARE_CPUPOWER	128	/* Domain members share cpu power */
671
#define SD_POWERSAVINGS_BALANCE	256	/* Balance for power savings */
672
#define SD_SHARE_PKG_RESOURCES	512	/* Domain members share cpu pkg resources */
673
#define SD_SERIALIZE		1024	/* Only a single load balancing instance */
674

675 676 677 678 679 680 681 682 683
#define BALANCE_FOR_MC_POWER	\
	(sched_smt_power_savings ? SD_POWERSAVINGS_BALANCE : 0)

#define BALANCE_FOR_PKG_POWER	\
	((sched_mc_power_savings || sched_smt_power_savings) ?	\
	 SD_POWERSAVINGS_BALANCE : 0)

#define test_sd_parent(sd, flag)	((sd->parent &&		\
					 (sd->parent->flags & flag)) ? 1 : 0)
684

Linus Torvalds's avatar
Linus Torvalds committed
685 686 687 688 689 690 691 692

struct sched_group {
	struct sched_group *next;	/* Must be a circular list */
	cpumask_t cpumask;

	/*
	 * CPU power of this group, SCHED_LOAD_SCALE being max power for a
	 * single CPU. This is read only (except for setup, hotplug CPU).
693
	 * Note : Never change cpu_power without recompute its reciprocal
Linus Torvalds's avatar
Linus Torvalds committed
694
	 */
695 696 697 698 699 700
	unsigned int __cpu_power;
	/*
	 * reciprocal value of cpu_power to avoid expensive divides
	 * (see include/linux/reciprocal_div.h)
	 */
	u32 reciprocal_cpu_power;
Linus Torvalds's avatar
Linus Torvalds committed
701 702 703 704 705
};

struct sched_domain {
	/* These fields must be setup */
	struct sched_domain *parent;	/* top domain must be null terminated */
706
	struct sched_domain *child;	/* bottom domain must be null terminated */
Linus Torvalds's avatar
Linus Torvalds committed
707 708 709 710 711 712 713
	struct sched_group *groups;	/* the balancing groups of the domain */
	cpumask_t span;			/* span of all CPUs in this domain */
	unsigned long min_interval;	/* Minimum balance interval ms */
	unsigned long max_interval;	/* Maximum balance interval ms */
	unsigned int busy_factor;	/* less balancing by factor if busy */
	unsigned int imbalance_pct;	/* No balance until over watermark */
	unsigned int cache_nice_tries;	/* Leave cache hot tasks for # tries */
Nick Piggin's avatar
Nick Piggin committed
714 715 716 717
	unsigned int busy_idx;
	unsigned int idle_idx;
	unsigned int newidle_idx;
	unsigned int wake_idx;
Nick Piggin's avatar
Nick Piggin committed
718
	unsigned int forkexec_idx;
Linus Torvalds's avatar
Linus Torvalds committed
719 720 721 722 723 724 725 726 727
	int flags;			/* See SD_* */

	/* Runtime fields. */
	unsigned long last_balance;	/* init to jiffies. units in jiffies */
	unsigned int balance_interval;	/* initialise to 1. units in ms. */
	unsigned int nr_balance_failed; /* initialise to 0 */

#ifdef CONFIG_SCHEDSTATS
	/* load_balance() stats */
728 729 730 731 732 733 734 735
	unsigned int lb_count[CPU_MAX_IDLE_TYPES];
	unsigned int lb_failed[CPU_MAX_IDLE_TYPES];
	unsigned int lb_balanced[CPU_MAX_IDLE_TYPES];
	unsigned int lb_imbalance[CPU_MAX_IDLE_TYPES];
	unsigned int lb_gained[CPU_MAX_IDLE_TYPES];
	unsigned int lb_hot_gained[CPU_MAX_IDLE_TYPES];
	unsigned int lb_nobusyg[CPU_MAX_IDLE_TYPES];
	unsigned int lb_nobusyq[CPU_MAX_IDLE_TYPES];
Linus Torvalds's avatar
Linus Torvalds committed
736 737

	/* Active load balancing */
738 739 740
	unsigned int alb_count;
	unsigned int alb_failed;
	unsigned int alb_pushed;
Linus Torvalds's avatar
Linus Torvalds committed
741

742
	/* SD_BALANCE_EXEC stats */
743 744 745
	unsigned int sbe_count;
	unsigned int sbe_balanced;
	unsigned int sbe_pushed;
Linus Torvalds's avatar
Linus Torvalds committed
746

747
	/* SD_BALANCE_FORK stats */
748 749 750
	unsigned int sbf_count;
	unsigned int sbf_balanced;
	unsigned int sbf_pushed;
751

Linus Torvalds's avatar
Linus Torvalds committed
752
	/* try_to_wake_up() stats */
753 754 755
	unsigned int ttwu_wake_remote;
	unsigned int ttwu_move_affine;
	unsigned int ttwu_move_balance;
Linus Torvalds's avatar
Linus Torvalds committed
756 757 758
#endif
};

Paul Jackson's avatar
Paul Jackson committed
759 760
extern void partition_sched_domains(int ndoms_new, cpumask_t *doms_new);

761
#endif	/* CONFIG_SMP */
Linus Torvalds's avatar
Linus Torvalds committed
762

763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778
/*
 * A runqueue laden with a single nice 0 task scores a weighted_cpuload of
 * SCHED_LOAD_SCALE. This function returns 1 if any cpu is laden with a
 * task of nice 0 or enough lower priority tasks to bring up the
 * weighted_cpuload
 */
static inline int above_background_load(void)
{
	unsigned long cpu;

	for_each_online_cpu(cpu) {
		if (weighted_cpuload(cpu) >= SCHED_LOAD_SCALE)
			return 1;
	}
	return 0;
}
Linus Torvalds's avatar
Linus Torvalds committed
779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805

struct io_context;			/* See blkdev.h */
#define NGROUPS_SMALL		32
#define NGROUPS_PER_BLOCK	((int)(PAGE_SIZE / sizeof(gid_t)))
struct group_info {
	int ngroups;
	atomic_t usage;
	gid_t small_block[NGROUPS_SMALL];
	int nblocks;
	gid_t *blocks[0];
};

/*
 * get_group_info() must be called with the owning task locked (via task_lock())
 * when task != current.  The reason being that the vast majority of callers are
 * looking at current->group_info, which can not be changed except by the
 * current task.  Changing current->group_info requires the task lock, too.
 */
#define get_group_info(group_info) do { \
	atomic_inc(&(group_info)->usage); \
} while (0)

#define put_group_info(group_info) do { \
	if (atomic_dec_and_test(&(group_info)->usage)) \
		groups_free(group_info); \
} while (0)

806 807 808 809
extern struct group_info *groups_alloc(int gidsetsize);
extern void groups_free(struct group_info *group_info);
extern int set_current_groups(struct group_info *group_info);
extern int groups_search(struct group_info *group_info, gid_t grp);
Linus Torvalds's avatar
Linus Torvalds committed
810 811 812 813
/* access the groups "array" with this macro */
#define GROUP_AT(gi, i) \
    ((gi)->blocks[(i)/NGROUPS_PER_BLOCK][(i)%NGROUPS_PER_BLOCK])

814
#ifdef ARCH_HAS_PREFETCH_SWITCH_STACK
815
extern void prefetch_stack(struct task_struct *t);
816 817 818
#else
static inline void prefetch_stack(struct task_struct *t) { }
#endif
Linus Torvalds's avatar
Linus Torvalds committed
819 820 821

struct audit_context;		/* See audit.c */
struct mempolicy;
822
struct pipe_inode_info;
823
struct uts_namespace;
Linus Torvalds's avatar
Linus Torvalds committed
824

Ingo Molnar's avatar
Ingo Molnar committed
825 826 827 828
struct rq;
struct sched_domain;

struct sched_class {
829
	const struct sched_class *next;
Ingo Molnar's avatar
Ingo Molnar committed
830

831
	void (*enqueue_task) (struct rq *rq, struct task_struct *p, int wakeup);
832
	void (*dequeue_task) (struct rq *rq, struct task_struct *p, int sleep);
833
	void (*yield_task) (struct rq *rq);
834
	int  (*select_task_rq)(struct task_struct *p, int sync);
Ingo Molnar's avatar
Ingo Molnar committed
835 836 837

	void (*check_preempt_curr) (struct rq *rq, struct task_struct *p);

838
	struct task_struct * (*pick_next_task) (struct rq *rq);
839
	void (*put_prev_task) (struct rq *rq, struct task_struct *p);
Ingo Molnar's avatar
Ingo Molnar committed
840

841
#ifdef CONFIG_SMP
Peter Williams's avatar
Peter Williams committed
842
	unsigned long (*load_balance) (struct rq *this_rq, int this_cpu,
843
			struct rq *busiest, unsigned long max_load_move,
Ingo Molnar's avatar
Ingo Molnar committed
844
			struct sched_domain *sd, enum cpu_idle_type idle,
845
			int *all_pinned, int *this_best_prio);
Ingo Molnar's avatar
Ingo Molnar committed
846

847 848 849
	int (*move_one_task) (struct rq *this_rq, int this_cpu,
			      struct rq *busiest, struct sched_domain *sd,
			      enum cpu_idle_type idle);
850 851 852
	void (*pre_schedule) (struct rq *this_rq, struct task_struct *task);
	void (*post_schedule) (struct rq *this_rq);
	void (*task_wake_up) (struct rq *this_rq, struct task_struct *task);
853
#endif
854

855
	void (*set_curr_task) (struct rq *rq);
856
	void (*task_tick) (struct rq *rq, struct task_struct *p, int queued);
857
	void (*task_new) (struct rq *rq, struct task_struct *p);
858
	void (*set_cpus_allowed)(struct task_struct *p, cpumask_t *newmask);
859 860 861

	void (*join_domain)(struct rq *rq);
	void (*leave_domain)(struct rq *rq);
862 863 864 865 866 867 868

	void (*switched_from) (struct rq *this_rq, struct task_struct *task,
			       int running);
	void (*switched_to) (struct rq *this_rq, struct task_struct *task,
			     int running);
	void (*prio_changed) (struct rq *this_rq, struct task_struct *task,
			     int oldprio, int running);
Ingo Molnar's avatar
Ingo Molnar committed
869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889
};

struct load_weight {
	unsigned long weight, inv_weight;
};

/*
 * CFS stats for a schedulable entity (task, task-group etc)
 *
 * Current field usage histogram:
 *
 *     4 se->block_start
 *     4 se->run_node
 *     4 se->sleep_start
 *     6 se->load.weight
 */
struct sched_entity {
	struct load_weight	load;		/* for load-balancing */
	struct rb_node		run_node;
	unsigned int		on_rq;

890 891
	u64			exec_start;
	u64			sum_exec_runtime;
Ingo Molnar's avatar
Ingo Molnar committed
892
	u64			vruntime;
893
	u64			prev_sum_exec_runtime;
894 895

#ifdef CONFIG_SCHEDSTATS
Ingo Molnar's avatar
Ingo Molnar committed
896
	u64			wait_start;
897 898
	u64			wait_max;

Ingo Molnar's avatar
Ingo Molnar committed
899 900
	u64			sleep_start;
	u64			sleep_max;
901 902 903
	s64			sum_sleep_runtime;

	u64			block_start;
Ingo Molnar's avatar
Ingo Molnar committed
904 905
	u64			block_max;
	u64			exec_max;
906
	u64			slice_max;
907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924

	u64			nr_migrations;
	u64			nr_migrations_cold;
	u64			nr_failed_migrations_affine;
	u64			nr_failed_migrations_running;
	u64			nr_failed_migrations_hot;
	u64			nr_forced_migrations;
	u64			nr_forced2_migrations;

	u64			nr_wakeups;
	u64			nr_wakeups_sync;
	u64			nr_wakeups_migrate;
	u64			nr_wakeups_local;
	u64			nr_wakeups_remote;
	u64			nr_wakeups_affine;
	u64			nr_wakeups_affine_attempts;
	u64			nr_wakeups_passive;
	u64			nr_wakeups_idle;
925 926
#endif

Ingo Molnar's avatar
Ingo Molnar committed
927 928 929 930 931 932 933 934
#ifdef CONFIG_FAIR_GROUP_SCHED
	struct sched_entity	*parent;
	/* rq on which this entity is (to be) queued: */
	struct cfs_rq		*cfs_rq;
	/* rq "owned" by this entity/group: */
	struct cfs_rq		*my_q;
#endif
};
935

Peter Zijlstra's avatar
Peter Zijlstra committed
936 937 938
struct sched_rt_entity {
	struct list_head run_list;
	unsigned int time_slice;
939
	unsigned long timeout;
Peter Zijlstra's avatar
Peter Zijlstra committed
940 941 942 943 944 945 946 947 948
	int nr_cpus_allowed;

#ifdef CONFIG_FAIR_GROUP_SCHED
	struct sched_rt_entity	*parent;
	/* rq on which this entity is (to be) queued: */
	struct rt_rq		*rt_rq;
	/* rq "owned" by this entity/group: */
	struct rt_rq		*my_q;
#endif
Peter Zijlstra's avatar
Peter Zijlstra committed
949 950
};

Linus Torvalds's avatar
Linus Torvalds committed
951 952
struct task_struct {
	volatile long state;	/* -1 unrunnable, 0 runnable, >0 stopped */
Roman Zippel's avatar
Roman Zippel committed
953
	void *stack;
Linus Torvalds's avatar
Linus Torvalds committed
954
	atomic_t usage;
955 956
	unsigned int flags;	/* per process flags, defined below */
	unsigned int ptrace;
Linus Torvalds's avatar
Linus Torvalds committed
957

958
	int lock_depth;		/* BKL lock depth */
Linus Torvalds's avatar
Linus Torvalds committed
959

960 961
#ifdef CONFIG_SMP
#ifdef __ARCH_WANT_UNLOCKED_CTXSW
962 963
	int oncpu;
#endif
964
#endif
965

966
	int prio, static_prio, normal_prio;
967
	const struct sched_class *sched_class;
Ingo Molnar's avatar
Ingo Molnar committed
968
	struct sched_entity se;
Peter Zijlstra's avatar
Peter Zijlstra committed
969
	struct sched_rt_entity rt;
Linus Torvalds's avatar
Linus Torvalds committed
970

971 972 973 974 975
#ifdef CONFIG_PREEMPT_NOTIFIERS
	/* list of struct preempt_notifier: */
	struct hlist_head preempt_notifiers;
#endif

976
	unsigned short ioprio;
977 978 979 980 981 982 983 984 985 986
	/*
	 * fpu_counter contains the number of consecutive context switches
	 * that the FPU is used. If this is over a threshold, the lazy fpu
	 * saving becomes unlazy to save the trap. This is an unsigned char
	 * so that after 256 times the counter wraps and the behavior turns
	 * lazy again; this to deal with bursty apps that only use FPU for
	 * a short time
	 */
	unsigned char fpu_counter;
	s8 oomkilladj; /* OOM kill score adjustment (bit shift). */
987
#ifdef CONFIG_BLK_DEV_IO_TRACE
988
	unsigned int btrace_seq;
989
#endif
Linus Torvalds's avatar
Linus Torvalds committed
990

991
	unsigned int policy;
Linus Torvalds's avatar
Linus Torvalds committed
992 993
	cpumask_t cpus_allowed;

Paul E. McKenney's avatar
Paul E. McKenney committed
994 995 996 997 998
#ifdef CONFIG_PREEMPT_RCU
	int rcu_read_lock_nesting;
	int rcu_flipctr_idx;
#endif /* #ifdef CONFIG_PREEMPT_RCU */

999
#if defined(CONFIG_SCHEDSTATS) || defined(CONFIG_TASK_DELAY_ACCT)
Linus Torvalds's avatar
Linus Torvalds committed
1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014
	struct sched_info sched_info;
#endif

	struct list_head tasks;
	/*
	 * ptrace_list/ptrace_children forms the list of my children
	 * that were stolen by a ptracer.
	 */
	struct list_head ptrace_children;
	struct list_head ptrace_list;

	struct mm_struct *mm, *active_mm;

/* task state */
	struct linux_binfmt *binfmt;
1015
	int exit_state;
Linus Torvalds's avatar
Linus Torvalds committed
1016 1017 1018
	int exit_code, exit_signal;
	int pdeath_signal;  /*  The signal sent when the parent dies  */
	/* ??? */
1019
	unsigned int personality;
Linus Torvalds's avatar
Linus Torvalds committed
1020 1021 1022
	unsigned did_exec:1;
	pid_t pid;
	pid_t tgid;
1023 1024 1025 1026 1027

#ifdef CONFIG_CC_STACKPROTECTOR
	/* Canary value for the -fstack-protector gcc feature */
	unsigned long stack_canary;
#endif
Linus Torvalds's avatar
Linus Torvalds committed
1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043
	/* 
	 * pointers to (original) parent process, youngest child, younger sibling,
	 * older sibling, respectively.  (p->father can be replaced with 
	 * p->parent->pid)
	 */
	struct task_struct *real_parent; /* real parent process (when being debugged) */
	struct task_struct *parent;	/* parent process */
	/*
	 * children/sibling forms the list of my children plus the
	 * tasks I'm ptracing.
	 */
	struct list_head children;	/* list of my children */
	struct list_head sibling;	/* linkage in my parent's children list */
	struct task_struct *group_leader;	/* threadgroup leader */

	/* PID/PID hash table linkage. */
1044
	struct pid_link pids[PIDTYPE_MAX];
1045
	struct list_head thread_group;
Linus Torvalds's avatar
Linus Torvalds committed
1046 1047 1048 1049 1050

	struct completion *vfork_done;		/* for vfork() */
	int __user *set_child_tid;		/* CLONE_CHILD_SETTID */
	int __user *clear_child_tid;		/* CLONE_CHILD_CLEARTID */

1051
	unsigned int rt_priority;
1052
	cputime_t utime, stime, utimescaled, stimescaled;
1053
	cputime_t gtime;
1054
	cputime_t prev_utime, prev_stime;
Linus Torvalds's avatar
Linus Torvalds committed
1055
	unsigned long nvcsw, nivcsw; /* context switch counts */
1056 1057
	struct timespec start_time; 		/* monotonic time */
	struct timespec real_start_time;	/* boot based time */
Linus Torvalds's avatar
Linus Torvalds committed
1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072
/* mm fault and swap info: this can arguably be seen as either mm-specific or thread-specific */
	unsigned long min_flt, maj_flt;

  	cputime_t it_prof_expires, it_virt_expires;
	unsigned long long it_sched_expires;
	struct list_head cpu_timers[3];

/* process credentials */
	uid_t uid,euid,suid,fsuid;
	gid_t gid,egid,sgid,fsgid;
	struct group_info *group_info;
	kernel_cap_t   cap_effective, cap_inheritable, cap_permitted;
	unsigned keep_capabilities:1;
	struct user_struct *user;
#ifdef CONFIG_KEYS
1073
	struct key *request_key_auth;	/* assumed request_key authority */
Linus Torvalds's avatar
Linus Torvalds committed
1074
	struct key *thread_keyring;	/* keyring private to this thread */
1075
	unsigned char jit_keyring;	/* default keyring to attach requested keys to */
Linus Torvalds's avatar
Linus Torvalds committed
1076
#endif
1077 1078 1079 1080
	char comm[TASK_COMM_LEN]; /* executable name excluding path
				     - access with [gs]et_task_comm (which lock
				       it with task_lock())
				     - initialized normally by flush_old_exec */
Linus Torvalds's avatar
Linus Torvalds committed
1081 1082
/* file system info */
	int link_count, total_link_count;
1083
#ifdef CONFIG_SYSVIPC
Linus Torvalds's avatar
Linus Torvalds committed
1084 1085
/* ipc stuff */
	struct sysv_sem sysvsem;
1086
#endif
1087 1088 1089 1090 1091
#ifdef CONFIG_DETECT_SOFTLOCKUP
/* hung task detection */
	unsigned long last_switch_timestamp;
	unsigned long last_switch_count;
#endif
Linus Torvalds's avatar
Linus Torvalds committed
1092 1093 1094 1095 1096 1097
/* CPU-specific state of this task */
	struct thread_struct thread;
/* filesystem information */
	struct fs_struct *fs;
/* open file information */
	struct files_struct *files;
1098
/* namespaces */
1099
	struct nsproxy *nsproxy;
Linus Torvalds's avatar
Linus Torvalds committed
1100 1101 1102 1103 1104
/* signal handlers */
	struct signal_struct *signal;
	struct sighand_struct *sighand;

	sigset_t blocked, real_blocked;
1105
	sigset_t saved_sigmask;		/* To be restored with TIF_RESTORE_SIGMASK */
Linus Torvalds's avatar
Linus Torvalds committed
1106 1107 1108 1109 1110 1111 1112
	struct sigpending pending;

	unsigned long sas_ss_sp;
	size_t sas_ss_size;
	int (*notifier)(void *priv);
	void *notifier_data;
	sigset_t *notifier_mask;
1113
#ifdef CONFIG_SECURITY
Linus Torvalds's avatar
Linus Torvalds committed
1114
	void *security;
1115
#endif
Linus Torvalds's avatar
Linus Torvalds committed
1116 1117 1118 1119 1120 1121 1122 1123 1124
	struct audit_context *audit_context;
	seccomp_t seccomp;

/* Thread group tracking */
   	u32 parent_exec_id;
   	u32 self_exec_id;
/* Protection of (de-)allocation: mm, files, fs, tty, keyrings */
	spinlock_t alloc_lock;

1125 1126 1127
	/* Protection of the PI data structures: */
	spinlock_t pi_lock;

Ingo Molnar's avatar
Ingo Molnar committed
1128 1129 1130 1131 1132 1133 1134
#ifdef CONFIG_RT_MUTEXES
	/* PI waiters blocked on a rt_mutex held by this task */
	struct plist_head pi_waiters;
	/* Deadlock detection and priority inheritance handling */
	struct rt_mutex_waiter *pi_blocked_on;
#endif

1135 1136 1137 1138
#ifdef CONFIG_DEBUG_MUTEXES
	/* mutex deadlock detection */
	struct mutex_waiter *blocked_on;
#endif
1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153
#ifdef CONFIG_TRACE_IRQFLAGS
	unsigned int irq_events;
	int hardirqs_enabled;
	unsigned long hardirq_enable_ip;
	unsigned int hardirq_enable_event;
	unsigned long hardirq_disable_ip;
	unsigned int hardirq_disable_event;
	int softirqs_enabled;
	unsigned long softirq_disable_ip;
	unsigned int softirq_disable_event;
	unsigned long softirq_enable_ip;
	unsigned int softirq_enable_event;
	int hardirq_context;
	int softirq_context;
#endif
Ingo Molnar's avatar
Ingo Molnar committed
1154 1155 1156 1157 1158 1159 1160
#ifdef CONFIG_LOCKDEP
# define MAX_LOCK_DEPTH 30UL
	u64 curr_chain_key;
	int lockdep_depth;
	struct held_lock held_locks[MAX_LOCK_DEPTH];
	unsigned int lockdep_recursion;
#endif
1161

Linus Torvalds's avatar
Linus Torvalds committed
1162 1163 1164
/* journalling filesystem info */
	void *journal_info;

1165 1166 1167
/* stacked block device info */
	struct bio *bio_list, **bio_tail;

Linus Torvalds's avatar<