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