Blame view
include/linux/init_task.h
7.47 KB
1da177e4c
|
1 2 |
#ifndef _LINUX__INIT_TASK_H #define _LINUX__INIT_TASK_H |
ab2af1f50
|
3 |
#include <linux/rcupdate.h> |
de30a2b35
|
4 |
#include <linux/irqflags.h> |
4865ecf13
|
5 |
#include <linux/utsname.h> |
fbb9ce953
|
6 |
#include <linux/lockdep.h> |
5ac9f6226
|
7 |
#include <linux/ftrace.h> |
73ea41302
|
8 |
#include <linux/ipc.h> |
9a575a92d
|
9 |
#include <linux/pid_namespace.h> |
acce292c8
|
10 |
#include <linux/user_namespace.h> |
3898b1b4e
|
11 |
#include <linux/securebits.h> |
6a61671bb
|
12 |
#include <linux/seqlock.h> |
fb00aca47
|
13 |
#include <linux/rbtree.h> |
772698f63
|
14 |
#include <net/net_namespace.h> |
77852fea6
|
15 |
#include <linux/sched/rt.h> |
1da177e4c
|
16 |
|
c65eacbe2
|
17 |
#include <asm/thread_info.h> |
806c09a7d
|
18 19 20 21 22 23 |
#ifdef CONFIG_SMP # define INIT_PUSHABLE_TASKS(tsk) \ .pushable_tasks = PLIST_NODE_INIT(tsk.pushable_tasks, MAX_PRIO), #else # define INIT_PUSHABLE_TASKS(tsk) #endif |
f52111b15
|
24 |
extern struct files_struct init_files; |
18d8fda7c
|
25 |
extern struct fs_struct init_fs; |
1da177e4c
|
26 |
|
cc9a6c877
|
27 |
#ifdef CONFIG_CPUSETS |
1ca7d67cf
|
28 29 |
#define INIT_CPUSET_SEQ(tsk) \ .mems_allowed_seq = SEQCNT_ZERO(tsk.mems_allowed_seq), |
cc9a6c877
|
30 |
#else |
1ca7d67cf
|
31 |
#define INIT_CPUSET_SEQ(tsk) |
cc9a6c877
|
32 |
#endif |
9d7fb0427
|
33 34 35 36 37 38 39 |
#ifndef CONFIG_VIRT_CPU_ACCOUNTING_NATIVE #define INIT_PREV_CPUTIME(x) .prev_cputime = { \ .lock = __RAW_SPIN_LOCK_UNLOCKED(x.prev_cputime.lock), \ }, #else #define INIT_PREV_CPUTIME(x) #endif |
1ec320afd
|
40 |
#define INIT_SIGNALS(sig) { \ |
b3ac022cb
|
41 |
.nr_threads = 1, \ |
0c740d0af
|
42 |
.thread_head = LIST_HEAD_INIT(init_task.thread_node), \ |
1da177e4c
|
43 |
.wait_chldexit = __WAIT_QUEUE_HEAD_INITIALIZER(sig.wait_chldexit),\ |
1ec320afd
|
44 |
.shared_pending = { \ |
1da177e4c
|
45 |
.list = LIST_HEAD_INIT(sig.shared_pending.list), \ |
1ec320afd
|
46 |
.signal = {{0}}}, \ |
1da177e4c
|
47 48 49 |
.posix_timers = LIST_HEAD_INIT(sig.posix_timers), \ .cpu_timers = INIT_CPU_TIMERS(sig.cpu_timers), \ .rlim = INIT_RLIMITS, \ |
4cd4c1b40
|
50 |
.cputimer = { \ |
711074451
|
51 |
.cputime_atomic = INIT_CPUTIME_ATOMIC, \ |
d5c373eb5
|
52 |
.running = false, \ |
c8d75aa47
|
53 |
.checking_timer = false, \ |
4cd4c1b40
|
54 |
}, \ |
9d7fb0427
|
55 |
INIT_PREV_CPUTIME(sig) \ |
9b1bf12d5
|
56 57 |
.cred_guard_mutex = \ __MUTEX_INITIALIZER(sig.cred_guard_mutex), \ |
1da177e4c
|
58 |
} |
ab516013a
|
59 |
extern struct nsproxy init_nsproxy; |
ab516013a
|
60 |
|
1da177e4c
|
61 62 |
#define INIT_SIGHAND(sighand) { \ .count = ATOMIC_INIT(1), \ |
0a14a130c
|
63 |
.action = { { { .sa_handler = SIG_DFL, } }, }, \ |
e4d919188
|
64 |
.siglock = __SPIN_LOCK_UNLOCKED(sighand.siglock), \ |
b8fceee17
|
65 |
.signalfd_wqh = __WAIT_QUEUE_HEAD_INITIALIZER(sighand.signalfd_wqh), \ |
1da177e4c
|
66 67 68 |
} extern struct group_info init_groups; |
820e45db2
|
69 70 |
#define INIT_STRUCT_PID { \ .count = ATOMIC_INIT(1), \ |
820e45db2
|
71 |
.tasks = { \ |
f20011457
|
72 73 74 |
{ .first = NULL }, \ { .first = NULL }, \ { .first = NULL }, \ |
820e45db2
|
75 |
}, \ |
4c3f2ead5
|
76 77 78 79 80 81 |
.level = 0, \ .numbers = { { \ .nr = 0, \ .ns = &init_pid_ns, \ .pid_chain = { .next = NULL, .pprev = NULL }, \ }, } \ |
820e45db2
|
82 83 84 85 86 87 |
} #define INIT_PID_LINK(type) \ { \ .node = { \ .next = NULL, \ |
f20011457
|
88 |
.pprev = NULL, \ |
820e45db2
|
89 90 91 |
}, \ .pid = &init_struct_pid, \ } |
bfef93a5d
|
92 93 |
#ifdef CONFIG_AUDITSYSCALL #define INIT_IDS \ |
e1760bd5f
|
94 |
.loginuid = INVALID_UID, \ |
4440e8548
|
95 |
.sessionid = (unsigned int)-1, |
bfef93a5d
|
96 97 98 |
#else #define INIT_IDS #endif |
3b7391de6
|
99 |
|
28f6569ab
|
100 |
#ifdef CONFIG_PREEMPT_RCU |
a57eb940d
|
101 102 103 104 105 106 |
#define INIT_TASK_RCU_TREE_PREEMPT() \ .rcu_blocked_node = NULL, #else #define INIT_TASK_RCU_TREE_PREEMPT(tsk) #endif #ifdef CONFIG_PREEMPT_RCU |
f41d911f8
|
107 108 |
#define INIT_TASK_RCU_PREEMPT(tsk) \ .rcu_read_lock_nesting = 0, \ |
1d082fd06
|
109 |
.rcu_read_unlock_special.s = 0, \ |
a57eb940d
|
110 |
.rcu_node_entry = LIST_HEAD_INIT(tsk.rcu_node_entry), \ |
abaa93d9e
|
111 |
INIT_TASK_RCU_TREE_PREEMPT() |
f41d911f8
|
112 113 114 |
#else #define INIT_TASK_RCU_PREEMPT(tsk) #endif |
8315f4229
|
115 116 117 118 |
#ifdef CONFIG_TASKS_RCU #define INIT_TASK_RCU_TASKS(tsk) \ .rcu_tasks_holdout = false, \ .rcu_tasks_holdout_list = \ |
176f8f7a5
|
119 120 |
LIST_HEAD_INIT(tsk.rcu_tasks_holdout_list), \ .rcu_tasks_idle_cpu = -1, |
8315f4229
|
121 122 123 |
#else #define INIT_TASK_RCU_TASKS(tsk) #endif |
f41d911f8
|
124 |
|
b6dff3ec5
|
125 |
extern struct cred init_cred; |
8323f26ce
|
126 127 128 129 130 131 132 133 |
extern struct task_group root_task_group; #ifdef CONFIG_CGROUP_SCHED # define INIT_CGROUP_SCHED(tsk) \ .sched_task_group = &root_task_group, #else # define INIT_CGROUP_SCHED(tsk) #endif |
cdd6c482c
|
134 |
#ifdef CONFIG_PERF_EVENTS |
8323f26ce
|
135 |
# define INIT_PERF_EVENTS(tsk) \ |
cdd6c482c
|
136 137 138 |
.perf_event_mutex = \ __MUTEX_INITIALIZER(tsk.perf_event_mutex), \ .perf_event_list = LIST_HEAD_INIT(tsk.perf_event_list), |
082ff5a27
|
139 |
#else |
cdd6c482c
|
140 |
# define INIT_PERF_EVENTS(tsk) |
082ff5a27
|
141 |
#endif |
6a61671bb
|
142 143 |
#ifdef CONFIG_VIRT_CPU_ACCOUNTING_GEN # define INIT_VTIME(tsk) \ |
b7ce2277f
|
144 |
.vtime_seqcount = SEQCNT_ZERO(tsk.vtime_seqcount), \ |
6a61671bb
|
145 146 147 148 149 |
.vtime_snap = 0, \ .vtime_snap_whence = VTIME_SYS, #else # define INIT_VTIME(tsk) #endif |
f1c6f1a7e
|
150 |
#define INIT_TASK_COMM "swapper" |
fb00aca47
|
151 152 153 154 155 156 157 |
#ifdef CONFIG_RT_MUTEXES # define INIT_RT_MUTEXES(tsk) \ .pi_waiters = RB_ROOT, \ .pi_waiters_leftmost = NULL, #else # define INIT_RT_MUTEXES(tsk) #endif |
d8b163c4c
|
158 159 160 161 162 163 164 165 |
#ifdef CONFIG_NUMA_BALANCING # define INIT_NUMA_BALANCING(tsk) \ .numa_preferred_nid = -1, \ .numa_group = NULL, \ .numa_faults = NULL, #else # define INIT_NUMA_BALANCING(tsk) #endif |
c420f167d
|
166 167 168 169 170 171 |
#ifdef CONFIG_KASAN # define INIT_KASAN(tsk) \ .kasan_depth = 1, #else # define INIT_KASAN(tsk) #endif |
c65eacbe2
|
172 |
#ifdef CONFIG_THREAD_INFO_IN_TASK |
68f24b08e
|
173 174 175 |
# define INIT_TASK_TI(tsk) \ .thread_info = INIT_THREAD_INFO(tsk), \ .stack_refcount = ATOMIC_INIT(1), |
c65eacbe2
|
176 177 178 |
#else # define INIT_TASK_TI(tsk) #endif |
1da177e4c
|
179 180 181 182 183 184 |
/* * INIT_TASK is used to set up the first task table, touch at * your own risk!. Base=0, limit=0x1fffff (=2MB) */ #define INIT_TASK(tsk) \ { \ |
c65eacbe2
|
185 |
INIT_TASK_TI(tsk) \ |
1da177e4c
|
186 |
.state = 0, \ |
7f1a00b6f
|
187 |
.stack = init_stack, \ |
1da177e4c
|
188 |
.usage = ATOMIC_INIT(2), \ |
7b34e4283
|
189 |
.flags = PF_KTHREAD, \ |
1da177e4c
|
190 191 |
.prio = MAX_PRIO-20, \ .static_prio = MAX_PRIO-20, \ |
b29739f90
|
192 |
.normal_prio = MAX_PRIO-20, \ |
1da177e4c
|
193 194 |
.policy = SCHED_NORMAL, \ .cpus_allowed = CPU_MASK_ALL, \ |
29baa7478
|
195 |
.nr_cpus_allowed= NR_CPUS, \ |
1da177e4c
|
196 197 |
.mm = NULL, \ .active_mm = &init_mm, \ |
f56141e3e
|
198 199 200 |
.restart_block = { \ .fn = do_no_restart_syscall, \ }, \ |
4a55bd5e9
|
201 202 203 |
.se = { \ .group_node = LIST_HEAD_INIT(tsk.se.group_node), \ }, \ |
fa717060f
|
204 205 |
.rt = { \ .run_list = LIST_HEAD_INIT(tsk.rt.run_list), \ |
de5bdff7a
|
206 |
.time_slice = RR_TIMESLICE, \ |
6f505b164
|
207 |
}, \ |
1da177e4c
|
208 |
.tasks = LIST_HEAD_INIT(tsk.tasks), \ |
806c09a7d
|
209 |
INIT_PUSHABLE_TASKS(tsk) \ |
8323f26ce
|
210 |
INIT_CGROUP_SCHED(tsk) \ |
f470021ad
|
211 212 |
.ptraced = LIST_HEAD_INIT(tsk.ptraced), \ .ptrace_entry = LIST_HEAD_INIT(tsk.ptrace_entry), \ |
1da177e4c
|
213 214 215 216 217 |
.real_parent = &tsk, \ .parent = &tsk, \ .children = LIST_HEAD_INIT(tsk.children), \ .sibling = LIST_HEAD_INIT(tsk.sibling), \ .group_leader = &tsk, \ |
d36cc701b
|
218 219 |
RCU_POINTER_INITIALIZER(real_cred, &init_cred), \ RCU_POINTER_INITIALIZER(cred, &init_cred), \ |
f1c6f1a7e
|
220 |
.comm = INIT_TASK_COMM, \ |
1da177e4c
|
221 222 223 224 225 |
.thread = INIT_THREAD, \ .fs = &init_fs, \ .files = &init_files, \ .signal = &init_signals, \ .sighand = &init_sighand, \ |
ab516013a
|
226 |
.nsproxy = &init_nsproxy, \ |
1da177e4c
|
227 228 229 230 |
.pending = { \ .list = LIST_HEAD_INIT(tsk.pending.list), \ .signal = {{0}}}, \ .blocked = {{0}}, \ |
e4d919188
|
231 |
.alloc_lock = __SPIN_LOCK_UNLOCKED(tsk.alloc_lock), \ |
b6e3224fb
|
232 |
.journal_info = NULL, \ |
1da177e4c
|
233 |
.cpu_timers = INIT_CPU_TIMERS(tsk.cpu_timers), \ |
1d6154825
|
234 |
.pi_lock = __RAW_SPIN_LOCK_UNLOCKED(tsk.pi_lock), \ |
6976675d9
|
235 |
.timer_slack_ns = 50000, /* 50 usec default slack */ \ |
820e45db2
|
236 237 238 239 240 |
.pids = { \ [PIDTYPE_PID] = INIT_PID_LINK(PIDTYPE_PID), \ [PIDTYPE_PGID] = INIT_PID_LINK(PIDTYPE_PGID), \ [PIDTYPE_SID] = INIT_PID_LINK(PIDTYPE_SID), \ }, \ |
fa2755e20
|
241 |
.thread_group = LIST_HEAD_INIT(tsk.thread_group), \ |
0c740d0af
|
242 |
.thread_node = LIST_HEAD_INIT(init_signals.thread_head), \ |
bfef93a5d
|
243 |
INIT_IDS \ |
cdd6c482c
|
244 |
INIT_PERF_EVENTS(tsk) \ |
de30a2b35
|
245 |
INIT_TRACE_IRQFLAGS \ |
fbb9ce953
|
246 |
INIT_LOCKDEP \ |
5ac9f6226
|
247 |
INIT_FTRACE_GRAPH \ |
261842b7c
|
248 |
INIT_TRACE_RECURSION \ |
f41d911f8
|
249 |
INIT_TASK_RCU_PREEMPT(tsk) \ |
8315f4229
|
250 |
INIT_TASK_RCU_TASKS(tsk) \ |
1ca7d67cf
|
251 |
INIT_CPUSET_SEQ(tsk) \ |
fb00aca47
|
252 |
INIT_RT_MUTEXES(tsk) \ |
9d7fb0427
|
253 |
INIT_PREV_CPUTIME(tsk) \ |
6a61671bb
|
254 |
INIT_VTIME(tsk) \ |
d8b163c4c
|
255 |
INIT_NUMA_BALANCING(tsk) \ |
c420f167d
|
256 |
INIT_KASAN(tsk) \ |
1da177e4c
|
257 258 259 260 261 262 263 264 265 |
} #define INIT_CPU_TIMERS(cpu_timers) \ { \ LIST_HEAD_INIT(cpu_timers[0]), \ LIST_HEAD_INIT(cpu_timers[1]), \ LIST_HEAD_INIT(cpu_timers[2]), \ } |
857eceebd
|
266 |
/* Attach to the init_task data structure for proper alignment */ |
2af7687f1
|
267 |
#define __init_task_data __attribute__((__section__(".data..init_task"))) |
857eceebd
|
268 |
|
1da177e4c
|
269 270 |
#endif |