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