Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | #ifndef _LINUX__INIT_TASK_H |
2 | #define _LINUX__INIT_TASK_H | |
3 | ||
ab2af1f5 | 4 | #include <linux/rcupdate.h> |
de30a2b3 | 5 | #include <linux/irqflags.h> |
4865ecf1 | 6 | #include <linux/utsname.h> |
fbb9ce95 | 7 | #include <linux/lockdep.h> |
5ac9f622 | 8 | #include <linux/ftrace.h> |
73ea4130 | 9 | #include <linux/ipc.h> |
9a575a92 | 10 | #include <linux/pid_namespace.h> |
acce292c | 11 | #include <linux/user_namespace.h> |
3898b1b4 | 12 | #include <linux/securebits.h> |
6a61671b | 13 | #include <linux/seqlock.h> |
fb00aca4 | 14 | #include <linux/rbtree.h> |
772698f6 | 15 | #include <net/net_namespace.h> |
77852fea | 16 | #include <linux/sched/rt.h> |
1da177e4 | 17 | |
806c09a7 DF |
18 | #ifdef CONFIG_SMP |
19 | # define INIT_PUSHABLE_TASKS(tsk) \ | |
20 | .pushable_tasks = PLIST_NODE_INIT(tsk.pushable_tasks, MAX_PRIO), | |
21 | #else | |
22 | # define INIT_PUSHABLE_TASKS(tsk) | |
23 | #endif | |
24 | ||
f52111b1 | 25 | extern struct files_struct init_files; |
18d8fda7 | 26 | extern struct fs_struct init_fs; |
1da177e4 | 27 | |
cc9a6c87 | 28 | #ifdef CONFIG_CPUSETS |
1ca7d67c JS |
29 | #define INIT_CPUSET_SEQ(tsk) \ |
30 | .mems_allowed_seq = SEQCNT_ZERO(tsk.mems_allowed_seq), | |
cc9a6c87 | 31 | #else |
1ca7d67c | 32 | #define INIT_CPUSET_SEQ(tsk) |
cc9a6c87 MG |
33 | #endif |
34 | ||
1ec320af | 35 | #define INIT_SIGNALS(sig) { \ |
b3ac022c | 36 | .nr_threads = 1, \ |
0c740d0a | 37 | .thread_head = LIST_HEAD_INIT(init_task.thread_node), \ |
1da177e4 | 38 | .wait_chldexit = __WAIT_QUEUE_HEAD_INITIALIZER(sig.wait_chldexit),\ |
1ec320af | 39 | .shared_pending = { \ |
1da177e4 | 40 | .list = LIST_HEAD_INIT(sig.shared_pending.list), \ |
1ec320af | 41 | .signal = {{0}}}, \ |
1da177e4 LT |
42 | .posix_timers = LIST_HEAD_INIT(sig.posix_timers), \ |
43 | .cpu_timers = INIT_CPU_TIMERS(sig.cpu_timers), \ | |
44 | .rlim = INIT_RLIMITS, \ | |
4cd4c1b4 | 45 | .cputimer = { \ |
71107445 JL |
46 | .cputime_atomic = INIT_CPUTIME_ATOMIC, \ |
47 | .running = 0, \ | |
4cd4c1b4 | 48 | }, \ |
9b1bf12d KM |
49 | .cred_guard_mutex = \ |
50 | __MUTEX_INITIALIZER(sig.cred_guard_mutex), \ | |
1da177e4 LT |
51 | } |
52 | ||
ab516013 | 53 | extern struct nsproxy init_nsproxy; |
ab516013 | 54 | |
1da177e4 LT |
55 | #define INIT_SIGHAND(sighand) { \ |
56 | .count = ATOMIC_INIT(1), \ | |
0a14a130 | 57 | .action = { { { .sa_handler = SIG_DFL, } }, }, \ |
e4d91918 | 58 | .siglock = __SPIN_LOCK_UNLOCKED(sighand.siglock), \ |
b8fceee1 | 59 | .signalfd_wqh = __WAIT_QUEUE_HEAD_INITIALIZER(sighand.signalfd_wqh), \ |
1da177e4 LT |
60 | } |
61 | ||
62 | extern struct group_info init_groups; | |
63 | ||
820e45db SB |
64 | #define INIT_STRUCT_PID { \ |
65 | .count = ATOMIC_INIT(1), \ | |
820e45db | 66 | .tasks = { \ |
f2001145 ON |
67 | { .first = NULL }, \ |
68 | { .first = NULL }, \ | |
69 | { .first = NULL }, \ | |
820e45db | 70 | }, \ |
4c3f2ead SB |
71 | .level = 0, \ |
72 | .numbers = { { \ | |
73 | .nr = 0, \ | |
74 | .ns = &init_pid_ns, \ | |
75 | .pid_chain = { .next = NULL, .pprev = NULL }, \ | |
76 | }, } \ | |
820e45db SB |
77 | } |
78 | ||
79 | #define INIT_PID_LINK(type) \ | |
80 | { \ | |
81 | .node = { \ | |
82 | .next = NULL, \ | |
f2001145 | 83 | .pprev = NULL, \ |
820e45db SB |
84 | }, \ |
85 | .pid = &init_struct_pid, \ | |
86 | } | |
87 | ||
bfef93a5 AV |
88 | #ifdef CONFIG_AUDITSYSCALL |
89 | #define INIT_IDS \ | |
e1760bd5 | 90 | .loginuid = INVALID_UID, \ |
4440e854 | 91 | .sessionid = (unsigned int)-1, |
bfef93a5 AV |
92 | #else |
93 | #define INIT_IDS | |
94 | #endif | |
3b7391de | 95 | |
28f6569a | 96 | #ifdef CONFIG_PREEMPT_RCU |
a57eb940 PM |
97 | #define INIT_TASK_RCU_TREE_PREEMPT() \ |
98 | .rcu_blocked_node = NULL, | |
99 | #else | |
100 | #define INIT_TASK_RCU_TREE_PREEMPT(tsk) | |
101 | #endif | |
102 | #ifdef CONFIG_PREEMPT_RCU | |
f41d911f PM |
103 | #define INIT_TASK_RCU_PREEMPT(tsk) \ |
104 | .rcu_read_lock_nesting = 0, \ | |
1d082fd0 | 105 | .rcu_read_unlock_special.s = 0, \ |
a57eb940 | 106 | .rcu_node_entry = LIST_HEAD_INIT(tsk.rcu_node_entry), \ |
abaa93d9 | 107 | INIT_TASK_RCU_TREE_PREEMPT() |
f41d911f PM |
108 | #else |
109 | #define INIT_TASK_RCU_PREEMPT(tsk) | |
110 | #endif | |
8315f422 PM |
111 | #ifdef CONFIG_TASKS_RCU |
112 | #define INIT_TASK_RCU_TASKS(tsk) \ | |
113 | .rcu_tasks_holdout = false, \ | |
114 | .rcu_tasks_holdout_list = \ | |
176f8f7a PM |
115 | LIST_HEAD_INIT(tsk.rcu_tasks_holdout_list), \ |
116 | .rcu_tasks_idle_cpu = -1, | |
8315f422 PM |
117 | #else |
118 | #define INIT_TASK_RCU_TASKS(tsk) | |
119 | #endif | |
f41d911f | 120 | |
b6dff3ec DH |
121 | extern struct cred init_cred; |
122 | ||
8323f26c PZ |
123 | extern struct task_group root_task_group; |
124 | ||
125 | #ifdef CONFIG_CGROUP_SCHED | |
126 | # define INIT_CGROUP_SCHED(tsk) \ | |
127 | .sched_task_group = &root_task_group, | |
128 | #else | |
129 | # define INIT_CGROUP_SCHED(tsk) | |
130 | #endif | |
131 | ||
cdd6c482 | 132 | #ifdef CONFIG_PERF_EVENTS |
8323f26c | 133 | # define INIT_PERF_EVENTS(tsk) \ |
cdd6c482 IM |
134 | .perf_event_mutex = \ |
135 | __MUTEX_INITIALIZER(tsk.perf_event_mutex), \ | |
136 | .perf_event_list = LIST_HEAD_INIT(tsk.perf_event_list), | |
082ff5a2 | 137 | #else |
cdd6c482 | 138 | # define INIT_PERF_EVENTS(tsk) |
082ff5a2 PZ |
139 | #endif |
140 | ||
6a61671b FW |
141 | #ifdef CONFIG_VIRT_CPU_ACCOUNTING_GEN |
142 | # define INIT_VTIME(tsk) \ | |
143 | .vtime_seqlock = __SEQLOCK_UNLOCKED(tsk.vtime_seqlock), \ | |
144 | .vtime_snap = 0, \ | |
145 | .vtime_snap_whence = VTIME_SYS, | |
146 | #else | |
147 | # define INIT_VTIME(tsk) | |
148 | #endif | |
149 | ||
f1c6f1a7 CE |
150 | #define INIT_TASK_COMM "swapper" |
151 | ||
fb00aca4 PZ |
152 | #ifdef CONFIG_RT_MUTEXES |
153 | # define INIT_RT_MUTEXES(tsk) \ | |
154 | .pi_waiters = RB_ROOT, \ | |
155 | .pi_waiters_leftmost = NULL, | |
156 | #else | |
157 | # define INIT_RT_MUTEXES(tsk) | |
158 | #endif | |
159 | ||
d8b163c4 KT |
160 | #ifdef CONFIG_NUMA_BALANCING |
161 | # define INIT_NUMA_BALANCING(tsk) \ | |
162 | .numa_preferred_nid = -1, \ | |
163 | .numa_group = NULL, \ | |
164 | .numa_faults = NULL, | |
165 | #else | |
166 | # define INIT_NUMA_BALANCING(tsk) | |
167 | #endif | |
168 | ||
c420f167 AR |
169 | #ifdef CONFIG_KASAN |
170 | # define INIT_KASAN(tsk) \ | |
171 | .kasan_depth = 1, | |
172 | #else | |
173 | # define INIT_KASAN(tsk) | |
174 | #endif | |
175 | ||
1da177e4 LT |
176 | /* |
177 | * INIT_TASK is used to set up the first task table, touch at | |
178 | * your own risk!. Base=0, limit=0x1fffff (=2MB) | |
179 | */ | |
180 | #define INIT_TASK(tsk) \ | |
181 | { \ | |
182 | .state = 0, \ | |
f7e4217b | 183 | .stack = &init_thread_info, \ |
1da177e4 | 184 | .usage = ATOMIC_INIT(2), \ |
7b34e428 | 185 | .flags = PF_KTHREAD, \ |
1da177e4 LT |
186 | .prio = MAX_PRIO-20, \ |
187 | .static_prio = MAX_PRIO-20, \ | |
b29739f9 | 188 | .normal_prio = MAX_PRIO-20, \ |
1da177e4 LT |
189 | .policy = SCHED_NORMAL, \ |
190 | .cpus_allowed = CPU_MASK_ALL, \ | |
29baa747 | 191 | .nr_cpus_allowed= NR_CPUS, \ |
1da177e4 LT |
192 | .mm = NULL, \ |
193 | .active_mm = &init_mm, \ | |
f56141e3 AL |
194 | .restart_block = { \ |
195 | .fn = do_no_restart_syscall, \ | |
196 | }, \ | |
4a55bd5e PZ |
197 | .se = { \ |
198 | .group_node = LIST_HEAD_INIT(tsk.se.group_node), \ | |
199 | }, \ | |
fa717060 PZ |
200 | .rt = { \ |
201 | .run_list = LIST_HEAD_INIT(tsk.rt.run_list), \ | |
de5bdff7 | 202 | .time_slice = RR_TIMESLICE, \ |
6f505b16 | 203 | }, \ |
1da177e4 | 204 | .tasks = LIST_HEAD_INIT(tsk.tasks), \ |
806c09a7 | 205 | INIT_PUSHABLE_TASKS(tsk) \ |
8323f26c | 206 | INIT_CGROUP_SCHED(tsk) \ |
f470021a RM |
207 | .ptraced = LIST_HEAD_INIT(tsk.ptraced), \ |
208 | .ptrace_entry = LIST_HEAD_INIT(tsk.ptrace_entry), \ | |
1da177e4 LT |
209 | .real_parent = &tsk, \ |
210 | .parent = &tsk, \ | |
211 | .children = LIST_HEAD_INIT(tsk.children), \ | |
212 | .sibling = LIST_HEAD_INIT(tsk.sibling), \ | |
213 | .group_leader = &tsk, \ | |
d36cc701 PM |
214 | RCU_POINTER_INITIALIZER(real_cred, &init_cred), \ |
215 | RCU_POINTER_INITIALIZER(cred, &init_cred), \ | |
f1c6f1a7 | 216 | .comm = INIT_TASK_COMM, \ |
1da177e4 LT |
217 | .thread = INIT_THREAD, \ |
218 | .fs = &init_fs, \ | |
219 | .files = &init_files, \ | |
220 | .signal = &init_signals, \ | |
221 | .sighand = &init_sighand, \ | |
ab516013 | 222 | .nsproxy = &init_nsproxy, \ |
1da177e4 LT |
223 | .pending = { \ |
224 | .list = LIST_HEAD_INIT(tsk.pending.list), \ | |
225 | .signal = {{0}}}, \ | |
226 | .blocked = {{0}}, \ | |
e4d91918 | 227 | .alloc_lock = __SPIN_LOCK_UNLOCKED(tsk.alloc_lock), \ |
b6e3224f | 228 | .journal_info = NULL, \ |
1da177e4 | 229 | .cpu_timers = INIT_CPU_TIMERS(tsk.cpu_timers), \ |
1d615482 | 230 | .pi_lock = __RAW_SPIN_LOCK_UNLOCKED(tsk.pi_lock), \ |
6976675d | 231 | .timer_slack_ns = 50000, /* 50 usec default slack */ \ |
820e45db SB |
232 | .pids = { \ |
233 | [PIDTYPE_PID] = INIT_PID_LINK(PIDTYPE_PID), \ | |
234 | [PIDTYPE_PGID] = INIT_PID_LINK(PIDTYPE_PGID), \ | |
235 | [PIDTYPE_SID] = INIT_PID_LINK(PIDTYPE_SID), \ | |
236 | }, \ | |
fa2755e2 | 237 | .thread_group = LIST_HEAD_INIT(tsk.thread_group), \ |
0c740d0a | 238 | .thread_node = LIST_HEAD_INIT(init_signals.thread_head), \ |
bfef93a5 | 239 | INIT_IDS \ |
cdd6c482 | 240 | INIT_PERF_EVENTS(tsk) \ |
de30a2b3 | 241 | INIT_TRACE_IRQFLAGS \ |
fbb9ce95 | 242 | INIT_LOCKDEP \ |
5ac9f622 | 243 | INIT_FTRACE_GRAPH \ |
261842b7 | 244 | INIT_TRACE_RECURSION \ |
f41d911f | 245 | INIT_TASK_RCU_PREEMPT(tsk) \ |
8315f422 | 246 | INIT_TASK_RCU_TASKS(tsk) \ |
1ca7d67c | 247 | INIT_CPUSET_SEQ(tsk) \ |
fb00aca4 | 248 | INIT_RT_MUTEXES(tsk) \ |
6a61671b | 249 | INIT_VTIME(tsk) \ |
d8b163c4 | 250 | INIT_NUMA_BALANCING(tsk) \ |
c420f167 | 251 | INIT_KASAN(tsk) \ |
1da177e4 LT |
252 | } |
253 | ||
254 | ||
255 | #define INIT_CPU_TIMERS(cpu_timers) \ | |
256 | { \ | |
257 | LIST_HEAD_INIT(cpu_timers[0]), \ | |
258 | LIST_HEAD_INIT(cpu_timers[1]), \ | |
259 | LIST_HEAD_INIT(cpu_timers[2]), \ | |
260 | } | |
261 | ||
857eceeb | 262 | /* Attach to the init_task data structure for proper alignment */ |
2af7687f | 263 | #define __init_task_data __attribute__((__section__(".data..init_task"))) |
857eceeb | 264 | |
1da177e4 LT |
265 | |
266 | #endif |