[PATCH 00/15] sched/headers: Optimize scheduler build time

Ingo Molnar
2022-03-15T08:43:53Z

Optimize the kernel scheduler build time by organizing the code into
larger build units. This cuts CPU usage by 60%.

These patches originate from the fast-headers tree.

The numbers:

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.

Ingo Molnar (15):
sched/headers: Fix header to build standalone: <linux/sched_clock.h>
sched/headers: Add header guard to kernel/sched/sched.h
sched/headers: Add header guard to kernel/sched/stats.h and kernel/sched/autogroup.h
sched/headers: sched/clock: Mark all functions 'notrace', remove CC_FLAGS_FTRACE build asymmetry
sched/headers: Add initial new headers as identity mappings
sched/headers: Fix comment typo in kernel/sched/cpudeadline.c
sched/headers: Make the <linux/sched/deadline.h> header build standalone
sched/headers: Introduce kernel/sched/build_utility.c and build multiple .c files there
sched/headers: Introduce kernel/sched/build_policy.c and build multiple .c files there
sched/headers: Standardize kernel/sched/sched.h header dependencies
sched/headers: Reorganize, clean up and optimize kernel/sched/core.c dependencies
sched/headers: Reorganize, clean up and optimize kernel/sched/fair.c dependencies
sched/headers: Reorganize, clean up and optimize kernel/sched/build_policy.c dependencies
sched/headers: Reorganize, clean up and optimize kernel/sched/build_utility.c dependencies
sched/headers: Reorganize, clean up and optimize kernel/sched/sched.h dependencies

arch/arm64/include/asm/paravirt_api_clock.h | 1 +
arch/x86/include/asm/paravirt_api_clock.h | 1 +
include/linux/cgroup_api.h | 1 +
include/linux/cpumask_api.h | 1 +
include/linux/fs_api.h | 1 +
include/linux/gfp_api.h | 1 +
include/linux/hashtable_api.h | 1 +
include/linux/hrtimer_api.h | 1 +
include/linux/kobject_api.h | 1 +
include/linux/kref_api.h | 1 +
include/linux/ktime_api.h | 1 +
include/linux/llist_api.h | 1 +
include/linux/lockdep_api.h | 1 +
include/linux/mm_api.h | 1 +
include/linux/mutex_api.h | 1 +
include/linux/perf_event_api.h | 1 +
include/linux/pgtable_api.h | 1 +
include/linux/ptrace_api.h | 1 +
include/linux/rcuwait_api.h | 1 +
include/linux/refcount_api.h | 1 +
include/linux/sched/affinity.h | 1 +
include/linux/sched/cond_resched.h | 1 +
include/linux/sched/deadline.h | 2 +
include/linux/sched/posix-timers.h | 1 +
include/linux/sched/rseq_api.h | 1 +
include/linux/sched/task_flags.h | 1 +
include/linux/sched/thread_info_api.h | 1 +
include/linux/sched_clock.h | 2 +
include/linux/seqlock_api.h | 1 +
include/linux/softirq.h | 1 +
include/linux/spinlock_api.h | 1 +
include/linux/swait_api.h | 1 +
include/linux/syscalls_api.h | 1 +
include/linux/u64_stats_sync_api.h | 1 +
include/linux/wait_api.h | 1 +
include/linux/workqueue_api.h | 1 +
kernel/sched/Makefile | 28 +++++-------
kernel/sched/autogroup.c | 3 +-
kernel/sched/autogroup.h | 5 +++
kernel/sched/build_policy.c | 52 ++++++++++++++++++++++
kernel/sched/build_utility.c | 109 +++++++++++++++++++++++++++++++++++++++++++++
kernel/sched/clock.c | 44 +++++++++----------
kernel/sched/completion.c | 2 +-
kernel/sched/core.c | 81 +++++++++++++++++++++++++++++-----
kernel/sched/core_sched.c | 3 --
kernel/sched/cpuacct.c | 3 +-
kernel/sched/cpudeadline.c | 3 +-
kernel/sched/cpufreq.c | 3 --
kernel/sched/cpufreq_schedutil.c | 7 ---
kernel/sched/cpupri.c | 1 -
kernel/sched/cputime.c | 1 -
kernel/sched/deadline.c | 2 -
kernel/sched/debug.c | 1 -
kernel/sched/fair.c | 31 +++++++++++++
kernel/sched/idle.c | 3 --
kernel/sched/isolation.c | 1 -
kernel/sched/loadavg.c | 1 -
kernel/sched/membarrier.c | 1 -
kernel/sched/pelt.c | 4 --
kernel/sched/psi.c | 15 -------
kernel/sched/rt.c | 3 --
kernel/sched/sched.h | 114 ++++++++++++++++++++++++++----------------------
kernel/sched/stats.c | 1 -
kernel/sched/stats.h | 4 ++
kernel/sched/stop_task.c | 1 -
kernel/sched/swait.c | 1 -
kernel/sched/topology.c | 1 -
kernel/sched/wait.c | 1 -
kernel/sched/wait_bit.c | 2 +-
69 files changed, 407 insertions(+), 163 deletions(-)
create mode 100644 arch/arm64/include/asm/paravirt_api_clock.h
create mode 100644 arch/x86/include/asm/paravirt_api_clock.h
create mode 100644 include/linux/cgroup_api.h
create mode 100644 include/linux/cpumask_api.h
create mode 100644 include/linux/fs_api.h
create mode 100644 include/linux/gfp_api.h
create mode 100644 include/linux/hashtable_api.h
create mode 100644 include/linux/hrtimer_api.h
create mode 100644 include/linux/kobject_api.h
create mode 100644 include/linux/kref_api.h
create mode 100644 include/linux/ktime_api.h
create mode 100644 include/linux/llist_api.h
create mode 100644 include/linux/lockdep_api.h
create mode 100644 include/linux/mm_api.h
create mode 100644 include/linux/mutex_api.h
create mode 100644 include/linux/perf_event_api.h
create mode 100644 include/linux/pgtable_api.h
create mode 100644 include/linux/ptrace_api.h
create mode 100644 include/linux/rcuwait_api.h
create mode 100644 include/linux/refcount_api.h
create mode 100644 include/linux/sched/affinity.h
create mode 100644 include/linux/sched/cond_resched.h
create mode 100644 include/linux/sched/posix-timers.h
create mode 100644 include/linux/sched/rseq_api.h
create mode 100644 include/linux/sched/task_flags.h
create mode 100644 include/linux/sched/thread_info_api.h
create mode 100644 include/linux/seqlock_api.h
create mode 100644 include/linux/softirq.h
create mode 100644 include/linux/spinlock_api.h
create mode 100644 include/linux/swait_api.h
create mode 100644 include/linux/syscalls_api.h
create mode 100644 include/linux/u64_stats_sync_api.h
create mode 100644 include/linux/wait_api.h
create mode 100644 include/linux/workqueue_api.h
create mode 100644 kernel/sched/build_policy.c
create mode 100644 kernel/sched/build_utility.c

--
2.32.0