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>
This commit is contained in:
Ingo Molnar 2022-02-22 13:23:24 +01:00
Родитель fbed5664b7
Коммит 801c141955
22 изменённых файлов: 139 добавлений и 63 удалений

Просмотреть файл

@ -22,18 +22,13 @@ ifneq ($(CONFIG_SCHED_OMIT_FRAME_POINTER),y)
CFLAGS_core.o := $(PROFILING) -fno-omit-frame-pointer
endif
obj-y += core.o loadavg.o clock.o cputime.o
obj-y += idle.o fair.o rt.o deadline.o
obj-y += wait.o wait_bit.o swait.o completion.o
obj-$(CONFIG_SMP) += cpupri.o cpudeadline.o topology.o stop_task.o pelt.o
obj-$(CONFIG_SCHED_AUTOGROUP) += autogroup.o
obj-$(CONFIG_SCHEDSTATS) += stats.o
obj-$(CONFIG_SCHED_DEBUG) += debug.o
obj-$(CONFIG_CGROUP_CPUACCT) += cpuacct.o
obj-$(CONFIG_CPU_FREQ) += cpufreq.o
obj-$(CONFIG_CPU_FREQ_GOV_SCHEDUTIL) += cpufreq_schedutil.o
obj-$(CONFIG_MEMBARRIER) += membarrier.o
obj-$(CONFIG_CPU_ISOLATION) += isolation.o
obj-$(CONFIG_PSI) += psi.o
obj-$(CONFIG_SCHED_CORE) += core_sched.o
#
# Build efficiency:
#
# These compilation units have roughly the same size and complexity - so their
# build parallelizes well and finishes roughly at once:
#
obj-y += core.o
obj-y += fair.o
obj-y += build_utility.o
obj-y += idle.o rt.o deadline.o cputime.o cpudeadline.o pelt.o

Просмотреть файл

@ -1,9 +1,8 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Auto-group scheduling implementation:
*/
#include <linux/nospec.h>
#include "sched.h"
unsigned int __read_mostly sysctl_sched_autogroup_enabled = 1;
static struct autogroup autogroup_default;

Просмотреть файл

@ -0,0 +1,70 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* These are various utility functions of the scheduler,
* built in a single compilation unit for build efficiency reasons.
*
* ( Incidentally, the size of the compilation unit is roughly
* comparable to core.c, fair.c, smp.c and policy.c, the other
* big compilation units. This helps balance build time, while
* coalescing source files to amortize header inclusion
* cost. )
*/
#include "sched.h"
#include "sched-pelt.h"
#include <linux/sched_clock.h>
#include "clock.c"
#ifdef CONFIG_CGROUP_CPUACCT
# include "cpuacct.c"
#endif
#ifdef CONFIG_CPU_FREQ
# include "cpufreq.c"
#endif
#ifdef CONFIG_CPU_FREQ_GOV_SCHEDUTIL
# include "cpufreq_schedutil.c"
#endif
#ifdef CONFIG_SCHED_DEBUG
# include "debug.c"
#endif
#ifdef CONFIG_SCHEDSTATS
# include "stats.c"
#endif
#include "loadavg.c"
#include "completion.c"
#include "swait.c"
#include "wait_bit.c"
#include "wait.c"
#ifdef CONFIG_SMP
# include "cpupri.c"
# include "stop_task.c"
# include "topology.c"
#endif
#ifdef CONFIG_SCHED_CORE
# include "core_sched.c"
#endif
#ifdef CONFIG_PSI
# include "psi.c"
#endif
#ifdef CONFIG_MEMBARRIER
# include "membarrier.c"
#endif
#ifdef CONFIG_CPU_ISOLATION
# include "isolation.c"
#endif
#ifdef CONFIG_SCHED_AUTOGROUP
# include "autogroup.c"
#endif

Просмотреть файл

