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