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