@ -53,8 +53,6 @@
* that is otherwise invisible (TSC gets stopped).
*
*/
#include "sched.h"
#include <linux/sched_clock.h>
/*
* Scheduler clock - returns current time in nanosec units.

Просмотреть файл

@ -1,4 +1,5 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Generic wait-for-completion handler;
*
@ -11,7 +12,6 @@
* typically be used for exclusion which gives rise to priority inversion.
* Waiting for completion is a typically sync point, but not an exclusion point.
*/
#include "sched.h"
/**
* complete: - signals a single thread waiting on this completion

Просмотреть файл

@ -1,8 +1,5 @@
// SPDX-License-Identifier: GPL-2.0-only
#include <linux/prctl.h>
#include "sched.h"
/*
* A simple wrapper around refcount. An allocated sched_core_cookie's
* address is used to compute the cookie of the task.

Просмотреть файл

@ -1,12 +1,11 @@
// SPDX-License-Identifier: GPL-2.0
/*
* CPU accounting code for task groups.
*
* Based on the work by Paul Menage (menage@google.com) and Balbir Singh
* (balbir@in.ibm.com).
*/
#include <asm/irq_regs.h>
#include "sched.h"
/* Time spent by the tasks of the CPU accounting group executing in ... */
enum cpuacct_stat_index {

Просмотреть файл

@ -5,9 +5,6 @@
* Copyright (C) 2016, Intel Corporation
* Author: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
*/
#include <linux/cpufreq.h>
#include "sched.h"
DEFINE_PER_CPU(struct update_util_data __rcu *, cpufreq_update_util_data);

Просмотреть файл

@ -6,13 +6,6 @@
* Author: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
*/
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include "sched.h"
#include <linux/sched/cpufreq.h>
#include <trace/events/power.h>
#define IOWAIT_BOOST_MIN (SCHED_CAPACITY_SCALE / 8)
struct sugov_tunables {

Просмотреть файл

@ -22,7 +22,6 @@
* worst case complexity of O(min(101, nr_domcpus)), though the scenario that
* yields the worst case search is fairly contrived.
*/
#include "sched.h"
/*
* p->rt_priority p->prio newpri cpupri

Просмотреть файл

@ -6,7 +6,6 @@
*
* Copyright(C) 2007, Red Hat, Inc., Ingo Molnar
*/
#include "sched.h"
/*
* This allows printing both to /proc/sched_debug and

Просмотреть файл

@ -7,7 +7,6 @@
* Copyright (C) 2017-2018 SUSE, Frederic Weisbecker
*
*/
#include "sched.h"
enum hk_flags {
HK_FLAG_TIMER = BIT(HK_TYPE_TIMER),

Просмотреть файл

@ -6,7 +6,6 @@
* figure. Its a silly number but people think its important. We go through
* great pains to make it work on big machines and tickless kernels.
*/
#include "sched.h"
/*
* Global load-average calculations

Просмотреть файл

@ -4,7 +4,6 @@
*
* membarrier system call
*/
#include "sched.h"
/*
* For documentation purposes, here are some membarrier ordering

Просмотреть файл

@ -137,21 +137,6 @@
* sampling of the aggregate task states would be.
*/
#include "../workqueue_internal.h"
#include <linux/sched/loadavg.h>
#include <linux/seq_file.h>
#include <linux/proc_fs.h>
#include <linux/seqlock.h>
#include <linux/uaccess.h>
#include <linux/cgroup.h>
#include <linux/module.h>
#include <linux/sched.h>
#include <linux/ctype.h>
#include <linux/file.h>
#include <linux/poll.h>
#include <linux/psi.h>
#include "sched.h"
static int psi_bug __read_mostly;
DEFINE_STATIC_KEY_FALSE(psi_disabled);

Просмотреть файл

@ -6,7 +6,25 @@
#define _KERNEL_SCHED_SCHED_H
#include <linux/sched.h>
#include <linux/cpumask.h>
#include <linux/ktime_api.h>
#include <linux/cgroup_api.h>
#include <linux/topology.h>
#include <linux/prctl.h>
#include <linux/ptrace_api.h>
#include <linux/gfp_api.h>
#include <linux/sched/clock.h>
#include <linux/workqueue_api.h>
#include <linux/tick.h>
#include <linux/ktime_api.h>
#include <linux/swait_api.h>
#include <linux/hashtable_api.h>
#include <linux/cpufreq.h>
#include <linux/utsname.h>
#include <asm/irq_regs.h>
#include <linux/sched/affinity.h>
#include <linux/sched/autogroup.h>
#include <linux/sched/clock.h>
#include <linux/sched/coredump.h>
@ -24,6 +42,7 @@
#include <linux/sched/nohz.h>
#include <linux/sched/numa_balancing.h>
#include <linux/sched/prio.h>
#include <linux/sched/rseq_api.h>
#include <linux/sched/rt.h>
#include <linux/sched/signal.h>
#include <linux/sched/smt.h>
@ -31,6 +50,7 @@
#include <linux/sched/sysctl.h>
#include <linux/sched/task.h>
#include <linux/sched/task_stack.h>
#include <linux/sched/thread_info_api.h>
#include <linux/sched/topology.h>
#include <linux/sched/user.h>
#include <linux/sched/wake_q.h>
@ -69,8 +89,7 @@
#include <linux/syscalls.h>
#include <linux/task_work.h>
#include <linux/tsacct_kern.h>
#include <asm/tlb.h>
#include <linux/hrtimer_api.h>
#ifdef CONFIG_PARAVIRT
# include <asm/paravirt.h>
@ -87,6 +106,40 @@
# define SCHED_WARN_ON(x) ({ (void)(x), 0; })
#endif
#include <linux/bitmap.h>
#include <linux/capability.h>
#include <linux/cgroup.h>
#include <linux/cpufreq.h>
#include <linux/cpumask_api.h>
#include <linux/ctype.h>
#include <linux/file.h>
#include <linux/jiffies.h>
#include <linux/kref_api.h>
#include <linux/lockdep_api.h>
#include <linux/module.h>
#include <linux/mutex_api.h>
#include <linux/poll.h>
#include <linux/proc_fs.h>
#include <linux/psi.h>
#include <linux/sched/affinity.h>
#include <linux/sched.h>
#include <linux/sched/loadavg.h>
#include <linux/sched/mm.h>
#include <linux/sched/rseq_api.h>
#include <linux/seq_file.h>
#include <linux/seqlock.h>
#include <linux/syscalls_api.h>
#include <linux/syscalls.h>
#include <linux/topology.h>
#include <linux/types.h>
#include <linux/uaccess.h>
#include <linux/wait_api.h>
#include <linux/workqueue_api.h>
#include <trace/events/power.h>
#include "../workqueue_internal.h"
struct rq;
struct cpuidle_state;

Просмотреть файл

@ -2,7 +2,6 @@
/*
* /proc/schedstat implementation
*/
#include "sched.h"
void __update_stats_wait_start(struct rq *rq, struct task_struct *p,
struct sched_statistics *stats)

Просмотреть файл

@ -7,7 +7,6 @@
*
* See kernel/stop_machine.c
*/
#include "sched.h"
#ifdef CONFIG_SMP
static int

Просмотреть файл

@ -2,7 +2,6 @@
/*
* <linux/swait.h> (simple wait queues ) implementation:
*/
#include "sched.h"
void __init_swait_queue_head(struct swait_queue_head *q, const char *name,
struct lock_class_key *key)

Просмотреть файл

@ -2,7 +2,6 @@
/*
* Scheduler topology setup/handling methods
*/
#include "sched.h"
DEFINE_MUTEX(sched_domains_mutex);

Просмотреть файл

@ -4,7 +4,6 @@
*
* (C) 2004 Nadia Yvette Chambers, Oracle
*/
#include "sched.h"
void __init_waitqueue_head(struct wait_queue_head *wq_head, const char *name, struct lock_class_key *key)
{

Просмотреть файл

@ -1,8 +1,8 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* The implementation of the wait_bit*() and related waiting APIs:
*/
#include "sched.h"
#define WAIT_TABLE_BITS 8
#define WAIT_TABLE_SIZE (1 << WAIT_TABLE_BITS)