Skip to content

Commit 325ea10

Browse files
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

Lines changed: 94 additions & 219 deletions

‎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);

0 commit comments

Comments
 (0)