Merge branch 'misc' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild
[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_CGROUPS
29 #define INIT_GROUP_RWSEM(sig)                                           \
30         .group_rwsem = __RWSEM_INITIALIZER(sig.group_rwsem),
31 #else
32 #define INIT_GROUP_RWSEM(sig)
33 #endif
34
35 #ifdef CONFIG_CPUSETS
36 #define INIT_CPUSET_SEQ(tsk)                                                    \
37         .mems_allowed_seq = SEQCNT_ZERO(tsk.mems_allowed_seq),
38 #else
39 #define INIT_CPUSET_SEQ(tsk)
40 #endif
41
42 #define INIT_SIGNALS(sig) {                                             \
43         .nr_threads     = 1,                                            \
44         .thread_head    = LIST_HEAD_INIT(init_task.thread_node),        \
45         .wait_chldexit  = __WAIT_QUEUE_HEAD_INITIALIZER(sig.wait_chldexit),\
46         .shared_pending = {                                             \
47                 .list = LIST_HEAD_INIT(sig.shared_pending.list),        \
48                 .signal =  {{0}}},                                      \
49         .posix_timers    = LIST_HEAD_INIT(sig.posix_timers),            \
50         .cpu_timers     = INIT_CPU_TIMERS(sig.cpu_timers),              \
51         .rlim           = INIT_RLIMITS,                                 \
52         .cputimer       = {                                             \
53                 .cputime = INIT_CPUTIME,                                \
54                 .running = 0,                                           \
55                 .lock = __RAW_SPIN_LOCK_UNLOCKED(sig.cputimer.lock),    \
56         },                                                              \
57         .cred_guard_mutex =                                             \
58                  __MUTEX_INITIALIZER(sig.cred_guard_mutex),             \
59         INIT_GROUP_RWSEM(sig)                                           \
60 }
61
62 extern struct nsproxy init_nsproxy;
63
64 #define INIT_SIGHAND(sighand) {                                         \
65         .count          = ATOMIC_INIT(1),                               \
66         .action         = { { { .sa_handler = SIG_DFL, } }, },          \
67         .siglock        = __SPIN_LOCK_UNLOCKED(sighand.siglock),        \
68         .signalfd_wqh   = __WAIT_QUEUE_HEAD_INITIALIZER(sighand.signalfd_wqh),  \
69 }
70
71 extern struct group_info init_groups;
72
73 #define INIT_STRUCT_PID {                                               \
74         .count          = ATOMIC_INIT(1),                               \
75         .tasks          = {                                             \
76                 { .first = NULL },                                      \
77                 { .first = NULL },                                      \
78                 { .first = NULL },                                      \
79         },                                                              \
80         .level          = 0,                                            \
81         .numbers        = { {                                           \
82                 .nr             = 0,                                    \
83                 .ns             = &init_pid_ns,                         \
84                 .pid_chain      = { .next = NULL, .pprev = NULL },      \
85         }, }                                                            \
86 }
87
88 #define INIT_PID_LINK(type)                                     \
89 {                                                               \
90         .node = {                                               \
91                 .next = NULL,                                   \
92                 .pprev = NULL,                                  \
93         },                                                      \
94         .pid = &init_struct_pid,                                \
95 }
96
97 #ifdef CONFIG_AUDITSYSCALL
98 #define INIT_IDS \
99         .loginuid = INVALID_UID, \
100         .sessionid = (unsigned int)-1,
101 #else
102 #define INIT_IDS
103 #endif
104
105 #ifdef CONFIG_RCU_BOOST
106 #define INIT_TASK_RCU_BOOST()                                           \
107         .rcu_boost_mutex = NULL,
108 #else
109 #define INIT_TASK_RCU_BOOST()
110 #endif
111 #ifdef CONFIG_TREE_PREEMPT_RCU
112 #define INIT_TASK_RCU_TREE_PREEMPT()                                    \
113         .rcu_blocked_node = NULL,
114 #else
115 #define INIT_TASK_RCU_TREE_PREEMPT(tsk)
116 #endif
117 #ifdef CONFIG_PREEMPT_RCU
118 #define INIT_TASK_RCU_PREEMPT(tsk)                                      \
119         .rcu_read_lock_nesting = 0,                                     \
120         .rcu_read_unlock_special = 0,                                   \
121         .rcu_node_entry = LIST_HEAD_INIT(tsk.rcu_node_entry),           \
122         INIT_TASK_RCU_TREE_PREEMPT()                                    \
123         INIT_TASK_RCU_BOOST()
124 #else
125 #define INIT_TASK_RCU_PREEMPT(tsk)
126 #endif
127
128 extern struct cred init_cred;
129
130 extern struct task_group root_task_group;
131
132 #ifdef CONFIG_CGROUP_SCHED
133 # define INIT_CGROUP_SCHED(tsk)                                         \
134         .sched_task_group = &root_task_group,
135 #else
136 # define INIT_CGROUP_SCHED(tsk)
137 #endif
138
139 #ifdef CONFIG_PERF_EVENTS
140 # define INIT_PERF_EVENTS(tsk)                                          \
141         .perf_event_mutex =                                             \
142                  __MUTEX_INITIALIZER(tsk.perf_event_mutex),             \
143         .perf_event_list = LIST_HEAD_INIT(tsk.perf_event_list),
144 #else
145 # define INIT_PERF_EVENTS(tsk)
146 #endif
147
148 #ifdef CONFIG_VIRT_CPU_ACCOUNTING_GEN
149 # define INIT_VTIME(tsk)                                                \
150         .vtime_seqlock = __SEQLOCK_UNLOCKED(tsk.vtime_seqlock), \
151         .vtime_snap = 0,                                \
152         .vtime_snap_whence = VTIME_SYS,
153 #else
154 # define INIT_VTIME(tsk)
155 #endif
156
157 #define INIT_TASK_COMM "swapper"
158
159 #ifdef CONFIG_RT_MUTEXES
160 # define INIT_RT_MUTEXES(tsk)                                           \
161         .pi_waiters = RB_ROOT,                                          \
162         .pi_waiters_leftmost = NULL,
163 #else
164 # define INIT_RT_MUTEXES(tsk)
165 #endif
166
167 /*
168  *  INIT_TASK is used to set up the first task table, touch at
169  * your own risk!. Base=0, limit=0x1fffff (=2MB)
170  */
171 #define INIT_TASK(tsk)  \
172 {                                                                       \
173         .state          = 0,                                            \
174         .stack          = &init_thread_info,                            \
175         .usage          = ATOMIC_INIT(2),                               \
176         .flags          = PF_KTHREAD,                                   \
177         .prio           = MAX_PRIO-20,                                  \
178         .static_prio    = MAX_PRIO-20,                                  \
179         .normal_prio    = MAX_PRIO-20,                                  \
180         .policy         = SCHED_NORMAL,                                 \
181         .cpus_allowed   = CPU_MASK_ALL,                                 \
182         .nr_cpus_allowed= NR_CPUS,                                      \
183         .mm             = NULL,                                         \
184         .active_mm      = &init_mm,                                     \
185         .se             = {                                             \
186                 .group_node     = LIST_HEAD_INIT(tsk.se.group_node),    \
187         },                                                              \
188         .rt             = {                                             \
189                 .run_list       = LIST_HEAD_INIT(tsk.rt.run_list),      \
190                 .time_slice     = RR_TIMESLICE,                         \
191         },                                                              \
192         .tasks          = LIST_HEAD_INIT(tsk.tasks),                    \
193         INIT_PUSHABLE_TASKS(tsk)                                        \
194         INIT_CGROUP_SCHED(tsk)                                          \
195         .ptraced        = LIST_HEAD_INIT(tsk.ptraced),                  \
196         .ptrace_entry   = LIST_HEAD_INIT(tsk.ptrace_entry),             \
197         .real_parent    = &tsk,                                         \
198         .parent         = &tsk,                                         \
199         .children       = LIST_HEAD_INIT(tsk.children),                 \
200         .sibling        = LIST_HEAD_INIT(tsk.sibling),                  \
201         .group_leader   = &tsk,                                         \
202         RCU_POINTER_INITIALIZER(real_cred, &init_cred),                 \
203         RCU_POINTER_INITIALIZER(cred, &init_cred),                      \
204         .comm           = INIT_TASK_COMM,                               \
205         .thread         = INIT_THREAD,                                  \
206         .fs             = &init_fs,                                     \
207         .files          = &init_files,                                  \
208         .signal         = &init_signals,                                \
209         .sighand        = &init_sighand,                                \
210         .nsproxy        = &init_nsproxy,                                \
211         .pending        = {                                             \
212                 .list = LIST_HEAD_INIT(tsk.pending.list),               \
213                 .signal = {{0}}},                                       \
214         .blocked        = {{0}},                                        \
215         .alloc_lock     = __SPIN_LOCK_UNLOCKED(tsk.alloc_lock),         \
216         .journal_info   = NULL,                                         \
217         .cpu_timers     = INIT_CPU_TIMERS(tsk.cpu_timers),              \
218         .pi_lock        = __RAW_SPIN_LOCK_UNLOCKED(tsk.pi_lock),        \
219         .timer_slack_ns = 50000, /* 50 usec default slack */            \
220         .pids = {                                                       \
221                 [PIDTYPE_PID]  = INIT_PID_LINK(PIDTYPE_PID),            \
222                 [PIDTYPE_PGID] = INIT_PID_LINK(PIDTYPE_PGID),           \
223                 [PIDTYPE_SID]  = INIT_PID_LINK(PIDTYPE_SID),            \
224         },                                                              \
225         .thread_group   = LIST_HEAD_INIT(tsk.thread_group),             \
226         .thread_node    = LIST_HEAD_INIT(init_signals.thread_head),     \
227         INIT_IDS                                                        \
228         INIT_PERF_EVENTS(tsk)                                           \
229         INIT_TRACE_IRQFLAGS                                             \
230         INIT_LOCKDEP                                                    \
231         INIT_FTRACE_GRAPH                                               \
232         INIT_TRACE_RECURSION                                            \
233         INIT_TASK_RCU_PREEMPT(tsk)                                      \
234         INIT_CPUSET_SEQ(tsk)                                            \
235         INIT_RT_MUTEXES(tsk)                                            \
236         INIT_VTIME(tsk)                                                 \
237 }
238
239
240 #define INIT_CPU_TIMERS(cpu_timers)                                     \
241 {                                                                       \
242         LIST_HEAD_INIT(cpu_timers[0]),                                  \
243         LIST_HEAD_INIT(cpu_timers[1]),                                  \
244         LIST_HEAD_INIT(cpu_timers[2]),                                  \
245 }
246
247 /* Attach to the init_task data structure for proper alignment */
248 #define __init_task_data __attribute__((__section__(".data..init_task")))
249
250
251 #endif