Skip to content

Commit 325ea10

Browse files
author
Ingo Molnar
committed
sched/headers: Simplify and clean up header usage in the scheduler
Do the following cleanups and simplifications: - sched/sched.h already includes <asm/paravirt.h>, so no need to include it in sched/core.c again. - order the <linux/sched/*.h> headers alphabetically - add all <linux/sched/*.h> headers to kernel/sched/sched.h - remove all unnecessary includes from the .c files that are already included in kernel/sched/sched.h. Finally, make all scheduler .c files use a single common header: #include "sched.h" ... which now contains a union of the relied upon headers. This makes the various .c files easier to read and easier to handle. Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Mike Galbraith <efault@gmx.de> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: linux-kernel@vger.kernel.org Signed-off-by: Ingo Molnar <mingo@kernel.org>
1 parent 97fb7a0 commit 325ea10

29 files changed

+94
-219
lines changed

include/linux/sched/deadline.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
11
/* SPDX-License-Identifier: GPL-2.0 */
2-
#ifndef _LINUX_SCHED_DEADLINE_H
3-
#define _LINUX_SCHED_DEADLINE_H
4-
5-
#include <linux/sched.h>
62

73
/*
84
* SCHED_DEADLINE tasks has negative priorities, reflecting
@@ -28,5 +24,3 @@ static inline bool dl_time_before(u64 a, u64 b)
2824
{
2925
return (s64)(a - b) < 0;
3026
}
31-
32-
#endif /* _LINUX_SCHED_DEADLINE_H */

kernel/sched/autogroup.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
// SPDX-License-Identifier: GPL-2.0
2-
#include <linux/proc_fs.h>
3-
#include <linux/seq_file.h>
4-
#include <linux/utsname.h>
5-
#include <linux/security.h>
6-
#include <linux/export.h>
7-
2+
/*
3+
* Auto-group scheduling implementation:
4+
*/
85
#include "sched.h"
96

107
unsigned int __read_mostly sysctl_sched_autogroup_enabled = 1;

kernel/sched/autogroup.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
/* SPDX-License-Identifier: GPL-2.0 */
22
#ifdef CONFIG_SCHED_AUTOGROUP
33

4-
#include <linux/kref.h>
5-
#include <linux/rwsem.h>
6-
#include <linux/sched/autogroup.h>
7-
84
struct autogroup {
95
/*
106
* Reference doesn't mean how many threads attach to this

kernel/sched/clock.c

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -52,19 +52,7 @@
5252
* that is otherwise invisible (TSC gets stopped).
5353
*
5454
*/
55-
#include <linux/spinlock.h>
56-
#include <linux/hardirq.h>
57-
#include <linux/export.h>
58-
#include <linux/percpu.h>
59-
#include <linux/ktime.h>
60-
#include <linux/sched.h>
61-
#include <linux/nmi.h>
62-
#include <linux/sched/clock.h>
63-
#include <linux/static_key.h>
64-
#include <linux/workqueue.h>
65-
#include <linux/compiler.h>
66-
#include <linux/tick.h>
67-
#include <linux/init.h>
55+
#include "sched.h"
6856

6957
/*
7058
* Scheduler clock - returns current time in nanosec units.

kernel/sched/completion.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,7 @@
1111
* typically be used for exclusion which gives rise to priority inversion.
1212
* Waiting for completion is a typically sync point, but not an exclusion point.
1313
*/
14-
15-
#include <linux/sched/signal.h>
16-
#include <linux/sched/debug.h>
17-
#include <linux/completion.h>
14+
#include "sched.h"
1815

1916
/**
2017
* complete: - signals a single thread waiting on this completion

kernel/sched/core.c

Lines changed: 13 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5,37 +5,11 @@
55
*
66
* Copyright (C) 1991-2002 Linus Torvalds
77
*/
8-
#include <linux/sched.h>
9-
#include <linux/sched/clock.h>
10-
#include <uapi/linux/sched/types.h>
11-
#include <linux/sched/loadavg.h>
12-
#include <linux/sched/hotplug.h>
13-
#include <linux/wait_bit.h>
14-
#include <linux/cpuset.h>
15-
#include <linux/delayacct.h>
16-
#include <linux/init_task.h>
17-
#include <linux/context_tracking.h>
18-
#include <linux/rcupdate_wait.h>
19-
#include <linux/compat.h>
20-
21-
#include <linux/blkdev.h>
22-
#include <linux/kprobes.h>
23-
#include <linux/mmu_context.h>
24-
#include <linux/module.h>
25-
#include <linux/nmi.h>
26-
#include <linux/prefetch.h>
27-
#include <linux/profile.h>
28-
#include <linux/security.h>
29-
#include <linux/syscalls.h>
30-
#include <linux/sched/isolation.h>
8+
#include "sched.h"
319

3210
#include <asm/switch_to.h>
3311
#include <asm/tlb.h>
34-
#ifdef CONFIG_PARAVIRT
35-
#include <asm/paravirt.h>
36-
#endif
3712

38-
#include "sched.h"
3913
#include "../workqueue_internal.h"
4014
#include "../smpboot.h"
4115

@@ -2629,6 +2603,18 @@ static inline void finish_lock_switch(struct rq *rq)
26292603
raw_spin_unlock_irq(&rq->lock);
26302604
}
26312605

