Blame view

include/linux/sched.h 79.7 KB
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1
2
  #ifndef _LINUX_SCHED_H
  #define _LINUX_SCHED_H
b7b3c76a0   David Woodhouse   Sanitise linux/sc...
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
  /*
   * 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 */
43bb40c9e   Dave Jones   sched: remove lon...
23
24
  /* 0x02000000 was previously the unused CLONE_STOPPED (Start in stopped state)
     and is now available for re-use. */
071df104f   Serge E. Hallyn   [PATCH] namespace...
25
  #define CLONE_NEWUTS		0x04000000	/* New utsname group? */
25b21cb2f   Kirill Korotaev   [PATCH] IPC names...
26
  #define CLONE_NEWIPC		0x08000000	/* New ipcs */
77ec739d8   Serge E. Hallyn   user namespace: a...
27
  #define CLONE_NEWUSER		0x10000000	/* New user namespace */
30e49c263   Pavel Emelyanov   pid namespaces: a...
28
  #define CLONE_NEWPID		0x20000000	/* New pid namespace */
169e36742   Eric W. Biederman   [NETNS]: CLONE_NE...
29
  #define CLONE_NEWNET		0x40000000	/* New network namespace */
fadad878c   Jens Axboe   kernel: add CLONE...
30
  #define CLONE_IO		0x80000000	/* Clone io context */
b7b3c76a0   David Woodhouse   Sanitise linux/sc...
31
32
33
34
35
36
37
38
  
  /*
   * Scheduling policies
   */
  #define SCHED_NORMAL		0
  #define SCHED_FIFO		1
  #define SCHED_RR		2
  #define SCHED_BATCH		3
0e6aca43e   Ingo Molnar   sched: add SCHED_...
39
40
  /* SCHED_ISO: reserved but not implemented yet */
  #define SCHED_IDLE		5
ca94c4425   Lennart Poettering   sched: Introduce ...
41
42
  /* Can be ORed in to make sure the process is reverted back to SCHED_NORMAL on fork */
  #define SCHED_RESET_ON_FORK     0x40000000
b7b3c76a0   David Woodhouse   Sanitise linux/sc...
43

a3b6714e1   David Woodhouse   Partially sanitis...
44
  #ifdef __KERNEL__
b7b3c76a0   David Woodhouse   Sanitise linux/sc...
45
46
47
48
  
  struct sched_param {
  	int sched_priority;
  };
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
49
  #include <asm/param.h>	/* for HZ */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
50
51
52
53
54
55
56
57
58
59
60
  #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>
c92ff1bde   Martin Schwidefsky   move mm_struct an...
61
  #include <linux/mm_types.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
62
63
  
  #include <asm/system.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
64
65
  #include <asm/page.h>
  #include <asm/ptrace.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
66
67
68
69
70
  #include <asm/cputime.h>
  
  #include <linux/smp.h>
  #include <linux/sem.h>
  #include <linux/signal.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
71
72
73
74
75
  #include <linux/compiler.h>
  #include <linux/completion.h>
  #include <linux/pid.h>
  #include <linux/percpu.h>
  #include <linux/topology.h>
3e26c149c   Peter Zijlstra   mm: dirty balanci...
76
  #include <linux/proportions.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
77
  #include <linux/seccomp.h>
e56d09031   Ingo Molnar   [PATCH] RCU signa...
78
  #include <linux/rcupdate.h>
05725f7eb   Jiri Pirko   rculist: use list...
79
  #include <linux/rculist.h>
23f78d4a0   Ingo Molnar   [PATCH] pi-futex:...
80
  #include <linux/rtmutex.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
81

a3b6714e1   David Woodhouse   Partially sanitis...
82
83
84
85
86
  #include <linux/time.h>
  #include <linux/param.h>
  #include <linux/resource.h>
  #include <linux/timer.h>
  #include <linux/hrtimer.h>
7c3ab7381   Andrew Morton   [PATCH] io-accoun...
87
  #include <linux/task_io_accounting.h>
9745512ce   Arjan van de Ven   sched: latencytop...
88
  #include <linux/latencytop.h>
9e2b2dc41   David Howells   CRED: Introduce c...
89
  #include <linux/cred.h>
a3b6714e1   David Woodhouse   Partially sanitis...
90
91
  
  #include <asm/processor.h>
36d57ac4a   H. J. Lu   [PATCH] auxiliary...
92

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
93
  struct exec_domain;
c87e2837b   Ingo Molnar   [PATCH] pi-futex:...
94
  struct futex_pi_state;
286100a6c   Alexey Dobriyan   sched, futex: det...
95
  struct robust_list_head;
bddd87c7e   Akinobu Mita   blk-core: use BIO...
96
  struct bio_list;
5ad4e53bd   Al Viro   Get rid of indire...
97
  struct fs_struct;
cdd6c482c   Ingo Molnar   perf: Do the big ...
98
  struct perf_event_context;
73c101011   Jens Axboe   block: initial pa...
99
  struct blk_plug;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
100
101
  
  /*
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
   * 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 */
2d02494f5   Thomas Gleixner   sched, timers: cl...
118
  extern void get_avenrun(unsigned long *loads, unsigned long offset, int shift);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
119
120
121
  
  #define FSHIFT		11		/* nr of bits of precision */
  #define FIXED_1		(1<<FSHIFT)	/* 1.0 as fixed-point */
0c2043abe   Linus Torvalds   Don't do load-ave...
122
  #define LOAD_FREQ	(5*HZ+1)	/* 5 sec intervals */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
123
124
125
126
127
128
129
130
131
132
133
  #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;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
134
135
136
137
138
  DECLARE_PER_CPU(unsigned long, process_counts);
  extern int nr_processes(void);
  extern unsigned long nr_running(void);
  extern unsigned long nr_uninterruptible(void);
  extern unsigned long nr_iowait(void);
8c215bd38   Peter Zijlstra   sched: Cure nr_io...
139
  extern unsigned long nr_iowait_cpu(int cpu);
69d25870f   Arjan van de Ven   cpuidle: fix the ...
140
  extern unsigned long this_cpu_load(void);
0f004f5a6   Peter Zijlstra   sched: Cure more ...
141
  extern void calc_global_load(unsigned long ticks);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
142

7e49fcce1   Steven Rostedt   trace, lockdep: m...
143
  extern unsigned long get_parent_ip(unsigned long addr);
43ae34cb4   Ingo Molnar   sched: scheduler ...
144
145
  struct seq_file;
  struct cfs_rq;
4cf86d77f   Ingo Molnar   sched: cleanup: r...
146
  struct task_group;
43ae34cb4   Ingo Molnar   sched: scheduler ...
147
148
149
150
  #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
5cef9eca3   Ingo Molnar   sched: remove the...
151
  print_cfs_rq(struct seq_file *m, int cpu, struct cfs_rq *cfs_rq);
43ae34cb4   Ingo Molnar   sched: scheduler ...
152
153
154
155
156
157
158
159
160
  #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
5cef9eca3   Ingo Molnar   sched: remove the...
161
  print_cfs_rq(struct seq_file *m, int cpu, struct cfs_rq *cfs_rq)
43ae34cb4   Ingo Molnar   sched: scheduler ...
162
163
164
  {
  }
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
165

4a8342d23   Linus Torvalds   Revert task flag ...
166
167
168
169
170
171
172
173
174
175
  /*
   * 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.
   */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
176
177
178
  #define TASK_RUNNING		0
  #define TASK_INTERRUPTIBLE	1
  #define TASK_UNINTERRUPTIBLE	2
f021a3c2b   Matthew Wilcox   Add TASK_WAKEKILL
179
180
  #define __TASK_STOPPED		4
  #define __TASK_TRACED		8
4a8342d23   Linus Torvalds   Revert task flag ...
181
182
183
184
  /* in tsk->exit_state */
  #define EXIT_ZOMBIE		16
  #define EXIT_DEAD		32
  /* in tsk->state again */
af9272326   Mike Galbraith   sched: cleanup, r...
185
  #define TASK_DEAD		64
f021a3c2b   Matthew Wilcox   Add TASK_WAKEKILL
186
  #define TASK_WAKEKILL		128
e9c843118   Peter Zijlstra   sched: Add TASK_W...
187
  #define TASK_WAKING		256
e1781538c   Peter Zijlstra   sched: Assert tas...
188
  #define TASK_STATE_MAX		512
f021a3c2b   Matthew Wilcox   Add TASK_WAKEKILL
189

44d90df6b   Peter Zijlstra   sched: Add missin...
190
  #define TASK_STATE_TO_CHAR_STR "RSDTtZXxKW"
733421516   Peter Zijlstra   sched: Move TASK_...
191

e1781538c   Peter Zijlstra   sched: Assert tas...
192
193
  extern char ___assert_task_state[1 - 2*!!(
  		sizeof(TASK_STATE_TO_CHAR_STR)-1 != ilog2(TASK_STATE_MAX)+1)];
f021a3c2b   Matthew Wilcox   Add TASK_WAKEKILL
194
195
196
197
198
  
  /* Convenience macros for the sake of set_task_state */
  #define TASK_KILLABLE		(TASK_WAKEKILL | TASK_UNINTERRUPTIBLE)
  #define TASK_STOPPED		(TASK_WAKEKILL | __TASK_STOPPED)
  #define TASK_TRACED		(TASK_WAKEKILL | __TASK_TRACED)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
199

92a1f4bc7   Matthew Wilcox   Add macros to rep...
200
201
  /* Convenience macros for the sake of wake_up */
  #define TASK_NORMAL		(TASK_INTERRUPTIBLE | TASK_UNINTERRUPTIBLE)
f021a3c2b   Matthew Wilcox   Add TASK_WAKEKILL
202
  #define TASK_ALL		(TASK_NORMAL | __TASK_STOPPED | __TASK_TRACED)
92a1f4bc7   Matthew Wilcox   Add macros to rep...
203
204
205
  
  /* get_task_state() */
  #define TASK_REPORT		(TASK_RUNNING | TASK_INTERRUPTIBLE | \
f021a3c2b   Matthew Wilcox   Add TASK_WAKEKILL
206
207
  				 TASK_UNINTERRUPTIBLE | __TASK_STOPPED | \
  				 __TASK_TRACED)
92a1f4bc7   Matthew Wilcox   Add macros to rep...
208

f021a3c2b   Matthew Wilcox   Add TASK_WAKEKILL
209
210
  #define task_is_traced(task)	((task->state & __TASK_TRACED) != 0)
  #define task_is_stopped(task)	((task->state & __TASK_STOPPED) != 0)
8f92054e7   David Howells   CRED: Fix __task_...
211
  #define task_is_dead(task)	((task)->exit_state != 0)
92a1f4bc7   Matthew Wilcox   Add macros to rep...
212
  #define task_is_stopped_or_traced(task)	\
f021a3c2b   Matthew Wilcox   Add TASK_WAKEKILL
213
  			((task->state & (__TASK_STOPPED | __TASK_TRACED)) != 0)
92a1f4bc7   Matthew Wilcox   Add macros to rep...
214
  #define task_contributes_to_load(task)	\
e3c8ca833   Nathan Lynch   sched: do not cou...
215
  				((task->state & TASK_UNINTERRUPTIBLE) != 0 && \
6301cb95c   Thomas Gleixner   sched: fix nr_uni...
216
  				 (task->flags & PF_FREEZING) == 0)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
217
218
219
220
221
  
  #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))
498d0c571   Andrew Morton   [PATCH] set_curre...
222
223
224
225
226
227
228
229
230
231
232
  /*
   * 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()
   */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
233
234
235
236
237
238
239
  #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
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
240
241
242
243
244
245
246
247
248
249
  #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;
36c8b5868   Ingo Molnar   [PATCH] sched: cl...
250
  struct task_struct;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
251

db1466b3e   Paul E. McKenney   rcu: Use wrapper ...
252
253
254
  #ifdef CONFIG_PROVE_RCU
  extern int lockdep_tasklist_lock_is_held(void);
  #endif /* #ifdef CONFIG_PROVE_RCU */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
255
256
  extern void sched_init(void);
  extern void sched_init_smp(void);
2d07b255c   Harvey Harrison   sched: add declar...
257
  extern asmlinkage void schedule_tail(struct task_struct *prev);
36c8b5868   Ingo Molnar   [PATCH] sched: cl...
258
  extern void init_idle(struct task_struct *idle, int cpu);
1df21055e   Ingo Molnar   sched: add init_i...
259
  extern void init_idle_bootup_task(struct task_struct *idle);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
260

89f19f04d   Andrew Morton   sched: Fix racine...
261
  extern int runqueue_is_locked(int cpu);
017730c11   Ingo Molnar   ftrace: fix wakeups
262

6a7b3dc34   Rusty Russell   sched: convert no...
263
  extern cpumask_var_t nohz_cpu_mask;
46cb4b7c8   Siddha, Suresh B   sched: dynticks i...
264
  #if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ)
83cd4fe27   Venkatesh Pallipadi   sched: Change noh...
265
266
  extern void select_nohz_load_balancer(int stop_tick);
  extern int get_nohz_timer_target(void);
46cb4b7c8   Siddha, Suresh B   sched: dynticks i...
267
  #else
83cd4fe27   Venkatesh Pallipadi   sched: Change noh...
268
  static inline void select_nohz_load_balancer(int stop_tick) { }
46cb4b7c8   Siddha, Suresh B   sched: dynticks i...
269
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
270

e59e2ae2c   Ingo Molnar   [PATCH] SysRq-X: ...
271
  /*
39bc89fd4   Ingo Molnar   make SysRq-T show...
272
   * Only dump TASK_* tasks. (0 for all tasks)
e59e2ae2c   Ingo Molnar   [PATCH] SysRq-X: ...
273
274
275
276
277
   */
  extern void show_state_filter(unsigned long state_filter);
  
  static inline void show_state(void)
  {
39bc89fd4   Ingo Molnar   make SysRq-T show...
278
  	show_state_filter(0);
e59e2ae2c   Ingo Molnar   [PATCH] SysRq-X: ...
279
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
  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);
  extern void update_process_times(int user);
  extern void scheduler_tick(void);
82a1fcb90   Ingo Molnar   softlockup: autom...
296
  extern void sched_show_task(struct task_struct *p);
19cc36c0f   Frederic Weisbecker   lockup_detector: ...
297
  #ifdef CONFIG_LOCKUP_DETECTOR
8446f1d39   Ingo Molnar   [PATCH] detect so...
298
  extern void touch_softlockup_watchdog(void);
d6ad3e286   Jason Wessel   softlockup: Add s...
299
  extern void touch_softlockup_watchdog_sync(void);
04c9167f9   Jeremy Fitzhardinge   add touch_all_sof...
300
  extern void touch_all_softlockup_watchdogs(void);
332fbdbca   Don Zickus   lockup_detector: ...
301
302
303
  extern int proc_dowatchdog_thresh(struct ctl_table *table, int write,
  				  void __user *buffer,
  				  size_t *lenp, loff_t *ppos);
9c44bc03f   Ingo Molnar   softlockup: allow...
304
  extern unsigned int  softlockup_panic;
004417a6d   Peter Zijlstra   perf, arch: Clean...
305
  void lockup_detector_init(void);
8446f1d39   Ingo Molnar   [PATCH] detect so...
306
  #else
8446f1d39   Ingo Molnar   [PATCH] detect so...
307
308
309
  static inline void touch_softlockup_watchdog(void)
  {
  }
d6ad3e286   Jason Wessel   softlockup: Add s...
310
311
312
  static inline void touch_softlockup_watchdog_sync(void)
  {
  }
04c9167f9   Jeremy Fitzhardinge   add touch_all_sof...
313
314
315
  static inline void touch_all_softlockup_watchdogs(void)
  {
  }
004417a6d   Peter Zijlstra   perf, arch: Clean...
316
317
318
  static inline void lockup_detector_init(void)
  {
  }
8446f1d39   Ingo Molnar   [PATCH] detect so...
319
  #endif
e162b39a3   Mandeep Singh Baines   softlockup: decou...
320
321
322
323
324
325
  #ifdef CONFIG_DETECT_HUNG_TASK
  extern unsigned int  sysctl_hung_task_panic;
  extern unsigned long sysctl_hung_task_check_count;
  extern unsigned long sysctl_hung_task_timeout_secs;
  extern unsigned long sysctl_hung_task_warnings;
  extern int proc_dohung_task_timeout_secs(struct ctl_table *table, int write,
8d65af789   Alexey Dobriyan   sysctl: remove "s...
326
  					 void __user *buffer,
e162b39a3   Mandeep Singh Baines   softlockup: decou...
327
  					 size_t *lenp, loff_t *ppos);
e4ecda1b6   Mark Lord   Fix compile error...
328
329
330
  #else
  /* Avoid need for ifdefs elsewhere in the code */
  enum { sysctl_hung_task_timeout_secs = 0 };
e162b39a3   Mandeep Singh Baines   softlockup: decou...
331
  #endif
8446f1d39   Ingo Molnar   [PATCH] detect so...
332

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
333
334
  /* Attach to any functions which should be ignored in wchan output. */
  #define __sched		__attribute__((__section__(".sched.text")))
deaf2227d   Ingo Molnar   sched: clean up, ...
335
336
337
  
  /* Linker adds these: start and end of __sched functions */
  extern char __sched_text_start[], __sched_text_end[];
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
338
339
340
341
  /* Is this address in the __sched functions? */
  extern int in_sched_functions(unsigned long addr);
  
  #define	MAX_SCHEDULE_TIMEOUT	LONG_MAX
b3c975286   Harvey Harrison   include/linux: Re...
342
  extern signed long schedule_timeout(signed long timeout);
64ed93a26   Nishanth Aravamudan   [PATCH] add sched...
343
  extern signed long schedule_timeout_interruptible(signed long timeout);
294d5cc23   Matthew Wilcox   Add schedule_time...
344
  extern signed long schedule_timeout_killable(signed long timeout);
64ed93a26   Nishanth Aravamudan   [PATCH] add sched...
345
  extern signed long schedule_timeout_uninterruptible(signed long timeout);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
346
  asmlinkage void schedule(void);
c6eb3dda2   Peter Zijlstra   mutex: Use p->on_...
347
  extern int mutex_spin_on_owner(struct mutex *lock, struct task_struct *owner);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
348

ab516013a   Serge E. Hallyn   [PATCH] namespace...
349
  struct nsproxy;
acce292c8   Cedric Le Goater   user namespace: a...
350
  struct user_namespace;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
351

341c87bf3   KAMEZAWA Hiroyuki   elf: limit max ma...
352
353
354
355
356
357
358
359
360
361
362
363
364
  /*
   * Default maximum number of active map areas, this limits the number of vmas
   * per mm struct. Users can overwrite this number by sysctl but there is a
   * problem.
   *
   * When a program's coredump is generated as ELF format, a section is created
   * per a vma. In ELF, the number of sections is represented in unsigned short.
   * This means the number of sections should be smaller than 65535 at coredump.
   * Because the kernel adds some informative sections to a image of program at
   * generating coredump, we need some margin. The number of extra sections is
   * 1-3 now and depends on arch. We use "5" as safe margin, here.
   */
  #define MAPCOUNT_ELF_CORE_MARGIN	(5)
4be929be3   Alexey Dobriyan   kernel-wide: repl...
365
  #define DEFAULT_MAX_MAP_COUNT	(USHRT_MAX - MAPCOUNT_ELF_CORE_MARGIN)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
366
367
368
369
  
  extern int sysctl_max_map_count;
  
  #include <linux/aio.h>
efc1a3b16   David Howells   nommu: don't need...
370
371
  #ifdef CONFIG_MMU
  extern void arch_pick_mmap_layout(struct mm_struct *mm);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
372
373
374
375
376
377
378
  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);
1363c3cd8   Wolfgang Wander   [PATCH] Avoiding ...
379
380
  extern void arch_unmap_area(struct mm_struct *, unsigned long);
  extern void arch_unmap_area_topdown(struct mm_struct *, unsigned long);
efc1a3b16   David Howells   nommu: don't need...
381
382
383
  #else
  static inline void arch_pick_mmap_layout(struct mm_struct *mm) {}
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
384

901608d90   Oleg Nesterov   mm: introduce get...
385

6c5d52382   Kawai, Hidehiro   coredump masking:...
386
387
388
389
  extern void set_dumpable(struct mm_struct *mm, int value);
  extern int get_dumpable(struct mm_struct *mm);
  
  /* mm flags */
