Skip to content

Commit 4e7e3ad

Browse files
committed
Expand various INIT_* macros and remove
Expand various INIT_* macros into the single places they're used in init/init_task.c and remove them. Signed-off-by: David Howells <dhowells@redhat.com> Tested-by: Tony Luck <tony.luck@intel.com> Tested-by: Will Deacon <will.deacon@arm.com> (arm64) Tested-by: Palmer Dabbelt <palmer@sifive.com> Acked-by: Thomas Gleixner <tglx@linutronix.de>
1 parent d11ed3a commit 4e7e3ad

5 files changed

Lines changed: 71 additions & 153 deletions

File tree

‎include/linux/ftrace.h‎

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -764,9 +764,6 @@ typedef int (*trace_func_graph_ent_t)(struct ftrace_graph_ent *); /* entry */
764764

765765
#ifdef CONFIG_FUNCTION_GRAPH_TRACER
766766

767-
/* for init task */
768-
#define INIT_FTRACE_GRAPH .ret_stack = NULL,
769-
770767
/*
771768
* Stack of return addresses for functions
772769
* of a thread.
@@ -844,7 +841,6 @@ static inline void unpause_graph_tracing(void)
844841
#else /* !CONFIG_FUNCTION_GRAPH_TRACER */
845842

846843
#define __notrace_funcgraph
847-
#define INIT_FTRACE_GRAPH
848844

849845
static inline void ftrace_graph_init_task(struct task_struct *t) { }
850846
static inline void ftrace_graph_exit_task(struct task_struct *t) { }
@@ -923,10 +919,6 @@ extern int tracepoint_printk;
923919
extern void disable_trace_on_warning(void);
924920
extern int __disable_trace_on_warning;
925921

926-
#ifdef CONFIG_PREEMPT
927-
#define INIT_TRACE_RECURSION .trace_recursion = 0,
928-
#endif
929-
930922
int tracepoint_printk_sysctl(struct ctl_table *table, int write,
931923
void __user *buffer, size_t *lenp,
932924
loff_t *ppos);
@@ -935,10 +927,6 @@ int tracepoint_printk_sysctl(struct ctl_table *table, int write,
935927
static inline void disable_trace_on_warning(void) { }
936928
#endif /* CONFIG_TRACING */
937929

938-
#ifndef INIT_TRACE_RECURSION
939-
#define INIT_TRACE_RECURSION
940-
#endif
941-
942930
#ifdef CONFIG_FTRACE_SYSCALLS
943931

944932
unsigned long arch_syscall_addr(int nr);

‎include/linux/init_task.h‎

Lines changed: 0 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,9 @@
2121

2222
#include <asm/thread_info.h>
2323

24-
#ifdef CONFIG_SMP
25-
# define INIT_PUSHABLE_TASKS(tsk) \
26-
.pushable_tasks = PLIST_NODE_INIT(tsk.pushable_tasks, MAX_PRIO),
27-
#else
28-
# define INIT_PUSHABLE_TASKS(tsk)
29-
#endif
30-
3124
extern struct files_struct init_files;
3225
extern struct fs_struct init_fs;
3326

34-
#ifdef CONFIG_CPUSETS
35-
#define INIT_CPUSET_SEQ(tsk) \
36-
.mems_allowed_seq = SEQCNT_ZERO(tsk.mems_allowed_seq),
37-
#else
38-
#define INIT_CPUSET_SEQ(tsk)
39-
#endif
40-
4127
#ifndef CONFIG_VIRT_CPU_ACCOUNTING_NATIVE
4228
#define INIT_PREV_CPUTIME(x) .prev_cputime = { \
4329
.lock = __RAW_SPIN_LOCK_UNLOCKED(x.prev_cputime.lock), \
@@ -117,107 +103,10 @@ extern struct group_info init_groups;
117103
.pid = &init_struct_pid, \
118104
}
119105

120-
#ifdef CONFIG_AUDITSYSCALL
121-
#define INIT_IDS \
122-
.loginuid = INVALID_UID, \
123-
.sessionid = (unsigned int)-1,
124-
#else
125-
#define INIT_IDS
126-
#endif
127-
128-
#ifdef CONFIG_PREEMPT_RCU
129-
#define INIT_TASK_RCU_PREEMPT(tsk) \
130-
.rcu_read_lock_nesting = 0, \
131-
.rcu_read_unlock_special.s = 0, \
132-
.rcu_node_entry = LIST_HEAD_INIT(tsk.rcu_node_entry), \
133-
.rcu_blocked_node = NULL,
134-
#else
135-
#define INIT_TASK_RCU_PREEMPT(tsk)
136-
#endif
137-
#ifdef CONFIG_TASKS_RCU
138-
#define INIT_TASK_RCU_TASKS(tsk) \
139-
.rcu_tasks_holdout = false, \
140-
.rcu_tasks_holdout_list = \
141-
LIST_HEAD_INIT(tsk.rcu_tasks_holdout_list), \
142-
.rcu_tasks_idle_cpu = -1,
143-
#else
144-
#define INIT_TASK_RCU_TASKS(tsk)
145-
#endif
146-
147106
extern struct cred init_cred;
148107