2606+
/*
2607+
* NOP if the arch has not defined these:
2608+
*/
2609+
2610+
#ifndef prepare_arch_switch
2611+
# define prepare_arch_switch(next) do { } while (0)
2612+
#endif
2613+
2614+
#ifndef finish_arch_post_lock_switch
2615+
# define finish_arch_post_lock_switch() do { } while (0)
2616+
#endif
2617+
26322618
/**
26332619
* prepare_task_switch - prepare to switch tasks
26342620
* @rq: the runqueue preparing to switch

kernel/sched/cpuacct.c

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,11 @@
11
// SPDX-License-Identifier: GPL-2.0
2-
#include <linux/cgroup.h>
3-
#include <linux/slab.h>
4-
#include <linux/percpu.h>
5-
#include <linux/spinlock.h>
6-
#include <linux/cpumask.h>
7-
#include <linux/seq_file.h>
8-
#include <linux/rcupdate.h>
9-
#include <linux/kernel_stat.h>
10-
#include <linux/err.h>
11-
12-
#include "sched.h"
13-
142
/*
153
* CPU accounting code for task groups.
164
*
175
* Based on the work by Paul Menage (menage@google.com) and Balbir Singh
186
* (balbir@in.ibm.com).
197
*/
8+
#include "sched.h"
209

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

kernel/sched/cpudeadline.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,7 @@
1010
* as published by the Free Software Foundation; version 2
1111
* of the License.
1212
*/
13-
#include <linux/gfp.h>
14-
#include <linux/kernel.h>
15-
#include <linux/slab.h>
16-
#include "cpudeadline.h"
13+
#include "sched.h"
1714