3cb4a0bb1   Kawai, Hidehiro   coredump masking:...
390
  /* dumpable bits */
6c5d52382   Kawai, Hidehiro   coredump masking:...
391
392
  #define MMF_DUMPABLE      0  /* core dump is permitted */
  #define MMF_DUMP_SECURELY 1  /* core file is readable only by root */
f8af4da3b   Hugh Dickins   ksm: the mm inter...
393

3cb4a0bb1   Kawai, Hidehiro   coredump masking:...
394
  #define MMF_DUMPABLE_BITS 2
f8af4da3b   Hugh Dickins   ksm: the mm inter...
395
  #define MMF_DUMPABLE_MASK ((1 << MMF_DUMPABLE_BITS) - 1)
3cb4a0bb1   Kawai, Hidehiro   coredump masking:...
396
397
398
399
400
401
  
  /* 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
82df39738   Roland McGrath   Add MMF_DUMP_ELF_...
402
  #define MMF_DUMP_ELF_HEADERS	6
e575f111d   KOSAKI Motohiro   coredump_filter: ...
403
404
  #define MMF_DUMP_HUGETLB_PRIVATE 7
  #define MMF_DUMP_HUGETLB_SHARED  8
f8af4da3b   Hugh Dickins   ksm: the mm inter...
405

3cb4a0bb1   Kawai, Hidehiro   coredump masking:...
406
  #define MMF_DUMP_FILTER_SHIFT	MMF_DUMPABLE_BITS
e575f111d   KOSAKI Motohiro   coredump_filter: ...
407
  #define MMF_DUMP_FILTER_BITS	7
3cb4a0bb1   Kawai, Hidehiro   coredump masking:...
408
409
410
  #define MMF_DUMP_FILTER_MASK \
  	(((1 << MMF_DUMP_FILTER_BITS) - 1) << MMF_DUMP_FILTER_SHIFT)
  #define MMF_DUMP_FILTER_DEFAULT \
e575f111d   KOSAKI Motohiro   coredump_filter: ...
411
  	((1 << MMF_DUMP_ANON_PRIVATE) |	(1 << MMF_DUMP_ANON_SHARED) |\
656eb2cd5   Roland McGrath   add CONFIG_CORE_D...
412
413
414
415
416
417
418
  	 (1 << MMF_DUMP_HUGETLB_PRIVATE) | MMF_DUMP_MASK_DEFAULT_ELF)
  
  #ifdef CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS
  # define MMF_DUMP_MASK_DEFAULT_ELF	(1 << MMF_DUMP_ELF_HEADERS)
  #else
  # define MMF_DUMP_MASK_DEFAULT_ELF	0
  #endif
f8af4da3b   Hugh Dickins   ksm: the mm inter...
419
420
  					/* leave room for more dump flags */
  #define MMF_VM_MERGEABLE	16	/* KSM may merge identical pages */
ba76149f4   Andrea Arcangeli   thp: khugepaged
421
  #define MMF_VM_HUGEPAGE		17	/* set when VM_HUGEPAGE is set on vma */
f8af4da3b   Hugh Dickins   ksm: the mm inter...
422
423
  
  #define MMF_INIT_MASK		(MMF_DUMPABLE_MASK | MMF_DUMP_FILTER_MASK)
6c5d52382   Kawai, Hidehiro   coredump masking:...
424

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
425
426
427
428
  struct sighand_struct {
  	atomic_t		count;
  	struct k_sigaction	action[_NSIG];
  	spinlock_t		siglock;
b8fceee17   Davide Libenzi   signalfd simplifi...
429
  	wait_queue_head_t	signalfd_wqh;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
430
  };
0e4648141   KaiGai Kohei   [PATCH] pacct: ad...
431
  struct pacct_struct {
f6ec29a42   KaiGai Kohei   [PATCH] pacct: av...
432
433
  	int			ac_flag;
  	long			ac_exitcode;
0e4648141   KaiGai Kohei   [PATCH] pacct: ad...
434
  	unsigned long		ac_mem;
77787bfb4   KaiGai Kohei   [PATCH] pacct: no...
435
436
  	cputime_t		ac_utime, ac_stime;
  	unsigned long		ac_minflt, ac_majflt;
0e4648141   KaiGai Kohei   [PATCH] pacct: ad...
437
  };
42c4ab41a   Stanislaw Gruszka   itimers: Merge IT...
438
439
440
  struct cpu_itimer {
  	cputime_t expires;
  	cputime_t incr;
8356b5f9c   Stanislaw Gruszka   itimers: Fix peri...
441
442
  	u32 error;
  	u32 incr_error;
42c4ab41a   Stanislaw Gruszka   itimers: Merge IT...
443
  };
f06febc96   Frank Mayhar   timers: fix itime...
444
445
446
447
448
  /**
   * struct task_cputime - collected CPU time counts
   * @utime:		time spent in user mode, in &cputime_t units
   * @stime:		time spent in kernel mode, in &cputime_t units
   * @sum_exec_runtime:	total time spent on the CPU, in nanoseconds
5ce73a4a5   Ingo Molnar   timers: fix itime...
449
   *
f06febc96   Frank Mayhar   timers: fix itime...
450
451
452
453
454
455
456
457
458
459
460
461
462
463
   * This structure groups together three kinds of CPU time that are
   * tracked for threads and thread groups.  Most things considering
   * CPU time want to group these counts together and treat all three
   * of them in parallel.
   */
  struct task_cputime {
  	cputime_t utime;
  	cputime_t stime;
  	unsigned long long sum_exec_runtime;
  };
  /* Alternate field names when used to cache expirations. */
  #define prof_exp	stime
  #define virt_exp	utime
  #define sched_exp	sum_exec_runtime
4cd4c1b40   Peter Zijlstra   timers: split pro...
464
465
466
467
468
469
  #define INIT_CPUTIME	\
  	(struct task_cputime) {					\
  		.utime = cputime_zero,				\
  		.stime = cputime_zero,				\
  		.sum_exec_runtime = 0,				\
  	}
c99e6efe1   Peter Zijlstra   sched: INIT_PREEM...
470
471
472
  /*
   * Disable preemption until the scheduler is running.
   * Reset by start_kernel()->sched_init()->init_idle().
d86ee4809   Peter Zijlstra   sched: optimize c...
473
474
475
   *
   * We include PREEMPT_ACTIVE to avoid cond_resched() from working
   * before the scheduler is active -- see should_resched().
c99e6efe1   Peter Zijlstra   sched: INIT_PREEM...
476
   */
d86ee4809   Peter Zijlstra   sched: optimize c...
477
  #define INIT_PREEMPT_COUNT	(1 + PREEMPT_ACTIVE)
c99e6efe1   Peter Zijlstra   sched: INIT_PREEM...
478

f06febc96   Frank Mayhar   timers: fix itime...
479
  /**
4cd4c1b40   Peter Zijlstra   timers: split pro...
480
481
482
483
484
   * struct thread_group_cputimer - thread group interval timer counts
   * @cputime:		thread group interval timers.
   * @running:		non-zero when there are timers running and
   * 			@cputime receives updates.
   * @lock:		lock for fields in this struct.
f06febc96   Frank Mayhar   timers: fix itime...
485
486
   *
   * This structure contains the version of task_cputime, above, that is
4cd4c1b40   Peter Zijlstra   timers: split pro...
487
   * used for thread group CPU timer calculations.
f06febc96   Frank Mayhar   timers: fix itime...
488
   */
4cd4c1b40   Peter Zijlstra   timers: split pro...
489
490
491
492
  struct thread_group_cputimer {
  	struct task_cputime cputime;
  	int running;
  	spinlock_t lock;
f06febc96   Frank Mayhar   timers: fix itime...
493
  };
f06febc96   Frank Mayhar   timers: fix itime...
494

4714d1d32   Ben Blum   cgroups: read-wri...
495
  #include <linux/rwsem.h>
5091faa44   Mike Galbraith   sched: Add 'autog...
496
  struct autogroup;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
497
  /*
e815f0a84   Jonathan Neuschäfer   sched.h: Fix a ty...
498
   * NOTE! "signal_struct" does not have its own
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
499
500
501
502
503
504
   * 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 {
ea6d290ca   Oleg Nesterov   signals: make tas...
505
  	atomic_t		sigcnt;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
506
  	atomic_t		live;
b3ac022cb   Oleg Nesterov   proc: turn signal...
507
  	int			nr_threads;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
508
509
510
511
  
  	wait_queue_head_t	wait_chldexit;	/* for wait4() */
  
  	/* current thread group signal load-balancing target: */
36c8b5868   Ingo Molnar   [PATCH] sched: cl...
512
  	struct task_struct	*curr_target;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
513
514
515
516
517
518
519
520
521
522
523
  
  	/* 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.
  	 */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
524
  	int			notify_count;
07dd20e03   Richard Kennedy   sched: reorder si...
525
  	struct task_struct	*group_exit_task;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
526
527
528
529
530
531
532
533
534
  
  	/* 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 */
2ff678b8d   Thomas Gleixner   [PATCH] hrtimer: ...
535
  	struct hrtimer real_timer;
fea9d1755   Oleg Nesterov   ITIMER_REAL: conv...
536
  	struct pid *leader_pid;
2ff678b8d   Thomas Gleixner   [PATCH] hrtimer: ...
537
  	ktime_t it_real_incr;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
538

42c4ab41a   Stanislaw Gruszka   itimers: Merge IT...
539
540
541
542
543
544
  	/*
  	 * ITIMER_PROF and ITIMER_VIRTUAL timers for the process, we use
  	 * CPUCLOCK_PROF and CPUCLOCK_VIRT for indexing array as these
  	 * values are defined to 0 and 1 respectively
  	 */
  	struct cpu_itimer it[2];
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
545

f06febc96   Frank Mayhar   timers: fix itime...
546
  	/*
4cd4c1b40   Peter Zijlstra   timers: split pro...
547
548
  	 * Thread group totals for process CPU timers.
  	 * See thread_group_cputimer(), et al, for details.
f06febc96   Frank Mayhar   timers: fix itime...
549
  	 */
4cd4c1b40   Peter Zijlstra   timers: split pro...
550
  	struct thread_group_cputimer cputimer;
f06febc96   Frank Mayhar   timers: fix itime...
551
552
553
554
555
  
  	/* Earliest-expiration cache. */
  	struct task_cputime cputime_expires;
  
  	struct list_head cpu_timers[3];
ab521dc0f   Eric W. Biederman   [PATCH] tty: upda...
556
  	struct pid *tty_old_pgrp;
1ec320afd   Cedric Le Goater   [PATCH] add proce...
557

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
558
559
560
561
  	/* boolean value for session group leader */
  	int leader;
  
  	struct tty_struct *tty; /* NULL if no tty */
5091faa44   Mike Galbraith   sched: Add 'autog...
562
563
564
  #ifdef CONFIG_SCHED_AUTOGROUP
  	struct autogroup *autogroup;
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
565
566
567
568
569
570
  	/*
  	 * 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.
  	 */
32bd671d6   Peter Zijlstra   signal: re-add de...
571
  	cputime_t utime, stime, cutime, cstime;
9ac52315d   Laurent Vivier   sched: guest CPU ...
572
573
  	cputime_t gtime;
  	cputime_t cgtime;
0cf55e1ec   Hidetoshi Seto   sched, cputime: I...
574
575
576
  #ifndef CONFIG_VIRT_CPU_ACCOUNTING
  	cputime_t prev_utime, prev_stime;
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
577
578
  	unsigned long nvcsw, nivcsw, cnvcsw, cnivcsw;
  	unsigned long min_flt, maj_flt, cmin_flt, cmaj_flt;
6eaeeaba3   Eric Dumazet   getrusage(): fill...
579
  	unsigned long inblock, oublock, cinblock, coublock;
1f10206cf   Jiri Pirko   getrusage: fill r...
580
  	unsigned long maxrss, cmaxrss;
940389b8a   Andrea Righi   task IO accountin...
581
  	struct task_io_accounting ioac;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
582
583
  
  	/*
32bd671d6   Peter Zijlstra   signal: re-add de...
584
585
586
587
588
589
590
591
  	 * Cumulative ns of schedule CPU time fo 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.)
  	 */
  	unsigned long long sum_sched_runtime;
  
  	/*
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
592
593
594
595
596
597
598
599
600
  	 * 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];
0e4648141   KaiGai Kohei   [PATCH] pacct: ad...
601
602
603
  #ifdef CONFIG_BSD_PROCESS_ACCT
  	struct pacct_struct pacct;	/* per-process accounting information */
  #endif
ad4ecbcba   Shailabh Nagar   [PATCH] delay acc...
604
  #ifdef CONFIG_TASKSTATS
ad4ecbcba   Shailabh Nagar   [PATCH] delay acc...
605
606
  	struct taskstats *stats;
  #endif
522ed7767   Miloslav Trmac   Audit: add TTY in...
607
608
609
610
  #ifdef CONFIG_AUDIT
  	unsigned audit_tty;
  	struct tty_audit_buf *tty_audit_buf;
  #endif
4714d1d32   Ben Blum   cgroups: read-wri...
611
612
613
614
615
616
617
618
619
620
  #ifdef CONFIG_CGROUPS
  	/*
  	 * The threadgroup_fork_lock prevents threads from forking with
  	 * CLONE_THREAD while held for writing. Use this for fork-sensitive
  	 * threadgroup-wide operations. It's taken for reading in fork.c in
  	 * copy_process().
  	 * Currently only needed write-side by cgroups.
  	 */
  	struct rw_semaphore threadgroup_fork_lock;
  #endif
28b83c519   KOSAKI Motohiro   oom: move oom_adj...
621

a63d83f42   David Rientjes   oom: badness heur...
622
623
  	int oom_adj;		/* OOM kill score adjustment (bit shift) */
  	int oom_score_adj;	/* OOM kill score adjustment */
dabb16f63   Mandeep Singh Baines   oom: allow a non-...
624
625
  	int oom_score_adj_min;	/* OOM kill score adjustment minimum value.
  				 * Only settable by CAP_SYS_RESOURCE. */
9b1bf12d5   KOSAKI Motohiro   signals: move cre...
626
627
628
629
  
  	struct mutex cred_guard_mutex;	/* guard against foreign influences on
  					 * credential calculations
  					 * (notably. ptrace) */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
630
  };
4866cde06   Nick Piggin   [PATCH] sched: cl...
631
632
633
634
  /* Context switch must be unlocked if interrupts are to be enabled */
  #ifdef __ARCH_WANT_INTERRUPTS_ON_CTXSW
  # define __ARCH_WANT_UNLOCKED_CTXSW
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
635
636
637
638
  /*
   * Bits in flags field of signal_struct.
   */
  #define SIGNAL_STOP_STOPPED	0x00000001 /* job control stop in effect */
ee77f0759   Oleg Nesterov   signal: Turn SIGN...
639
640
  #define SIGNAL_STOP_CONTINUED	0x00000002 /* SIGCONT since WCONTINUED reap */
  #define SIGNAL_GROUP_EXIT	0x00000004 /* group exit in progress */
e44205519   Oleg Nesterov   signals: re-assig...
641
642
643
644
645
646
  /*
   * Pending notifications to parent.
   */
  #define SIGNAL_CLD_STOPPED	0x00000010
  #define SIGNAL_CLD_CONTINUED	0x00000020
  #define SIGNAL_CLD_MASK		(SIGNAL_CLD_STOPPED|SIGNAL_CLD_CONTINUED)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
647

fae5fa44f   Oleg Nesterov   signals: fix /sbi...
648
  #define SIGNAL_UNKILLABLE	0x00000040 /* for init: ignore fatal signals */
ed5d2cac1   Oleg Nesterov   exec: rework the ...
649
650
651
652
653
654
  /* If true, all threads except ->group_exit_task have pending SIGKILL */
  static inline int signal_group_exit(const struct signal_struct *sig)
  {
  	return	(sig->flags & SIGNAL_GROUP_EXIT) ||
  		(sig->group_exit_task != NULL);
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
655
656
657
658
659
660
661
662
  /*
   * 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? */
2d9048e20   Amy Griffis   [PATCH] inotify (...
663
  #ifdef CONFIG_INOTIFY_USER
0eeca2830   Robert Love   [PATCH] inotify
664
665
666
  	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
4afeff850   Eric Paris   fanotify: limit n...
667
668
669
  #ifdef CONFIG_FANOTIFY
  	atomic_t fanotify_listeners;
  #endif
7ef9964e6   Davide Libenzi   epoll: introduce ...
670
  #ifdef CONFIG_EPOLL
52bd19f76   Robin Holt   epoll: convert ma...
671
  	atomic_long_t epoll_watches; /* The number of file descriptors currently watched */
7ef9964e6   Davide Libenzi   epoll: introduce ...
672
  #endif
970a8645c   Alexey Dobriyan   user.c: #ifdef ->...
673
  #ifdef CONFIG_POSIX_MQUEUE
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
674
675
  	/* protected by mq_lock	*/
  	unsigned long mq_bytes;	/* How many bytes can be allocated to mqueue? */
970a8645c   Alexey Dobriyan   user.c: #ifdef ->...
676
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
677
678
679
680
681
682
683
684
  	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 */
735de2230   Pavel Emelyanov   Convert uid hash ...
685
  	struct hlist_node uidhash_node;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
686
  	uid_t uid;
18b6e0414   Serge Hallyn   User namespaces: ...
687
  	struct user_namespace *user_ns;
24e377a83   Srivatsa Vaddagiri   sched: add fair-u...
688

cdd6c482c   Ingo Molnar   perf: Do the big ...
689
  #ifdef CONFIG_PERF_EVENTS
789f90fcf   Peter Zijlstra   perf_counter: per...
690
691
  	atomic_long_t locked_vm;
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
692
  };
eb41d9465   Kay Sievers   fix struct user_i...
693
  extern int uids_sysfs_init(void);
5cb350baf   Dhaval Giani   sched: group sche...
694

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
695
696
697
698
  extern struct user_struct *find_user(uid_t);
  
  extern struct user_struct root_user;
  #define INIT_USER (&root_user)
b6dff3ec5   David Howells   CRED: Separate ta...
699

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
700
701
  struct backing_dev_info;
  struct reclaim_state;
52f17b6c2   Chandra Seetharaman   [PATCH] per-task-...
702
  #if defined(CONFIG_SCHEDSTATS) || defined(CONFIG_TASK_DELAY_ACCT)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
703
704
  struct sched_info {
  	/* cumulative counters */
2d72376b3   Ingo Molnar   sched: clean up s...
705
  	unsigned long pcount;	      /* # of times run on this cpu */
9c2c48020   Ken Chen   schedstat: consol...
706
  	unsigned long long run_delay; /* time spent waiting on a runqueue */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
707
708
  
  	/* timestamps */
172ba844a   Balbir Singh   sched: update del...
709
710
  	unsigned long long last_arrival,/* when we last ran on a cpu */
  			   last_queued;	/* when we were last queued to run */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
711
  };
52f17b6c2   Chandra Seetharaman   [PATCH] per-task-...
712
  #endif /* defined(CONFIG_SCHEDSTATS) || defined(CONFIG_TASK_DELAY_ACCT) */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
713

ca74e92b4   Shailabh Nagar   [PATCH] per-task-...
714
715
716
717
718
719
720
721
722
723
724
725
726
727
  #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).
  	 */
0ff922452   Shailabh Nagar   [PATCH] per-task-...
728
729
730
731
732
733
734
735
736
737
738
739
740
  
  	/*
  	 * 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 */
873b47717   Keika Kobayashi   per-task-delay-ac...
741
742
743
744
  
  	struct timespec freepages_start, freepages_end;
  	u64 freepages_delay;	/* wait for memory reclaim */
  	u32 freepages_count;	/* total count of memory reclaim */
ca74e92b4   Shailabh Nagar   [PATCH] per-task-...
745
  };
52f17b6c2   Chandra Seetharaman   [PATCH] per-task-...
746
747
748
749
750
751
752
753
754
755
756
  #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;
ca74e92b4   Shailabh Nagar   [PATCH] per-task-...
757
  #endif
52f17b6c2   Chandra Seetharaman   [PATCH] per-task-...
758
  }
ca74e92b4   Shailabh Nagar   [PATCH] per-task-...
759

