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>
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>
19 # define INIT_PUSHABLE_TASKS(tsk) \
20 .pushable_tasks = PLIST_NODE_INIT(tsk.pushable_tasks, MAX_PRIO),
22 # define INIT_PUSHABLE_TASKS(tsk)
25 extern struct files_struct init_files;
26 extern struct fs_struct init_fs;
29 #define INIT_GROUP_RWSEM(sig) \
30 .group_rwsem = __RWSEM_INITIALIZER(sig.group_rwsem),
32 #define INIT_GROUP_RWSEM(sig)
36 #define INIT_CPUSET_SEQ(tsk) \
37 .mems_allowed_seq = SEQCNT_ZERO(tsk.mems_allowed_seq),
39 #define INIT_CPUSET_SEQ(tsk)
42 #define INIT_SIGNALS(sig) { \
44 .thread_head = LIST_HEAD_INIT(init_task.thread_node), \
45 .wait_chldexit = __WAIT_QUEUE_HEAD_INITIALIZER(sig.wait_chldexit),\
47 .list = LIST_HEAD_INIT(sig.shared_pending.list), \
49 .posix_timers = LIST_HEAD_INIT(sig.posix_timers), \
50 .cpu_timers = INIT_CPU_TIMERS(sig.cpu_timers), \
51 .rlim = INIT_RLIMITS, \
53 .cputime = INIT_CPUTIME, \
55 .lock = __RAW_SPIN_LOCK_UNLOCKED(sig.cputimer.lock), \
58 __MUTEX_INITIALIZER(sig.cred_guard_mutex), \
59 INIT_GROUP_RWSEM(sig) \
62 extern struct nsproxy init_nsproxy;
64 #define INIT_SIGHAND(sighand) { \
65 .count = ATOMIC_INIT(1), \
66 .action = { { { .sa_handler = SIG_DFL, } }, }, \
67 .siglock = __SPIN_LOCK_UNLOCKED(sighand.siglock), \
68 .signalfd_wqh = __WAIT_QUEUE_HEAD_INITIALIZER(sighand.signalfd_wqh), \
71 extern struct group_info init_groups;
73 #define INIT_STRUCT_PID { \
74 .count = ATOMIC_INIT(1), \
84 .pid_chain = { .next = NULL, .pprev = NULL }, \
88 #define INIT_PID_LINK(type) \
94 .pid = &init_struct_pid, \
97 #ifdef CONFIG_AUDITSYSCALL
99 .loginuid = INVALID_UID, \
100 .sessionid = (unsigned int)-1,
105 #ifdef CONFIG_RCU_BOOST
106 #define INIT_TASK_RCU_BOOST() \
107 .rcu_boost_mutex = NULL,
109 #define INIT_TASK_RCU_BOOST()
111 #ifdef CONFIG_TREE_PREEMPT_RCU
112 #define INIT_TASK_RCU_TREE_PREEMPT() \
113 .rcu_blocked_node = NULL,
115 #define INIT_TASK_RCU_TREE_PREEMPT(tsk)
117 #ifdef CONFIG_PREEMPT_RCU
118 #define INIT_TASK_RCU_PREEMPT(tsk) \
119 .rcu_read_lock_nesting = 0, \
120 .rcu_read_unlock_special = 0, \
121 .rcu_node_entry = LIST_HEAD_INIT(tsk.rcu_node_entry), \
122 INIT_TASK_RCU_TREE_PREEMPT() \
123 INIT_TASK_RCU_BOOST()
125 #define INIT_TASK_RCU_PREEMPT(tsk)
128 extern struct cred init_cred;
130 extern struct task_group root_task_group;
132 #ifdef CONFIG_CGROUP_SCHED
133 # define INIT_CGROUP_SCHED(tsk) \
134 .sched_task_group = &root_task_group,
136 # define INIT_CGROUP_SCHED(tsk)
139 #ifdef CONFIG_PERF_EVENTS
140 # define INIT_PERF_EVENTS(tsk) \
141 .perf_event_mutex = \
142 __MUTEX_INITIALIZER(tsk.perf_event_mutex), \
143 .perf_event_list = LIST_HEAD_INIT(tsk.perf_event_list),
145 # define INIT_PERF_EVENTS(tsk)
148 #ifdef CONFIG_VIRT_CPU_ACCOUNTING_GEN
149 # define INIT_VTIME(tsk) \
150 .vtime_seqlock = __SEQLOCK_UNLOCKED(tsk.vtime_seqlock), \
152 .vtime_snap_whence = VTIME_SYS,
154 # define INIT_VTIME(tsk)
157 #define INIT_TASK_COMM "swapper"
159 #ifdef CONFIG_RT_MUTEXES
160 # define INIT_RT_MUTEXES(tsk) \
161 .pi_waiters = RB_ROOT, \
162 .pi_waiters_leftmost = NULL,
164 # define INIT_RT_MUTEXES(tsk)
168 * INIT_TASK is used to set up the first task table, touch at
169 * your own risk!. Base=0, limit=0x1fffff (=2MB)
171 #define INIT_TASK(tsk) \
174 .stack = &init_thread_info, \
175 .usage = ATOMIC_INIT(2), \
176 .flags = PF_KTHREAD, \
177 .prio = MAX_PRIO-20, \
178 .static_prio = MAX_PRIO-20, \
179 .normal_prio = MAX_PRIO-20, \
180 .policy = SCHED_NORMAL, \
181 .cpus_allowed = CPU_MASK_ALL, \
182 .nr_cpus_allowed= NR_CPUS, \
184 .active_mm = &init_mm, \
186 .group_node = LIST_HEAD_INIT(tsk.se.group_node), \
189 .run_list = LIST_HEAD_INIT(tsk.rt.run_list), \
190 .time_slice = RR_TIMESLICE, \
192 .tasks = LIST_HEAD_INIT(tsk.tasks), \
193 INIT_PUSHABLE_TASKS(tsk) \
194 INIT_CGROUP_SCHED(tsk) \
195 .ptraced = LIST_HEAD_INIT(tsk.ptraced), \
196 .ptrace_entry = LIST_HEAD_INIT(tsk.ptrace_entry), \
197 .real_parent = &tsk, \
199 .children = LIST_HEAD_INIT(tsk.children), \
200 .sibling = LIST_HEAD_INIT(tsk.sibling), \
201 .group_leader = &tsk, \
202 RCU_POINTER_INITIALIZER(real_cred, &init_cred), \
203 RCU_POINTER_INITIALIZER(cred, &init_cred), \
204 .comm = INIT_TASK_COMM, \
205 .thread = INIT_THREAD, \
207 .files = &init_files, \
208 .signal = &init_signals, \
209 .sighand = &init_sighand, \
210 .nsproxy = &init_nsproxy, \
212 .list = LIST_HEAD_INIT(tsk.pending.list), \
215 .alloc_lock = __SPIN_LOCK_UNLOCKED(tsk.alloc_lock), \
216 .journal_info = NULL, \
217 .cpu_timers = INIT_CPU_TIMERS(tsk.cpu_timers), \
218 .pi_lock = __RAW_SPIN_LOCK_UNLOCKED(tsk.pi_lock), \
219 .timer_slack_ns = 50000, /* 50 usec default slack */ \
221 [PIDTYPE_PID] = INIT_PID_LINK(PIDTYPE_PID), \
222 [PIDTYPE_PGID] = INIT_PID_LINK(PIDTYPE_PGID), \
223 [PIDTYPE_SID] = INIT_PID_LINK(PIDTYPE_SID), \
225 .thread_group = LIST_HEAD_INIT(tsk.thread_group), \
226 .thread_node = LIST_HEAD_INIT(init_signals.thread_head), \
228 INIT_PERF_EVENTS(tsk) \
229 INIT_TRACE_IRQFLAGS \
232 INIT_TRACE_RECURSION \
233 INIT_TASK_RCU_PREEMPT(tsk) \
234 INIT_CPUSET_SEQ(tsk) \
235 INIT_RT_MUTEXES(tsk) \
240 #define INIT_CPU_TIMERS(cpu_timers) \
242 LIST_HEAD_INIT(cpu_timers[0]), \
243 LIST_HEAD_INIT(cpu_timers[1]), \
244 LIST_HEAD_INIT(cpu_timers[2]), \
247 /* Attach to the init_task data structure for proper alignment */
248 #define __init_task_data __attribute__((__section__(".data..init_task")))