1815
static inline int parent(int i)
1916
{

kernel/sched/cpudeadline.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
/* SPDX-License-Identifier: GPL-2.0 */
2-
#include <linux/sched.h>
3-
#include <linux/sched/deadline.h>
42

53
#define IDX_INVALID -1
64

kernel/sched/cpufreq.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
* it under the terms of the GNU General Public License version 2 as
99
* published by the Free Software Foundation.
1010
*/
11-
1211
#include "sched.h"
1312

1413
DEFINE_PER_CPU(struct update_util_data *, cpufreq_update_util_data);

kernel/sched/cpufreq_schedutil.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,10 @@
1111

1212
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
1313

14-
#include <linux/cpufreq.h>
15-
#include <linux/kthread.h>
16-
#include <uapi/linux/sched/types.h>
17-
#include <linux/slab.h>
18-
#include <trace/events/power.h>
19-
2014
#include "sched.h"
2115

16+
#include <trace/events/power.h>
17+
2218
struct sugov_tunables {
2319
struct gov_attr_set attr_set;
2420
unsigned int rate_limit_us;

kernel/sched/cpupri.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,7 @@
2626
* as published by the Free Software Foundation; version 2
2727
* of the License.
2828
*/
29-
#include <linux/gfp.h>
30-
#include <linux/sched.h>
31-
#include <linux/sched/rt.h>
32-
#include <linux/slab.h>
33-
#include "cpupri.h"
29+
#include "sched.h"
3430

3531
/* Convert between a 140 based task->prio, and our 102 based cpupri */
3632
static int convert_prio(int prio)

kernel/sched/cpupri.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/* SPDX-License-Identifier: GPL-2.0 */
2-
#include <linux/sched.h>
32

43
#define CPUPRI_NR_PRIORITIES (MAX_RT_PRIO + 2)
54

kernel/sched/cputime.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
1-
#include <linux/export.h>
2-
#include <linux/sched.h>
3-
#include <linux/tsacct_kern.h>
4-
#include <linux/kernel_stat.h>
5-
#include <linux/static_key.h>
6-
#include <linux/context_tracking.h>
7-
#include <linux/sched/cputime.h>
1+
/*
2+
* Simple CPU accounting cgroup controller
3+
*/
84
#include "sched.h"
95

106
#ifdef CONFIG_IRQ_TIME_ACCOUNTING

kernel/sched/deadline.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@
1717
*/
1818
#include "sched.h"
1919

20-
#include <linux/slab.h>
21-
#include <uapi/linux/sched/types.h>
22-
2320
struct dl_bandwidth def_dl_bandwidth;
2421

2522
static inline struct task_struct *dl_task_of(struct sched_dl_entity *dl_se)

kernel/sched/debug.c

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,14 @@
11
/*
22
* kernel/sched/debug.c
33
*
4-
* Print the CFS rbtree
4+
* Print the CFS rbtree and other debugging details
55
*
66
* Copyright(C) 2007, Red Hat, Inc., Ingo Molnar
77
*
88
* This program is free software; you can redistribute it and/or modify
99
* it under the terms of the GNU General Public License version 2 as
1010
* published by the Free Software Foundation.
1111
*/
12-
#include <linux/proc_fs.h>
13-
#include <linux/sched/mm.h>
14-
#include <linux/sched/task.h>
15-
#include <linux/seq_file.h>
16-
#include <linux/kallsyms.h>
17-
#include <linux/utsname.h>
18-
#include <linux/mempolicy.h>
19-
#include <linux/debugfs.h>
20-
2112
#include "sched.h"
2213

2314
static DEFINE_SPINLOCK(sched_debug_lock);

kernel/sched/fair.c

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,24 +20,10 @@
2020
* Adaptive scheduling granularity, math enhancements by Peter Zijlstra
2121
* Copyright (C) 2007 Red Hat, Inc., Peter Zijlstra
2222
*/
23-
#include <linux/sched/mm.h>
24-
#include <linux/sched/topology.h>
25-
26-
#include <linux/latencytop.h>
27-
#include <linux/cpumask.h>
28-
#include <linux/cpuidle.h>
29-
#include <linux/slab.h>
30-
#include <linux/profile.h>
31-
#include <linux/interrupt.h>
32-
#include <linux/mempolicy.h>
33-
#include <linux/migrate.h>
34-
#include <linux/task_work.h>
35-
#include <linux/sched/isolation.h>
23+
#include "sched.h"
3624

3725
#include <trace/events/sched.h>
3826

39-
#include "sched.h"
40-
4127
/*
4228
* Targeted preemption latency for CPU-bound tasks:
4329
*

kernel/sched/idle.c

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,10 @@
11
/*
22
* Generic entry points for the idle threads
33
*/
4-
#include <linux/sched.h>
5-
#include <linux/sched/idle.h>
6-
#include <linux/cpu.h>
7-
#include <linux/cpuidle.h>
8-
#include <linux/cpuhotplug.h>
9-
#include <linux/tick.h>
10-
#include <linux/mm.h>
11-
#include <linux/stackprotector.h>
12-
#include <linux/suspend.h>
13-
#include <linux/livepatch.h>
14-
15-
#include <asm/tlb.h>
4+
#include "sched.h"
165

176
#include <trace/events/power.h>
187

19-
#include "sched.h"
20-
218
/* Linker adds these: start and end of __cpuidle functions */
229
extern char __cpuidle_text_start[], __cpuidle_text_end[];
2310

kernel/sched/idle_task.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
// SPDX-License-Identifier: GPL-2.0
2-
#include "sched.h"
3-
42
/*
53
* idle-task scheduling class.
64
*
7-
* (NOTE: these are not related to SCHED_IDLE tasks which are
5+
* (NOTE: these are not related to SCHED_IDLE batch scheduling tasks which are
86
* handled in sched/fair.c)
97
*/
8+
#include "sched.h"
109

1110
#ifdef CONFIG_SMP
1211
static int

kernel/sched/isolation.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,6 @@
66
* Copyright (C) 2017-2018 SUSE, Frederic Weisbecker
77
*
88
*/
9-
#include <linux/sched/isolation.h>
10-
#include <linux/tick.h>
11-
#include <linux/init.h>
12-
#include <linux/kernel.h>
13-
#include <linux/static_key.h>
14-
#include <linux/ctype.h>
15-
169
#include "sched.h"
1710

1811
DEFINE_STATIC_KEY_FALSE(housekeeping_overriden);

kernel/sched/loadavg.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@
66
* figure. Its a silly number but people think its important. We go through
77
* great pains to make it work on big machines and tickless kernels.
88
*/
9-
10-
#include <linux/export.h>
11-
#include <linux/sched/loadavg.h>
12-
139
#include "sched.h"
1410

1511
/*

kernel/sched/membarrier.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,7 @@
1313
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1414
* GNU General Public License for more details.
1515
*/
16-
17-
#include <linux/syscalls.h>
18-
#include <linux/membarrier.h>
19-
#include <linux/tick.h>
20-
#include <linux/cpumask.h>
21-
#include <linux/atomic.h>
22-
23-
#include "sched.h" /* for cpu_rq(). */
16+
#include "sched.h"
2417

2518
/*
2619
* Bitmask made from a "or" of all commands within enum membarrier_cmd,

kernel/sched/rt.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,8 @@
33
* Real-Time Scheduling Class (mapped to the SCHED_FIFO and SCHED_RR
44
* policies)
55
*/
6-
76
#include "sched.h"
87

9-
#include <linux/slab.h>
10-
#include <linux/irq_work.h>
11-
128
int sched_rr_timeslice = RR_TIMESLICE;
139
int sysctl_sched_rr_timeslice = (MSEC_PER_SEC / HZ) * RR_TIMESLICE;
1410

0 commit comments

Comments
 (0)