d15bcfdbe   Ingo Molnar   sched: rename idl...
760
761
762
763
764
  enum cpu_idle_type {
  	CPU_IDLE,
  	CPU_NOT_IDLE,
  	CPU_NEWLY_IDLE,
  	CPU_MAX_IDLE_TYPES
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
765
766
767
  };
  
  /*
c8b281161   Nikhil Rao   sched: Increase S...
768
769
770
771
772
773
774
775
776
777
   * Increase resolution of nice-level calculations for 64-bit architectures.
   * The extra resolution improves shares distribution and load balancing of
   * low-weight task groups (eg. nice +19 on an autogroup), deeper taskgroup
   * hierarchies, especially on larger systems. This is not a user-visible change
   * and does not change the user-interface for setting shares/weights.
   *
   * We increase resolution only if we have enough bits to allow this increased
   * resolution (i.e. BITS_PER_LONG > 32). The costs for increasing resolution
   * when BITS_PER_LONG <= 32 are pretty high and the returns do not justify the
   * increased costs.
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
778
   */
e4c2fb0d5   Peter Zijlstra   sched: Disable (r...
779
  #if 0 /* BITS_PER_LONG > 32 -- currently broken: it increases power usage under light load  */
c8b281161   Nikhil Rao   sched: Increase S...
780
781
782
783
784
785
786
787
  # define SCHED_LOAD_RESOLUTION	10
  # define scale_load(w)		((w) << SCHED_LOAD_RESOLUTION)
  # define scale_load_down(w)	((w) >> SCHED_LOAD_RESOLUTION)
  #else
  # define SCHED_LOAD_RESOLUTION	0
  # define scale_load(w)		(w)
  # define scale_load_down(w)	(w)
  #endif
9aa7b3698   Ingo Molnar   sched: increase t...
788

c8b281161   Nikhil Rao   sched: Increase S...
789
  #define SCHED_LOAD_SHIFT	(10 + SCHED_LOAD_RESOLUTION)
9aa7b3698   Ingo Molnar   sched: increase t...
790
  #define SCHED_LOAD_SCALE	(1L << SCHED_LOAD_SHIFT)
1399fa780   Nikhil Rao   sched: Introduce ...
791
792
793
794
795
  /*
   * Increase resolution of cpu_power calculations
   */
  #define SCHED_POWER_SHIFT	10
  #define SCHED_POWER_SCALE	(1L << SCHED_POWER_SHIFT)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
796

1399fa780   Nikhil Rao   sched: Introduce ...
797
798
799
  /*
   * sched-domains (multiprocessor balancing) declarations:
   */
2dd73a4f0   Peter Williams   [PATCH] sched: im...
800
  #ifdef CONFIG_SMP
b5d978e0c   Peter Zijlstra   sched: Add SD_PRE...
801
802
803
804
  #define SD_LOAD_BALANCE		0x0001	/* Do load balancing on this domain. */
  #define SD_BALANCE_NEWIDLE	0x0002	/* Balance when about to become idle */
  #define SD_BALANCE_EXEC		0x0004	/* Balance on exec */
  #define SD_BALANCE_FORK		0x0008	/* Balance on fork, clone */
c88d59108   Peter Zijlstra   sched: Merge sele...
805
  #define SD_BALANCE_WAKE		0x0010  /* Balance on wakeup */
b5d978e0c   Peter Zijlstra   sched: Add SD_PRE...
806
  #define SD_WAKE_AFFINE		0x0020	/* Wake task to waking CPU */
59abf0264   Peter Zijlstra   sched: Add SD_PRE...
807
  #define SD_PREFER_LOCAL		0x0040  /* Prefer to keep tasks local to this domain */
b5d978e0c   Peter Zijlstra   sched: Add SD_PRE...
808
809
810
811
  #define SD_SHARE_CPUPOWER	0x0080	/* Domain members share cpu power */
  #define SD_POWERSAVINGS_BALANCE	0x0100	/* Balance for power savings */
  #define SD_SHARE_PKG_RESOURCES	0x0200	/* Domain members share cpu pkg resources */
  #define SD_SERIALIZE		0x0400	/* Only a single load balancing instance */
532cb4c40   Michael Neuling   sched: Add asymme...
812
  #define SD_ASYM_PACKING		0x0800  /* Place busy groups earlier in the domain */
b5d978e0c   Peter Zijlstra   sched: Add SD_PRE...
813
  #define SD_PREFER_SIBLING	0x1000	/* Prefer to place tasks in a sibling domain */
e3589f6c8   Peter Zijlstra   sched: Allow for ...
814
  #define SD_OVERLAP		0x2000	/* sched_domains of this level overlap */
5c45bf279   Siddha, Suresh B   [PATCH] sched: mc...
815

afb8a9b70   Gautham R Shenoy   sched: framework ...
816
817
818
819
820
821
822
823
824
825
  enum powersavings_balance_level {
  	POWERSAVINGS_BALANCE_NONE = 0,  /* No power saving load balance */
  	POWERSAVINGS_BALANCE_BASIC,	/* Fill one thread/core/package
  					 * first for long running threads
  					 */
  	POWERSAVINGS_BALANCE_WAKEUP,	/* Also bias task wakeups to semi-idle
  					 * cpu package for power savings
  					 */
  	MAX_POWERSAVINGS_BALANCE_LEVELS
  };
89c4710ee   Siddha, Suresh B   [PATCH] sched: cl...
826

716707b29   Vaidyanathan Srinivasan   sched: convert BA...
827
  extern int sched_mc_power_savings, sched_smt_power_savings;
89c4710ee   Siddha, Suresh B   [PATCH] sched: cl...
828

716707b29   Vaidyanathan Srinivasan   sched: convert BA...
829
830
831
832
  static inline int sd_balance_for_mc_power(void)
  {
  	if (sched_smt_power_savings)
  		return SD_POWERSAVINGS_BALANCE;
5c45bf279   Siddha, Suresh B   [PATCH] sched: mc...
833

28f531816   Vaidyanathan Srinivasan   sched: Fix sched_...
834
835
836
837
  	if (!sched_mc_power_savings)
  		return SD_PREFER_SIBLING;
  
  	return 0;
716707b29   Vaidyanathan Srinivasan   sched: convert BA...
838
  }
89c4710ee   Siddha, Suresh B   [PATCH] sched: cl...
839

716707b29   Vaidyanathan Srinivasan   sched: convert BA...
840
841
842
843
  static inline int sd_balance_for_package_power(void)
  {
  	if (sched_mc_power_savings | sched_smt_power_savings)
  		return SD_POWERSAVINGS_BALANCE;
b5d978e0c   Peter Zijlstra   sched: Add SD_PRE...
844
  	return SD_PREFER_SIBLING;
716707b29   Vaidyanathan Srinivasan   sched: convert BA...
845
  }
5c45bf279   Siddha, Suresh B   [PATCH] sched: mc...
846

532cb4c40   Michael Neuling   sched: Add asymme...
847
  extern int __weak arch_sd_sibiling_asym_packing(void);
100fdaee7   Vaidyanathan Srinivasan   sched: add SD_BAL...
848
849
  /*
   * Optimise SD flags for power savings:
25985edce   Lucas De Marchi   Fix common misspe...
850
   * SD_BALANCE_NEWIDLE helps aggressive task consolidation and power savings.
100fdaee7   Vaidyanathan Srinivasan   sched: add SD_BAL...
851
852
853
854
855
856
857
858
859
860
   * Keep default SD flags if sched_{smt,mc}_power_saving=0
   */
  
  static inline int sd_power_saving_flags(void)
  {
  	if (sched_mc_power_savings | sched_smt_power_savings)
  		return SD_BALANCE_NEWIDLE;
  
  	return 0;
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
861

9c3f75cbd   Peter Zijlstra   sched: Break out ...
862
  struct sched_group_power {
e3589f6c8   Peter Zijlstra   sched: Allow for ...
863
  	atomic_t ref;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
864
865
  	/*
  	 * CPU power of this group, SCHED_LOAD_SCALE being max power for a
18a3885fc   Peter Zijlstra   sched: Remove rec...
866
  	 * single CPU.
5517d86be   Eric Dumazet   Speed up divides ...
867
  	 */
9c3f75cbd   Peter Zijlstra   sched: Break out ...
868
869
870
871
872
873
  	unsigned int power, power_orig;
  };
  
  struct sched_group {
  	struct sched_group *next;	/* Must be a circular list */
  	atomic_t ref;
aae6d3ddd   Suresh Siddha   sched: Use group ...
874
  	unsigned int group_weight;
9c3f75cbd   Peter Zijlstra   sched: Break out ...
875
  	struct sched_group_power *sgp;
6c99e9ad4   Rusty Russell   sched: convert st...
876

4200efd9a   Ingo Molnar   sched: properly d...
877
878
879
880
881
882
  	/*
  	 * The CPUs this group covers.
  	 *
  	 * NOTE: this field is variable length. (Allocated dynamically
  	 * by attaching extra space to the end of the structure,
  	 * depending on how many CPUs the kernel has booted up with)
4200efd9a   Ingo Molnar   sched: properly d...
883
884
  	 */
  	unsigned long cpumask[0];
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
885
  };
758b2cdc6   Rusty Russell   sched: wrap sched...
886
887
  static inline struct cpumask *sched_group_cpus(struct sched_group *sg)
  {
6c99e9ad4   Rusty Russell   sched: convert st...
888
  	return to_cpumask(sg->cpumask);
758b2cdc6   Rusty Russell   sched: wrap sched...
889
  }
1d3504fcf   Hidetoshi Seto   sched, cpuset: cu...
890
891
892
893
894
895
896
  struct sched_domain_attr {
  	int relax_domain_level;
  };
  
  #define SD_ATTR_INIT	(struct sched_domain_attr) {	\
  	.relax_domain_level = -1,			\
  }
60495e776   Peter Zijlstra   sched: Dynamic sc...
897
  extern int sched_domain_level_max;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
898
899
900
  struct sched_domain {
  	/* These fields must be setup */
  	struct sched_domain *parent;	/* top domain must be null terminated */
1a8488708   Siddha, Suresh B   [PATCH] sched: in...
901
  	struct sched_domain *child;	/* bottom domain must be null terminated */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
902
  	struct sched_group *groups;	/* the balancing groups of the domain */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
903
904
905
906
  	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 */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
907
  	unsigned int cache_nice_tries;	/* Leave cache hot tasks for # tries */
7897986ba   Nick Piggin   [PATCH] sched: ba...
908
909
910
911
  	unsigned int busy_idx;
  	unsigned int idle_idx;
  	unsigned int newidle_idx;
  	unsigned int wake_idx;
147cbb4bb   Nick Piggin   [PATCH] sched: ba...
912
  	unsigned int forkexec_idx;
a52bfd735   Peter Zijlstra   sched: Add smt_gain
913
  	unsigned int smt_gain;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
914
  	int flags;			/* See SD_* */
60495e776   Peter Zijlstra   sched: Dynamic sc...
915
  	int level;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
916
917
918
919
920
  
  	/* 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 */
2398f2c6d   Peter Zijlstra   sched: update sha...
921
  	u64 last_update;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
922
923
  #ifdef CONFIG_SCHEDSTATS
  	/* load_balance() stats */
480b9434c   Ken Chen   sched: reduce sch...
924
925
926
927
928
929
930
931
  	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];
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
932
933
  
  	/* Active load balancing */
480b9434c   Ken Chen   sched: reduce sch...
934
935
936
  	unsigned int alb_count;
  	unsigned int alb_failed;
  	unsigned int alb_pushed;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
937

68767a0ae   Nick Piggin   [PATCH] sched: sc...
938
  	/* SD_BALANCE_EXEC stats */
480b9434c   Ken Chen   sched: reduce sch...
939
940
941
  	unsigned int sbe_count;
  	unsigned int sbe_balanced;
  	unsigned int sbe_pushed;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
942

68767a0ae   Nick Piggin   [PATCH] sched: sc...
943
  	/* SD_BALANCE_FORK stats */
480b9434c   Ken Chen   sched: reduce sch...
944
945
946
  	unsigned int sbf_count;
  	unsigned int sbf_balanced;
  	unsigned int sbf_pushed;
68767a0ae   Nick Piggin   [PATCH] sched: sc...
947

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
948
  	/* try_to_wake_up() stats */
480b9434c   Ken Chen   sched: reduce sch...
949
950
951
  	unsigned int ttwu_wake_remote;
  	unsigned int ttwu_move_affine;
  	unsigned int ttwu_move_balance;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
952
  #endif
a5d8c3483   Ingo Molnar   sched debug: add ...
953
954
955
  #ifdef CONFIG_SCHED_DEBUG
  	char *name;
  #endif
dce840a08   Peter Zijlstra   sched: Dynamicall...
956
957
958
959
  	union {
  		void *private;		/* used during construction */
  		struct rcu_head rcu;	/* used during destruction */
  	};
6c99e9ad4   Rusty Russell   sched: convert st...
960

669c55e9f   Peter Zijlstra   sched: Pre-comput...
961
  	unsigned int span_weight;
4200efd9a   Ingo Molnar   sched: properly d...
962
963
964
965
966
967
  	/*
  	 * Span of all CPUs in this domain.
  	 *
  	 * NOTE: this field is variable length. (Allocated dynamically
  	 * by attaching extra space to the end of the structure,
  	 * depending on how many CPUs the kernel has booted up with)
4200efd9a   Ingo Molnar   sched: properly d...
968
969
  	 */
  	unsigned long span[0];
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
970
  };
758b2cdc6   Rusty Russell   sched: wrap sched...
971
972
  static inline struct cpumask *sched_domain_span(struct sched_domain *sd)
  {
6c99e9ad4   Rusty Russell   sched: convert st...
973
  	return to_cpumask(sd->span);
758b2cdc6   Rusty Russell   sched: wrap sched...
974
  }
acc3f5d7c   Rusty Russell   cpumask: Partitio...
975
  extern void partition_sched_domains(int ndoms_new, cpumask_var_t doms_new[],
1d3504fcf   Hidetoshi Seto   sched, cpuset: cu...
976
  				    struct sched_domain_attr *dattr_new);
029190c51   Paul Jackson   cpuset sched_load...
977

acc3f5d7c   Rusty Russell   cpumask: Partitio...
978
979
980
  /* Allocate an array of sched domains, for partition_sched_domains(). */
  cpumask_var_t *alloc_sched_domains(unsigned int ndoms);
  void free_sched_domains(cpumask_var_t doms[], unsigned int ndoms);
06aaf76a7   Ingo Molnar   sched: move test_...
981
982
983
984
985
986
987
988
  /* Test a flag in parent sched domain */
  static inline int test_sd_parent(struct sched_domain *sd, int flag)
  {
  	if (sd->parent && (sd->parent->flags & flag))
  		return 1;
  
  	return 0;
  }
029190c51   Paul Jackson   cpuset sched_load...
989

47fe38fcf   Peter Zijlstra   x86: sched: Provi...
990
991
  unsigned long default_scale_freq_power(struct sched_domain *sd, int cpu);
  unsigned long default_scale_smt_power(struct sched_domain *sd, int cpu);
1b427c153   Ingo Molnar   sched: fix build ...
992
  #else /* CONFIG_SMP */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
993

1b427c153   Ingo Molnar   sched: fix build ...
994
  struct sched_domain_attr;
d02c7a8cf   Con Kolivas   [PATCH] sched: ad...
995

1b427c153   Ingo Molnar   sched: fix build ...
996
  static inline void
acc3f5d7c   Rusty Russell   cpumask: Partitio...
997
  partition_sched_domains(int ndoms_new, cpumask_var_t doms_new[],
1b427c153   Ingo Molnar   sched: fix build ...
998
999
  			struct sched_domain_attr *dattr_new)
  {
d02c7a8cf   Con Kolivas   [PATCH] sched: ad...
1000
  }
1b427c153   Ingo Molnar   sched: fix build ...
1001
  #endif	/* !CONFIG_SMP */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1002

47fe38fcf   Peter Zijlstra   x86: sched: Provi...
1003

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1004
  struct io_context;			/* See blkdev.h */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1005

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1006

383f2835e   Kenneth W Chen   [PATCH] Prefetch ...
1007
  #ifdef ARCH_HAS_PREFETCH_SWITCH_STACK
36c8b5868   Ingo Molnar   [PATCH] sched: cl...
1008
  extern void prefetch_stack(struct task_struct *t);
383f2835e   Kenneth W Chen   [PATCH] Prefetch ...
1009
1010
1011
  #else
  static inline void prefetch_stack(struct task_struct *t) { }
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1012
1013
1014
  
  struct audit_context;		/* See audit.c */
  struct mempolicy;
b92ce5589   Jens Axboe   [PATCH] splice: a...
1015
  struct pipe_inode_info;
4865ecf13   Serge E. Hallyn   [PATCH] namespace...
1016
  struct uts_namespace;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1017

20b8a59f2   Ingo Molnar   sched: cfs, core ...
1018
1019
  struct rq;
  struct sched_domain;
7d4787214   Peter Zijlstra   sched: Rename syn...
1020
1021
1022
1023
  /*
   * wake flags
   */
  #define WF_SYNC		0x01		/* waker goes to sleep after wakup */
a7558e010   Peter Zijlstra   sched: Add WF_FORK
1024
  #define WF_FORK		0x02		/* child wakeup after fork */
f339b9dc1   Peter Zijlstra   sched: Fix scheds...
1025
  #define WF_MIGRATED	0x04		/* internal use, task got migrated */
7d4787214   Peter Zijlstra   sched: Rename syn...
1026

371fd7e7a   Peter Zijlstra   sched: Add enqueu...
1027
  #define ENQUEUE_WAKEUP		1
74f8e4b23   Peter Zijlstra   sched: Remove rq ...
1028
1029
1030
1031
1032
1033
  #define ENQUEUE_HEAD		2
  #ifdef CONFIG_SMP
  #define ENQUEUE_WAKING		4	/* sched_class::task_waking was called */
  #else
  #define ENQUEUE_WAKING		0
  #endif
371fd7e7a   Peter Zijlstra   sched: Add enqueu...
1034
1035
  
  #define DEQUEUE_SLEEP		1
20b8a59f2   Ingo Molnar   sched: cfs, core ...
1036
  struct sched_class {
5522d5d5f   Ingo Molnar   sched: mark sched...
1037
  	const struct sched_class *next;
20b8a59f2   Ingo Molnar   sched: cfs, core ...
1038

371fd7e7a   Peter Zijlstra   sched: Add enqueu...
1039
1040
  	void (*enqueue_task) (struct rq *rq, struct task_struct *p, int flags);
  	void (*dequeue_task) (struct rq *rq, struct task_struct *p, int flags);
4530d7ab0   Dmitry Adamushko   sched: simplify s...
1041
  	void (*yield_task) (struct rq *rq);
d95f41220   Mike Galbraith   sched: Add yield_...
1042
  	bool (*yield_to_task) (struct rq *rq, struct task_struct *p, bool preempt);
20b8a59f2   Ingo Molnar   sched: cfs, core ...
1043

7d4787214   Peter Zijlstra   sched: Rename syn...
1044
  	void (*check_preempt_curr) (struct rq *rq, struct task_struct *p, int flags);
20b8a59f2   Ingo Molnar   sched: cfs, core ...
1045

fb8d47240   Ingo Molnar   sched: remove the...
1046
  	struct task_struct * (*pick_next_task) (struct rq *rq);
31ee529cc   Ingo Molnar   sched: remove the...
1047
  	void (*put_prev_task) (struct rq *rq, struct task_struct *p);
20b8a59f2   Ingo Molnar   sched: cfs, core ...
1048

681f3e685   Peter Williams   sched: isolate SM...
1049
  #ifdef CONFIG_SMP
7608dec2c   Peter Zijlstra   sched: Drop the r...
1050
  	int  (*select_task_rq)(struct task_struct *p, int sd_flag, int flags);
4ce72a2c0   Li Zefan   sched: add CONFIG...
1051

9a897c5a6   Steven Rostedt   sched: RT-balance...
1052
1053
  	void (*pre_schedule) (struct rq *this_rq, struct task_struct *task);
  	void (*post_schedule) (struct rq *this_rq);
74f8e4b23   Peter Zijlstra   sched: Remove rq ...
1054
  	void (*task_waking) (struct task_struct *task);
efbbd05a5   Peter Zijlstra   sched: Add pre an...
1055
  	void (*task_woken) (struct rq *this_rq, struct task_struct *task);
e1d1484f7   Peter Williams   sched: reduce bal...
1056

cd8ba7cd9   Mike Travis   sched: add new se...
1057
  	void (*set_cpus_allowed)(struct task_struct *p,
96f874e26   Rusty Russell   sched: convert re...
1058
  				 const struct cpumask *newmask);
57d885fea   Gregory Haskins   sched: add sched-...
1059

1f11eb6a8   Gregory Haskins   sched: fix cpupri...
1060
1061
  	void (*rq_online)(struct rq *rq);
  	void (*rq_offline)(struct rq *rq);
4ce72a2c0   Li Zefan   sched: add CONFIG...
1062
1063
1064
1065
  #endif
  
  	void (*set_curr_task) (struct rq *rq);
  	void (*task_tick) (struct rq *rq, struct task_struct *p, int queued);
cd29fe6f2   Peter Zijlstra   sched: Sanitize f...
1066
  	void (*task_fork) (struct task_struct *p);
cb4698450   Steven Rostedt   sched: RT-balance...
1067

da7a735e5   Peter Zijlstra   sched: Fix switch...
1068
1069
  	void (*switched_from) (struct rq *this_rq, struct task_struct *task);
  	void (*switched_to) (struct rq *this_rq, struct task_struct *task);
cb4698450   Steven Rostedt   sched: RT-balance...
1070
  	void (*prio_changed) (struct rq *this_rq, struct task_struct *task,
da7a735e5   Peter Zijlstra   sched: Fix switch...
1071
  			     int oldprio);
810b38179   Peter Zijlstra   sched: retain vru...
1072

dba091b9e   Thomas Gleixner   sched: Protect sc...
1073
1074
  	unsigned int (*get_rr_interval) (struct rq *rq,
  					 struct task_struct *task);
0d721cead   Peter Williams   sched: Simplify s...
1075

810b38179   Peter Zijlstra   sched: retain vru...
1076
  #ifdef CONFIG_FAIR_GROUP_SCHED
b2b5ce022   Peter Zijlstra   sched, cgroup: Fi...
1077
  	void (*task_move_group) (struct task_struct *p, int on_rq);
810b38179   Peter Zijlstra   sched: retain vru...
1078
  #endif
20b8a59f2   Ingo Molnar   sched: cfs, core ...
1079
1080
1081
1082
1083
  };
  
  struct load_weight {
  	unsigned long weight, inv_weight;
  };
