Skip to content

Commit 801c141

Browse files
committed
sched/headers: Introduce kernel/sched/build_utility.c and build multiple .c files there
Collect all utility functionality source code files into a single kernel/sched/build_utility.c file, via #include-ing the .c files: kernel/sched/clock.c kernel/sched/completion.c kernel/sched/loadavg.c kernel/sched/swait.c kernel/sched/wait_bit.c kernel/sched/wait.c CONFIG_CPU_FREQ: kernel/sched/cpufreq.c CONFIG_CPU_FREQ_GOV_SCHEDUTIL: kernel/sched/cpufreq_schedutil.c CONFIG_CGROUP_CPUACCT: kernel/sched/cpuacct.c CONFIG_SCHED_DEBUG: kernel/sched/debug.c CONFIG_SCHEDSTATS: kernel/sched/stats.c CONFIG_SMP: kernel/sched/cpupri.c kernel/sched/stop_task.c kernel/sched/topology.c CONFIG_SCHED_CORE: kernel/sched/core_sched.c CONFIG_PSI: kernel/sched/psi.c CONFIG_MEMBARRIER: kernel/sched/membarrier.c CONFIG_CPU_ISOLATION: kernel/sched/isolation.c CONFIG_SCHED_AUTOGROUP: kernel/sched/autogroup.c The goal is to amortize the 60+ KLOC header bloat from over a dozen build units into a single build unit. The build time of build_utility.c also roughly matches the build time of core.c and fair.c - allowing better load-balancing of scheduler-only rebuilds. Signed-off-by: Ingo Molnar <mingo@kernel.org> Reviewed-by: Peter Zijlstra <peterz@infradead.org>
1 parent fbed566 commit 801c141

22 files changed

Lines changed: 139 additions & 63 deletions

kernel/sched/Makefile

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,13 @@ ifneq ($(CONFIG_SCHED_OMIT_FRAME_POINTER),y)
2222
CFLAGS_core.o := $(PROFILING) -fno-omit-frame-pointer
2323
endif
2424

25-
obj-y += core.o loadavg.o clock.o cputime.o
26-
obj-y += idle.o fair.o rt.o deadline.o
27-
obj-y += wait.o wait_bit.o swait.o completion.o
28-
29-
obj-$(CONFIG_SMP) += cpupri.o cpudeadline.o topology.o stop_task.o pelt.o
30-
obj-$(CONFIG_SCHED_AUTOGROUP) += autogroup.o
31-
obj-$(CONFIG_SCHEDSTATS) += stats.o
32-
obj-$(CONFIG_SCHED_DEBUG) += debug.o
33-
obj-$(CONFIG_CGROUP_CPUACCT) += cpuacct.o
34-
obj-$(CONFIG_CPU_FREQ) += cpufreq.o
35-
obj-$(CONFIG_CPU_FREQ_GOV_SCHEDUTIL) += cpufreq_schedutil.o
36-
obj-$(CONFIG_MEMBARRIER) += membarrier.o
37-
obj-$(CONFIG_CPU_ISOLATION) += isolation.o
38-
obj-$(CONFIG_PSI) += psi.o
39-
obj-$(CONFIG_SCHED_CORE) += core_sched.o
25+
#
26+
# Build efficiency:
27+
#
28+
# These compilation units have roughly the same size and complexity - so their
29+
# build parallelizes well and finishes roughly at once:
30+
#
31+
obj-y += core.o
32+
obj-y += fair.o
33+
obj-y += build_utility.o
34+
obj-y += idle.o rt.o deadline.o cputime.o cpudeadline.o pelt.o

kernel/sched/autogroup.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
// SPDX-License-Identifier: GPL-2.0
2+
23
/*
34
* Auto-group scheduling implementation:
45
*/
5-
#include <linux/nospec.h>
6-
#include "sched.h"
76

87
unsigned int __read_mostly sysctl_sched_autogroup_enabled = 1;
98
static struct autogroup autogroup_default;

