Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
Thomas Gleixner | a4a2eb4 | 2012-05-03 09:02:48 +0000 | [diff] [blame] | 2 | #include <linux/init_task.h> |
| 3 | #include <linux/export.h> |
| 4 | #include <linux/mqueue.h> |
| 5 | #include <linux/sched.h> |
Clark Williams | cf4aebc2 | 2013-02-07 09:46:59 -0600 | [diff] [blame] | 6 | #include <linux/sched/sysctl.h> |
Clark Williams | 8bd75c7 | 2013-02-07 09:47:07 -0600 | [diff] [blame] | 7 | #include <linux/sched/rt.h> |
Ingo Molnar | 9164bb4 | 2017-02-04 01:20:53 +0100 | [diff] [blame] | 8 | #include <linux/sched/task.h> |
Thomas Gleixner | a4a2eb4 | 2012-05-03 09:02:48 +0000 | [diff] [blame] | 9 | #include <linux/init.h> |
| 10 | #include <linux/fs.h> |
| 11 | #include <linux/mm.h> |
| 12 | |
| 13 | #include <asm/pgtable.h> |
Linus Torvalds | 7c0f6ba | 2016-12-24 11:46:01 -0800 | [diff] [blame] | 14 | #include <linux/uaccess.h> |
Thomas Gleixner | a4a2eb4 | 2012-05-03 09:02:48 +0000 | [diff] [blame] | 15 | |
| 16 | static struct signal_struct init_signals = INIT_SIGNALS(init_signals); |
| 17 | static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); |
| 18 | |
David Howells | d11ed3a | 2018-01-02 15:12:01 +0000 | [diff] [blame] | 19 | /* |
| 20 | * Set up the first task table, touch at your own risk!. Base=0, |
| 21 | * limit=0x1fffff (=2MB) |
| 22 | */ |
David Howells | 0500871 | 2018-01-02 15:12:01 +0000 | [diff] [blame] | 23 | struct task_struct init_task |
| 24 | #ifdef CONFIG_ARCH_TASK_STRUCT_ON_STACK |
| 25 | __init_task_data |
| 26 | #endif |
David Howells | d11ed3a | 2018-01-02 15:12:01 +0000 | [diff] [blame] | 27 | = { |
David Howells | 4e7e3ad | 2018-01-02 15:12:01 +0000 | [diff] [blame^] | 28 | #ifdef CONFIG_THREAD_INFO_IN_TASK |
| 29 | .thread_info = INIT_THREAD_INFO(init_task), |
| 30 | .stack_refcount = ATOMIC_INIT(1), |
| 31 | #endif |
David Howells | d11ed3a | 2018-01-02 15:12:01 +0000 | [diff] [blame] | 32 | .state = 0, |
| 33 | .stack = init_stack, |
| 34 | .usage = ATOMIC_INIT(2), |
| 35 | .flags = PF_KTHREAD, |
David Howells | 4e7e3ad | 2018-01-02 15:12:01 +0000 | [diff] [blame^] | 36 | .prio = MAX_PRIO - 20, |
| 37 | .static_prio = MAX_PRIO - 20, |
| 38 | .normal_prio = MAX_PRIO - 20, |
David Howells | d11ed3a | 2018-01-02 15:12:01 +0000 | [diff] [blame] | 39 | .policy = SCHED_NORMAL, |
| 40 | .cpus_allowed = CPU_MASK_ALL, |
| 41 | .nr_cpus_allowed= NR_CPUS, |
| 42 | .mm = NULL, |
| 43 | .active_mm = &init_mm, |
David Howells | 4e7e3ad | 2018-01-02 15:12:01 +0000 | [diff] [blame^] | 44 | .restart_block = { |
David Howells | d11ed3a | 2018-01-02 15:12:01 +0000 | [diff] [blame] | 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), |
David Howells | 4e7e3ad | 2018-01-02 15:12:01 +0000 | [diff] [blame^] | 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 |
David Howells | d11ed3a | 2018-01-02 15:12:01 +0000 | [diff] [blame] | 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), |
David Howells | 4e7e3ad | 2018-01-02 15:12:01 +0000 | [diff] [blame^] | 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 |
David Howells | d11ed3a | 2018-01-02 15:12:01 +0000 | [diff] [blame] | 120 | INIT_PREV_CPUTIME(init_task) |
David Howells | 4e7e3ad | 2018-01-02 15:12:01 +0000 | [diff] [blame^] | 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 |
David Howells | d11ed3a | 2018-01-02 15:12:01 +0000 | [diff] [blame] | 152 | }; |
Thomas Gleixner | a4a2eb4 | 2012-05-03 09:02:48 +0000 | [diff] [blame] | 153 | EXPORT_SYMBOL(init_task); |
| 154 | |
| 155 | /* |
| 156 | * Initial thread structure. Alignment of this is handled by a special |
| 157 | * linker map entry. |
| 158 | */ |
Andy Lutomirski | c65eacb | 2016-09-13 14:29:24 -0700 | [diff] [blame] | 159 | #ifndef CONFIG_THREAD_INFO_IN_TASK |
David Howells | 0500871 | 2018-01-02 15:12:01 +0000 | [diff] [blame] | 160 | struct thread_info init_thread_info __init_thread_info = INIT_THREAD_INFO(init_task); |
Andy Lutomirski | c65eacb | 2016-09-13 14:29:24 -0700 | [diff] [blame] | 161 | #endif |