Skip to content

Commit 4ff8f2c

Browse files
author
Ingo Molnar
committed
sched/headers: Reorganize, clean up and optimize kernel/sched/sched.h dependencies
Remove all headers, except the ones required to make this header build standalone. Also include stats.h in sched.h explicitly - dependencies already require this. Summary of the build speedup gained through the last ~15 scheduler build & header dependency patches: Cumulative scheduler (kernel/sched/) build time speedup on a Linux distribution's config, which enables all scheduler features, compared to the vanilla kernel: _____________________________________________________________________________ | | Vanilla kernel (v5.13-rc7): |_____________________________________________________________________________ | | Performance counter stats for 'make -j96 kernel/sched/' (3 runs): | | 126,975,564,374 instructions # 1.45 insn per cycle ( +- 0.00% ) | 87,637,847,671 cycles # 3.959 GHz ( +- 0.30% ) | 22,136.96 msec cpu-clock # 7.499 CPUs utilized ( +- 0.29% ) | | 2.9520 +- 0.0169 seconds time elapsed ( +- 0.57% ) |_____________________________________________________________________________ | | Patched kernel: |_____________________________________________________________________________ | | Performance counter stats for 'make -j96 kernel/sched/' (3 runs): | | 50,420,496,914 instructions # 1.47 insn per cycle ( +- 0.00% ) | 34,234,322,038 cycles # 3.946 GHz ( +- 0.31% ) | 8,675.81 msec cpu-clock # 3.053 CPUs utilized ( +- 0.45% ) | | 2.8420 +- 0.0181 seconds time elapsed ( +- 0.64% ) |_____________________________________________________________________________ Summary: - CPU time used to build the scheduler dropped by -60.9%, a reduction from 22.1 clock-seconds to 8.7 clock-seconds. - Wall-clock time to build the scheduler dropped by -3.9%, a reduction from 2.95 seconds to 2.84 seconds. Signed-off-by: Ingo Molnar <[email protected]> Reviewed-by: Peter Zijlstra <[email protected]>
1 parent e81daa7 commit 4ff8f2c

File tree

4 files changed

+46
-113
lines changed

4 files changed

+46
-113
lines changed

kernel/sched/build_policy.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,6 @@
2828
#include <linux/tsacct_kern.h>
2929
#include <linux/vtime.h>
3030

31-
#ifdef CONFIG_PARAVIRT
32-
# include <asm/paravirt.h>
33-
#endif
34-
3531
#include <uapi/linux/sched/types.h>
3632

3733
#include "sched.h"

kernel/sched/build_utility.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,11 @@
4444
#include <linux/wait_api.h>
4545
#include <linux/workqueue_api.h>
4646

47-
#ifdef CONFIG_PARAVIRT
48-
# include <asm/paravirt.h>
49-
#endif
50-
5147
#include <uapi/linux/prctl.h>
5248
#include <uapi/linux/sched/types.h>
5349

50+
#include <asm/switch_to.h>
51+
5452
#include "sched.h"
5553
#include "sched-pelt.h"
5654
#include "stats.h"

kernel/sched/sched.h

Lines changed: 44 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -5,158 +5,97 @@
55
#ifndef _KERNEL_SCHED_SCHED_H
66
#define _KERNEL_SCHED_SCHED_H
77

