]> bbs.cooldavid.org Git - net-next-2.6.git/blame - include/linux/init_task.h
proc: turn signal_struct->count into "int nr_threads"
[net-next-2.6.git] / include / linux / init_task.h
CommitLineData
1da177e4
LT
1#ifndef _LINUX__INIT_TASK_H
2#define _LINUX__INIT_TASK_H
3
ab2af1f5 4#include <linux/rcupdate.h>
de30a2b3 5#include <linux/irqflags.h>
4865ecf1 6#include <linux/utsname.h>
fbb9ce95 7#include <linux/lockdep.h>
5ac9f622 8#include <linux/ftrace.h>
73ea4130 9#include <linux/ipc.h>
9a575a92 10#include <linux/pid_namespace.h>
acce292c 11#include <linux/user_namespace.h>
3898b1b4 12#include <linux/securebits.h>
772698f6 13#include <net/net_namespace.h>
1da177e4 14
f52111b1 15extern struct files_struct init_files;
18d8fda7 16extern struct fs_struct init_fs;
1da177e4 17
1ec320af 18#define INIT_SIGNALS(sig) { \
b3ac022c 19 .nr_threads = 1, \
1da177e4 20 .wait_chldexit = __WAIT_QUEUE_HEAD_INITIALIZER(sig.wait_chldexit),\
1ec320af 21 .shared_pending = { \
1da177e4 22 .list = LIST_HEAD_INIT(sig.shared_pending.list), \
1ec320af 23 .signal = {{0}}}, \
1da177e4
LT
24 .posix_timers = LIST_HEAD_INIT(sig.posix_timers), \
25 .cpu_timers = INIT_CPU_TIMERS(sig.cpu_timers), \
26 .rlim = INIT_RLIMITS, \
4cd4c1b4
PZ
27 .cputimer = { \
28 .cputime = INIT_CPUTIME, \
29 .running = 0, \
30 .lock = __SPIN_LOCK_UNLOCKED(sig.cputimer.lock), \
31 }, \
1da177e4
LT
32}
33
ab516013 34extern struct nsproxy init_nsproxy;
ab516013 35
1da177e4
LT
36#define INIT_SIGHAND(sighand) { \
37 .count = ATOMIC_INIT(1), \
38 .action = { { { .sa_handler = NULL, } }, }, \
e4d91918 39 .siglock = __SPIN_LOCK_UNLOCKED(sighand.siglock), \
b8fceee1 40 .signalfd_wqh = __WAIT_QUEUE_HEAD_INITIALIZER(sighand.signalfd_wqh), \
1da177e4
LT
41}
42
43extern struct group_info init_groups;
44
820e45db
SB
45#define INIT_STRUCT_PID { \
46 .count = ATOMIC_INIT(1), \
820e45db
SB
47 .tasks = { \
48 { .first = &init_task.pids[PIDTYPE_PID].node }, \
49 { .first = &init_task.pids[PIDTYPE_PGID].node }, \
50 { .first = &init_task.pids[PIDTYPE_SID].node }, \
51 }, \
4c3f2ead
SB
52 .level = 0, \
53 .numbers = { { \
54 .nr = 0, \
55 .ns = &init_pid_ns, \
56 .pid_chain = { .next = NULL, .pprev = NULL }, \
57 }, } \
820e45db
SB
58}
59
60#define INIT_PID_LINK(type) \
61{ \
62 .node = { \
63 .next = NULL, \
64 .pprev = &init_struct_pid.tasks[type].first, \
65 }, \
66 .pid = &init_struct_pid, \
67}
68
bfef93a5
AV
69#ifdef CONFIG_AUDITSYSCALL
70#define INIT_IDS \
4746ec5b
EP
71 .loginuid = -1, \
72 .sessionid = -1,
bfef93a5
AV
73#else
74#define INIT_IDS
75#endif
3b7391de 76
3b7391de
SH
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
3b7391de 83
6b3ef48a 84#ifdef CONFIG_TREE_PREEMPT_RCU
f41d911f
PM
85#define INIT_TASK_RCU_PREEMPT(tsk) \
86 .rcu_read_lock_nesting = 0, \
87 .rcu_read_unlock_special = 0, \
dd5d19ba 88 .rcu_blocked_node = NULL, \
f41d911f
PM
89 .rcu_node_entry = LIST_HEAD_INIT(tsk.rcu_node_entry),
90#else
91#define INIT_TASK_RCU_PREEMPT(tsk)
92#endif
93
b6dff3ec
DH
94extern struct cred init_cred;
95
cdd6c482
IM
96#ifdef CONFIG_PERF_EVENTS
97# define INIT_PERF_EVENTS(tsk) \
98 .perf_event_mutex = \
99 __MUTEX_INITIALIZER(tsk.perf_event_mutex), \
100 .perf_event_list = LIST_HEAD_INIT(tsk.perf_event_list),
082ff5a2 101#else
cdd6c482 102# define INIT_PERF_EVENTS(tsk)
082ff5a2
PZ
103#endif
104
1da177e4
LT
105/*
106 * INIT_TASK is used to set up the first task table, touch at
107 * your own risk!. Base=0, limit=0x1fffff (=2MB)
108 */
109#define INIT_TASK(tsk) \
110{ \
111 .state = 0, \
f7e4217b 112 .stack = &init_thread_info, \
1da177e4 113 .usage = ATOMIC_INIT(2), \
7b34e428 114 .flags = PF_KTHREAD, \
1da177e4
LT
115 .lock_depth = -1, \
116 .prio = MAX_PRIO-20, \
117 .static_prio = MAX_PRIO-20, \
b29739f9 118 .normal_prio = MAX_PRIO-20, \
1da177e4
LT
119 .policy = SCHED_NORMAL, \
120 .cpus_allowed = CPU_MASK_ALL, \
121 .mm = NULL, \
122 .active_mm = &init_mm, \
4a55bd5e
PZ
123 .se = { \
124 .group_node = LIST_HEAD_INIT(tsk.se.group_node), \
125 }, \
fa717060
PZ
126 .rt = { \
127 .run_list = LIST_HEAD_INIT(tsk.rt.run_list), \
6f505b16
PZ
128 .time_slice = HZ, \
129 .nr_cpus_allowed = NR_CPUS, \
130 }, \
1da177e4 131 .tasks = LIST_HEAD_INIT(tsk.tasks), \
917b627d 132 .pushable_tasks = PLIST_NODE_INIT(tsk.pushable_tasks, MAX_PRIO), \
f470021a
RM
133 .ptraced = LIST_HEAD_INIT(tsk.ptraced), \
134 .ptrace_entry = LIST_HEAD_INIT(tsk.ptrace_entry), \
1da177e4
LT
135 .real_parent = &tsk, \
136 .parent = &tsk, \
137 .children = LIST_HEAD_INIT(tsk.children), \
138 .sibling = LIST_HEAD_INIT(tsk.sibling), \
139 .group_leader = &tsk, \
3b11a1de 140 .real_cred = &init_cred, \
f1752eec 141 .cred = &init_cred, \
5e751e99
DH
142 .cred_guard_mutex = \
143 __MUTEX_INITIALIZER(tsk.cred_guard_mutex), \
1da177e4
LT
144 .comm = "swapper", \
145 .thread = INIT_THREAD, \
146 .fs = &init_fs, \
147 .files = &init_files, \
148 .signal = &init_signals, \
149 .sighand = &init_sighand, \
ab516013 150 .nsproxy = &init_nsproxy, \
1da177e4
LT
151 .pending = { \
152 .list = LIST_HEAD_INIT(tsk.pending.list), \
153 .signal = {{0}}}, \
154 .blocked = {{0}}, \
e4d91918 155 .alloc_lock = __SPIN_LOCK_UNLOCKED(tsk.alloc_lock), \
b6e3224f 156 .journal_info = NULL, \
1da177e4 157 .cpu_timers = INIT_CPU_TIMERS(tsk.cpu_timers), \
22e2c507 158 .fs_excl = ATOMIC_INIT(0), \
1d615482 159 .pi_lock = __RAW_SPIN_LOCK_UNLOCKED(tsk.pi_lock), \
6976675d 160 .timer_slack_ns = 50000, /* 50 usec default slack */ \
820e45db
SB
161 .pids = { \
162 [PIDTYPE_PID] = INIT_PID_LINK(PIDTYPE_PID), \
163 [PIDTYPE_PGID] = INIT_PID_LINK(PIDTYPE_PGID), \
164 [PIDTYPE_SID] = INIT_PID_LINK(PIDTYPE_SID), \
165 }, \
3e26c149 166 .dirties = INIT_PROP_LOCAL_SINGLE(dirties), \
bfef93a5 167 INIT_IDS \
cdd6c482 168 INIT_PERF_EVENTS(tsk) \
de30a2b3 169 INIT_TRACE_IRQFLAGS \
fbb9ce95 170 INIT_LOCKDEP \
5ac9f622 171 INIT_FTRACE_GRAPH \
261842b7 172 INIT_TRACE_RECURSION \
f41d911f 173 INIT_TASK_RCU_PREEMPT(tsk) \
1da177e4
LT
174}
175
176
177#define INIT_CPU_TIMERS(cpu_timers) \
178{ \
179 LIST_HEAD_INIT(cpu_timers[0]), \
180 LIST_HEAD_INIT(cpu_timers[1]), \
181 LIST_HEAD_INIT(cpu_timers[2]), \
182}
183
857eceeb
TA
184/* Attach to the init_task data structure for proper alignment */
185#define __init_task_data __attribute__((__section__(".data.init_task")))
186
1da177e4
LT
187
188#endif