kernel/sched/build_utility.c

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
// SPDX-License-Identifier: GPL-2.0-only
2+
/*
3+
* These are various utility functions of the scheduler,
4+
* built in a single compilation unit for build efficiency reasons.
5+
*
6+
* ( Incidentally, the size of the compilation unit is roughly
7+
* comparable to core.c, fair.c, smp.c and policy.c, the other
8+
* big compilation units. This helps balance build time, while
9+
* coalescing source files to amortize header inclusion
10+
* cost. )
11+
*/
12+
13+
#include "sched.h"
14+
#include "sched-pelt.h"
15+
16+
#include <linux/sched_clock.h>
17+
18+
#include "clock.c"
19+
20+
#ifdef CONFIG_CGROUP_CPUACCT
21+
# include "cpuacct.c"
22+
#endif
23+
24+
#ifdef CONFIG_CPU_FREQ
25+
# include "cpufreq.c"
26+
#endif
27+
28+
#ifdef CONFIG_CPU_FREQ_GOV_SCHEDUTIL
29+
# include "cpufreq_schedutil.c"
30+
#endif
31+
32+
#ifdef CONFIG_SCHED_DEBUG
33+
# include "debug.c"
34+
#endif
35+
36+
#ifdef CONFIG_SCHEDSTATS
37+
# include "stats.c"
38+
#endif
39+
40+
#include "loadavg.c"
41+
#include "completion.c"
42+
#include "swait.c"
43+
#include "wait_bit.c"
44+
#include "wait.c"
45+
46+
#ifdef CONFIG_SMP
47+
# include "cpupri.c"
48+
# include "stop_task.c"
49+
# include "topology.c"
50+
#endif
51+
52+
#ifdef CONFIG_SCHED_CORE
53+
# include "core_sched.c"
54+
#endif
55+
56+
#ifdef CONFIG_PSI
57+
# include "psi.c"
58+
#endif
59+
60+
#ifdef CONFIG_MEMBARRIER
61+
# include "membarrier.c"
62+
#endif
63+
64+
#ifdef CONFIG_CPU_ISOLATION
65+
# include "isolation.c"
66+
#endif
67+
68+
#ifdef CONFIG_SCHED_AUTOGROUP
69+
# include "autogroup.c"
70+
#endif

kernel/sched/clock.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,6 @@
5353
* that is otherwise invisible (TSC gets stopped).
5454
*
5555
*/
56-
#include "sched.h"
57-
#include <linux/sched_clock.h>
5856

5957
/*
6058
* Scheduler clock - returns current time in nanosec units.

kernel/sched/completion.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// SPDX-License-Identifier: GPL-2.0
2+
23
/*
34
* Generic wait-for-completion handler;
45
*
@@ -11,7 +12,6 @@
1112
* typically be used for exclusion which gives rise to priority inversion.
1213
* Waiting for completion is a typically sync point, but not an exclusion point.
1314
*/
14-
#include "sched.h"
1515

1616
/**
1717
* complete: - signals a single thread waiting on this completion

kernel/sched/core_sched.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
// SPDX-License-Identifier: GPL-2.0-only
22

3-
#include <linux/prctl.h>
4-
#include "sched.h"
5-
63
/*
74
* A simple wrapper around refcount. An allocated sched_core_cookie's
85
* address is used to compute the cookie of the task.

kernel/sched/cpuacct.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
// SPDX-License-Identifier: GPL-2.0
2+
23
/*
34
* CPU accounting code for task groups.
45
*
56
* Based on the work by Paul Menage (menage@google.com) and Balbir Singh
67
* (balbir@in.ibm.com).
78
*/
8-
#include <asm/irq_regs.h>
9-
#include "sched.h"
109

1110
/* Time spent by the tasks of the CPU accounting group executing in ... */
1211
enum cpuacct_stat_index {

kernel/sched/cpufreq.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@
55
* Copyright (C) 2016, Intel Corporation
66
* Author: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
77
*/
8-
#include <linux/cpufreq.h>
9-
10-
#include "sched.h"
118

129
DEFINE_PER_CPU(struct update_util_data __rcu *, cpufreq_update_util_data);
1310

kernel/sched/cpufreq_schedutil.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,6 @@
66
* Author: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
77
*/
88

9-
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
10-
11-
#include "sched.h"
12-
13-
#include <linux/sched/cpufreq.h>
14-
#include <trace/events/power.h>
15-
169
#define IOWAIT_BOOST_MIN (SCHED_CAPACITY_SCALE / 8)
1710

1811
struct sugov_tunables {

kernel/sched/cpupri.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
* worst case complexity of O(min(101, nr_domcpus)), though the scenario that
2323
* yields the worst case search is fairly contrived.
2424
*/
25-
#include "sched.h"
2625

2726
/*
2827
* p->rt_priority p->prio newpri cpupri

0 commit comments

Comments
 (0)