8-
#include <linux/sched.h>
9-
#include <linux/cpumask.h>
10-
#include <linux/ktime_api.h>
11-
#include <linux/cgroup_api.h>
12-
#include <linux/topology.h>
13-
#include <linux/prctl.h>
14-
#include <linux/ptrace_api.h>
15-
#include <linux/gfp_api.h>
16-
#include <linux/posix-timers.h>
17-
#include <linux/sched/clock.h>
18-
#include <linux/workqueue_api.h>
19-
#include <linux/tick.h>
20-
#include <linux/ktime_api.h>
21-
#include <linux/swait_api.h>
22-
#include <linux/hashtable_api.h>
23-
#include <linux/cpufreq.h>
24-
#include <linux/utsname.h>
25-
26-
#include <asm/irq_regs.h>
27-
288
#include <linux/sched/affinity.h>
299
#include <linux/sched/autogroup.h>
30-
#include <linux/sched/clock.h>
31-
#include <linux/sched/coredump.h>
3210
#include <linux/sched/cpufreq.h>
33-
#include <linux/sched/cputime.h>
3411
#include <linux/sched/deadline.h>
35-
#include <linux/sched/debug.h>
36-
#include <linux/sched/hotplug.h>
37-
#include <linux/sched/idle.h>
38-
#include <linux/sched/init.h>
39-
#include <linux/sched/isolation.h>
40-
#include <linux/sched/jobctl.h>
12+
#include <linux/sched.h>
4113
#include <linux/sched/loadavg.h>
4214
#include <linux/sched/mm.h>
43-
#include <linux/sched/nohz.h>
44-
#include <linux/sched/numa_balancing.h>
45-
#include <linux/sched/prio.h>
4615
#include <linux/sched/rseq_api.h>
47-
#include <linux/sched/rt.h>
4816
#include <linux/sched/signal.h>
4917
#include <linux/sched/smt.h>
5018
#include <linux/sched/stat.h>
5119
#include <linux/sched/sysctl.h>
20+
#include <linux/sched/task_flags.h>
5221
#include <linux/sched/task.h>
53-
#include <linux/sched/task_stack.h>
54-
#include <linux/sched/thread_info_api.h>
5522
#include <linux/sched/topology.h>
56-
#include <linux/sched/user.h>
57-
#include <linux/sched/wake_q.h>
58-
#include <linux/sched/xacct.h>
59-
60-
#include <uapi/linux/sched/types.h>
61-
62-
#include <linux/binfmts.h>
63-
#include <linux/bitops.h>
64-
#include <linux/compat.h>
65-
#include <linux/context_tracking.h>
66-
#include <linux/cpufreq.h>
67-
#include <linux/cpuidle.h>
68-
#include <linux/cpuset.h>
69-
#include <linux/ctype.h>
70-
#include <linux/debugfs.h>
71-
#include <linux/delayacct.h>
72-
#include <linux/energy_model.h>
73-
#include <linux/init_task.h>
74-
#include <linux/kprobes.h>
75-
#include <linux/kthread.h>
76-
#include <linux/membarrier.h>
77-
#include <linux/migrate.h>
78-
#include <linux/mmu_context.h>
79-
#include <linux/nmi.h>
80-
#include <linux/proc_fs.h>
81-
#include <linux/prefetch.h>
82-
#include <linux/profile.h>
83-
#include <linux/psi.h>
84-
#include <linux/ratelimit.h>
85-
#include <linux/rcupdate_wait.h>
86-
#include <linux/security.h>
87-
#include <linux/stop_machine.h>
88-
#include <linux/suspend.h>
89-
#include <linux/swait.h>
90-
#include <linux/syscalls.h>
91-
#include <linux/task_work.h>
92-
#include <linux/tsacct_kern.h>
93-
#include <linux/hrtimer_api.h>
94-
95-
#ifdef CONFIG_PARAVIRT
96-
# include <asm/paravirt.h>
97-
#endif
98-
99-
#include <trace/events/sched.h>
100-
101-
#ifdef CONFIG_CGROUP_SCHED
102-
#include <linux/cgroup.h>
103-
#include <linux/psi.h>
104-
#endif
105-
106-
#ifdef CONFIG_SCHED_DEBUG
107-
# include <linux/static_key.h>
108-
#endif
109-
110-
#include "cpupri.h"
111-
#include "cpudeadline.h"
112-
113-
#ifdef CONFIG_SCHED_DEBUG
114-
# define SCHED_WARN_ON(x) WARN_ONCE(x, #x)
115-
#else
116-
# define SCHED_WARN_ON(x) ({ (void)(x), 0; })
117-
#endif
11823