94c18227d   Ingo Molnar   [PATCH] sched: re...
1084
  #ifdef CONFIG_SCHEDSTATS
41acab885   Lucas De Marchi   sched: Implement ...
1085
  struct sched_statistics {
20b8a59f2   Ingo Molnar   sched: cfs, core ...
1086
  	u64			wait_start;
94c18227d   Ingo Molnar   [PATCH] sched: re...
1087
  	u64			wait_max;
6d082592b   Arjan van de Ven   sched: keep total...
1088
1089
  	u64			wait_count;
  	u64			wait_sum;
8f0dfc34e   Arjan van de Ven   sched: Provide io...
1090
1091
  	u64			iowait_count;
  	u64			iowait_sum;
94c18227d   Ingo Molnar   [PATCH] sched: re...
1092

20b8a59f2   Ingo Molnar   sched: cfs, core ...
1093
  	u64			sleep_start;
20b8a59f2   Ingo Molnar   sched: cfs, core ...
1094
  	u64			sleep_max;
94c18227d   Ingo Molnar   [PATCH] sched: re...
1095
1096
1097
  	s64			sum_sleep_runtime;
  
  	u64			block_start;
20b8a59f2   Ingo Molnar   sched: cfs, core ...
1098
1099
  	u64			block_max;
  	u64			exec_max;
eba1ed4b7   Ingo Molnar   sched: debug: tra...
1100
  	u64			slice_max;
cc367732f   Ingo Molnar   sched: debug, imp...
1101

cc367732f   Ingo Molnar   sched: debug, imp...
1102
1103
1104
1105
1106
  	u64			nr_migrations_cold;
  	u64			nr_failed_migrations_affine;
  	u64			nr_failed_migrations_running;
  	u64			nr_failed_migrations_hot;
  	u64			nr_forced_migrations;
cc367732f   Ingo Molnar   sched: debug, imp...
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
  
  	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;
41acab885   Lucas De Marchi   sched: Implement ...
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
  };
  #endif
  
  struct sched_entity {
  	struct load_weight	load;		/* for load-balancing */
  	struct rb_node		run_node;
  	struct list_head	group_node;
  	unsigned int		on_rq;
  
  	u64			exec_start;
  	u64			sum_exec_runtime;
  	u64			vruntime;
  	u64			prev_sum_exec_runtime;
41acab885   Lucas De Marchi   sched: Implement ...
1130
  	u64			nr_migrations;
41acab885   Lucas De Marchi   sched: Implement ...
1131
1132
  #ifdef CONFIG_SCHEDSTATS
  	struct sched_statistics statistics;
94c18227d   Ingo Molnar   [PATCH] sched: re...
1133
  #endif
20b8a59f2   Ingo Molnar   sched: cfs, core ...
1134
1135
1136
1137
1138
1139
1140
1141
  #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
  };
70b97a7f0   Ingo Molnar   [PATCH] sched: cl...
1142

fa717060f   Peter Zijlstra   sched: sched_rt_e...
1143
1144
  struct sched_rt_entity {
  	struct list_head run_list;
78f2c7db6   Peter Zijlstra   sched: SCHED_FIFO...
1145
  	unsigned long timeout;
bee367ed0   Richard Kennedy   sched: reorder st...
1146
  	unsigned int time_slice;
6f505b164   Peter Zijlstra   sched: rt group s...
1147
  	int nr_cpus_allowed;
58d6c2d72   Peter Zijlstra   sched: rt-group: ...
1148
  	struct sched_rt_entity *back;
052f1dc7e   Peter Zijlstra   sched: rt-group: ...
1149
  #ifdef CONFIG_RT_GROUP_SCHED
6f505b164   Peter Zijlstra   sched: rt group s...
1150
1151
1152
1153
1154
1155
  	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
fa717060f   Peter Zijlstra   sched: sched_rt_e...
1156
  };
868489660   Paul E. McKenney   rcu: Changes from...
1157
  struct rcu_node;
8dc85d547   Peter Zijlstra   perf: Multiple ta...
1158
1159
1160
  enum perf_event_task_context {
  	perf_invalid_context = -1,
  	perf_hw_context = 0,
89a1e1873   Peter Zijlstra   perf: Provide a s...
1161
  	perf_sw_context,
8dc85d547   Peter Zijlstra   perf: Multiple ta...
1162
1163
  	perf_nr_task_contexts,
  };
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1164
1165
  struct task_struct {
  	volatile long state;	/* -1 unrunnable, 0 runnable, >0 stopped */
f7e4217b0   Roman Zippel   rename thread_inf...
1166
  	void *stack;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1167
  	atomic_t usage;
97dc32cdb   William Cohen   reduce size of ta...
1168
1169
  	unsigned int flags;	/* per process flags, defined below */
  	unsigned int ptrace;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1170

2dd73a4f0   Peter Williams   [PATCH] sched: im...
1171
  #ifdef CONFIG_SMP
317f39416   Peter Zijlstra   sched: Move the s...
1172
  	struct task_struct *wake_entry;
3ca7a440d   Peter Zijlstra   sched: Always pro...
1173
  	int on_cpu;
2dd73a4f0   Peter Williams   [PATCH] sched: im...
1174
  #endif
fd2f4419b   Peter Zijlstra   sched: Provide p-...
1175
  	int on_rq;
50e645a8a   Ingo Molnar   sched: remove int...
1176

b29739f90   Ingo Molnar   [PATCH] pi-futex:...
1177
  	int prio, static_prio, normal_prio;
c7aceaba0   Richard Kennedy   sched: reorder ta...
1178
  	unsigned int rt_priority;
5522d5d5f   Ingo Molnar   sched: mark sched...
1179
  	const struct sched_class *sched_class;
20b8a59f2   Ingo Molnar   sched: cfs, core ...
1180
  	struct sched_entity se;
fa717060f   Peter Zijlstra   sched: sched_rt_e...
1181
  	struct sched_rt_entity rt;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1182

e107be36e   Avi Kivity   [PATCH] sched: ar...
1183
1184
1185
1186
  #ifdef CONFIG_PREEMPT_NOTIFIERS
  	/* list of struct preempt_notifier: */
  	struct hlist_head preempt_notifiers;
  #endif
18796aa00   Alexey Dobriyan   task_struct: move...
1187
1188
1189
1190
1191
1192
1193
1194
1195
  	/*
  	 * 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;
6c5c93415   Alexey Dobriyan   [PATCH] ifdef blk...
1196
  #ifdef CONFIG_BLK_DEV_IO_TRACE
2056a782f   Jens Axboe   [PATCH] Block que...
1197
  	unsigned int btrace_seq;
6c5c93415   Alexey Dobriyan   [PATCH] ifdef blk...
1198
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1199

97dc32cdb   William Cohen   reduce size of ta...
1200
  	unsigned int policy;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1201
  	cpumask_t cpus_allowed;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1202

a57eb940d   Paul E. McKenney   rcu: Add a TINY_P...
1203
  #ifdef CONFIG_PREEMPT_RCU
e260be673   Paul E. McKenney   Preempt-RCU: impl...
1204
  	int rcu_read_lock_nesting;
f41d911f8   Paul E. McKenney   rcu: Merge preemp...
1205
  	char rcu_read_unlock_special;
7765be2fe   Paul E. McKenney   rcu: Fix RCU_BOOS...
1206
1207
1208
  #if defined(CONFIG_RCU_BOOST) && defined(CONFIG_TREE_PREEMPT_RCU)
  	int rcu_boosted;
  #endif /* #if defined(CONFIG_RCU_BOOST) && defined(CONFIG_TREE_PREEMPT_RCU) */
f41d911f8   Paul E. McKenney   rcu: Merge preemp...
1209
  	struct list_head rcu_node_entry;
a57eb940d   Paul E. McKenney   rcu: Add a TINY_P...
1210
1211
1212
  #endif /* #ifdef CONFIG_PREEMPT_RCU */
  #ifdef CONFIG_TREE_PREEMPT_RCU
  	struct rcu_node *rcu_blocked_node;
f41d911f8   Paul E. McKenney   rcu: Merge preemp...
1213
  #endif /* #ifdef CONFIG_TREE_PREEMPT_RCU */
24278d148   Paul E. McKenney   rcu: priority boo...
1214
1215
1216
  #ifdef CONFIG_RCU_BOOST
  	struct rt_mutex *rcu_boost_mutex;
  #endif /* #ifdef CONFIG_RCU_BOOST */
e260be673   Paul E. McKenney   Preempt-RCU: impl...
1217

52f17b6c2   Chandra Seetharaman   [PATCH] per-task-...
1218
  #if defined(CONFIG_SCHEDSTATS) || defined(CONFIG_TASK_DELAY_ACCT)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1219
1220
1221
1222
  	struct sched_info sched_info;
  #endif
  
  	struct list_head tasks;
806c09a7d   Dario Faggioli   sched: Make pusha...
1223
  #ifdef CONFIG_SMP
917b627d4   Gregory Haskins   sched: create "pu...
1224
  	struct plist_node pushable_tasks;
806c09a7d   Dario Faggioli   sched: Make pusha...
1225
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1226
1227
  
  	struct mm_struct *mm, *active_mm;
4471a675d   Jiri Kosina   brk: COMPAT_BRK: ...
1228
1229
1230
  #ifdef CONFIG_COMPAT_BRK
  	unsigned brk_randomized:1;
  #endif
34e55232e   KAMEZAWA Hiroyuki   mm: avoid false s...
1231
1232
1233
  #if defined(SPLIT_RSS_COUNTING)
  	struct task_rss_stat	rss_stat;
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1234
  /* task state */
97dc32cdb   William Cohen   reduce size of ta...
1235
  	int exit_state;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1236
1237
  	int exit_code, exit_signal;
  	int pdeath_signal;  /*  The signal sent when the parent dies  */
a8f072c1d   Tejun Heo   job control: rena...
1238
  	unsigned int jobctl;	/* JOBCTL_*, siglock protected */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1239
  	/* ??? */
97dc32cdb   William Cohen   reduce size of ta...
1240
  	unsigned int personality;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1241
  	unsigned did_exec:1;
f9ce1f1cd   Kentaro Takeda   Add in_execve fla...
1242
1243
  	unsigned in_execve:1;	/* Tell the LSMs that the process is doing an
  				 * execve */
8f0dfc34e   Arjan van de Ven   sched: Provide io...
1244
  	unsigned in_iowait:1;
ca94c4425   Lennart Poettering   sched: Introduce ...
1245
1246
1247
  
  	/* Revert to default priority/policy when forking */
  	unsigned sched_reset_on_fork:1;
a8e4f2eae   Peter Zijlstra   sched: Delay task...
1248
  	unsigned sched_contributes_to_load:1;
ca94c4425   Lennart Poettering   sched: Introduce ...
1249

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1250
1251
  	pid_t pid;
  	pid_t tgid;
0a4254058   Arjan van de Ven   [PATCH] Add the c...
1252

1314562a9   Hiroshi Shimamoto   sched, task_struc...
1253
  #ifdef CONFIG_CC_STACKPROTECTOR
0a4254058   Arjan van de Ven   [PATCH] Add the c...
1254
1255
  	/* Canary value for the -fstack-protector gcc feature */
  	unsigned long stack_canary;
1314562a9   Hiroshi Shimamoto   sched, task_struc...
1256
  #endif
e00320875   Ingo Molnar   x86: fix stackpro...
1257

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1258
1259
1260
  	/* 
  	 * pointers to (original) parent process, youngest child, younger sibling,
  	 * older sibling, respectively.  (p->father can be replaced with 
f470021ad   Roland McGrath   ptrace children r...
1261
  	 * p->real_parent->pid)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1262
  	 */
f470021ad   Roland McGrath   ptrace children r...
1263
1264
  	struct task_struct *real_parent; /* real parent process */
  	struct task_struct *parent; /* recipient of SIGCHLD, wait4() reports */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1265
  	/*
f470021ad   Roland McGrath   ptrace children r...
1266
  	 * children/sibling forms the list of my natural children
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1267
1268
1269
1270
  	 */
  	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 */
f470021ad   Roland McGrath   ptrace children r...
1271
1272
1273
1274
1275
1276
1277
  	/*
  	 * ptraced is the list of tasks this task is using ptrace on.
  	 * This includes both natural children and PTRACE_ATTACH targets.
  	 * p->ptrace_entry is p's link on the p->parent->ptraced list.
  	 */
  	struct list_head ptraced;
  	struct list_head ptrace_entry;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1278
  	/* PID/PID hash table linkage. */
92476d7fc   Eric W. Biederman   [PATCH] pidhash: ...
1279
  	struct pid_link pids[PIDTYPE_MAX];
47e65328a   Oleg Nesterov   [PATCH] pids: kil...
1280
  	struct list_head thread_group;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1281
1282
1283
1284
  
  	struct completion *vfork_done;		/* for vfork() */
  	int __user *set_child_tid;		/* CLONE_CHILD_SETTID */
  	int __user *clear_child_tid;		/* CLONE_CHILD_CLEARTID */
c66f08be7   Michael Neuling   Add scaled time t...
1285
  	cputime_t utime, stime, utimescaled, stimescaled;
9ac52315d   Laurent Vivier   sched: guest CPU ...
1286
  	cputime_t gtime;
d99ca3b97   Hidetoshi Seto   sched, cputime: C...
1287
  #ifndef CONFIG_VIRT_CPU_ACCOUNTING
9301899be   Balbir Singh   sched: fix /proc/...
1288
  	cputime_t prev_utime, prev_stime;
d99ca3b97   Hidetoshi Seto   sched, cputime: C...
1289
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1290
  	unsigned long nvcsw, nivcsw; /* context switch counts */
924b42d5a   Tomas Janousek   Use boot based ti...
1291
1292
  	struct timespec start_time; 		/* monotonic time */
  	struct timespec real_start_time;	/* boot based time */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1293
1294
  /* mm fault and swap info: this can arguably be seen as either mm-specific or thread-specific */
  	unsigned long min_flt, maj_flt;
f06febc96   Frank Mayhar   timers: fix itime...
1295
  	struct task_cputime cputime_expires;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1296
1297
1298
  	struct list_head cpu_timers[3];
  
  /* process credentials */
1b0ba1c90   Arnd Bergmann   credentials: rcu ...
1299
  	const struct cred __rcu *real_cred; /* objective and real subjective task
3b11a1dec   David Howells   CRED: Differentia...
1300
  					 * credentials (COW) */
1b0ba1c90   Arnd Bergmann   credentials: rcu ...
1301
  	const struct cred __rcu *cred;	/* effective (overridable) subjective task
3b11a1dec   David Howells   CRED: Differentia...
1302
  					 * credentials (COW) */
ee18d64c1   David Howells   KEYS: Add a keyct...
1303
  	struct cred *replacement_session_keyring; /* for KEYCTL_SESSION_TO_PARENT */
b6dff3ec5   David Howells   CRED: Separate ta...
1304

367720923   Paolo 'Blaisorblade' Giarrusso   [PATCH] comments ...
1305
1306
1307
  	char comm[TASK_COMM_LEN]; /* executable name excluding path
  				     - access with [gs]et_task_comm (which lock
  				       it with task_lock())
221af7f87   Linus Torvalds   Split 'flush_old_...
1308
  				     - initialized normally by setup_new_exec */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1309
1310
  /* file system info */
  	int link_count, total_link_count;
3d5b6fccc   Alexey Dobriyan   [PATCH] task_stru...
1311
  #ifdef CONFIG_SYSVIPC
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1312
1313
  /* ipc stuff */
  	struct sysv_sem sysvsem;
3d5b6fccc   Alexey Dobriyan   [PATCH] task_stru...
1314
  #endif
e162b39a3   Mandeep Singh Baines   softlockup: decou...
1315
  #ifdef CONFIG_DETECT_HUNG_TASK
82a1fcb90   Ingo Molnar   softlockup: autom...
1316
  /* hung task detection */
82a1fcb90   Ingo Molnar   softlockup: autom...
1317
1318
  	unsigned long last_switch_count;
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1319
1320
1321
1322
1323
1324
  /* CPU-specific state of this task */
  	struct thread_struct thread;
  /* filesystem information */
  	struct fs_struct *fs;
  /* open file information */
  	struct files_struct *files;
1651e14e2   Serge E. Hallyn   [PATCH] namespace...
1325
  /* namespaces */
ab516013a   Serge E. Hallyn   [PATCH] namespace...
1326
  	struct nsproxy *nsproxy;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1327
1328
1329
1330
1331
  /* signal handlers */
  	struct signal_struct *signal;
  	struct sighand_struct *sighand;
  
  	sigset_t blocked, real_blocked;
f3de272b8   Roland McGrath   signals: use HAVE...
1332
  	sigset_t saved_sigmask;	/* restored if set_restore_sigmask() was used */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1333
1334
1335
1336
1337
1338
1339
  	struct sigpending pending;
  
  	unsigned long sas_ss_sp;
  	size_t sas_ss_size;
  	int (*notifier)(void *priv);
  	void *notifier_data;
  	sigset_t *notifier_mask;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1340
  	struct audit_context *audit_context;
bfef93a5d   Al Viro   [PATCH] get rid o...
1341
1342
  #ifdef CONFIG_AUDITSYSCALL
  	uid_t loginuid;
4746ec5b0   Eric Paris   [AUDIT] add sessi...
1343
  	unsigned int sessionid;
bfef93a5d   Al Viro   [PATCH] get rid o...
1344
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1345
1346
1347
1348
1349
  	seccomp_t seccomp;
  
  /* Thread group tracking */
     	u32 parent_exec_id;
     	u32 self_exec_id;
58568d2a8   Miao Xie   cpuset,mm: update...
1350
1351
  /* Protection of (de-)allocation: mm, files, fs, tty, keyrings, mems_allowed,
   * mempolicy */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1352
  	spinlock_t alloc_lock;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1353

3aa551c9b   Thomas Gleixner   genirq: add threa...
1354
1355
1356
1357
  #ifdef CONFIG_GENERIC_HARDIRQS
  	/* IRQ handler threads */
  	struct irqaction *irqaction;
  #endif
b29739f90   Ingo Molnar   [PATCH] pi-futex:...
1358
  	/* Protection of the PI data structures: */
1d6154825   Thomas Gleixner   sched: Convert pi...
1359
  	raw_spinlock_t pi_lock;
b29739f90   Ingo Molnar   [PATCH] pi-futex:...
1360

23f78d4a0   Ingo Molnar   [PATCH] pi-futex:...
1361
1362
1363
1364
1365
  #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;
23f78d4a0   Ingo Molnar   [PATCH] pi-futex:...
1366
  #endif
408894ee4   Ingo Molnar   [PATCH] mutex sub...
1367
1368
1369
1370
  #ifdef CONFIG_DEBUG_MUTEXES
  	/* mutex deadlock detection */
  	struct mutex_waiter *blocked_on;
  #endif
de30a2b35   Ingo Molnar   [PATCH] lockdep: ...
1371
1372
  #ifdef CONFIG_TRACE_IRQFLAGS
  	unsigned int irq_events;
de30a2b35   Ingo Molnar   [PATCH] lockdep: ...
1373
  	unsigned long hardirq_enable_ip;
de30a2b35   Ingo Molnar   [PATCH] lockdep: ...
1374
  	unsigned long hardirq_disable_ip;
fa1452e80   Hiroshi Shimamoto   locking, task_str...
1375
  	unsigned int hardirq_enable_event;
de30a2b35   Ingo Molnar   [PATCH] lockdep: ...
1376
  	unsigned int hardirq_disable_event;
fa1452e80   Hiroshi Shimamoto   locking, task_str...
1377
1378
  	int hardirqs_enabled;
  	int hardirq_context;
de30a2b35   Ingo Molnar   [PATCH] lockdep: ...
1379
  	unsigned long softirq_disable_ip;
de30a2b35   Ingo Molnar   [PATCH] lockdep: ...
1380
  	unsigned long softirq_enable_ip;
fa1452e80   Hiroshi Shimamoto   locking, task_str...
1381
  	unsigned int softirq_disable_event;
de30a2b35   Ingo Molnar   [PATCH] lockdep: ...
1382
  	unsigned int softirq_enable_event;
fa1452e80   Hiroshi Shimamoto   locking, task_str...
1383
  	int softirqs_enabled;
de30a2b35   Ingo Molnar   [PATCH] lockdep: ...
1384
1385
  	int softirq_context;
  #endif
fbb9ce953   Ingo Molnar   [PATCH] lockdep: ...
1386
  #ifdef CONFIG_LOCKDEP
bdb9441e9   Peter Zijlstra   lockdep: increase...
1387
  # define MAX_LOCK_DEPTH 48UL
fbb9ce953   Ingo Molnar   [PATCH] lockdep: ...
1388
1389
  	u64 curr_chain_key;
  	int lockdep_depth;
fbb9ce953   Ingo Molnar   [PATCH] lockdep: ...
1390
  	unsigned int lockdep_recursion;
c7aceaba0   Richard Kennedy   sched: reorder ta...
1391
  	struct held_lock held_locks[MAX_LOCK_DEPTH];
cf40bd16f   Nick Piggin   lockdep: annotate...
1392
  	gfp_t lockdep_reclaim_gfp;
fbb9ce953   Ingo Molnar   [PATCH] lockdep: ...
1393
  #endif
408894ee4   Ingo Molnar   [PATCH] mutex sub...
1394

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1395
1396
  /* journalling filesystem info */
  	void *journal_info;
d89d87965   Neil Brown   When stacked bloc...
1397
  /* stacked block device info */
bddd87c7e   Akinobu Mita   blk-core: use BIO...
1398
  	struct bio_list *bio_list;
d89d87965   Neil Brown   When stacked bloc...
1399

73c101011   Jens Axboe   block: initial pa...
1400
1401
1402
1403
  #ifdef CONFIG_BLOCK
  /* stack plugging */
  	struct blk_plug *plug;
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1404
1405
  /* VM state */
  	struct reclaim_state *reclaim_state;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1406
1407
1408
1409
1410
1411
  	struct backing_dev_info *backing_dev_info;
  
  	struct io_context *io_context;
  
  	unsigned long ptrace_message;
  	siginfo_t *last_siginfo; /* For ptrace use.  */
7c3ab7381   Andrew Morton   [PATCH] io-accoun...
1412
  	struct task_io_accounting ioac;
8f0ab5147   Jay Lan   [PATCH] csa: conv...
1413
  #if defined(CONFIG_TASK_XACCT)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1414
1415
  	u64 acct_rss_mem1;	/* accumulated rss usage */
  	u64 acct_vm_mem1;	/* accumulated virtual memory usage */
49b5cf347   Jonathan Lim   accounting: accou...
1416
  	cputime_t acct_timexpd;	/* stime + utime since last update */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1417
1418
  #endif
  #ifdef CONFIG_CPUSETS
58568d2a8   Miao Xie   cpuset,mm: update...
1419
  	nodemask_t mems_allowed;	/* Protected by alloc_lock */
c0ff7453b   Miao Xie   cpuset,mm: fix no...
1420
  	int mems_allowed_change_disable;
825a46af5   Paul Jackson   [PATCH] cpuset me...
1421
  	int cpuset_mem_spread_rotor;
6adef3ebe   Jack Steiner   cpusets: new roun...
1422
  	int cpuset_slab_spread_rotor;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1423
  #endif
ddbcc7e8e   Paul Menage   Task Control Grou...
1424
  #ifdef CONFIG_CGROUPS
817929ec2   Paul Menage   Task Control Grou...
1425
  	/* Control Group info protected by css_set_lock */
2c392b8c3   Arnd Bergmann   cgroups: __rcu an...
1426
  	struct css_set __rcu *cgroups;
817929ec2   Paul Menage   Task Control Grou...
1427
1428
  	/* cg_list protected by css_set_lock and tsk->alloc_lock */
  	struct list_head cg_list;
ddbcc7e8e   Paul Menage   Task Control Grou...
1429
  #endif
42b2dd0a0   Alexey Dobriyan   Shrink task_struc...
1430
  #ifdef CONFIG_FUTEX
0771dfefc   Ingo Molnar   [PATCH] lightweig...
1431
  	struct robust_list_head __user *robust_list;
34f192c65   Ingo Molnar   [PATCH] lightweig...
1432
1433
1434
  #ifdef CONFIG_COMPAT
  	struct compat_robust_list_head __user *compat_robust_list;
  #endif
c87e2837b   Ingo Molnar   [PATCH] pi-futex:...
1435
1436
  	struct list_head pi_state_list;
  	struct futex_pi_state *pi_state_cache;
42b2dd0a0   Alexey Dobriyan   Shrink task_struc...
1437
  #endif
cdd6c482c   Ingo Molnar   perf: Do the big ...
1438
  #ifdef CONFIG_PERF_EVENTS
8dc85d547   Peter Zijlstra   perf: Multiple ta...
1439
  	struct perf_event_context *perf_event_ctxp[perf_nr_task_contexts];
cdd6c482c   Ingo Molnar   perf: Do the big ...
1440
1441
  	struct mutex perf_event_mutex;
  	struct list_head perf_event_list;
a63eaf34a   Paul Mackerras   perf_counter: Dyn...
1442
  #endif
c7aceaba0   Richard Kennedy   sched: reorder ta...
1443
  #ifdef CONFIG_NUMA
58568d2a8   Miao Xie   cpuset,mm: update...
1444
  	struct mempolicy *mempolicy;	/* Protected by alloc_lock */
c7aceaba0   Richard Kennedy   sched: reorder ta...
1445
  	short il_next;
207205a2b   Eric Dumazet   kthread: NUMA awa...
1446
  	short pref_node_fork;
c7aceaba0   Richard Kennedy   sched: reorder ta...
1447
  #endif
e56d09031   Ingo Molnar   [PATCH] RCU signa...
1448
  	struct rcu_head rcu;
b92ce5589   Jens Axboe   [PATCH] splice: a...
1449
1450
1451
1452
1453
  
  	/*
  	 * cache last used pipe for splice
  	 */
  	struct pipe_inode_info *splice_pipe;
ca74e92b4   Shailabh Nagar   [PATCH] per-task-...
1454
1455
  #ifdef	CONFIG_TASK_DELAY_ACCT
  	struct task_delay_info *delays;
f4f154fd9   Akinobu Mita   [PATCH] fault inj...
1456
1457
1458
  #endif
  #ifdef CONFIG_FAULT_INJECTION
  	int make_it_fail;
ca74e92b4   Shailabh Nagar   [PATCH] per-task-...
1459
  #endif
3e26c149c   Peter Zijlstra   mm: dirty balanci...
1460
  	struct prop_local_single dirties;
9745512ce   Arjan van de Ven   sched: latencytop...
1461
1462
1463
1464
  #ifdef CONFIG_LATENCYTOP
  	int latency_record_count;
  	struct latency_record latency_record[LT_SAVECOUNT];
  #endif
6976675d9   Arjan van de Ven   hrtimer: create a...
1465
1466
1467
1468
1469
1470
  	/*
  	 * time slack values; these are used to round up poll() and
  	 * select() etc timeout values. These are in nanoseconds.
  	 */
  	unsigned long timer_slack_ns;
  	unsigned long default_timer_slack_ns;
f8d570a47   David Miller   net: Fix recursiv...
1471
1472
  
  	struct list_head	*scm_work_list;
fb52607af   Frederic Weisbecker   tracing/function-...
1473
  #ifdef CONFIG_FUNCTION_GRAPH_TRACER
3ad2f3fbb   Daniel Mack   tree-wide: Assort...
1474
  	/* Index of current stored address in ret_stack */
f201ae235   Frederic Weisbecker   tracing/function-...
1475
1476
1477
  	int curr_ret_stack;
  	/* Stack of return addresses for return function tracing */
  	struct ftrace_ret_stack	*ret_stack;
8aef2d285   Steven Rostedt   function-graph: i...
1478
1479
  	/* time stamp for last schedule */
  	unsigned long long ftrace_timestamp;
f201ae235   Frederic Weisbecker   tracing/function-...
1480
1481
1482
1483
1484
  	/*
  	 * Number of functions that haven't been traced
  	 * because of depth overrun.
  	 */
  	atomic_t trace_overrun;
380c4b141   Frederic Weisbecker   tracing/function-...
1485
1486
  	/* Pause for the tracing */
  	atomic_t tracing_graph_pause;
f201ae235   Frederic Weisbecker   tracing/function-...
1487
  #endif
ea4e2bc4d   Steven Rostedt   ftrace: graph of ...
1488
1489
1490
  #ifdef CONFIG_TRACING
  	/* state flags for use by tracers */
  	unsigned long trace;
b1cff0ad1   Steven Rostedt   ftrace: Add inter...
1491
  	/* bitmask and counter of trace recursion */
261842b7c   Steven Rostedt   tracing: add same...
1492
1493
  	unsigned long trace_recursion;
  #endif /* CONFIG_TRACING */
569b846df   KAMEZAWA Hiroyuki   memcg: coalesce u...
1494
1495
1496
1497
  #ifdef CONFIG_CGROUP_MEM_RES_CTLR /* memcg uses this to do batch job */
  	struct memcg_batch_info {
  		int do_batch;	/* incremented when batch uncharge started */
  		struct mem_cgroup *memcg; /* target memcg of uncharge */
7ffd4ca7a   Johannes Weiner   memcg: convert un...
1498
1499
  		unsigned long nr_pages;	/* uncharged usage */
  		unsigned long memsw_nr_pages; /* uncharged mem+swap usage */
569b846df   KAMEZAWA Hiroyuki   memcg: coalesce u...
1500
1501
  	} memcg_batch;
  #endif
bf26c0184   Frederic Weisbecker   ptrace: Prepare t...
1502
1503
1504
  #ifdef CONFIG_HAVE_HW_BREAKPOINT
  	atomic_t ptrace_bp_refcnt;
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1505
  };
