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