24+
#include <linux/atomic.h>
11925
#include <linux/bitmap.h>
26+
#include <linux/bug.h>
12027
#include <linux/capability.h>
28+
#include <linux/cgroup_api.h>
12129
#include <linux/cgroup.h>
12230
#include <linux/cpufreq.h>
12331
#include <linux/cpumask_api.h>
12432
#include <linux/ctype.h>
12533
#include <linux/file.h>
34+
#include <linux/fs_api.h>
12635
#include <linux/hrtimer_api.h>
12736
#include <linux/interrupt.h>
37+
#include <linux/irq_work.h>
12838
#include <linux/jiffies.h>
12939
#include <linux/kref_api.h>
40+
#include <linux/kthread.h>
13041
#include <linux/ktime_api.h>
13142
#include <linux/lockdep_api.h>
43+
#include <linux/lockdep.h>
44+
#include <linux/minmax.h>
45+
#include <linux/mm.h>
13246
#include <linux/module.h>
13347
#include <linux/mutex_api.h>
48+
#include <linux/plist.h>
13449
#include <linux/poll.h>
13550
#include <linux/proc_fs.h>
51+
#include <linux/profile.h>
13652
#include <linux/psi.h>
137-
#include <linux/sched/affinity.h>
138-
#include <linux/sched.h>
139-
#include <linux/sched/loadavg.h>
140-
#include <linux/sched/mm.h>
141-
#include <linux/sched/rseq_api.h>
142-
#include <linux/sched/signal.h>
53+
#include <linux/rcupdate.h>
14354
#include <linux/seq_file.h>
14455
#include <linux/seqlock.h>
14556
#include <linux/softirq.h>
14657
#include <linux/spinlock_api.h>
58+
#include <linux/static_key.h>
59+
#include <linux/stop_machine.h>
14760
#include <linux/syscalls_api.h>
14861
#include <linux/syscalls.h>
62+
#include <linux/tick.h>
14963
#include <linux/topology.h>
15064
#include <linux/types.h>
15165
#include <linux/u64_stats_sync_api.h>
15266
#include <linux/uaccess.h>
15367
#include <linux/wait_api.h>
68+
#include <linux/wait_bit.h>
15469
#include <linux/workqueue_api.h>
15570

15671
#include <trace/events/power.h>
72+
#include <trace/events/sched.h>
15773

15874
#include "../workqueue_internal.h"
15975

76+
#ifdef CONFIG_CGROUP_SCHED
77+
#include <linux/cgroup.h>
78+
#include <linux/psi.h>
79+
#endif
80+
81+
#ifdef CONFIG_SCHED_DEBUG
82+
# include <linux/static_key.h>
83+
#endif
84+
85+
#ifdef CONFIG_PARAVIRT
86+
# include <asm/paravirt.h>
87+
# include <asm/paravirt_api_clock.h>
88+
#endif
89+
90+
#include "cpupri.h"
91+
#include "cpudeadline.h"
92+
93+
#ifdef CONFIG_SCHED_DEBUG
94+
# define SCHED_WARN_ON(x) WARN_ONCE(x, #x)
95+
#else
96+
# define SCHED_WARN_ON(x) ({ (void)(x), 0; })
97+
#endif
98+
16099
struct rq;
161100
struct cpuidle_state;
162101

@@ -1925,6 +1864,8 @@ extern void flush_smp_call_function_from_idle(void);
19251864
static inline void flush_smp_call_function_from_idle(void) { }
19261865
#endif
19271866

1867+
#include "stats.h"
1868+
19281869
#if defined(CONFIG_SCHED_CORE) && defined(CONFIG_SCHEDSTATS)
19291870

19301871
extern void __sched_core_account_forceidle(struct rq *rq);

kernel/sched/stats.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
#ifndef _KERNEL_STATS_H
33
#define _KERNEL_STATS_H
44

5-
#include "sched.h"
6-
75
#ifdef CONFIG_SCHEDSTATS
86

97
extern struct static_key_false sched_schedstats;

0 commit comments

Comments
 (0)