149-
#ifdef CONFIG_CGROUP_SCHED
150-
# define INIT_CGROUP_SCHED(tsk) \
151-
.sched_task_group = &root_task_group,
152-
#else
153-
# define INIT_CGROUP_SCHED(tsk)
154-
#endif
155-
156-
#ifdef CONFIG_PERF_EVENTS
157-
# define INIT_PERF_EVENTS(tsk) \
158-
.perf_event_mutex = \
159-
__MUTEX_INITIALIZER(tsk.perf_event_mutex), \
160-
.perf_event_list = LIST_HEAD_INIT(tsk.perf_event_list),
161-
#else
162-
# define INIT_PERF_EVENTS(tsk)
163-
#endif
164-
165-
#ifdef CONFIG_VIRT_CPU_ACCOUNTING_GEN
166-
# define INIT_VTIME(tsk) \
167-
.vtime.seqcount = SEQCNT_ZERO(tsk.vtime.seqcount), \
168-
.vtime.starttime = 0, \
169-
.vtime.state = VTIME_SYS,
170-
#else
171-
# define INIT_VTIME(tsk)
172-
#endif
173-
174108
#define INIT_TASK_COMM "swapper"
175109

176-
#ifdef CONFIG_RT_MUTEXES
177-
# define INIT_RT_MUTEXES(tsk) \
178-
.pi_waiters = RB_ROOT_CACHED, \
179-
.pi_top_task = NULL,
180-
#else
181-
# define INIT_RT_MUTEXES(tsk)
182-
#endif
183-
184-
#ifdef CONFIG_NUMA_BALANCING
185-
# define INIT_NUMA_BALANCING(tsk) \
186-
.numa_preferred_nid = -1, \
187-
.numa_group = NULL, \
188-
.numa_faults = NULL,
189-
#else
190-
# define INIT_NUMA_BALANCING(tsk)
191-
#endif
192-
193-
#ifdef CONFIG_KASAN
194-
# define INIT_KASAN(tsk) \
195-
.kasan_depth = 1,
196-
#else
197-
# define INIT_KASAN(tsk)
198-
#endif
199-
200-
#ifdef CONFIG_LIVEPATCH
201-
# define INIT_LIVEPATCH(tsk) \
202-
.patch_state = KLP_UNDEFINED,
203-
#else
204-
# define INIT_LIVEPATCH(tsk)
205-
#endif
206-
207-
#ifdef CONFIG_THREAD_INFO_IN_TASK
208-
# define INIT_TASK_TI(tsk) \
209-
.thread_info = INIT_THREAD_INFO(tsk), \
210-
.stack_refcount = ATOMIC_INIT(1),
211-
#else
212-
# define INIT_TASK_TI(tsk)
213-
#endif
214-
215-
#ifdef CONFIG_SECURITY
216-
#define INIT_TASK_SECURITY .security = NULL,
217-
#else
218-
#define INIT_TASK_SECURITY
219-
#endif
220-
221110
/* Attach to the init_task data structure for proper alignment */
222111
#ifdef CONFIG_ARCH_TASK_STRUCT_ON_STACK
223112
#define __init_task_data __attribute__((__section__(".data..init_task")))
@@ -228,5 +117,4 @@ extern struct cred init_cred;
228117
/* Attach to the thread_info data structure for proper alignment */
229118
#define __init_thread_info __attribute__((__section__(".data..init_thread_info")))
230119

231-
232120
#endif