76e6eee03   Rusty Russell   cpumask: tsk_cpum...
1506
  /* Future-safe accessor for struct task_struct's cpus_allowed. */
a4636818f   Rusty Russell   cpumask: rename t...
1507
  #define tsk_cpus_allowed(tsk) (&(tsk)->cpus_allowed)
76e6eee03   Rusty Russell   cpumask: tsk_cpum...
1508

e05606d33   Ingo Molnar   sched: clean up t...
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
  /*
   * Priority of a process goes from 0..MAX_PRIO-1, valid RT
   * priority is 0..MAX_RT_PRIO-1, and SCHED_NORMAL/SCHED_BATCH
   * tasks are in the range MAX_RT_PRIO..MAX_PRIO-1. Priority
   * values are inverted: lower p->prio value means higher priority.
   *
   * The MAX_USER_RT_PRIO value allows the actual maximum
   * RT priority to be separate from the value exported to
   * user-space.  This allows kernel threads to set their
   * priority to a value higher than any user task. Note:
   * MAX_RT_PRIO must not be smaller than MAX_USER_RT_PRIO.
   */
  
  #define MAX_USER_RT_PRIO	100
  #define MAX_RT_PRIO		MAX_USER_RT_PRIO
  
  #define MAX_PRIO		(MAX_RT_PRIO + 40)
  #define DEFAULT_PRIO		(MAX_RT_PRIO + 20)
  
  static inline int rt_prio(int prio)
  {
  	if (unlikely(prio < MAX_RT_PRIO))
  		return 1;
  	return 0;
  }
e868171a9   Alexey Dobriyan   De-constify sched.h
1534
  static inline int rt_task(struct task_struct *p)
e05606d33   Ingo Molnar   sched: clean up t...
1535
1536
1537
  {
  	return rt_prio(p->prio);
  }
e868171a9   Alexey Dobriyan   De-constify sched.h
1538
  static inline struct pid *task_pid(struct task_struct *task)
22c935f47   Eric W. Biederman   [PATCH] pid: impl...
1539
1540
1541
  {
  	return task->pids[PIDTYPE_PID].pid;
  }
e868171a9   Alexey Dobriyan   De-constify sched.h
1542
  static inline struct pid *task_tgid(struct task_struct *task)
22c935f47   Eric W. Biederman   [PATCH] pid: impl...
1543
1544
1545
  {
  	return task->group_leader->pids[PIDTYPE_PID].pid;
  }
6dda81f43   Oleg Nesterov   pids: document ta...
1546
1547
1548
1549
1550
  /*
   * Without tasklist or rcu lock it is not safe to dereference
   * the result of task_pgrp/task_session even if task == current,
   * we can race with another thread doing sys_setsid/sys_setpgid.
   */
e868171a9   Alexey Dobriyan   De-constify sched.h
1551
  static inline struct pid *task_pgrp(struct task_struct *task)
22c935f47   Eric W. Biederman   [PATCH] pid: impl...
1552
1553
1554
  {
  	return task->group_leader->pids[PIDTYPE_PGID].pid;
  }
e868171a9   Alexey Dobriyan   De-constify sched.h
1555
  static inline struct pid *task_session(struct task_struct *task)
22c935f47   Eric W. Biederman   [PATCH] pid: impl...
1556
1557
1558
  {
  	return task->group_leader->pids[PIDTYPE_SID].pid;
  }
7af572947   Pavel Emelyanov   pid namespaces: h...
1559
1560
1561
1562
1563
1564
1565
  struct pid_namespace;
  
  /*
   * the helpers to get the task's different pids as they are seen
   * from various namespaces
   *
   * task_xid_nr()     : global id, i.e. the id seen from the init namespace;
44c4e1b25   Eric W. Biederman   pid: Extend/Fix p...
1566
1567
   * task_xid_vnr()    : virtual id, i.e. the id seen from the pid namespace of
   *                     current.
7af572947   Pavel Emelyanov   pid namespaces: h...
1568
1569
1570
1571
   * task_xid_nr_ns()  : id seen from the ns specified;
   *
   * set_task_vxid()   : assigns a virtual id to a task;
   *
7af572947   Pavel Emelyanov   pid namespaces: h...
1572
1573
   * see also pid_nr() etc in include/linux/pid.h
   */
52ee2dfdd   Oleg Nesterov   pids: refactor vn...
1574
1575
  pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,
  			struct pid_namespace *ns);
7af572947   Pavel Emelyanov   pid namespaces: h...
1576

e868171a9   Alexey Dobriyan   De-constify sched.h
1577
  static inline pid_t task_pid_nr(struct task_struct *tsk)
7af572947   Pavel Emelyanov   pid namespaces: h...
1578
1579
1580
  {
  	return tsk->pid;
  }
52ee2dfdd   Oleg Nesterov   pids: refactor vn...
1581
1582
1583
1584
1585
  static inline pid_t task_pid_nr_ns(struct task_struct *tsk,
  					struct pid_namespace *ns)
  {
  	return __task_pid_nr_ns(tsk, PIDTYPE_PID, ns);
  }
7af572947   Pavel Emelyanov   pid namespaces: h...
1586
1587
1588
  
  static inline pid_t task_pid_vnr(struct task_struct *tsk)
  {
52ee2dfdd   Oleg Nesterov   pids: refactor vn...
1589
  	return __task_pid_nr_ns(tsk, PIDTYPE_PID, NULL);
7af572947   Pavel Emelyanov   pid namespaces: h...
1590
  }
e868171a9   Alexey Dobriyan   De-constify sched.h
1591
  static inline pid_t task_tgid_nr(struct task_struct *tsk)
7af572947   Pavel Emelyanov   pid namespaces: h...
1592
1593
1594
  {
  	return tsk->tgid;
  }
2f2a3a46f   Pavel Emelyanov   Uninline the task...
1595
  pid_t task_tgid_nr_ns(struct task_struct *tsk, struct pid_namespace *ns);
7af572947   Pavel Emelyanov   pid namespaces: h...
1596
1597
1598
1599
1600
  
  static inline pid_t task_tgid_vnr(struct task_struct *tsk)
  {
  	return pid_vnr(task_tgid(tsk));
  }
52ee2dfdd   Oleg Nesterov   pids: refactor vn...
1601
1602
  static inline pid_t task_pgrp_nr_ns(struct task_struct *tsk,
  					struct pid_namespace *ns)
7af572947   Pavel Emelyanov   pid namespaces: h...
1603
  {
52ee2dfdd   Oleg Nesterov   pids: refactor vn...
1604
  	return __task_pid_nr_ns(tsk, PIDTYPE_PGID, ns);
7af572947   Pavel Emelyanov   pid namespaces: h...
1605
  }
7af572947   Pavel Emelyanov   pid namespaces: h...
1606
1607
  static inline pid_t task_pgrp_vnr(struct task_struct *tsk)
  {
52ee2dfdd   Oleg Nesterov   pids: refactor vn...
1608
  	return __task_pid_nr_ns(tsk, PIDTYPE_PGID, NULL);
7af572947   Pavel Emelyanov   pid namespaces: h...
1609
  }
52ee2dfdd   Oleg Nesterov   pids: refactor vn...
1610
1611
  static inline pid_t task_session_nr_ns(struct task_struct *tsk,
  					struct pid_namespace *ns)
7af572947   Pavel Emelyanov   pid namespaces: h...
1612
  {
52ee2dfdd   Oleg Nesterov   pids: refactor vn...
1613
  	return __task_pid_nr_ns(tsk, PIDTYPE_SID, ns);
7af572947   Pavel Emelyanov   pid namespaces: h...
1614
  }
7af572947   Pavel Emelyanov   pid namespaces: h...
1615
1616
  static inline pid_t task_session_vnr(struct task_struct *tsk)
  {
52ee2dfdd   Oleg Nesterov   pids: refactor vn...
1617
  	return __task_pid_nr_ns(tsk, PIDTYPE_SID, NULL);
7af572947   Pavel Emelyanov   pid namespaces: h...
1618
  }
1b0f7ffd0   Oleg Nesterov   pids: kill signal...
1619
1620
1621
1622
1623
  /* obsolete, do not use */
  static inline pid_t task_pgrp_nr(struct task_struct *tsk)
  {
  	return task_pgrp_nr_ns(tsk, &init_pid_ns);
  }
7af572947   Pavel Emelyanov   pid namespaces: h...
1624

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1625
1626
1627
1628
1629
1630
1631
1632
  /**
   * pid_alive - check that a task structure is not stale
   * @p: Task structure to be checked.
   *
   * Test if a process is not yet dead (at most zombie state)
   * If pid_alive fails, then pointers within the task structure
   * can be stale and must not be dereferenced.
   */
e868171a9   Alexey Dobriyan   De-constify sched.h
1633
  static inline int pid_alive(struct task_struct *p)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1634
  {
92476d7fc   Eric W. Biederman   [PATCH] pidhash: ...
1635
  	return p->pids[PIDTYPE_PID].pid != NULL;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1636
  }
