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