Merge tag 'v3.3.7' into 3.3/master
[zen-stable.git] / include / linux / init_task.h
blob19a57fab3ce35f5a283fe991d46b18afb7bcc70d
1 #ifndef _LINUX__INIT_TASK_H
2 #define _LINUX__INIT_TASK_H
4 #include <linux/rcupdate.h>
5 #include <linux/irqflags.h>
6 #include <linux/utsname.h>
7 #include <linux/lockdep.h>
8 #include <linux/ftrace.h>
9 #include <linux/ipc.h>
10 #include <linux/pid_namespace.h>
11 #include <linux/user_namespace.h>
12 #include <linux/securebits.h>
13 #include <net/net_namespace.h>
15 #ifdef CONFIG_SMP
16 # define INIT_PUSHABLE_TASKS(tsk) \
17 .pushable_tasks = PLIST_NODE_INIT(tsk.pushable_tasks, MAX_PRIO),
18 #else
19 # define INIT_PUSHABLE_TASKS(tsk)
20 #endif
22 extern struct files_struct init_files;
23 extern struct fs_struct init_fs;
25 #ifdef CONFIG_CGROUPS
26 #define INIT_GROUP_RWSEM(sig) \
27 .group_rwsem = __RWSEM_INITIALIZER(sig.group_rwsem),
28 #else
29 #define INIT_GROUP_RWSEM(sig)
30 #endif
32 #define INIT_SIGNALS(sig) { \
33 .nr_threads = 1, \
34 .wait_chldexit = __WAIT_QUEUE_HEAD_INITIALIZER(sig.wait_chldexit),\
35 .shared_pending = { \
36 .list = LIST_HEAD_INIT(sig.shared_pending.list), \
37 .signal = {{0}}}, \
38 .posix_timers = LIST_HEAD_INIT(sig.posix_timers), \
39 .cpu_timers = INIT_CPU_TIMERS(sig.cpu_timers), \
40 .rlim = INIT_RLIMITS, \
41 .cputimer = { \
42 .cputime = INIT_CPUTIME, \
43 .running = 0, \
44 .lock = __RAW_SPIN_LOCK_UNLOCKED(sig.cputimer.lock), \
45 }, \
46 .cred_guard_mutex = \
47 __MUTEX_INITIALIZER(sig.cred_guard_mutex), \
48 INIT_GROUP_RWSEM(sig) \
51 extern struct nsproxy init_nsproxy;
53 #define INIT_SIGHAND(sighand) { \
54 .count = ATOMIC_INIT(1), \
55 .action = { { { .sa_handler = SIG_DFL, } }, }, \
56 .siglock = __SPIN_LOCK_UNLOCKED(sighand.siglock), \
57 .signalfd_wqh = __WAIT_QUEUE_HEAD_INITIALIZER(sighand.signalfd_wqh), \
60 extern struct group_info init_groups;
62 #define INIT_STRUCT_PID { \
63 .count = ATOMIC_INIT(1), \
64 .tasks = { \
65 { .first = NULL }, \
66 { .first = NULL }, \
67 { .first = NULL }, \
68 }, \
69 .level = 0, \
70 .numbers = { { \
71 .nr = 0, \
72 .ns = &init_pid_ns, \
73 .pid_chain = { .next = NULL, .pprev = NULL }, \
74 }, } \
77 #define INIT_PID_LINK(type) \
78 { \
79 .node = { \
80 .next = NULL, \
81 .pprev = NULL, \
82 }, \
83 .pid = &init_struct_pid, \
86 #ifdef CONFIG_AUDITSYSCALL
87 #define INIT_IDS \
88 .loginuid = -1, \
89 .sessionid = -1,
90 #else
91 #define INIT_IDS
92 #endif
94 #ifdef CONFIG_RCU_BOOST
95 #define INIT_TASK_RCU_BOOST() \
96 .rcu_boost_mutex = NULL,
97 #else
98 #define INIT_TASK_RCU_BOOST()
99 #endif
100 #ifdef CONFIG_TREE_PREEMPT_RCU
101 #define INIT_TASK_RCU_TREE_PREEMPT() \
102 .rcu_blocked_node = NULL,
103 #else
104 #define INIT_TASK_RCU_TREE_PREEMPT(tsk)
105 #endif
106 #ifdef CONFIG_PREEMPT_RCU
107 #define INIT_TASK_RCU_PREEMPT(tsk) \
108 .rcu_read_lock_nesting = 0, \
109 .rcu_read_unlock_special = 0, \
110 .rcu_node_entry = LIST_HEAD_INIT(tsk.rcu_node_entry), \
111 INIT_TASK_RCU_TREE_PREEMPT() \
112 INIT_TASK_RCU_BOOST()
113 #else
114 #define INIT_TASK_RCU_PREEMPT(tsk)
115 #endif
117 extern struct cred init_cred;
119 #ifdef CONFIG_PERF_EVENTS
120 # define INIT_PERF_EVENTS(tsk) \
121 .perf_event_mutex = \
122 __MUTEX_INITIALIZER(tsk.perf_event_mutex), \
123 .perf_event_list = LIST_HEAD_INIT(tsk.perf_event_list),
124 #else
125 # define INIT_PERF_EVENTS(tsk)
126 #endif
129 * INIT_TASK is used to set up the first task table, touch at
130 * your own risk!. Base=0, limit=0x1fffff (=2MB)
132 #ifdef CONFIG_SCHED_BFS
133 #define INIT_TASK_COMM "BFS"
134 #define INIT_TASK(tsk) \
136 .state = 0, \
137 .stack = &init_thread_info, \
138 .usage = ATOMIC_INIT(2), \
139 .flags = PF_KTHREAD, \
140 .prio = NORMAL_PRIO, \
141 .static_prio = MAX_PRIO-20, \
142 .normal_prio = NORMAL_PRIO, \
143 .deadline = 0, \
144 .policy = SCHED_NORMAL, \
145 .cpus_allowed = CPU_MASK_ALL, \
146 .mm = NULL, \
147 .active_mm = &init_mm, \
148 .run_list = LIST_HEAD_INIT(tsk.run_list), \
149 .time_slice = HZ, \
150 .tasks = LIST_HEAD_INIT(tsk.tasks), \
151 INIT_PUSHABLE_TASKS(tsk) \
152 .ptraced = LIST_HEAD_INIT(tsk.ptraced), \
153 .ptrace_entry = LIST_HEAD_INIT(tsk.ptrace_entry), \
154 .real_parent = &tsk, \
155 .parent = &tsk, \
156 .children = LIST_HEAD_INIT(tsk.children), \
157 .sibling = LIST_HEAD_INIT(tsk.sibling), \
158 .group_leader = &tsk, \
159 RCU_INIT_POINTER(.real_cred, &init_cred), \
160 RCU_INIT_POINTER(.cred, &init_cred), \
161 .comm = INIT_TASK_COMM, \
162 .thread = INIT_THREAD, \
163 .fs = &init_fs, \
164 .files = &init_files, \
165 .signal = &init_signals, \
166 .sighand = &init_sighand, \
167 .nsproxy = &init_nsproxy, \
168 .pending = { \
169 .list = LIST_HEAD_INIT(tsk.pending.list), \
170 .signal = {{0}}}, \
171 .blocked = {{0}}, \
172 .alloc_lock = __SPIN_LOCK_UNLOCKED(tsk.alloc_lock), \
173 .journal_info = NULL, \
174 .cpu_timers = INIT_CPU_TIMERS(tsk.cpu_timers), \
175 .pi_lock = __RAW_SPIN_LOCK_UNLOCKED(tsk.pi_lock), \
176 .timer_slack_ns = 50000, /* 50 usec default slack */ \
177 .pids = { \
178 [PIDTYPE_PID] = INIT_PID_LINK(PIDTYPE_PID), \
179 [PIDTYPE_PGID] = INIT_PID_LINK(PIDTYPE_PGID), \
180 [PIDTYPE_SID] = INIT_PID_LINK(PIDTYPE_SID), \
181 }, \
182 INIT_IDS \
183 INIT_PERF_EVENTS(tsk) \
184 INIT_TRACE_IRQFLAGS \
185 INIT_LOCKDEP \
186 INIT_FTRACE_GRAPH \
187 INIT_TRACE_RECURSION \
188 INIT_TASK_RCU_PREEMPT(tsk) \
190 #else /* CONFIG_SCHED_BFS */
191 #define INIT_TASK_COMM "swapper"
192 #define INIT_TASK(tsk) \
194 .state = 0, \
195 .stack = &init_thread_info, \
196 .usage = ATOMIC_INIT(2), \
197 .flags = PF_KTHREAD, \
198 .prio = MAX_PRIO-20, \
199 .static_prio = MAX_PRIO-20, \
200 .normal_prio = MAX_PRIO-20, \
201 .policy = SCHED_NORMAL, \
202 .cpus_allowed = CPU_MASK_ALL, \
203 .mm = NULL, \
204 .active_mm = &init_mm, \
205 .se = { \
206 .group_node = LIST_HEAD_INIT(tsk.se.group_node), \
207 }, \
208 .rt = { \
209 .run_list = LIST_HEAD_INIT(tsk.rt.run_list), \
210 .time_slice = HZ, \
211 .nr_cpus_allowed = NR_CPUS, \
212 }, \
213 .tasks = LIST_HEAD_INIT(tsk.tasks), \
214 INIT_PUSHABLE_TASKS(tsk) \
215 .ptraced = LIST_HEAD_INIT(tsk.ptraced), \
216 .ptrace_entry = LIST_HEAD_INIT(tsk.ptrace_entry), \
217 .real_parent = &tsk, \
218 .parent = &tsk, \
219 .children = LIST_HEAD_INIT(tsk.children), \
220 .sibling = LIST_HEAD_INIT(tsk.sibling), \
221 .group_leader = &tsk, \
222 RCU_INIT_POINTER(.real_cred, &init_cred), \
223 RCU_INIT_POINTER(.cred, &init_cred), \
224 .comm = INIT_TASK_COMM, \
225 .thread = INIT_THREAD, \
226 .fs = &init_fs, \
227 .files = &init_files, \
228 .signal = &init_signals, \
229 .sighand = &init_sighand, \
230 .nsproxy = &init_nsproxy, \
231 .pending = { \
232 .list = LIST_HEAD_INIT(tsk.pending.list), \
233 .signal = {{0}}}, \
234 .blocked = {{0}}, \
235 .alloc_lock = __SPIN_LOCK_UNLOCKED(tsk.alloc_lock), \
236 .journal_info = NULL, \
237 .cpu_timers = INIT_CPU_TIMERS(tsk.cpu_timers), \
238 .pi_lock = __RAW_SPIN_LOCK_UNLOCKED(tsk.pi_lock), \
239 .timer_slack_ns = 50000, /* 50 usec default slack */ \
240 .pids = { \
241 [PIDTYPE_PID] = INIT_PID_LINK(PIDTYPE_PID), \
242 [PIDTYPE_PGID] = INIT_PID_LINK(PIDTYPE_PGID), \
243 [PIDTYPE_SID] = INIT_PID_LINK(PIDTYPE_SID), \
244 }, \
245 .thread_group = LIST_HEAD_INIT(tsk.thread_group), \
246 INIT_IDS \
247 INIT_PERF_EVENTS(tsk) \
248 INIT_TRACE_IRQFLAGS \
249 INIT_LOCKDEP \
250 INIT_FTRACE_GRAPH \
251 INIT_TRACE_RECURSION \
252 INIT_TASK_RCU_PREEMPT(tsk) \
254 #endif /* CONFIG_SCHED_BFS */
256 #define INIT_CPU_TIMERS(cpu_timers) \
258 LIST_HEAD_INIT(cpu_timers[0]), \
259 LIST_HEAD_INIT(cpu_timers[1]), \
260 LIST_HEAD_INIT(cpu_timers[2]), \
263 /* Attach to the init_task data structure for proper alignment */
264 #define __init_task_data __attribute__((__section__(".data..init_task")))
267 #endif