]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blob - include/linux/init_task.h
Merge tag 'platform-drivers-x86-v4.9-2' of git://git.infradead.org/users/dvhart/linux...
[mirror_ubuntu-artful-kernel.git] / include / linux / init_task.h
1 #ifndef _LINUX__INIT_TASK_H
2 #define _LINUX__INIT_TASK_H
3
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 <linux/seqlock.h>
14 #include <linux/rbtree.h>
15 #include <net/net_namespace.h>
16 #include <linux/sched/rt.h>
17
18 #include <asm/thread_info.h>
19
20 #ifdef CONFIG_SMP
21 # define INIT_PUSHABLE_TASKS(tsk) \
22 .pushable_tasks = PLIST_NODE_INIT(tsk.pushable_tasks, MAX_PRIO),
23 #else
24 # define INIT_PUSHABLE_TASKS(tsk)
25 #endif
26
27 extern struct files_struct init_files;
28 extern struct fs_struct init_fs;
29
30 #ifdef CONFIG_CPUSETS
31 #define INIT_CPUSET_SEQ(tsk) \
32 .mems_allowed_seq = SEQCNT_ZERO(tsk.mems_allowed_seq),
33 #else
34 #define INIT_CPUSET_SEQ(tsk)
35 #endif
36
37 #ifndef CONFIG_VIRT_CPU_ACCOUNTING_NATIVE
38 #define INIT_PREV_CPUTIME(x) .prev_cputime = { \
39 .lock = __RAW_SPIN_LOCK_UNLOCKED(x.prev_cputime.lock), \
40 },
41 #else
42 #define INIT_PREV_CPUTIME(x)
43 #endif
44
45 #define INIT_SIGNALS(sig) { \
46 .nr_threads = 1, \
47 .thread_head = LIST_HEAD_INIT(init_task.thread_node), \
48 .wait_chldexit = __WAIT_QUEUE_HEAD_INITIALIZER(sig.wait_chldexit),\
49 .shared_pending = { \
50 .list = LIST_HEAD_INIT(sig.shared_pending.list), \
51 .signal = {{0}}}, \
52 .posix_timers = LIST_HEAD_INIT(sig.posix_timers), \
53 .cpu_timers = INIT_CPU_TIMERS(sig.cpu_timers), \
54 .rlim = INIT_RLIMITS, \
55 .cputimer = { \
56 .cputime_atomic = INIT_CPUTIME_ATOMIC, \
57 .running = false, \
58 .checking_timer = false, \
59 }, \
60 INIT_PREV_CPUTIME(sig) \
61 .cred_guard_mutex = \
62 __MUTEX_INITIALIZER(sig.cred_guard_mutex), \
63 }
64
65 extern struct nsproxy init_nsproxy;
66
67 #define INIT_SIGHAND(sighand) { \
68 .count = ATOMIC_INIT(1), \
69 .action = { { { .sa_handler = SIG_DFL, } }, }, \
70 .siglock = __SPIN_LOCK_UNLOCKED(sighand.siglock), \
71 .signalfd_wqh = __WAIT_QUEUE_HEAD_INITIALIZER(sighand.signalfd_wqh), \
72 }
73
74 extern struct group_info init_groups;
75
76 #define INIT_STRUCT_PID { \
77 .count = ATOMIC_INIT(1), \
78 .tasks = { \
79 { .first = NULL }, \
80 { .first = NULL }, \
81 { .first = NULL }, \
82 }, \
83 .level = 0, \
84 .numbers = { { \
85 .nr = 0, \
86 .ns = &init_pid_ns, \
87 .pid_chain = { .next = NULL, .pprev = NULL }, \
88 }, } \
89 }
90
91 #define INIT_PID_LINK(type) \
92 { \
93 .node = { \
94 .next = NULL, \
95 .pprev = NULL, \
96 }, \
97 .pid = &init_struct_pid, \
98 }
99
100 #ifdef CONFIG_AUDITSYSCALL
101 #define INIT_IDS \
102 .loginuid = INVALID_UID, \
103 .sessionid = (unsigned int)-1,
104 #else
105 #define INIT_IDS
106 #endif
107
108 #ifdef CONFIG_PREEMPT_RCU
109 #define INIT_TASK_RCU_TREE_PREEMPT() \
110 .rcu_blocked_node = NULL,
111 #else
112 #define INIT_TASK_RCU_TREE_PREEMPT(tsk)
113 #endif
114 #ifdef CONFIG_PREEMPT_RCU
115 #define INIT_TASK_RCU_PREEMPT(tsk) \
116 .rcu_read_lock_nesting = 0, \
117 .rcu_read_unlock_special.s = 0, \
118 .rcu_node_entry = LIST_HEAD_INIT(tsk.rcu_node_entry), \
119 INIT_TASK_RCU_TREE_PREEMPT()
120 #else
121 #define INIT_TASK_RCU_PREEMPT(tsk)
122 #endif
123 #ifdef CONFIG_TASKS_RCU
124 #define INIT_TASK_RCU_TASKS(tsk) \
125 .rcu_tasks_holdout = false, \
126 .rcu_tasks_holdout_list = \
127 LIST_HEAD_INIT(tsk.rcu_tasks_holdout_list), \
128 .rcu_tasks_idle_cpu = -1,
129 #else
130 #define INIT_TASK_RCU_TASKS(tsk)
131 #endif
132
133 extern struct cred init_cred;
134
135 extern struct task_group root_task_group;
136
137 #ifdef CONFIG_CGROUP_SCHED
138 # define INIT_CGROUP_SCHED(tsk) \
139 .sched_task_group = &root_task_group,
140 #else
141 # define INIT_CGROUP_SCHED(tsk)
142 #endif
143
144 #ifdef CONFIG_PERF_EVENTS
145 # define INIT_PERF_EVENTS(tsk) \
146 .perf_event_mutex = \
147 __MUTEX_INITIALIZER(tsk.perf_event_mutex), \
148 .perf_event_list = LIST_HEAD_INIT(tsk.perf_event_list),
149 #else
150 # define INIT_PERF_EVENTS(tsk)
151 #endif
152
153 #ifdef CONFIG_VIRT_CPU_ACCOUNTING_GEN
154 # define INIT_VTIME(tsk) \
155 .vtime_seqcount = SEQCNT_ZERO(tsk.vtime_seqcount), \
156 .vtime_snap = 0, \
157 .vtime_snap_whence = VTIME_SYS,
158 #else
159 # define INIT_VTIME(tsk)
160 #endif
161
162 #define INIT_TASK_COMM "swapper"
163
164 #ifdef CONFIG_RT_MUTEXES
165 # define INIT_RT_MUTEXES(tsk) \
166 .pi_waiters = RB_ROOT, \
167 .pi_waiters_leftmost = NULL,
168 #else
169 # define INIT_RT_MUTEXES(tsk)
170 #endif
171
172 #ifdef CONFIG_NUMA_BALANCING
173 # define INIT_NUMA_BALANCING(tsk) \
174 .numa_preferred_nid = -1, \
175 .numa_group = NULL, \
176 .numa_faults = NULL,
177 #else
178 # define INIT_NUMA_BALANCING(tsk)
179 #endif
180
181 #ifdef CONFIG_KASAN
182 # define INIT_KASAN(tsk) \
183 .kasan_depth = 1,
184 #else
185 # define INIT_KASAN(tsk)
186 #endif
187
188 #ifdef CONFIG_THREAD_INFO_IN_TASK
189 # define INIT_TASK_TI(tsk) \
190 .thread_info = INIT_THREAD_INFO(tsk), \
191 .stack_refcount = ATOMIC_INIT(1),
192 #else
193 # define INIT_TASK_TI(tsk)
194 #endif
195
196 /*
197 * INIT_TASK is used to set up the first task table, touch at
198 * your own risk!. Base=0, limit=0x1fffff (=2MB)
199 */
200 #define INIT_TASK(tsk) \
201 { \
202 INIT_TASK_TI(tsk) \
203 .state = 0, \
204 .stack = init_stack, \
205 .usage = ATOMIC_INIT(2), \
206 .flags = PF_KTHREAD, \
207 .prio = MAX_PRIO-20, \
208 .static_prio = MAX_PRIO-20, \
209 .normal_prio = MAX_PRIO-20, \
210 .policy = SCHED_NORMAL, \
211 .cpus_allowed = CPU_MASK_ALL, \
212 .nr_cpus_allowed= NR_CPUS, \
213 .mm = NULL, \
214 .active_mm = &init_mm, \
215 .restart_block = { \
216 .fn = do_no_restart_syscall, \
217 }, \
218 .se = { \
219 .group_node = LIST_HEAD_INIT(tsk.se.group_node), \
220 }, \
221 .rt = { \
222 .run_list = LIST_HEAD_INIT(tsk.rt.run_list), \
223 .time_slice = RR_TIMESLICE, \
224 }, \
225 .tasks = LIST_HEAD_INIT(tsk.tasks), \
226 INIT_PUSHABLE_TASKS(tsk) \
227 INIT_CGROUP_SCHED(tsk) \
228 .ptraced = LIST_HEAD_INIT(tsk.ptraced), \
229 .ptrace_entry = LIST_HEAD_INIT(tsk.ptrace_entry), \
230 .real_parent = &tsk, \
231 .parent = &tsk, \
232 .children = LIST_HEAD_INIT(tsk.children), \
233 .sibling = LIST_HEAD_INIT(tsk.sibling), \
234 .group_leader = &tsk, \
235 RCU_POINTER_INITIALIZER(real_cred, &init_cred), \
236 RCU_POINTER_INITIALIZER(cred, &init_cred), \
237 .comm = INIT_TASK_COMM, \
238 .thread = INIT_THREAD, \
239 .fs = &init_fs, \
240 .files = &init_files, \
241 .signal = &init_signals, \
242 .sighand = &init_sighand, \
243 .nsproxy = &init_nsproxy, \
244 .pending = { \
245 .list = LIST_HEAD_INIT(tsk.pending.list), \
246 .signal = {{0}}}, \
247 .blocked = {{0}}, \
248 .alloc_lock = __SPIN_LOCK_UNLOCKED(tsk.alloc_lock), \
249 .journal_info = NULL, \
250 .cpu_timers = INIT_CPU_TIMERS(tsk.cpu_timers), \
251 .pi_lock = __RAW_SPIN_LOCK_UNLOCKED(tsk.pi_lock), \
252 .timer_slack_ns = 50000, /* 50 usec default slack */ \
253 .pids = { \
254 [PIDTYPE_PID] = INIT_PID_LINK(PIDTYPE_PID), \
255 [PIDTYPE_PGID] = INIT_PID_LINK(PIDTYPE_PGID), \
256 [PIDTYPE_SID] = INIT_PID_LINK(PIDTYPE_SID), \
257 }, \
258 .thread_group = LIST_HEAD_INIT(tsk.thread_group), \
259 .thread_node = LIST_HEAD_INIT(init_signals.thread_head), \
260 INIT_IDS \
261 INIT_PERF_EVENTS(tsk) \
262 INIT_TRACE_IRQFLAGS \
263 INIT_LOCKDEP \
264 INIT_FTRACE_GRAPH \
265 INIT_TRACE_RECURSION \
266 INIT_TASK_RCU_PREEMPT(tsk) \
267 INIT_TASK_RCU_TASKS(tsk) \
268 INIT_CPUSET_SEQ(tsk) \
269 INIT_RT_MUTEXES(tsk) \
270 INIT_PREV_CPUTIME(tsk) \
271 INIT_VTIME(tsk) \
272 INIT_NUMA_BALANCING(tsk) \
273 INIT_KASAN(tsk) \
274 }
275
276
277 #define INIT_CPU_TIMERS(cpu_timers) \
278 { \
279 LIST_HEAD_INIT(cpu_timers[0]), \
280 LIST_HEAD_INIT(cpu_timers[1]), \
281 LIST_HEAD_INIT(cpu_timers[2]), \
282 }
283
284 /* Attach to the init_task data structure for proper alignment */
285 #define __init_task_data __attribute__((__section__(".data..init_task")))
286
287
288 #endif