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 <net/net_namespace.h>
15 #include <linux/sched/rt.h>
18 # define INIT_PUSHABLE_TASKS(tsk) \
19 .pushable_tasks = PLIST_NODE_INIT(tsk.pushable_tasks, MAX_PRIO),
21 # define INIT_PUSHABLE_TASKS(tsk)
24 extern struct files_struct init_files;
25 extern struct fs_struct init_fs;
28 #define INIT_GROUP_RWSEM(sig) \
29 .group_rwsem = __RWSEM_INITIALIZER(sig.group_rwsem),
31 #define INIT_GROUP_RWSEM(sig)
35 #define INIT_CPUSET_SEQ \
36 .mems_allowed_seq = SEQCNT_ZERO,
38 #define INIT_CPUSET_SEQ
41 #define INIT_SIGNALS(sig) { \
43 .wait_chldexit = __WAIT_QUEUE_HEAD_INITIALIZER(sig.wait_chldexit),\
45 .list = LIST_HEAD_INIT(sig.shared_pending.list), \
47 .posix_timers = LIST_HEAD_INIT(sig.posix_timers), \
48 .cpu_timers = INIT_CPU_TIMERS(sig.cpu_timers), \
49 .rlim = INIT_RLIMITS, \
51 .cputime = INIT_CPUTIME, \
53 .lock = __RAW_SPIN_LOCK_UNLOCKED(sig.cputimer.lock), \
56 __MUTEX_INITIALIZER(sig.cred_guard_mutex), \
57 INIT_GROUP_RWSEM(sig) \
60 extern struct nsproxy init_nsproxy;
62 #define INIT_SIGHAND(sighand) { \
63 .count = ATOMIC_INIT(1), \
64 .action = { { { .sa_handler = SIG_DFL, } }, }, \
65 .siglock = __SPIN_LOCK_UNLOCKED(sighand.siglock), \
66 .signalfd_wqh = __WAIT_QUEUE_HEAD_INITIALIZER(sighand.signalfd_wqh), \
69 extern struct group_info init_groups;
71 #define INIT_STRUCT_PID { \
72 .count = ATOMIC_INIT(1), \
82 .pid_chain = { .next = NULL, .pprev = NULL }, \
86 #define INIT_PID_LINK(type) \
92 .pid = &init_struct_pid, \
95 #ifdef CONFIG_AUDITSYSCALL
97 .loginuid = INVALID_UID, \
103 #ifdef CONFIG_RCU_BOOST
104 #define INIT_TASK_RCU_BOOST() \
105 .rcu_boost_mutex = NULL,
107 #define INIT_TASK_RCU_BOOST()
109 #ifdef CONFIG_TREE_PREEMPT_RCU
110 #define INIT_TASK_RCU_TREE_PREEMPT() \
111 .rcu_blocked_node = NULL,
113 #define INIT_TASK_RCU_TREE_PREEMPT(tsk)
115 #ifdef CONFIG_PREEMPT_RCU
116 #define INIT_TASK_RCU_PREEMPT(tsk) \
117 .rcu_read_lock_nesting = 0, \
118 .rcu_read_unlock_special = 0, \
119 .rcu_node_entry = LIST_HEAD_INIT(tsk.rcu_node_entry), \
120 INIT_TASK_RCU_TREE_PREEMPT() \
121 INIT_TASK_RCU_BOOST()
123 #define INIT_TASK_RCU_PREEMPT(tsk)
126 extern struct cred init_cred;
128 extern struct task_group root_task_group;
130 #ifdef CONFIG_CGROUP_SCHED
131 # define INIT_CGROUP_SCHED(tsk) \
132 .sched_task_group = &root_task_group,
134 # define INIT_CGROUP_SCHED(tsk)
137 #ifdef CONFIG_PERF_EVENTS
138 # define INIT_PERF_EVENTS(tsk) \
139 .perf_event_mutex = \
140 __MUTEX_INITIALIZER(tsk.perf_event_mutex), \
141 .perf_event_list = LIST_HEAD_INIT(tsk.perf_event_list),
143 # define INIT_PERF_EVENTS(tsk)
146 #ifdef CONFIG_VIRT_CPU_ACCOUNTING_GEN
147 # define INIT_VTIME(tsk) \
148 .vtime_seqlock = __SEQLOCK_UNLOCKED(tsk.vtime_seqlock), \
150 .vtime_snap_whence = VTIME_SYS,
152 # define INIT_VTIME(tsk)
155 #define INIT_TASK_COMM "swapper"
158 * INIT_TASK is used to set up the first task table, touch at
159 * your own risk!. Base=0, limit=0x1fffff (=2MB)
161 #define INIT_TASK(tsk) \
164 .stack = &init_thread_info, \
165 .usage = ATOMIC_INIT(2), \
166 .flags = PF_KTHREAD, \
167 .prio = MAX_PRIO-20, \
168 .static_prio = MAX_PRIO-20, \
169 .normal_prio = MAX_PRIO-20, \
170 .policy = SCHED_NORMAL, \
171 .cpus_allowed = CPU_MASK_ALL, \
172 .nr_cpus_allowed= NR_CPUS, \
174 .active_mm = &init_mm, \
176 .group_node = LIST_HEAD_INIT(tsk.se.group_node), \
179 .run_list = LIST_HEAD_INIT(tsk.rt.run_list), \
180 .time_slice = RR_TIMESLICE, \
182 .tasks = LIST_HEAD_INIT(tsk.tasks), \
183 INIT_PUSHABLE_TASKS(tsk) \
184 INIT_CGROUP_SCHED(tsk) \
185 .ptraced = LIST_HEAD_INIT(tsk.ptraced), \
186 .ptrace_entry = LIST_HEAD_INIT(tsk.ptrace_entry), \
187 .real_parent = &tsk, \
189 .children = LIST_HEAD_INIT(tsk.children), \
190 .sibling = LIST_HEAD_INIT(tsk.sibling), \
191 .group_leader = &tsk, \
192 RCU_POINTER_INITIALIZER(real_cred, &init_cred), \
193 RCU_POINTER_INITIALIZER(cred, &init_cred), \
194 .comm = INIT_TASK_COMM, \
195 .thread = INIT_THREAD, \
197 .files = &init_files, \
198 .signal = &init_signals, \
199 .sighand = &init_sighand, \
200 .nsproxy = &init_nsproxy, \
202 .list = LIST_HEAD_INIT(tsk.pending.list), \
205 .alloc_lock = __SPIN_LOCK_UNLOCKED(tsk.alloc_lock), \
206 .journal_info = NULL, \
207 .cpu_timers = INIT_CPU_TIMERS(tsk.cpu_timers), \
208 .pi_lock = __RAW_SPIN_LOCK_UNLOCKED(tsk.pi_lock), \
209 .timer_slack_ns = 50000, /* 50 usec default slack */ \
211 [PIDTYPE_PID] = INIT_PID_LINK(PIDTYPE_PID), \
212 [PIDTYPE_PGID] = INIT_PID_LINK(PIDTYPE_PGID), \
213 [PIDTYPE_SID] = INIT_PID_LINK(PIDTYPE_SID), \
215 .thread_group = LIST_HEAD_INIT(tsk.thread_group), \
217 INIT_PERF_EVENTS(tsk) \
218 INIT_TRACE_IRQFLAGS \
221 INIT_TRACE_RECURSION \
222 INIT_TASK_RCU_PREEMPT(tsk) \
228 #define INIT_CPU_TIMERS(cpu_timers) \
230 LIST_HEAD_INIT(cpu_timers[0]), \
231 LIST_HEAD_INIT(cpu_timers[1]), \
232 LIST_HEAD_INIT(cpu_timers[2]), \
235 /* Attach to the init_task data structure for proper alignment */
236 #define __init_task_data __attribute__((__section__(".data..init_task")))