Merge tag 'fbdev-4.4' of git://git.kernel.org/pub/scm/linux/kernel/git/tomba/linux
[firefly-linux-kernel-4.4.55.git] / include / linux / init_task.h
1 #ifndef _LINUX__INIT_TASK_H
2 #define _LINUX__INIT_TASK_H
3
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>
9 #include <linux/ipc.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>
17
18 #ifdef CONFIG_SMP
19 # define INIT_PUSHABLE_TASKS(tsk)                                       \
20         .pushable_tasks = PLIST_NODE_INIT(tsk.pushable_tasks, MAX_PRIO),
21 #else
22 # define INIT_PUSHABLE_TASKS(tsk)
23 #endif
24
25 extern struct files_struct init_files;
26 extern struct fs_struct init_fs;
27
28 #ifdef CONFIG_CPUSETS
29 #define INIT_CPUSET_SEQ(tsk)                                                    \
30         .mems_allowed_seq = SEQCNT_ZERO(tsk.mems_allowed_seq),
31 #else
32 #define INIT_CPUSET_SEQ(tsk)
33 #endif
34
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),          \
38 },
39 #else
40 #define INIT_PREV_CPUTIME(x)
41 #endif
42
43 #define INIT_SIGNALS(sig) {                                             \
44         .nr_threads     = 1,                                            \
45         .thread_head    = LIST_HEAD_INIT(init_task.thread_node),        \
46         .wait_chldexit  = __WAIT_QUEUE_HEAD_INITIALIZER(sig.wait_chldexit),\
47         .shared_pending = {                                             \
48                 .list = LIST_HEAD_INIT(sig.shared_pending.list),        \
49                 .signal =  {{0}}},                                      \
50         .posix_timers    = LIST_HEAD_INIT(sig.posix_timers),            \
51         .cpu_timers     = INIT_CPU_TIMERS(sig.cpu_timers),              \
52         .rlim           = INIT_RLIMITS,                                 \
53         .cputimer       = {                                             \
54                 .cputime_atomic = INIT_CPUTIME_ATOMIC,                  \
55                 .running        = false,                                \
56                 .checking_timer = false,                                \
57         },                                                              \
58         INIT_PREV_CPUTIME(sig)                                          \
59         .cred_guard_mutex =                                             \
60                  __MUTEX_INITIALIZER(sig.cred_guard_mutex),             \
61 }
62
63 extern struct nsproxy init_nsproxy;
64
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),  \
70 }
71
72 extern struct group_info init_groups;
73
74 #define INIT_STRUCT_PID {                                               \
75         .count          = ATOMIC_INIT(1),                               \
76         .tasks          = {                                             \
77                 { .first = NULL },                                      \
78                 { .first = NULL },                                      \
79                 { .first = NULL },                                      \
80         },                                                              \
81         .level          = 0,                                            \
82         .numbers        = { {                                           \
83                 .nr             = 0,                                    \
84                 .ns             = &init_pid_ns,                         \
85                 .pid_chain      = { .next = NULL, .pprev = NULL },      \
86         }, }                                                            \
87 }
88
89 #define INIT_PID_LINK(type)                                     \
90 {                                                               \
91         .node = {                                               \
92                 .next = NULL,                                   \
93                 .pprev = NULL,                                  \
94         },                                                      \
95         .pid = &init_struct_pid,                                \
96 }
97
98 #ifdef CONFIG_AUDITSYSCALL
99 #define INIT_IDS \
100         .loginuid = INVALID_UID, \
101         .sessionid = (unsigned int)-1,
102 #else
103 #define INIT_IDS
104 #endif
105
106 #ifdef CONFIG_PREEMPT_RCU
107 #define INIT_TASK_RCU_TREE_PREEMPT()                                    \
108         .rcu_blocked_node = NULL,
109 #else
110 #define INIT_TASK_RCU_TREE_PREEMPT(tsk)
111 #endif
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()
118 #else
119 #define INIT_TASK_RCU_PREEMPT(tsk)
120 #endif
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,
127 #else
128 #define INIT_TASK_RCU_TASKS(tsk)
129 #endif
130
131 extern struct cred init_cred;
132
133 extern struct task_group root_task_group;
134
135 #ifdef CONFIG_CGROUP_SCHED
136 # define INIT_CGROUP_SCHED(tsk)                                         \
137         .sched_task_group = &root_task_group,
138 #else
139 # define INIT_CGROUP_SCHED(tsk)
140 #endif
141
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),
147 #else
148 # define INIT_PERF_EVENTS(tsk)
149 #endif
150
151 #ifdef CONFIG_VIRT_CPU_ACCOUNTING_GEN
152 # define INIT_VTIME(tsk)                                                \
153         .vtime_seqlock = __SEQLOCK_UNLOCKED(tsk.vtime_seqlock), \
154         .vtime_snap = 0,                                \
155         .vtime_snap_whence = VTIME_SYS,
156 #else
157 # define INIT_VTIME(tsk)
158 #endif
159
160 #define INIT_TASK_COMM "swapper"
161
162 #ifdef CONFIG_RT_MUTEXES
163 # define INIT_RT_MUTEXES(tsk)                                           \
164         .pi_waiters = RB_ROOT,                                          \
165         .pi_waiters_leftmost = NULL,
166 #else
167 # define INIT_RT_MUTEXES(tsk)
168 #endif
169
170 #ifdef CONFIG_NUMA_BALANCING
171 # define INIT_NUMA_BALANCING(tsk)                                       \
172         .numa_preferred_nid = -1,                                       \
173         .numa_group = NULL,                                             \
174         .numa_faults = NULL,
175 #else
176 # define INIT_NUMA_BALANCING(tsk)
177 #endif
178
179 #ifdef CONFIG_KASAN
180 # define INIT_KASAN(tsk)                                                \
181         .kasan_depth = 1,
182 #else
183 # define INIT_KASAN(tsk)
184 #endif
185
186 /*
187  *  INIT_TASK is used to set up the first task table, touch at
188  * your own risk!. Base=0, limit=0x1fffff (=2MB)
189  */
190 #define INIT_TASK(tsk)  \
191 {                                                                       \
192         .state          = 0,                                            \
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,                                      \
202         .mm             = NULL,                                         \
203         .active_mm      = &init_mm,                                     \
204         .restart_block = {                                              \
205                 .fn = do_no_restart_syscall,                            \
206         },                                                              \
207         .se             = {                                             \
208                 .group_node     = LIST_HEAD_INIT(tsk.se.group_node),    \
209         },                                                              \
210         .rt             = {                                             \
211                 .run_list       = LIST_HEAD_INIT(tsk.rt.run_list),      \
212                 .time_slice     = RR_TIMESLICE,                         \
213         },                                                              \
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,                                         \
220         .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,                                  \
228         .fs             = &init_fs,                                     \
229         .files          = &init_files,                                  \
230         .signal         = &init_signals,                                \
231         .sighand        = &init_sighand,                                \
232         .nsproxy        = &init_nsproxy,                                \
233         .pending        = {                                             \
234                 .list = LIST_HEAD_INIT(tsk.pending.list),               \
235                 .signal = {{0}}},                                       \
236         .blocked        = {{0}},                                        \
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 */            \
242         .pids = {                                                       \
243                 [PIDTYPE_PID]  = INIT_PID_LINK(PIDTYPE_PID),            \
244                 [PIDTYPE_PGID] = INIT_PID_LINK(PIDTYPE_PGID),           \
245                 [PIDTYPE_SID]  = INIT_PID_LINK(PIDTYPE_SID),            \
246         },                                                              \
247         .thread_group   = LIST_HEAD_INIT(tsk.thread_group),             \
248         .thread_node    = LIST_HEAD_INIT(init_signals.thread_head),     \
249         INIT_IDS                                                        \
250         INIT_PERF_EVENTS(tsk)                                           \
251         INIT_TRACE_IRQFLAGS                                             \
252         INIT_LOCKDEP                                                    \
253         INIT_FTRACE_GRAPH                                               \
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)                                          \
260         INIT_VTIME(tsk)                                                 \
261         INIT_NUMA_BALANCING(tsk)                                        \
262         INIT_KASAN(tsk)                                                 \
263 }
264
265
266 #define INIT_CPU_TIMERS(cpu_timers)                                     \
267 {                                                                       \
268         LIST_HEAD_INIT(cpu_timers[0]),                                  \
269         LIST_HEAD_INIT(cpu_timers[1]),                                  \
270         LIST_HEAD_INIT(cpu_timers[2]),                                  \
271 }
272
273 /* Attach to the init_task data structure for proper alignment */
274 #define __init_task_data __attribute__((__section__(".data..init_task")))
275
276
277 #endif