f400e198b   Sukadev Bhattiprolu   [PATCH] pidspace:...
1637
  /**
b460cbc58   Serge E. Hallyn   pid namespaces: d...
1638
   * is_global_init - check if a task structure is init
3260259f0   Henrik Kretzschmar   [PATCH] sched: fi...
1639
1640
1641
   * @tsk: Task structure to be checked.
   *
   * Check if a task structure is the first user space task the kernel created.
b460cbc58   Serge E. Hallyn   pid namespaces: d...
1642
   */
e868171a9   Alexey Dobriyan   De-constify sched.h
1643
  static inline int is_global_init(struct task_struct *tsk)
b461cc038   Pavel Emelyanov   pid namespaces: m...
1644
1645
1646
  {
  	return tsk->pid == 1;
  }
b460cbc58   Serge E. Hallyn   pid namespaces: d...
1647
1648
1649
1650
  
  /*
   * is_container_init:
   * check whether in the task is init in its own pid namespace.
f400e198b   Sukadev Bhattiprolu   [PATCH] pidspace:...
1651
   */
b461cc038   Pavel Emelyanov   pid namespaces: m...
1652
  extern int is_container_init(struct task_struct *tsk);
f400e198b   Sukadev Bhattiprolu   [PATCH] pidspace:...
1653

9ec52099e   Cedric Le Goater   [PATCH] replace c...
1654
  extern struct pid *cad_pid;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1655
  extern void free_task(struct task_struct *tsk);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1656
  #define get_task_struct(tsk) do { atomic_inc(&(tsk)->usage); } while(0)
e56d09031   Ingo Molnar   [PATCH] RCU signa...
1657

158d9ebd1   Andrew Morton   [PATCH] resurrect...
1658
  extern void __put_task_struct(struct task_struct *t);
