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_CPUSET_SEQ(tsk) \
30 .mems_allowed_seq = SEQCNT_ZERO(tsk.mems_allowed_seq),
32 #define INIT_CPUSET_SEQ(tsk)
35 #ifndef CONFIG_VIRT_CPU_ACCOUNTING_NATIVE
36 #define INIT_PREV_CPUTIME(x) .prev_cputime = { \
37 .lock = __RAW_SPIN_LOCK_UNLOCKED(x.prev_cputime.lock), \
40 #define INIT_PREV_CPUTIME(x)
43 #define INIT_SIGNALS(sig) { \
45 .thread_head = LIST_HEAD_INIT(init_task.thread_node), \
46 .wait_chldexit = __WAIT_QUEUE_HEAD_INITIALIZER(sig.wait_chldexit),\
48 .list = LIST_HEAD_INIT(sig.shared_pending.list), \
50 .posix_timers = LIST_HEAD_INIT(sig.posix_timers), \
51 .cpu_timers = INIT_CPU_TIMERS(sig.cpu_timers), \
52 .rlim = INIT_RLIMITS, \
54 .cputime_atomic = INIT_CPUTIME_ATOMIC, \
56 .checking_timer = false, \
58 INIT_PREV_CPUTIME(sig) \
60 __MUTEX_INITIALIZER(sig.cred_guard_mutex), \
63 extern struct nsproxy init_nsproxy;
65 #define INIT_SIGHAND(sighand) { \
66 .count = ATOMIC_INIT(1), \
67 .action = { { { .sa_handler = SIG_DFL, } }, }, \
68 .siglock = __SPIN_LOCK_UNLOCKED(sighand.siglock), \
69 .signalfd_wqh = __WAIT_QUEUE_HEAD_INITIALIZER(sighand.signalfd_wqh), \
72 extern struct group_info init_groups;
74 #define INIT_STRUCT_PID { \
75 .count = ATOMIC_INIT(1), \
85 .pid_chain = { .next = NULL, .pprev = NULL }, \
89 #define INIT_PID_LINK(type) \
95 .pid = &init_struct_pid, \
98 #ifdef CONFIG_AUDITSYSCALL
100 .loginuid = INVALID_UID, \
101 .sessionid = (unsigned int)-1,
106 #ifdef CONFIG_PREEMPT_RCU
107 #define INIT_TASK_RCU_TREE_PREEMPT() \
108 .rcu_blocked_node = NULL,
110 #define INIT_TASK_RCU_TREE_PREEMPT(tsk)
112 #ifdef CONFIG_PREEMPT_RCU
113 #define INIT_TASK_RCU_PREEMPT(tsk) \
114 .rcu_read_lock_nesting = 0, \
115 .rcu_read_unlock_special.s = 0, \
116 .rcu_node_entry = LIST_HEAD_INIT(tsk.rcu_node_entry), \
117 INIT_TASK_RCU_TREE_PREEMPT()
119 #define INIT_TASK_RCU_PREEMPT(tsk)
121 #ifdef CONFIG_TASKS_RCU
122 #define INIT_TASK_RCU_TASKS(tsk) \
123 .rcu_tasks_holdout = false, \
124 .rcu_tasks_holdout_list = \
125 LIST_HEAD_INIT(tsk.rcu_tasks_holdout_list), \
126 .rcu_tasks_idle_cpu = -1,
128 #define INIT_TASK_RCU_TASKS(tsk)
131 extern struct cred init_cred;
133 extern struct task_group root_task_group;
135 #ifdef CONFIG_CGROUP_SCHED
136 # define INIT_CGROUP_SCHED(tsk) \
137 .sched_task_group = &root_task_group,
139 # define INIT_CGROUP_SCHED(tsk)
142 #ifdef CONFIG_PERF_EVENTS
143 # define INIT_PERF_EVENTS(tsk) \
144 .perf_event_mutex = \
145 __MUTEX_INITIALIZER(tsk.perf_event_mutex), \
146 .perf_event_list = LIST_HEAD_INIT(tsk.perf_event_list),
148 # define INIT_PERF_EVENTS(tsk)
151 #ifdef CONFIG_VIRT_CPU_ACCOUNTING_GEN
152 # define INIT_VTIME(tsk) \
153 .vtime_seqlock = __SEQLOCK_UNLOCKED(tsk.vtime_seqlock), \
155 .vtime_snap_whence = VTIME_SYS,
157 # define INIT_VTIME(tsk)
160 #define INIT_TASK_COMM "swapper"
162 #ifdef CONFIG_RT_MUTEXES
163 # define INIT_RT_MUTEXES(tsk) \
164 .pi_waiters = RB_ROOT, \
165 .pi_waiters_leftmost = NULL,
167 # define INIT_RT_MUTEXES(tsk)
170 #ifdef CONFIG_NUMA_BALANCING
171 # define INIT_NUMA_BALANCING(tsk) \
172 .numa_preferred_nid = -1, \
173 .numa_group = NULL, \
176 # define INIT_NUMA_BALANCING(tsk)
180 # define INIT_KASAN(tsk) \
183 # define INIT_KASAN(tsk)
187 * INIT_TASK is used to set up the first task table, touch at
188 * your own risk!. Base=0, limit=0x1fffff (=2MB)
190 #define INIT_TASK(tsk) \
193 .stack = &init_thread_info, \
194 .usage = ATOMIC_INIT(2), \
195 .flags = PF_KTHREAD, \
196 .prio = MAX_PRIO-20, \
197 .static_prio = MAX_PRIO-20, \
198 .normal_prio = MAX_PRIO-20, \
199 .policy = SCHED_NORMAL, \
200 .cpus_allowed = CPU_MASK_ALL, \
201 .nr_cpus_allowed= NR_CPUS, \
203 .active_mm = &init_mm, \
205 .fn = do_no_restart_syscall, \
208 .group_node = LIST_HEAD_INIT(tsk.se.group_node), \
211 .run_list = LIST_HEAD_INIT(tsk.rt.run_list), \
212 .time_slice = RR_TIMESLICE, \
214 .tasks = LIST_HEAD_INIT(tsk.tasks), \
215 INIT_PUSHABLE_TASKS(tsk) \
216 INIT_CGROUP_SCHED(tsk) \
217 .ptraced = LIST_HEAD_INIT(tsk.ptraced), \
218 .ptrace_entry = LIST_HEAD_INIT(tsk.ptrace_entry), \
219 .real_parent = &tsk, \
221 .children = LIST_HEAD_INIT(tsk.children), \
222 .sibling = LIST_HEAD_INIT(tsk.sibling), \
223 .group_leader = &tsk, \
224 RCU_POINTER_INITIALIZER(real_cred, &init_cred), \
225 RCU_POINTER_INITIALIZER(cred, &init_cred), \
226 .comm = INIT_TASK_COMM, \
227 .thread = INIT_THREAD, \
229 .files = &init_files, \
230 .signal = &init_signals, \
231 .sighand = &init_sighand, \
232 .nsproxy = &init_nsproxy, \
234 .list = LIST_HEAD_INIT(tsk.pending.list), \
237 .alloc_lock = __SPIN_LOCK_UNLOCKED(tsk.alloc_lock), \
238 .journal_info = NULL, \
239 .cpu_timers = INIT_CPU_TIMERS(tsk.cpu_timers), \
240 .pi_lock = __RAW_SPIN_LOCK_UNLOCKED(tsk.pi_lock), \
241 .timer_slack_ns = 50000, /* 50 usec default slack */ \
243 [PIDTYPE_PID] = INIT_PID_LINK(PIDTYPE_PID), \
244 [PIDTYPE_PGID] = INIT_PID_LINK(PIDTYPE_PGID), \
245 [PIDTYPE_SID] = INIT_PID_LINK(PIDTYPE_SID), \
247 .thread_group = LIST_HEAD_INIT(tsk.thread_group), \
248 .thread_node = LIST_HEAD_INIT(init_signals.thread_head), \
250 INIT_PERF_EVENTS(tsk) \
251 INIT_TRACE_IRQFLAGS \
254 INIT_TRACE_RECURSION \
255 INIT_TASK_RCU_PREEMPT(tsk) \
256 INIT_TASK_RCU_TASKS(tsk) \
257 INIT_CPUSET_SEQ(tsk) \
258 INIT_RT_MUTEXES(tsk) \
259 INIT_PREV_CPUTIME(tsk) \
261 INIT_NUMA_BALANCING(tsk) \
266 #define INIT_CPU_TIMERS(cpu_timers) \
268 LIST_HEAD_INIT(cpu_timers[0]), \
269 LIST_HEAD_INIT(cpu_timers[1]), \
270 LIST_HEAD_INIT(cpu_timers[2]), \
273 /* Attach to the init_task data structure for proper alignment */
274 #define __init_task_data __attribute__((__section__(".data..init_task")))