Expand various INIT_* macros and remove
[linux-block.git] / init / init_task.c
CommitLineData
b2441318 1// SPDX-License-Identifier: GPL-2.0
a4a2eb49
TG
2#include <linux/init_task.h>
3#include <linux/export.h>
4#include <linux/mqueue.h>
5#include <linux/sched.h>
cf4aebc2 6#include <linux/sched/sysctl.h>
8bd75c77 7#include <linux/sched/rt.h>
9164bb4a 8#include <linux/sched/task.h>
a4a2eb49
TG
9#include <linux/init.h>
10#include <linux/fs.h>
11#include <linux/mm.h>
12
13#include <asm/pgtable.h>
7c0f6ba6 14#include <linux/uaccess.h>
a4a2eb49
TG
15
16static struct signal_struct init_signals = INIT_SIGNALS(init_signals);
17static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand);
18
d11ed3ab
DH
19/*
20 * Set up the first task table, touch at your own risk!. Base=0,
21 * limit=0x1fffff (=2MB)
22 */
0500871f
DH
23struct task_struct init_task
24#ifdef CONFIG_ARCH_TASK_STRUCT_ON_STACK
25 __init_task_data
26#endif
d11ed3ab 27= {
4e7e3adb
DH
28#ifdef CONFIG_THREAD_INFO_IN_TASK
29 .thread_info = INIT_THREAD_INFO(init_task),
30 .stack_refcount = ATOMIC_INIT(1),
31#endif
d11ed3ab
DH
32 .state = 0,
33 .stack = init_stack,
34 .usage = ATOMIC_INIT(2),
35 .flags = PF_KTHREAD,
4e7e3adb
DH
36 .prio = MAX_PRIO - 20,
37 .static_prio = MAX_PRIO - 20,
38 .normal_prio = MAX_PRIO - 20,
d11ed3ab
DH
39 .policy = SCHED_NORMAL,
40 .cpus_allowed = CPU_MASK_ALL,
41 .nr_cpus_allowed= NR_CPUS,
42 .mm = NULL,
43 .active_mm = &init_mm,
4e7e3adb 44 .restart_block = {
d11ed3ab
DH
45 .fn = do_no_restart_syscall,
46 },
47 .se = {
48 .group_node = LIST_HEAD_INIT(init_task.se.group_node),
49 },
50 .rt = {
51 .run_list = LIST_HEAD_INIT(init_task.rt.run_list),
52 .time_slice = RR_TIMESLICE,
53 },
54 .tasks = LIST_HEAD_INIT(init_task.tasks),
4e7e3adb
DH
55#ifdef CONFIG_SMP
56 .pushable_tasks = PLIST_NODE_INIT(init_task.pushable_tasks, MAX_PRIO),
57#endif
58#ifdef CONFIG_CGROUP_SCHED
59 .sched_task_group = &root_task_group,
60#endif
d11ed3ab
DH
61 .ptraced = LIST_HEAD_INIT(init_task.ptraced),
62 .ptrace_entry = LIST_HEAD_INIT(init_task.ptrace_entry),
63 .real_parent = &init_task,
64 .parent = &init_task,
65 .children = LIST_HEAD_INIT(init_task.children),
66 .sibling = LIST_HEAD_INIT(init_task.sibling),
67 .group_leader = &init_task,
68 RCU_POINTER_INITIALIZER(real_cred, &init_cred),
69 RCU_POINTER_INITIALIZER(cred, &init_cred),
70 .comm = INIT_TASK_COMM,
71 .thread = INIT_THREAD,
72 .fs = &init_fs,
73 .files = &init_files,
74 .signal = &init_signals,
75 .sighand = &init_sighand,
76 .nsproxy = &init_nsproxy,
77 .pending = {
78 .list = LIST_HEAD_INIT(init_task.pending.list),
79 .signal = {{0}}
80 },
81 .blocked = {{0}},
82 .alloc_lock = __SPIN_LOCK_UNLOCKED(init_task.alloc_lock),
83 .journal_info = NULL,
84 INIT_CPU_TIMERS(init_task)
85 .pi_lock = __RAW_SPIN_LOCK_UNLOCKED(init_task.pi_lock),
86 .timer_slack_ns = 50000, /* 50 usec default slack */
87 .pids = {
88 [PIDTYPE_PID] = INIT_PID_LINK(PIDTYPE_PID),
89 [PIDTYPE_PGID] = INIT_PID_LINK(PIDTYPE_PGID),
90 [PIDTYPE_SID] = INIT_PID_LINK(PIDTYPE_SID),
91 },
92 .thread_group = LIST_HEAD_INIT(init_task.thread_group),
93 .thread_node = LIST_HEAD_INIT(init_signals.thread_head),
4e7e3adb
DH
94#ifdef CONFIG_AUDITSYSCALL
95 .loginuid = INVALID_UID,
96 .sessionid = (unsigned int)-1,
97#endif
98#ifdef CONFIG_PERF_EVENTS
99 .perf_event_mutex = __MUTEX_INITIALIZER(init_task.perf_event_mutex),
100 .perf_event_list = LIST_HEAD_INIT(init_task.perf_event_list),
101#endif
102#ifdef CONFIG_PREEMPT_RCU
103 .rcu_read_lock_nesting = 0,
104 .rcu_read_unlock_special.s = 0,
105 .rcu_node_entry = LIST_HEAD_INIT(init_task.rcu_node_entry),
106 .rcu_blocked_node = NULL,
107#endif
108#ifdef CONFIG_TASKS_RCU
109 .rcu_tasks_holdout = false,
110 .rcu_tasks_holdout_list = LIST_HEAD_INIT(init_task.rcu_tasks_holdout_list),
111 .rcu_tasks_idle_cpu = -1,
112#endif
113#ifdef CONFIG_CPUSETS
114 .mems_allowed_seq = SEQCNT_ZERO(init_task.mems_allowed_seq),
115#endif
116#ifdef CONFIG_RT_MUTEXES
117 .pi_waiters = RB_ROOT_CACHED,
118 .pi_top_task = NULL,
119#endif
d11ed3ab 120 INIT_PREV_CPUTIME(init_task)
4e7e3adb
DH
121#ifdef CONFIG_VIRT_CPU_ACCOUNTING_GEN
122 .vtime.seqcount = SEQCNT_ZERO(init_task.vtime_seqcount),
123 .vtime.starttime = 0,
124 .vtime.state = VTIME_SYS,
125#endif
126#ifdef CONFIG_NUMA_BALANCING
127 .numa_preferred_nid = -1,
128 .numa_group = NULL,
129 .numa_faults = NULL,
130#endif
131#ifdef CONFIG_KASAN
132 .kasan_depth = 1,
133#endif
134#ifdef CONFIG_TRACE_IRQFLAGS
135 .softirqs_enabled = 1,
136#endif
137#ifdef CONFIG_LOCKDEP
138 .lockdep_recursion = 0,
139#endif
140#ifdef CONFIG_FUNCTION_GRAPH_TRACER
141 .ret_stack = NULL,
142#endif
143#if defined(CONFIG_TRACING) && defined(CONFIG_PREEMPT)
144 .trace_recursion = 0,
145#endif
146#ifdef CONFIG_LIVEPATCH
147 .patch_state = KLP_UNDEFINED,
148#endif
149#ifdef CONFIG_SECURITY
150 .security = NULL,
151#endif
d11ed3ab 152};
a4a2eb49
TG
153EXPORT_SYMBOL(init_task);
154
155/*
156 * Initial thread structure. Alignment of this is handled by a special
157 * linker map entry.
158 */
c65eacbe 159#ifndef CONFIG_THREAD_INFO_IN_TASK
0500871f 160struct thread_info init_thread_info __init_thread_info = INIT_THREAD_INFO(init_task);
c65eacbe 161#endif