e56d09031   Ingo Molnar   [PATCH] RCU signa...
1659
1660
1661
1662
  
  static inline void put_task_struct(struct task_struct *t)
  {
  	if (atomic_dec_and_test(&t->usage))
8c7904a00   Eric W. Biederman   [PATCH] task: RCU...
1663
  		__put_task_struct(t);
e56d09031   Ingo Molnar   [PATCH] RCU signa...
1664
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1665

d180c5bcc   Hidetoshi Seto   sched: Introduce ...
1666
  extern void task_times(struct task_struct *p, cputime_t *ut, cputime_t *st);
0cf55e1ec   Hidetoshi Seto   sched, cputime: I...
1667
  extern void thread_group_times(struct task_struct *p, cputime_t *ut, cputime_t *st);
49048622e   Balbir Singh   sched: fix proces...
1668

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1669
1670
1671
  /*
   * Per process flags
   */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1672
1673
  #define PF_STARTING	0x00000002	/* being created */
  #define PF_EXITING	0x00000004	/* getting shut down */
778e9a9c3   Alexey Kuznetsov   pi-futex: fix exi...
1674
  #define PF_EXITPIDONE	0x00000008	/* pi exit done on shut down */
94886b84b   Laurent Vivier   sched: guest CPU ...
1675
  #define PF_VCPU		0x00000010	/* I'm a virtual CPU */
21aa9af03   Tejun Heo   sched: add hooks ...
1676
  #define PF_WQ_WORKER	0x00000020	/* I'm a workqueue worker */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1677
  #define PF_FORKNOEXEC	0x00000040	/* forked but didn't exec */
4db96cf07   Andi Kleen   HWPOISON: Add PR_...
1678
  #define PF_MCE_PROCESS  0x00000080      /* process policy on mce errors */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1679
1680
1681
1682
  #define PF_SUPERPRIV	0x00000100	/* used super-user privileges */
  #define PF_DUMPCORE	0x00000200	/* dumped core */
  #define PF_SIGNALED	0x00000400	/* killed by a signal */
  #define PF_MEMALLOC	0x00000800	/* Allocating memory */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1683
  #define PF_USED_MATH	0x00002000	/* if unset the fpu must be initialized before use */
6301cb95c   Thomas Gleixner   sched: fix nr_uni...
1684
  #define PF_FREEZING	0x00004000	/* freeze in progress. do not account to load */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1685
1686
1687
1688
  #define PF_NOFREEZE	0x00008000	/* this thread should not be frozen */
  #define PF_FROZEN	0x00010000	/* frozen for system suspend */
  #define PF_FSTRANS	0x00020000	/* inside a filesystem transaction */
  #define PF_KSWAPD	0x00040000	/* I am kswapd */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1689
  #define PF_LESS_THROTTLE 0x00100000	/* Throttle me less: I clean memory */
246bb0b1d   Oleg Nesterov   kill PF_BORROWED_...
1690
  #define PF_KTHREAD	0x00200000	/* I am a kernel thread */
b31dc66a5   Jens Axboe   [PATCH] Kill PF_S...
1691
1692
1693
1694
  #define PF_RANDOMIZE	0x00400000	/* randomize virtual address space */
  #define PF_SWAPWRITE	0x00800000	/* Allowed to write to swap */
  #define PF_SPREAD_PAGE	0x01000000	/* Spread page cache over cpuset */
  #define PF_SPREAD_SLAB	0x02000000	/* Spread some slab caches over cpuset */
9985b0bab   David Rientjes   sched: prevent bo...
1695
  #define PF_THREAD_BOUND	0x04000000	/* Thread bound to specific cpu */
4db96cf07   Andi Kleen   HWPOISON: Add PR_...
1696
  #define PF_MCE_EARLY    0x08000000      /* Early kill for mce process policy */
c61afb181   Paul Jackson   [PATCH] cpuset me...
1697
  #define PF_MEMPOLICY	0x10000000	/* Non-default NUMA mempolicy */
61a871228   Thomas Gleixner   [PATCH] pi-futex:...
1698
  #define PF_MUTEX_TESTER	0x20000000	/* Thread belongs to the rt mutex tester */
58a69cb47   Tejun Heo   workqueue, freeze...
1699
  #define PF_FREEZER_SKIP	0x40000000	/* Freezer should not count it as freezable */
ebb12db51   Rafael J. Wysocki   Freezer: Introduc...
1700
  #define PF_FREEZER_NOSIG 0x80000000	/* Freezer won't send signals to it */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
  
  /*
   * Only the _current_ task can read/write to tsk->flags, but other
   * tasks can access tsk->flags in readonly mode for example
   * with tsk_used_math (like during threaded core dumping).
   * There is however an exception to this rule during ptrace
   * or during fork: the ptracer task is allowed to write to the
   * child->flags of its traced child (same goes for fork, the parent
   * can write to the child->flags), because we're guaranteed the
   * child is not running and in turn not changing child->flags
   * at the same time the parent does it.
   */
  #define clear_stopped_child_used_math(child) do { (child)->flags &= ~PF_USED_MATH; } while (0)
  #define set_stopped_child_used_math(child) do { (child)->flags |= PF_USED_MATH; } while (0)
  #define clear_used_math() clear_stopped_child_used_math(current)
  #define set_used_math() set_stopped_child_used_math(current)
  #define conditional_stopped_child_used_math(condition, child) \
  	do { (child)->flags &= ~PF_USED_MATH, (child)->flags |= (condition) ? PF_USED_MATH : 0; } while (0)
  #define conditional_used_math(condition) \
  	conditional_stopped_child_used_math(condition, current)
  #define copy_to_stopped_child_used_math(child) \
  	do { (child)->flags &= ~PF_USED_MATH, (child)->flags |= current->flags & PF_USED_MATH; } while (0)
  /* NOTE: this will return 0 or PF_USED_MATH, it will never return 1 */
  #define tsk_used_math(p) ((p)->flags & PF_USED_MATH)
  #define used_math() tsk_used_math(current)
e5c1902e9   Tejun Heo   signal: Fix prema...
1726
  /*
a8f072c1d   Tejun Heo   job control: rena...
1727
   * task->jobctl flags
e5c1902e9   Tejun Heo   signal: Fix prema...
1728
   */
a8f072c1d   Tejun Heo   job control: rena...
1729
  #define JOBCTL_STOP_SIGMASK	0xffff	/* signr of the last group stop */
e5c1902e9   Tejun Heo   signal: Fix prema...
1730

a8f072c1d   Tejun Heo   job control: rena...
1731
1732
1733
  #define JOBCTL_STOP_DEQUEUED_BIT 16	/* stop signal dequeued */
  #define JOBCTL_STOP_PENDING_BIT	17	/* task should stop for group stop */
  #define JOBCTL_STOP_CONSUME_BIT	18	/* consume group stop count */
73ddff2be   Tejun Heo   job control: intr...
1734
  #define JOBCTL_TRAP_STOP_BIT	19	/* trap for STOP */
fb1d910c1   Tejun Heo   ptrace: implement...
1735
  #define JOBCTL_TRAP_NOTIFY_BIT	20	/* trap for NOTIFY */
a8f072c1d   Tejun Heo   job control: rena...
1736
  #define JOBCTL_TRAPPING_BIT	21	/* switching to TRACED */
544b2c91a   Tejun Heo   ptrace: implement...
1737
  #define JOBCTL_LISTENING_BIT	22	/* ptracer is listening for events */
a8f072c1d   Tejun Heo   job control: rena...
1738
1739
1740
1741
  
  #define JOBCTL_STOP_DEQUEUED	(1 << JOBCTL_STOP_DEQUEUED_BIT)
  #define JOBCTL_STOP_PENDING	(1 << JOBCTL_STOP_PENDING_BIT)
  #define JOBCTL_STOP_CONSUME	(1 << JOBCTL_STOP_CONSUME_BIT)
73ddff2be   Tejun Heo   job control: intr...
1742
  #define JOBCTL_TRAP_STOP	(1 << JOBCTL_TRAP_STOP_BIT)
fb1d910c1   Tejun Heo   ptrace: implement...
1743
  #define JOBCTL_TRAP_NOTIFY	(1 << JOBCTL_TRAP_NOTIFY_BIT)
a8f072c1d   Tejun Heo   job control: rena...
1744
  #define JOBCTL_TRAPPING		(1 << JOBCTL_TRAPPING_BIT)
544b2c91a   Tejun Heo   ptrace: implement...
1745
  #define JOBCTL_LISTENING	(1 << JOBCTL_LISTENING_BIT)
a8f072c1d   Tejun Heo   job control: rena...
1746

fb1d910c1   Tejun Heo   ptrace: implement...
1747
  #define JOBCTL_TRAP_MASK	(JOBCTL_TRAP_STOP | JOBCTL_TRAP_NOTIFY)
73ddff2be   Tejun Heo   job control: intr...
1748
  #define JOBCTL_PENDING_MASK	(JOBCTL_STOP_PENDING | JOBCTL_TRAP_MASK)
3759a0d94   Tejun Heo   job control: intr...
1749

7dd3db54e   Tejun Heo   job control: intr...
1750
1751
  extern bool task_set_jobctl_pending(struct task_struct *task,
  				    unsigned int mask);
73ddff2be   Tejun Heo   job control: intr...
1752
  extern void task_clear_jobctl_trapping(struct task_struct *task);
3759a0d94   Tejun Heo   job control: intr...
1753
1754
  extern void task_clear_jobctl_pending(struct task_struct *task,
  				      unsigned int mask);
39efa3ef3   Tejun Heo   signal: Use GROUP...
1755

a57eb940d   Paul E. McKenney   rcu: Add a TINY_P...
1756
  #ifdef CONFIG_PREEMPT_RCU
f41d911f8   Paul E. McKenney   rcu: Merge preemp...
1757
1758
  
  #define RCU_READ_UNLOCK_BLOCKED (1 << 0) /* blocked while in RCU read-side. */
24278d148   Paul E. McKenney   rcu: priority boo...
1759
1760
  #define RCU_READ_UNLOCK_BOOSTED (1 << 1) /* boosted while in RCU read-side. */
  #define RCU_READ_UNLOCK_NEED_QS (1 << 2) /* RCU core needs CPU response. */
f41d911f8   Paul E. McKenney   rcu: Merge preemp...
1761
1762
1763
1764
1765
  
  static inline void rcu_copy_process(struct task_struct *p)
  {
  	p->rcu_read_lock_nesting = 0;
  	p->rcu_read_unlock_special = 0;
a57eb940d   Paul E. McKenney   rcu: Add a TINY_P...
1766
  #ifdef CONFIG_TREE_PREEMPT_RCU
dd5d19baf   Paul E. McKenney   rcu: Create rcutr...
1767
  	p->rcu_blocked_node = NULL;
24278d148   Paul E. McKenney   rcu: priority boo...
1768
1769
1770
1771
  #endif /* #ifdef CONFIG_TREE_PREEMPT_RCU */
  #ifdef CONFIG_RCU_BOOST
  	p->rcu_boost_mutex = NULL;
  #endif /* #ifdef CONFIG_RCU_BOOST */
f41d911f8   Paul E. McKenney   rcu: Merge preemp...
1772
1773
  	INIT_LIST_HEAD(&p->rcu_node_entry);
  }
f41d911f8   Paul E. McKenney   rcu: Merge preemp...
1774
1775
1776
1777
1778
1779
1780
  #else
  
  static inline void rcu_copy_process(struct task_struct *p)
  {
  }
  
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1781
  #ifdef CONFIG_SMP
1e1b6c511   KOSAKI Motohiro   cpuset: Fix cpuse...
1782
1783
  extern void do_set_cpus_allowed(struct task_struct *p,
  			       const struct cpumask *new_mask);
cd8ba7cd9   Mike Travis   sched: add new se...
1784
  extern int set_cpus_allowed_ptr(struct task_struct *p,
96f874e26   Rusty Russell   sched: convert re...
1785
  				const struct cpumask *new_mask);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1786
  #else
1e1b6c511   KOSAKI Motohiro   cpuset: Fix cpuse...
1787
1788
1789
1790
  static inline void do_set_cpus_allowed(struct task_struct *p,
  				      const struct cpumask *new_mask)
  {
  }
cd8ba7cd9   Mike Travis   sched: add new se...
1791
  static inline int set_cpus_allowed_ptr(struct task_struct *p,
96f874e26   Rusty Russell   sched: convert re...
1792
  				       const struct cpumask *new_mask)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1793
  {
96f874e26   Rusty Russell   sched: convert re...
1794
  	if (!cpumask_test_cpu(0, new_mask))
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1795
1796
1797
1798
  		return -EINVAL;
  	return 0;
  }
  #endif
e0ad95568   Rusty Russell   cpumask: don't de...
1799
1800
  
  #ifndef CONFIG_CPUMASK_OFFSTACK
cd8ba7cd9   Mike Travis   sched: add new se...
1801
1802
1803
1804
  static inline int set_cpus_allowed(struct task_struct *p, cpumask_t new_mask)
  {
  	return set_cpus_allowed_ptr(p, &new_mask);
  }
e0ad95568   Rusty Russell   cpumask: don't de...
1805
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1806

b342501cd   Ingo Molnar   sched: allow arch...
1807
  /*
c676329ab   Peter Zijlstra   sched_clock: Add ...
1808
1809
1810
1811
1812
1813
   * Do not use outside of architecture code which knows its limitations.
   *
   * sched_clock() has no promise of monotonicity or bounded drift between
   * CPUs, use (which you should not) requires disabling IRQs.
   *
   * Please use one of the three interfaces below.
b342501cd   Ingo Molnar   sched: allow arch...
1814
   */
1bbfa6f25   Mike Frysinger   sched: Mark sched...
1815
  extern unsigned long long notrace sched_clock(void);
c676329ab   Peter Zijlstra   sched_clock: Add ...
1816
1817
1818
1819
1820
1821
  /*
   * See the comment in kernel/sched_clock.c
   */
  extern u64 cpu_clock(int cpu);
  extern u64 local_clock(void);
  extern u64 sched_clock_cpu(int cpu);
e436d8008   Ingo Molnar   [PATCH] sched: im...
1822

c1955a3d4   Peter Zijlstra   sched_clock: dela...
1823
  extern void sched_clock_init(void);
3e51f33fc   Peter Zijlstra   sched: add option...
1824

c1955a3d4   Peter Zijlstra   sched_clock: dela...
1825
  #ifndef CONFIG_HAVE_UNSTABLE_SCHED_CLOCK
3e51f33fc   Peter Zijlstra   sched: add option...
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
  static inline void sched_clock_tick(void)
  {
  }
  
  static inline void sched_clock_idle_sleep_event(void)
  {
  }
  
  static inline void sched_clock_idle_wakeup_event(u64 delta_ns)
  {
  }
  #else
c676329ab   Peter Zijlstra   sched_clock: Add ...
1838
1839
1840
1841
1842
1843
1844
  /*
   * Architectures can set this to 1 if they have specified
   * CONFIG_HAVE_UNSTABLE_SCHED_CLOCK in their arch Kconfig,
   * but then during bootup it turns out that sched_clock()
   * is reliable after all:
   */
  extern int sched_clock_stable;
3e51f33fc   Peter Zijlstra   sched: add option...
1845
1846
1847
1848
  extern void sched_clock_tick(void);
  extern void sched_clock_idle_sleep_event(void);
  extern void sched_clock_idle_wakeup_event(u64 delta_ns);
  #endif
b52bfee44   Venkatesh Pallipadi   sched: Add IRQ_TI...
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
  #ifdef CONFIG_IRQ_TIME_ACCOUNTING
  /*
   * An i/f to runtime opt-in for irq time accounting based off of sched_clock.
   * The reason for this explicit opt-in is not to have perf penalty with
   * slow sched_clocks.
   */
  extern void enable_sched_clock_irqtime(void);
  extern void disable_sched_clock_irqtime(void);
  #else
  static inline void enable_sched_clock_irqtime(void) {}
  static inline void disable_sched_clock_irqtime(void) {}
  #endif
36c8b5868   Ingo Molnar   [PATCH] sched: cl...
1861
  extern unsigned long long
41b86e9c5   Ingo Molnar   sched: make posix...
1862
  task_sched_runtime(struct task_struct *task);
f06febc96   Frank Mayhar   timers: fix itime...
1863
  extern unsigned long long thread_group_sched_runtime(struct task_struct *task);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1864
1865
1866
1867
1868
1869
1870
  
  /* sched_exec is called by processes performing an exec */
  #ifdef CONFIG_SMP
  extern void sched_exec(void);
  #else
  #define sched_exec()   {}
  #endif
2aa44d056   Ingo Molnar   sched: sched_cloc...
1871
1872
  extern void sched_clock_idle_sleep_event(void);
  extern void sched_clock_idle_wakeup_event(u64 delta_ns);
bb29ab268   Ingo Molnar   sched: x86, track...
1873

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1874
1875
1876
1877
1878
  #ifdef CONFIG_HOTPLUG_CPU
  extern void idle_task_exit(void);
  #else
  static inline void idle_task_exit(void) {}
  #endif
06d8308c6   Thomas Gleixner   NOHZ: reevaluate ...
1879
1880
1881
1882
1883
  #if defined(CONFIG_NO_HZ) && defined(CONFIG_SMP)
  extern void wake_up_idle_cpu(int cpu);
  #else
  static inline void wake_up_idle_cpu(int cpu) { }
  #endif
218050855   Peter Zijlstra   sched: adaptive s...
1884
  extern unsigned int sysctl_sched_latency;
b2be5e96d   Peter Zijlstra   sched: reintroduc...
1885
  extern unsigned int sysctl_sched_min_granularity;
bf0f6f24a   Ingo Molnar   sched: cfs core, ...
1886
  extern unsigned int sysctl_sched_wakeup_granularity;
bf0f6f24a   Ingo Molnar   sched: cfs core, ...
1887
  extern unsigned int sysctl_sched_child_runs_first;
1983a922a   Christian Ehrhardt   sched: Make tunab...
1888
1889
1890
1891
1892
1893
1894
1895
  
  enum sched_tunable_scaling {
  	SCHED_TUNABLESCALING_NONE,
  	SCHED_TUNABLESCALING_LOG,
  	SCHED_TUNABLESCALING_LINEAR,
  	SCHED_TUNABLESCALING_END,
  };
  extern enum sched_tunable_scaling sysctl_sched_tunable_scaling;
2bba22c50   Mike Galbraith   sched: Turn off c...
1896
  #ifdef CONFIG_SCHED_DEBUG
da84d9617   Ingo Molnar   sched: reintroduc...
1897
  extern unsigned int sysctl_sched_migration_cost;
b82d9fdd8   Peter Zijlstra   sched: avoid larg...
1898
  extern unsigned int sysctl_sched_nr_migrate;
e9e9250bc   Peter Zijlstra   sched: Scale down...
1899
  extern unsigned int sysctl_sched_time_avg;
cd1bb94b4   Arun R Bharadwaj   timers: /proc/sys...
1900
  extern unsigned int sysctl_timer_migration;
a7a4f8a75   Paul Turner   sched: Add sysctl...
1901
  extern unsigned int sysctl_sched_shares_window;
b2be5e96d   Peter Zijlstra   sched: reintroduc...
1902

1983a922a   Christian Ehrhardt   sched: Make tunab...
1903
  int sched_proc_update_handler(struct ctl_table *table, int write,
8d65af789   Alexey Dobriyan   sysctl: remove "s...
1904
  		void __user *buffer, size_t *length,
b2be5e96d   Peter Zijlstra   sched: reintroduc...
1905
  		loff_t *ppos);
2bd8e6d42   Ingo Molnar   sched: use consta...
1906
  #endif
eea08f32a   Arun R Bharadwaj   timers: Logic to ...
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
  #ifdef CONFIG_SCHED_DEBUG
  static inline unsigned int get_sysctl_timer_migration(void)
  {
  	return sysctl_timer_migration;
  }
  #else
  static inline unsigned int get_sysctl_timer_migration(void)
  {
  	return 1;
  }
  #endif
9f0c1e560   Peter Zijlstra   sched: rt-group: ...
1918
1919
  extern unsigned int sysctl_sched_rt_period;
  extern int sysctl_sched_rt_runtime;
2bd8e6d42   Ingo Molnar   sched: use consta...
1920

d0b27fa77   Peter Zijlstra   sched: rt-group: ...
1921
  int sched_rt_handler(struct ctl_table *table, int write,
8d65af789   Alexey Dobriyan   sysctl: remove "s...
1922
  		void __user *buffer, size_t *lenp,
d0b27fa77   Peter Zijlstra   sched: rt-group: ...
1923
  		loff_t *ppos);
5091faa44   Mike Galbraith   sched: Add 'autog...
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
  #ifdef CONFIG_SCHED_AUTOGROUP
  extern unsigned int sysctl_sched_autogroup_enabled;
  
  extern void sched_autogroup_create_attach(struct task_struct *p);
  extern void sched_autogroup_detach(struct task_struct *p);
  extern void sched_autogroup_fork(struct signal_struct *sig);
  extern void sched_autogroup_exit(struct signal_struct *sig);
  #ifdef CONFIG_PROC_FS
  extern void proc_sched_autogroup_show_task(struct task_struct *p, struct seq_file *m);
  extern int proc_sched_autogroup_set_nice(struct task_struct *p, int *nice);
  #endif
  #else
  static inline void sched_autogroup_create_attach(struct task_struct *p) { }
  static inline void sched_autogroup_detach(struct task_struct *p) { }
  static inline void sched_autogroup_fork(struct signal_struct *sig) { }
  static inline void sched_autogroup_exit(struct signal_struct *sig) { }
  #endif
b29739f90   Ingo Molnar   [PATCH] pi-futex:...
1941
  #ifdef CONFIG_RT_MUTEXES
36c8b5868   Ingo Molnar   [PATCH] sched: cl...
1942
1943
1944
  extern int rt_mutex_getprio(struct task_struct *p);
  extern void rt_mutex_setprio(struct task_struct *p, int prio);
  extern void rt_mutex_adjust_pi(struct task_struct *p);
b29739f90   Ingo Molnar   [PATCH] pi-futex:...
1945
  #else
e868171a9   Alexey Dobriyan   De-constify sched.h
1946
  static inline int rt_mutex_getprio(struct task_struct *p)
b29739f90   Ingo Molnar   [PATCH] pi-futex:...
1947
1948
1949
  {
  	return p->normal_prio;
  }
95e02ca9b   Thomas Gleixner   [PATCH] rtmutex: ...
1950
  # define rt_mutex_adjust_pi(p)		do { } while (0)
b29739f90   Ingo Molnar   [PATCH] pi-futex:...
1951
  #endif
d95f41220   Mike Galbraith   sched: Add yield_...
1952
  extern bool yield_to(struct task_struct *p, bool preempt);
36c8b5868   Ingo Molnar   [PATCH] sched: cl...
1953
1954
1955
1956
1957
  extern void set_user_nice(struct task_struct *p, long nice);
  extern int task_prio(const struct task_struct *p);
  extern int task_nice(const struct task_struct *p);
  extern int can_nice(const struct task_struct *p, const int nice);
  extern int task_curr(const struct task_struct *p);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1958
  extern int idle_cpu(int cpu);
fe7de49f9   KOSAKI Motohiro   sched: Make sched...
1959
1960
  extern int sched_setscheduler(struct task_struct *, int,
  			      const struct sched_param *);
961ccddd5   Rusty Russell   sched: add new AP...
1961
  extern int sched_setscheduler_nocheck(struct task_struct *, int,
fe7de49f9   KOSAKI Motohiro   sched: Make sched...
1962
  				      const struct sched_param *);
36c8b5868   Ingo Molnar   [PATCH] sched: cl...
1963
1964
1965
  extern struct task_struct *idle_task(int cpu);
  extern struct task_struct *curr_task(int cpu);
  extern void set_curr_task(int cpu, struct task_struct *p);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
  
  void yield(void);
  
  /*
   * The default (Linux) execution domain.
   */
  extern struct exec_domain	default_exec_domain;
  
  union thread_union {
  	struct thread_info thread_info;
  	unsigned long stack[THREAD_SIZE/sizeof(long)];
  };
  
  #ifndef __HAVE_ARCH_KSTACK_END
  static inline int kstack_end(void *addr)
  {
  	/* Reliable end of stack detection:
  	 * Some APM bios versions misalign the stack
  	 */
  	return !(((unsigned long)addr+sizeof(void*)-1) & (THREAD_SIZE-sizeof(void*)));
  }
  #endif
  
  extern union thread_union init_thread_union;
  extern struct task_struct init_task;
  
  extern struct   mm_struct init_mm;
198fe21b0   Pavel Emelyanov   pid namespaces: h...
1993
1994
1995
1996
1997
  extern struct pid_namespace init_pid_ns;
  
  /*
   * find a task by one of its numerical ids
   *
198fe21b0   Pavel Emelyanov   pid namespaces: h...
1998
1999
   * find_task_by_pid_ns():
   *      finds a task by its pid in the specified namespace
228ebcbe6   Pavel Emelyanov   Uninline find_tas...
2000
2001
   * find_task_by_vpid():
   *      finds a task by its virtual pid
198fe21b0   Pavel Emelyanov   pid namespaces: h...
2002
   *
e49859e71   Pavel Emelyanov   pidns: remove now...
2003
   * see also find_vpid() etc in include/linux/pid.h
198fe21b0   Pavel Emelyanov   pid namespaces: h...
2004
   */
228ebcbe6   Pavel Emelyanov   Uninline find_tas...
2005
2006
2007
  extern struct task_struct *find_task_by_vpid(pid_t nr);
  extern struct task_struct *find_task_by_pid_ns(pid_t nr,
  		struct pid_namespace *ns);
198fe21b0   Pavel Emelyanov   pid namespaces: h...
2008

8520d7c7f   Oleg Nesterov   teach set_special...
2009
  extern void __set_special_pids(struct pid *pid);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2010
2011
  
  /* per-UID process charging. */
acce292c8   Cedric Le Goater   user namespace: a...
2012
  extern struct user_struct * alloc_uid(struct user_namespace *, uid_t);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2013
2014
2015
2016
2017
2018
  static inline struct user_struct *get_uid(struct user_struct *u)
  {
  	atomic_inc(&u->__count);
  	return u;
  }
  extern void free_uid(struct user_struct *);
28f300d23   Pavel Emelyanov   Fix user namespac...
2019
  extern void release_uids(struct user_namespace *ns);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2020
2021
  
  #include <asm/current.h>
f0af911a9   Torben Hohn   time: Provide xti...
2022
  extern void xtime_update(unsigned long ticks);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2023

b3c975286   Harvey Harrison   include/linux: Re...
2024
2025
  extern int wake_up_state(struct task_struct *tsk, unsigned int state);
  extern int wake_up_process(struct task_struct *tsk);
3e51e3edf   Samir Bellabes   sched: Remove unu...
2026
  extern void wake_up_new_task(struct task_struct *tsk);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2027
2028
2029
2030
2031
  #ifdef CONFIG_SMP
   extern void kick_process(struct task_struct *tsk);
  #else
   static inline void kick_process(struct task_struct *tsk) { }
  #endif
3e51e3edf   Samir Bellabes   sched: Remove unu...
2032
  extern void sched_fork(struct task_struct *p);
ad46c2c4e   Ingo Molnar   sched: clean up f...
2033
  extern void sched_dead(struct task_struct *p);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2034

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2035
2036
  extern void proc_caches_init(void);
  extern void flush_signals(struct task_struct *);
3bcac0263   David Howells   SELinux: Don't fl...
2037
  extern void __flush_signals(struct task_struct *);
10ab825bd   Oleg Nesterov   change kernel thr...
2038
  extern void ignore_signals(struct task_struct *);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
  extern void flush_signal_handlers(struct task_struct *, int force_default);
  extern int dequeue_signal(struct task_struct *tsk, sigset_t *mask, siginfo_t *info);
  
  static inline int dequeue_signal_lock(struct task_struct *tsk, sigset_t *mask, siginfo_t *info)
  {
  	unsigned long flags;
  	int ret;
  
  	spin_lock_irqsave(&tsk->sighand->siglock, flags);
  	ret = dequeue_signal(tsk, mask, info);
  	spin_unlock_irqrestore(&tsk->sighand->siglock, flags);
  
  	return ret;
53c8f9f19   Oleg Nesterov   make do_notify_pa...
2052
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2053
2054
2055
2056
2057
2058
  
  extern void block_all_signals(int (*notifier)(void *priv), void *priv,
  			      sigset_t *mask);
  extern void unblock_all_signals(void);
  extern void release_task(struct task_struct * p);
  extern int send_sig_info(int, struct siginfo *, struct task_struct *);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2059
2060
  extern int force_sigsegv(int, struct task_struct *);
  extern int force_sig_info(int, struct siginfo *, struct task_struct *);
c4b92fc11   Eric W. Biederman   [PATCH] pid: impl...
2061
  extern int __kill_pgrp_info(int sig, struct siginfo *info, struct pid *pgrp);
c4b92fc11   Eric W. Biederman   [PATCH] pid: impl...
2062
  extern int kill_pid_info(int sig, struct siginfo *info, struct pid *pid);
2425c08b3   Eric W. Biederman   [PATCH] usb: fixu...
2063
  extern int kill_pid_info_as_uid(int, struct siginfo *, struct pid *, uid_t, uid_t, u32);
c4b92fc11   Eric W. Biederman   [PATCH] pid: impl...
2064
2065
  extern int kill_pgrp(struct pid *pid, int sig, int priv);
  extern int kill_pid(struct pid *pid, int sig, int priv);
c3de4b381   Matthew Wilcox   Revert "[PATCH] m...
2066
  extern int kill_proc_info(int, struct siginfo *, pid_t);
867734737   Oleg Nesterov   make do_notify_pa...
2067
  extern __must_check bool do_notify_parent(struct task_struct *, int);
a7f0765ed   Oleg Nesterov   ptrace: __ptrace_...
2068
  extern void __wake_up_parent(struct task_struct *p, struct task_struct *parent);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2069
  extern void force_sig(int, struct task_struct *);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2070
  extern int send_sig(int, struct task_struct *, int);
09faef11d   Oleg Nesterov   exit: change zap_...
2071
  extern int zap_other_threads(struct task_struct *p);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2072
2073
  extern struct sigqueue *sigqueue_alloc(void);
  extern void sigqueue_free(struct sigqueue *);
ac5c21538   Oleg Nesterov   signals: join sen...
2074
  extern int send_sigqueue(struct sigqueue *,  struct task_struct *, int group);
9ac95f2f9   Oleg Nesterov   [PATCH] do_sigact...
2075
  extern int do_sigaction(int, struct k_sigaction *, struct k_sigaction *);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2076
  extern int do_sigaltstack(const stack_t __user *, stack_t __user *, unsigned long);
9ec52099e   Cedric Le Goater   [PATCH] replace c...
2077
2078
2079
2080
  static inline int kill_cad_pid(int sig, int priv)
  {
  	return kill_pid(cad_pid, sig, priv);
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2081
2082
2083
2084
  /* These can be the second arg to send_sig_info/send_group_sig_info.  */
  #define SEND_SIG_NOINFO ((struct siginfo *) 0)
  #define SEND_SIG_PRIV	((struct siginfo *) 1)
  #define SEND_SIG_FORCED	((struct siginfo *) 2)
2a855dd01   Sebastian Andrzej Siewior   signal: Fix alter...
2085
2086
2087
  /*
   * True if we are on the alternate signal stack.
   */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2088
2089
  static inline int on_sig_stack(unsigned long sp)
  {
2a855dd01   Sebastian Andrzej Siewior   signal: Fix alter...
2090
2091
2092
2093
2094
2095
2096
  #ifdef CONFIG_STACK_GROWSUP
  	return sp >= current->sas_ss_sp &&
  		sp - current->sas_ss_sp < current->sas_ss_size;
  #else
  	return sp > current->sas_ss_sp &&
  		sp - current->sas_ss_sp <= current->sas_ss_size;
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2097
2098
2099
2100
2101
2102
2103
  }
  
  static inline int sas_ss_flags(unsigned long sp)
  {
  	return (current->sas_ss_size == 0 ? SS_DISABLE
  		: on_sig_stack(sp) ? SS_ONSTACK : 0);
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2104
2105
2106
2107
2108
2109
  /*
   * Routines for handling mm_structs
   */
  extern struct mm_struct * mm_alloc(void);
  
  /* mmdrop drops the mm and the page tables */
b3c975286   Harvey Harrison   include/linux: Re...
2110
  extern void __mmdrop(struct mm_struct *);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2111
2112
  static inline void mmdrop(struct mm_struct * mm)
  {
6fb43d7b5   Ingo Molnar   sched: micro-opti...
2113
  	if (unlikely(atomic_dec_and_test(&mm->mm_count)))
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2114
2115
2116
2117
2118
2119
2120
2121
2122
  		__mmdrop(mm);
  }
  
  /* mmput gets rid of the mappings and all user-space */
  extern void mmput(struct mm_struct *);
  /* Grab a reference to a task's mm, if it is not already going away */
  extern struct mm_struct *get_task_mm(struct task_struct *task);
  /* Remove the current tasks stale references to the old mm_struct */
  extern void mm_release(struct task_struct *, struct mm_struct *);
402b08622   Carsten Otte   s390: KVM prepara...
2123
2124
  /* Allocate a new mm structure and copy contents from tsk->mm */
  extern struct mm_struct *dup_mm(struct task_struct *tsk);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2125

6f2c55b84   Alexey Dobriyan   Simplify copy_thr...
2126
2127
  extern int copy_thread(unsigned long, unsigned long, unsigned long,
  			struct task_struct *, struct pt_regs *);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2128
2129
  extern void flush_thread(void);
  extern void exit_thread(void);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2130
  extern void exit_files(struct task_struct *);
a7e5328a0   Oleg Nesterov   [PATCH] cleanup _...
2131
  extern void __cleanup_sighand(struct sighand_struct *);
cbaffba12   Oleg Nesterov   posix timers: dis...
2132

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2133
  extern void exit_itimers(struct signal_struct *);
cbaffba12   Oleg Nesterov   posix timers: dis...
2134
  extern void flush_itimer_signals(void);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2135
2136
  
  extern NORET_TYPE void do_group_exit(int);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2137
2138
2139
  extern void daemonize(const char *, ...);
  extern int allow_signal(int);
  extern int disallow_signal(int);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2140

d7627467b   David Howells   Make do_execve() ...
2141
2142
2143
  extern int do_execve(const char *,
  		     const char __user * const __user *,
  		     const char __user * const __user *, struct pt_regs *);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2144
  extern long do_fork(unsigned long, unsigned long, struct pt_regs *, unsigned long, int __user *, int __user *);
36c8b5868   Ingo Molnar   [PATCH] sched: cl...
2145
  struct task_struct *fork_idle(int);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2146
2147
  
  extern void set_task_comm(struct task_struct *tsk, char *from);
59714d65d   Andrew Morton   get_task_comm(): ...
2148
  extern char *get_task_comm(char *to, struct task_struct *tsk);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2149
2150
  
  #ifdef CONFIG_SMP
317f39416   Peter Zijlstra   sched: Move the s...
2151
  void scheduler_ipi(void);
85ba2d862   Roland McGrath   tracehook: wait_t...
2152
  extern unsigned long wait_task_inactive(struct task_struct *, long match_state);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2153
  #else
184748cc5   Peter Zijlstra   sched: Provide sc...
2154
  static inline void scheduler_ipi(void) { }
85ba2d862   Roland McGrath   tracehook: wait_t...
2155
2156
2157
2158
2159
  static inline unsigned long wait_task_inactive(struct task_struct *p,
  					       long match_state)
  {
  	return 1;
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2160
  #endif
05725f7eb   Jiri Pirko   rculist: use list...
2161
2162
  #define next_task(p) \
  	list_entry_rcu((p)->tasks.next, struct task_struct, tasks)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2163
2164
2165
  
  #define for_each_process(p) \
  	for (p = &init_task ; (p = next_task(p)) != &init_task ; )
5bb459bb4   Oleg Nesterov   kernel: rename is...
2166
  extern bool current_is_single_threaded(void);
d84f4f992   David Howells   CRED: Inaugurate ...
2167

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2168
2169
2170
2171
2172
2173
2174
2175
2176
  /*
   * Careful: do_each_thread/while_each_thread is a double loop so
   *          'break' will not work as expected - use goto instead.
   */
  #define do_each_thread(g, t) \
  	for (g = t = &init_task ; (g = t = next_task(g)) != &init_task ; ) do
  
  #define while_each_thread(g, t) \
  	while ((t = next_thread(t)) != g)
7e49827cc   Oleg Nesterov   proc: get_nr_thre...
2177
2178
  static inline int get_nr_threads(struct task_struct *tsk)
  {
b3ac022cb   Oleg Nesterov   proc: turn signal...
2179
  	return tsk->signal->nr_threads;
7e49827cc   Oleg Nesterov   proc: get_nr_thre...
2180
  }
087806b12   Oleg Nesterov   redefine thread_g...
2181
2182
2183
2184
  static inline bool thread_group_leader(struct task_struct *p)
  {
  	return p->exit_signal >= 0;
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2185

0804ef4b0   Eric W. Biederman   [PATCH] proc: rea...
2186
2187
2188
2189
2190
2191
  /* Do to the insanities of de_thread it is possible for a process
   * to have the pid of the thread group leader without actually being
   * the thread group leader.  For iteration through the pids in proc
   * all we care about is that we have a task with the appropriate
   * pid, we don't actually care if we have the right task.
   */
e868171a9   Alexey Dobriyan   De-constify sched.h
2192
  static inline int has_group_leader_pid(struct task_struct *p)
0804ef4b0   Eric W. Biederman   [PATCH] proc: rea...
2193
2194
2195
  {
  	return p->pid == p->tgid;
  }
bac0abd61   Pavel Emelyanov   Isolate some expl...
2196
2197
2198
2199
2200
  static inline
  int same_thread_group(struct task_struct *p1, struct task_struct *p2)
  {
  	return p1->tgid == p2->tgid;
  }
36c8b5868   Ingo Molnar   [PATCH] sched: cl...
2201
  static inline struct task_struct *next_thread(const struct task_struct *p)
47e65328a   Oleg Nesterov   [PATCH] pids: kil...
2202
  {
05725f7eb   Jiri Pirko   rculist: use list...
2203
2204
  	return list_entry_rcu(p->thread_group.next,
  			      struct task_struct, thread_group);
47e65328a   Oleg Nesterov   [PATCH] pids: kil...
2205
  }
e868171a9   Alexey Dobriyan   De-constify sched.h
2206
  static inline int thread_group_empty(struct task_struct *p)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2207
  {
47e65328a   Oleg Nesterov   [PATCH] pids: kil...
2208
  	return list_empty(&p->thread_group);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2209
2210
2211
2212
  }
  
  #define delay_group_leader(p) \
  		(thread_group_leader(p) && !thread_group_empty(p))
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2213
  /*
260ea1013   Eric W. Biederman   [PATCH] ptrace: d...
2214
   * Protects ->fs, ->files, ->mm, ->group_info, ->comm, keyring
22e2c507c   Jens Axboe   [PATCH] Update cf...
2215
   * subscriptions and synchronises with wait4().  Also used in procfs.  Also
ddbcc7e8e   Paul Menage   Task Control Grou...
2216
2217
   * pins the final release of task.io_context.  Also protects ->cpuset and
   * ->cgroup.subsys[].
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
   *
   * Nests both inside and outside of read_lock(&tasklist_lock).
   * It must not be nested with write_lock_irq(&tasklist_lock),
   * neither inside nor outside.
   */
  static inline void task_lock(struct task_struct *p)
  {
  	spin_lock(&p->alloc_lock);
  }
  
  static inline void task_unlock(struct task_struct *p)
  {
  	spin_unlock(&p->alloc_lock);
  }
b8ed374e2   Namhyung Kim   signals: annotate...
2232
  extern struct sighand_struct *__lock_task_sighand(struct task_struct *tsk,
f63ee72e0   Oleg Nesterov   [PATCH] introduce...
2233
  							unsigned long *flags);
b8ed374e2   Namhyung Kim   signals: annotate...
2234
2235
2236
2237
2238
2239
  #define lock_task_sighand(tsk, flags)					\
  ({	struct sighand_struct *__ss;					\
  	__cond_lock(&(tsk)->sighand->siglock,				\
  		    (__ss = __lock_task_sighand(tsk, flags)));		\
  	__ss;								\
  })									\
f63ee72e0   Oleg Nesterov   [PATCH] introduce...
2240
2241
2242
2243
2244
  static inline void unlock_task_sighand(struct task_struct *tsk,
  						unsigned long *flags)
  {
  	spin_unlock_irqrestore(&tsk->sighand->siglock, *flags);
  }
4714d1d32   Ben Blum   cgroups: read-wri...
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
  /* See the declaration of threadgroup_fork_lock in signal_struct. */
  #ifdef CONFIG_CGROUPS
  static inline void threadgroup_fork_read_lock(struct task_struct *tsk)
  {
  	down_read(&tsk->signal->threadgroup_fork_lock);
  }
  static inline void threadgroup_fork_read_unlock(struct task_struct *tsk)
  {
  	up_read(&tsk->signal->threadgroup_fork_lock);
  }
  static inline void threadgroup_fork_write_lock(struct task_struct *tsk)
  {
  	down_write(&tsk->signal->threadgroup_fork_lock);
  }
  static inline void threadgroup_fork_write_unlock(struct task_struct *tsk)
  {
  	up_write(&tsk->signal->threadgroup_fork_lock);
  }
  #else
  static inline void threadgroup_fork_read_lock(struct task_struct *tsk) {}
  static inline void threadgroup_fork_read_unlock(struct task_struct *tsk) {}
  static inline void threadgroup_fork_write_lock(struct task_struct *tsk) {}
  static inline void threadgroup_fork_write_unlock(struct task_struct *tsk) {}
  #endif
f037360f2   Al Viro   [PATCH] m68k: thr...
2269
  #ifndef __HAVE_THREAD_FUNCTIONS
f7e4217b0   Roman Zippel   rename thread_inf...
2270
2271
  #define task_thread_info(task)	((struct thread_info *)(task)->stack)
  #define task_stack_page(task)	((task)->stack)
a1261f546   Al Viro   [PATCH] m68k: int...
2272

10ebffde3   Al Viro   [PATCH] m68k: int...
2273
2274
2275
2276
2277
2278
2279
2280
  static inline void setup_thread_stack(struct task_struct *p, struct task_struct *org)
  {
  	*task_thread_info(p) = *task_thread_info(org);
  	task_thread_info(p)->task = p;
  }
  
  static inline unsigned long *end_of_stack(struct task_struct *p)
  {
f7e4217b0   Roman Zippel   rename thread_inf...
2281
  	return (unsigned long *)(task_thread_info(p) + 1);
10ebffde3   Al Viro   [PATCH] m68k: int...
2282
  }
f037360f2   Al Viro   [PATCH] m68k: thr...
2283
  #endif
8b05c7e6e   FUJITA Tomonori   add a helper func...
2284
2285
2286
2287
2288
2289
  static inline int object_is_on_stack(void *obj)
  {
  	void *stack = task_stack_page(current);
  
  	return (obj >= stack) && (obj < (stack + THREAD_SIZE));
  }
8c9843e57   Benjamin Herrenschmidt   [POWERPC] Add thr...
2290
  extern void thread_info_cache_init(void);
7c9f8861e   Eric Sandeen   stackprotector: u...
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
  #ifdef CONFIG_DEBUG_STACK_USAGE
  static inline unsigned long stack_not_used(struct task_struct *p)
  {
  	unsigned long *n = end_of_stack(p);
  
  	do { 	/* Skip over canary */
  		n++;
  	} while (!*n);
  
  	return (unsigned long)n - (unsigned long)end_of_stack(p);
  }
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2303
2304
2305
2306
2307
  /* set thread flags in other task's structures
   * - see asm/thread_info.h for TIF_xxxx flags available
   */
  static inline void set_tsk_thread_flag(struct task_struct *tsk, int flag)
  {
a1261f546   Al Viro   [PATCH] m68k: int...
2308
  	set_ti_thread_flag(task_thread_info(tsk), flag);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2309
2310
2311
2312
  }
  
  static inline void clear_tsk_thread_flag(struct task_struct *tsk, int flag)
  {
a1261f546   Al Viro   [PATCH] m68k: int...
2313
  	clear_ti_thread_flag(task_thread_info(tsk), flag);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2314
2315
2316
2317
  }
  
  static inline int test_and_set_tsk_thread_flag(struct task_struct *tsk, int flag)
  {
a1261f546   Al Viro   [PATCH] m68k: int...
2318
  	return test_and_set_ti_thread_flag(task_thread_info(tsk), flag);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2319
2320
2321
2322
  }
  
  static inline int test_and_clear_tsk_thread_flag(struct task_struct *tsk, int flag)
  {
a1261f546   Al Viro   [PATCH] m68k: int...
2323
  	return test_and_clear_ti_thread_flag(task_thread_info(tsk), flag);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2324
2325
2326
2327
  }
  
  static inline int test_tsk_thread_flag(struct task_struct *tsk, int flag)
  {
a1261f546   Al Viro   [PATCH] m68k: int...
2328
  	return test_ti_thread_flag(task_thread_info(tsk), flag);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
  }
  
  static inline void set_tsk_need_resched(struct task_struct *tsk)
  {
  	set_tsk_thread_flag(tsk,TIF_NEED_RESCHED);
  }
  
  static inline void clear_tsk_need_resched(struct task_struct *tsk)
  {
  	clear_tsk_thread_flag(tsk,TIF_NEED_RESCHED);
  }
8ae121ac8   Gregory Haskins   sched: fix RT tas...
2340
2341
2342
2343
  static inline int test_tsk_need_resched(struct task_struct *tsk)
  {
  	return unlikely(test_tsk_thread_flag(tsk,TIF_NEED_RESCHED));
  }
690cc3ffe   Eric W. Biederman   syscall: Implemen...
2344
2345
2346
2347
2348
  static inline int restart_syscall(void)
  {
  	set_tsk_thread_flag(current, TIF_SIGPENDING);
  	return -ERESTARTNOINTR;
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2349
2350
2351
2352
  static inline int signal_pending(struct task_struct *p)
  {
  	return unlikely(test_tsk_thread_flag(p,TIF_SIGPENDING));
  }
f776d12dd   Matthew Wilcox   Add fatal_signal_...
2353

d9588725e   Roland McGrath   signals: inline _...
2354
2355
2356
2357
  static inline int __fatal_signal_pending(struct task_struct *p)
  {
  	return unlikely(sigismember(&p->pending.signal, SIGKILL));
  }
f776d12dd   Matthew Wilcox   Add fatal_signal_...
2358
2359
2360
2361
2362
  
  static inline int fatal_signal_pending(struct task_struct *p)
  {
  	return signal_pending(p) && __fatal_signal_pending(p);
  }
16882c1e9   Oleg Nesterov   sched: fix TASK_W...
2363
2364
2365
2366
2367
2368
  static inline int signal_pending_state(long state, struct task_struct *p)
  {
  	if (!(state & (TASK_INTERRUPTIBLE | TASK_WAKEKILL)))
  		return 0;
  	if (!signal_pending(p))
  		return 0;
16882c1e9   Oleg Nesterov   sched: fix TASK_W...
2369
2370
  	return (state & TASK_INTERRUPTIBLE) || __fatal_signal_pending(p);
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2371
2372
  static inline int need_resched(void)
  {
9404ef029   Linus Torvalds   Fix up 'need_resc...
2373
  	return unlikely(test_thread_flag(TIF_NEED_RESCHED));
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2374
2375
2376
2377
2378
2379
2380
2381
2382
  }
  
  /*
   * cond_resched() and cond_resched_lock(): latency reduction via
   * explicit rescheduling in places that are safe. The return
   * value indicates whether a reschedule was done in fact.
   * cond_resched_lock() will drop the spinlock before scheduling,
   * cond_resched_softirq() will enable bhs before scheduling.
   */
c3921ab71   Linus Torvalds   Add new 'cond_res...
2383
  extern int _cond_resched(void);
6f80bd985   Frederic Weisbecker   sched: Remove the...
2384

613afbf83   Frederic Weisbecker   sched: Pull up th...
2385
2386
2387
2388
  #define cond_resched() ({			\
  	__might_sleep(__FILE__, __LINE__, 0);	\
  	_cond_resched();			\
  })
6f80bd985   Frederic Weisbecker   sched: Remove the...
2389

613afbf83   Frederic Weisbecker   sched: Pull up th...
2390
  extern int __cond_resched_lock(spinlock_t *lock);
bdd4e85dc   Frederic Weisbecker   sched: Isolate pr...
2391
  #ifdef CONFIG_PREEMPT_COUNT
716a42348   Frederic Weisbecker   sched: Fix cond_r...
2392
  #define PREEMPT_LOCK_OFFSET	PREEMPT_OFFSET
02b67cc3b   Herbert Xu   sched: do not do ...
2393
  #else
716a42348   Frederic Weisbecker   sched: Fix cond_r...
2394
  #define PREEMPT_LOCK_OFFSET	0
02b67cc3b   Herbert Xu   sched: do not do ...
2395
  #endif
716a42348   Frederic Weisbecker   sched: Fix cond_r...
2396

613afbf83   Frederic Weisbecker   sched: Pull up th...
2397
  #define cond_resched_lock(lock) ({				\
716a42348   Frederic Weisbecker   sched: Fix cond_r...
2398
  	__might_sleep(__FILE__, __LINE__, PREEMPT_LOCK_OFFSET);	\
613afbf83   Frederic Weisbecker   sched: Pull up th...
2399
2400
2401
2402
  	__cond_resched_lock(lock);				\
  })
  
  extern int __cond_resched_softirq(void);
75e1056f5   Venkatesh Pallipadi   sched: Fix softir...
2403
2404
2405
  #define cond_resched_softirq() ({					\
  	__might_sleep(__FILE__, __LINE__, SOFTIRQ_DISABLE_OFFSET);	\
  	__cond_resched_softirq();					\
613afbf83   Frederic Weisbecker   sched: Pull up th...
2406
  })
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2407
2408
2409
  
  /*
   * Does a critical section need to be broken due to another
95c354fe9   Nick Piggin   spinlock: lockbre...
2410
2411
   * task waiting?: (technically does not depend on CONFIG_PREEMPT,
   * but a general need for low latency)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2412
   */
95c354fe9   Nick Piggin   spinlock: lockbre...
2413
  static inline int spin_needbreak(spinlock_t *lock)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2414
  {
95c354fe9   Nick Piggin   spinlock: lockbre...
2415
2416
2417
  #ifdef CONFIG_PREEMPT
  	return spin_is_contended(lock);
  #else
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2418
  	return 0;
95c354fe9   Nick Piggin   spinlock: lockbre...
2419
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2420
  }
7bb44adef   Roland McGrath   recalc_sigpending...
2421
  /*
f06febc96   Frank Mayhar   timers: fix itime...
2422
2423
   * Thread group CPU time accounting.
   */
4cd4c1b40   Peter Zijlstra   timers: split pro...
2424
  void thread_group_cputime(struct task_struct *tsk, struct task_cputime *times);
4da94d49b   Peter Zijlstra   timers: fix TIMER...
2425
  void thread_group_cputimer(struct task_struct *tsk, struct task_cputime *times);
f06febc96   Frank Mayhar   timers: fix itime...
2426

490dea45d   Peter Zijlstra   itimers: remove t...
2427
  static inline void thread_group_cputime_init(struct signal_struct *sig)
f06febc96   Frank Mayhar   timers: fix itime...
2428
  {
4cd4c1b40   Peter Zijlstra   timers: split pro...
2429
  	spin_lock_init(&sig->cputimer.lock);
f06febc96   Frank Mayhar   timers: fix itime...
2430
  }
f06febc96   Frank Mayhar   timers: fix itime...
2431
  /*
7bb44adef   Roland McGrath   recalc_sigpending...
2432
2433
2434
2435
2436
2437
   * Reevaluate whether the task has signals pending delivery.
   * Wake the task if so.
   * This is required every time the blocked sigset_t changes.
   * callers must hold sighand->siglock.
   */
  extern void recalc_sigpending_and_wake(struct task_struct *t);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
  extern void recalc_sigpending(void);
  
  extern void signal_wake_up(struct task_struct *t, int resume_stopped);
  
  /*
   * Wrappers for p->thread_info->cpu access. No-op on UP.
   */
  #ifdef CONFIG_SMP
  
  static inline unsigned int task_cpu(const struct task_struct *p)
  {
a1261f546   Al Viro   [PATCH] m68k: int...
2449
  	return task_thread_info(p)->cpu;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2450
  }
c65cc8705   Ingo Molnar   sched: uninline s...
2451
  extern void set_task_cpu(struct task_struct *p, unsigned int cpu);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
  
  #else
  
  static inline unsigned int task_cpu(const struct task_struct *p)
  {
  	return 0;
  }
  
  static inline void set_task_cpu(struct task_struct *p, unsigned int cpu)
  {
  }
  
  #endif /* CONFIG_SMP */
96f874e26   Rusty Russell   sched: convert re...
2465
2466
  extern long sched_setaffinity(pid_t pid, const struct cpumask *new_mask);
  extern long sched_getaffinity(pid_t pid, struct cpumask *mask);
5c45bf279   Siddha, Suresh B   [PATCH] sched: mc...
2467

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2468
  extern void normalize_rt_tasks(void);
7c9414385   Dhaval Giani   sched: Remove USE...
2469
  #ifdef CONFIG_CGROUP_SCHED
9b5b77512   Srivatsa Vaddagiri   sched: clean up c...
2470

07e06b011   Yong Zhang   sched: Consolidat...
2471
  extern struct task_group root_task_group;
9b5b77512   Srivatsa Vaddagiri   sched: clean up c...
2472

ec7dc8ac7   Dhaval Giani   sched: allow the ...
2473
  extern struct task_group *sched_create_group(struct task_group *parent);
4cf86d77f   Ingo Molnar   sched: cleanup: r...
2474
  extern void sched_destroy_group(struct task_group *tg);
9b5b77512   Srivatsa Vaddagiri   sched: clean up c...
2475
  extern void sched_move_task(struct task_struct *tsk);
052f1dc7e   Peter Zijlstra   sched: rt-group: ...
2476
  #ifdef CONFIG_FAIR_GROUP_SCHED
4cf86d77f   Ingo Molnar   sched: cleanup: r...
2477
  extern int sched_group_set_shares(struct task_group *tg, unsigned long shares);
5cb350baf   Dhaval Giani   sched: group sche...
2478
  extern unsigned long sched_group_shares(struct task_group *tg);
052f1dc7e   Peter Zijlstra   sched: rt-group: ...
2479
2480
  #endif
  #ifdef CONFIG_RT_GROUP_SCHED
9f0c1e560   Peter Zijlstra   sched: rt-group: ...
2481
2482
2483
  extern int sched_group_set_rt_runtime(struct task_group *tg,
  				      long rt_runtime_us);
  extern long sched_group_rt_runtime(struct task_group *tg);
d0b27fa77   Peter Zijlstra   sched: rt-group: ...
2484
2485
2486
  extern int sched_group_set_rt_period(struct task_group *tg,
  				      long rt_period_us);
  extern long sched_group_rt_period(struct task_group *tg);
54e991242   Dhaval Giani   sched: don't allo...
2487
  extern int sched_rt_can_attach(struct task_group *tg, struct task_struct *tsk);
052f1dc7e   Peter Zijlstra   sched: rt-group: ...
2488
  #endif
9b5b77512   Srivatsa Vaddagiri   sched: clean up c...
2489
  #endif
54e991242   Dhaval Giani   sched: don't allo...
2490
2491
  extern int task_can_switch_user(struct user_struct *up,
  					struct task_struct *tsk);
4b98d11b4   Alexey Dobriyan   [PATCH] ifdef ->r...
2492
2493
2494
  #ifdef CONFIG_TASK_XACCT
  static inline void add_rchar(struct task_struct *tsk, ssize_t amt)
  {
940389b8a   Andrea Righi   task IO accountin...
2495
  	tsk->ioac.rchar += amt;
4b98d11b4   Alexey Dobriyan   [PATCH] ifdef ->r...
2496
2497
2498
2499
  }
  
  static inline void add_wchar(struct task_struct *tsk, ssize_t amt)
  {
940389b8a   Andrea Righi   task IO accountin...
2500
  	tsk->ioac.wchar += amt;
4b98d11b4   Alexey Dobriyan   [PATCH] ifdef ->r...
2501
2502
2503
2504
  }
  
  static inline void inc_syscr(struct task_struct *tsk)
  {
940389b8a   Andrea Righi   task IO accountin...
2505
  	tsk->ioac.syscr++;
4b98d11b4   Alexey Dobriyan   [PATCH] ifdef ->r...
2506
2507
2508
2509
  }
  
  static inline void inc_syscw(struct task_struct *tsk)
  {
940389b8a   Andrea Righi   task IO accountin...
2510
  	tsk->ioac.syscw++;
4b98d11b4   Alexey Dobriyan   [PATCH] ifdef ->r...
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
  }
  #else
  static inline void add_rchar(struct task_struct *tsk, ssize_t amt)
  {
  }
  
  static inline void add_wchar(struct task_struct *tsk, ssize_t amt)
  {
  }
  
  static inline void inc_syscr(struct task_struct *tsk)
  {
  }
  
  static inline void inc_syscw(struct task_struct *tsk)
  {
  }
  #endif
824552574   Dave Hansen   maps4: rework TAS...
2529
2530
2531
  #ifndef TASK_SIZE_OF
  #define TASK_SIZE_OF(tsk)	TASK_SIZE
  #endif
cf475ad28   Balbir Singh   cgroups: add an o...
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
  #ifdef CONFIG_MM_OWNER
  extern void mm_update_next_owner(struct mm_struct *mm);
  extern void mm_init_owner(struct mm_struct *mm, struct task_struct *p);
  #else
  static inline void mm_update_next_owner(struct mm_struct *mm)
  {
  }
  
  static inline void mm_init_owner(struct mm_struct *mm, struct task_struct *p)
  {
  }
  #endif /* CONFIG_MM_OWNER */
3e10e716a   Jiri Slaby   resource: add hel...
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
  static inline unsigned long task_rlimit(const struct task_struct *tsk,
  		unsigned int limit)
  {
  	return ACCESS_ONCE(tsk->signal->rlim[limit].rlim_cur);
  }
  
  static inline unsigned long task_rlimit_max(const struct task_struct *tsk,
  		unsigned int limit)
  {
  	return ACCESS_ONCE(tsk->signal->rlim[limit].rlim_max);
  }
  
  static inline unsigned long rlimit(unsigned int limit)
  {
  	return task_rlimit(current, limit);
  }
  
  static inline unsigned long rlimit_max(unsigned int limit)
  {
  	return task_rlimit_max(current, limit);
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2565
2566
2567
  #endif /* __KERNEL__ */
  
  #endif