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>
18 #include <asm/thread_info.h>
21 # define INIT_PUSHABLE_TASKS(tsk) \
22 .pushable_tasks = PLIST_NODE_INIT(tsk.pushable_tasks, MAX_PRIO),
24 # define INIT_PUSHABLE_TASKS(tsk)
27 extern struct files_struct init_files
;
28 extern struct fs_struct init_fs
;
31 #define INIT_CPUSET_SEQ(tsk) \
32 .mems_allowed_seq = SEQCNT_ZERO(tsk.mems_allowed_seq),
34 #define INIT_CPUSET_SEQ(tsk)
37 #ifndef CONFIG_VIRT_CPU_ACCOUNTING_NATIVE
38 #define INIT_PREV_CPUTIME(x) .prev_cputime = { \
39 .lock = __RAW_SPIN_LOCK_UNLOCKED(x.prev_cputime.lock), \
42 #define INIT_PREV_CPUTIME(x)
45 #define INIT_SIGNALS(sig) { \
47 .thread_head = LIST_HEAD_INIT(init_task.thread_node), \
48 .wait_chldexit = __WAIT_QUEUE_HEAD_INITIALIZER(sig.wait_chldexit),\
50 .list = LIST_HEAD_INIT(sig.shared_pending.list), \
52 .posix_timers = LIST_HEAD_INIT(sig.posix_timers), \
53 .cpu_timers = INIT_CPU_TIMERS(sig.cpu_timers), \
54 .rlim = INIT_RLIMITS, \
56 .cputime_atomic = INIT_CPUTIME_ATOMIC, \
58 .checking_timer = false, \
60 INIT_PREV_CPUTIME(sig) \
62 __MUTEX_INITIALIZER(sig.cred_guard_mutex), \
65 extern struct nsproxy init_nsproxy
;
67 #define INIT_SIGHAND(sighand) { \
68 .count = ATOMIC_INIT(1), \
69 .action = { { { .sa_handler = SIG_DFL, } }, }, \
70 .siglock = __SPIN_LOCK_UNLOCKED(sighand.siglock), \
71 .signalfd_wqh = __WAIT_QUEUE_HEAD_INITIALIZER(sighand.signalfd_wqh), \
74 extern struct group_info init_groups
;
76 #define INIT_STRUCT_PID { \
77 .count = ATOMIC_INIT(1), \
87 .pid_chain = { .next = NULL, .pprev = NULL }, \
91 #define INIT_PID_LINK(type) \
97 .pid = &init_struct_pid, \
100 #ifdef CONFIG_AUDITSYSCALL
102 .loginuid = INVALID_UID, \
103 .sessionid = (unsigned int)-1,
108 #ifdef CONFIG_PREEMPT_RCU
109 #define INIT_TASK_RCU_TREE_PREEMPT() \
110 .rcu_blocked_node = NULL,
112 #define INIT_TASK_RCU_TREE_PREEMPT(tsk)
114 #ifdef CONFIG_PREEMPT_RCU
115 #define INIT_TASK_RCU_PREEMPT(tsk) \
116 .rcu_read_lock_nesting = 0, \
117 .rcu_read_unlock_special.s = 0, \
118 .rcu_node_entry = LIST_HEAD_INIT(tsk.rcu_node_entry), \
119 INIT_TASK_RCU_TREE_PREEMPT()
121 #define INIT_TASK_RCU_PREEMPT(tsk)
123 #ifdef CONFIG_TASKS_RCU
124 #define INIT_TASK_RCU_TASKS(tsk) \
125 .rcu_tasks_holdout = false, \
126 .rcu_tasks_holdout_list = \
127 LIST_HEAD_INIT(tsk.rcu_tasks_holdout_list), \
128 .rcu_tasks_idle_cpu = -1,
130 #define INIT_TASK_RCU_TASKS(tsk)
133 extern struct cred init_cred
;
135 extern struct task_group root_task_group
;
137 #ifdef CONFIG_CGROUP_SCHED
138 # define INIT_CGROUP_SCHED(tsk) \
139 .sched_task_group = &root_task_group,
141 # define INIT_CGROUP_SCHED(tsk)
144 #ifdef CONFIG_PERF_EVENTS
145 # define INIT_PERF_EVENTS(tsk) \
146 .perf_event_mutex = \
147 __MUTEX_INITIALIZER(tsk.perf_event_mutex), \
148 .perf_event_list = LIST_HEAD_INIT(tsk.perf_event_list),
150 # define INIT_PERF_EVENTS(tsk)
153 #ifdef CONFIG_VIRT_CPU_ACCOUNTING_GEN
154 # define INIT_VTIME(tsk) \
155 .vtime_seqcount = SEQCNT_ZERO(tsk.vtime_seqcount), \
157 .vtime_snap_whence = VTIME_SYS,
159 # define INIT_VTIME(tsk)
162 #define INIT_TASK_COMM "swapper"
164 #ifdef CONFIG_RT_MUTEXES
165 # define INIT_RT_MUTEXES(tsk) \
166 .pi_waiters = RB_ROOT, \
167 .pi_waiters_leftmost = NULL,
169 # define INIT_RT_MUTEXES(tsk)
172 #ifdef CONFIG_NUMA_BALANCING
173 # define INIT_NUMA_BALANCING(tsk) \
174 .numa_preferred_nid = -1, \
175 .numa_group = NULL, \
178 # define INIT_NUMA_BALANCING(tsk)
182 # define INIT_KASAN(tsk) \
185 # define INIT_KASAN(tsk)
188 #ifdef CONFIG_THREAD_INFO_IN_TASK
189 # define INIT_TASK_TI(tsk) \
190 .thread_info = INIT_THREAD_INFO(tsk), \
191 .stack_refcount = ATOMIC_INIT(1),
193 # define INIT_TASK_TI(tsk)
197 * INIT_TASK is used to set up the first task table, touch at
198 * your own risk!. Base=0, limit=0x1fffff (=2MB)
200 #define INIT_TASK(tsk) \
204 .stack = init_stack, \
205 .usage = ATOMIC_INIT(2), \
206 .flags = PF_KTHREAD, \
207 .prio = MAX_PRIO-20, \
208 .static_prio = MAX_PRIO-20, \
209 .normal_prio = MAX_PRIO-20, \
210 .policy = SCHED_NORMAL, \
211 .cpus_allowed = CPU_MASK_ALL, \
212 .nr_cpus_allowed= NR_CPUS, \
214 .active_mm = &init_mm, \
216 .fn = do_no_restart_syscall, \
219 .group_node = LIST_HEAD_INIT(tsk.se.group_node), \
222 .run_list = LIST_HEAD_INIT(tsk.rt.run_list), \
223 .time_slice = RR_TIMESLICE, \
225 .tasks = LIST_HEAD_INIT(tsk.tasks), \
226 INIT_PUSHABLE_TASKS(tsk) \
227 INIT_CGROUP_SCHED(tsk) \
228 .ptraced = LIST_HEAD_INIT(tsk.ptraced), \
229 .ptrace_entry = LIST_HEAD_INIT(tsk.ptrace_entry), \
230 .real_parent = &tsk, \
232 .children = LIST_HEAD_INIT(tsk.children), \
233 .sibling = LIST_HEAD_INIT(tsk.sibling), \
234 .group_leader = &tsk, \
235 RCU_POINTER_INITIALIZER(real_cred, &init_cred), \
236 RCU_POINTER_INITIALIZER(cred, &init_cred), \
237 .comm = INIT_TASK_COMM, \
238 .thread = INIT_THREAD, \
240 .files = &init_files, \
241 .signal = &init_signals, \
242 .sighand = &init_sighand, \
243 .nsproxy = &init_nsproxy, \
245 .list = LIST_HEAD_INIT(tsk.pending.list), \
248 .alloc_lock = __SPIN_LOCK_UNLOCKED(tsk.alloc_lock), \
249 .journal_info = NULL, \
250 .cpu_timers = INIT_CPU_TIMERS(tsk.cpu_timers), \
251 .pi_lock = __RAW_SPIN_LOCK_UNLOCKED(tsk.pi_lock), \
252 .timer_slack_ns = 50000, /* 50 usec default slack */ \
254 [PIDTYPE_PID] = INIT_PID_LINK(PIDTYPE_PID), \
255 [PIDTYPE_PGID] = INIT_PID_LINK(PIDTYPE_PGID), \
256 [PIDTYPE_SID] = INIT_PID_LINK(PIDTYPE_SID), \
258 .thread_group = LIST_HEAD_INIT(tsk.thread_group), \
259 .thread_node = LIST_HEAD_INIT(init_signals.thread_head), \
261 INIT_PERF_EVENTS(tsk) \
262 INIT_TRACE_IRQFLAGS \
265 INIT_TRACE_RECURSION \
266 INIT_TASK_RCU_PREEMPT(tsk) \
267 INIT_TASK_RCU_TASKS(tsk) \
268 INIT_CPUSET_SEQ(tsk) \
269 INIT_RT_MUTEXES(tsk) \
270 INIT_PREV_CPUTIME(tsk) \
272 INIT_NUMA_BALANCING(tsk) \
277 #define INIT_CPU_TIMERS(cpu_timers) \
279 LIST_HEAD_INIT(cpu_timers[0]), \
280 LIST_HEAD_INIT(cpu_timers[1]), \
281 LIST_HEAD_INIT(cpu_timers[2]), \
284 /* Attach to the init_task data structure for proper alignment */
285 #define __init_task_data __attribute__((__section__(".data..init_task")))