‎include/linux/irqflags.h‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ do { \
4444
current->softirq_context--; \
4545
crossrelease_hist_end(XHLOCK_SOFT); \
4646
} while (0)
47-
# define INIT_TRACE_IRQFLAGS .softirqs_enabled = 1,
4847
#else
4948
# define trace_hardirqs_on() do { } while (0)
5049
# define trace_hardirqs_off() do { } while (0)
@@ -58,7 +57,6 @@ do { \
5857
# define trace_hardirq_exit() do { } while (0)
5958
# define lockdep_softirq_enter() do { } while (0)
6059
# define lockdep_softirq_exit() do { } while (0)
61-
# define INIT_TRACE_IRQFLAGS
6260
#endif
6361

6462
#if defined(CONFIG_IRQSOFF_TRACER) || \

‎include/linux/lockdep.h‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -367,8 +367,6 @@ extern struct pin_cookie lock_pin_lock(struct lockdep_map *lock);
367367
extern void lock_repin_lock(struct lockdep_map *lock, struct pin_cookie);
368368
extern void lock_unpin_lock(struct lockdep_map *lock, struct pin_cookie);
369369

370-
# define INIT_LOCKDEP .lockdep_recursion = 0,
371-
372370
#define lockdep_depth(tsk) (debug_locks ? (tsk)->lockdep_depth : 0)
373371

374372
#define lockdep_assert_held(l) do { \
@@ -426,7 +424,6 @@ static inline void lockdep_on(void)
426424
* #ifdef the call himself.
427425
*/
428426

429-
# define INIT_LOCKDEP
430427
# define lockdep_reset() do { debug_locks = 1; } while (0)
431428
# define lockdep_free_key_range(start, size) do { } while (0)
432429
# define lockdep_sys_exit() do { } while (0)

‎init/init_task.c‎

Lines changed: 71 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
static struct signal_struct init_signals = INIT_SIGNALS(init_signals);
1717
static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand);
1818

19-
2019
/*
2120
* Set up the first task table, touch at your own risk!. Base=0,
2221
* limit=0x1fffff (=2MB)
@@ -26,20 +25,23 @@ struct task_struct init_task
2625
__init_task_data
2726
#endif
2827
= {
29-
INIT_TASK_TI(init_task)
28+
#ifdef CONFIG_THREAD_INFO_IN_TASK
29+
.thread_info = INIT_THREAD_INFO(init_task),
30+
.stack_refcount = ATOMIC_INIT(1),
31+
#endif
3032
.state = 0,
3133
.stack = init_stack,
3234
.usage = ATOMIC_INIT(2),
3335
.flags = PF_KTHREAD,
34-
.prio = MAX_PRIO-20,
35-
.static_prio = MAX_PRIO-20,
36-
.normal_prio = MAX_PRIO-20,
36+
.prio = MAX_PRIO - 20,
37+
.static_prio = MAX_PRIO - 20,
38+
.normal_prio = MAX_PRIO - 20,
3739
.policy = SCHED_NORMAL,
3840
.cpus_allowed = CPU_MASK_ALL,
3941
.nr_cpus_allowed= NR_CPUS,
4042
.mm = NULL,
4143
.active_mm = &init_mm,
42-
.restart_block = {
44+
.restart_block = {
4345
.fn = do_no_restart_syscall,
4446
},
4547
.se = {
@@ -50,8 +52,12 @@ struct task_struct init_task
5052
.time_slice = RR_TIMESLICE,
5153
},
5254
.tasks = LIST_HEAD_INIT(init_task.tasks),
53-
INIT_PUSHABLE_TASKS(init_task)
54-
INIT_CGROUP_SCHED(init_task)
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
5561
.ptraced = LIST_HEAD_INIT(init_task.ptraced),
5662
.ptrace_entry = LIST_HEAD_INIT(init_task.ptrace_entry),
5763
.real_parent = &init_task,
@@ -85,24 +91,65 @@ struct task_struct init_task
8591
},
8692
.thread_group = LIST_HEAD_INIT(init_task.thread_group),
8793
.thread_node = LIST_HEAD_INIT(init_signals.thread_head),
88-
INIT_IDS
89-
INIT_PERF_EVENTS(init_task)
90-
INIT_TRACE_IRQFLAGS
91-
INIT_LOCKDEP
92-
INIT_FTRACE_GRAPH
93-
INIT_TRACE_RECURSION
94-
INIT_TASK_RCU_PREEMPT(init_task)
95-
INIT_TASK_RCU_TASKS(init_task)
96-
INIT_CPUSET_SEQ(init_task)
97-
INIT_RT_MUTEXES(init_task)
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
98120
INIT_PREV_CPUTIME(init_task)
99-
INIT_VTIME(init_task)
100-
INIT_NUMA_BALANCING(init_task)
101-
INIT_KASAN(init_task)
102-
INIT_LIVEPATCH(init_task)
103-
INIT_TASK_SECURITY
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
104152
};
105-
106153
EXPORT_SYMBOL(init_task);
107154

108155
/*

0 commit comments

Comments
 (0)