diff options
author | Ingo Molnar <mingo@kernel.org> | 2017-03-05 07:09:07 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2017-06-20 06:19:14 -0400 |
commit | 5822a454d6d22297c5fcd66264120587b2ec21cd (patch) | |
tree | 0c05d2c4c95dc1d6c234b5d5f030dc35147a6676 | |
parent | 5dd43ce2f69d42a71dcacdb13d17d8c0ac1fe8f7 (diff) |
sched/wait: Move bit_wait_table[] and related functionality from sched/core.c to sched/wait_bit.c
The key hashed waitqueue data structures and their initialization
was done in the main scheduler file for no good reason, move them
to sched/wait_bit.c instead.
Cc: Linus Torvalds <torvalds@linux-foundation.org>
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>
-rw-r--r-- | include/linux/wait_bit.h | 1 | ||||
-rw-r--r-- | kernel/sched/core.c | 18 | ||||
-rw-r--r-- | kernel/sched/wait_bit.c | 23 |
3 files changed, 26 insertions, 16 deletions
diff --git a/include/linux/wait_bit.h b/include/linux/wait_bit.h index 8c85c52d94b6..9cc82114dbcb 100644 --- a/include/linux/wait_bit.h +++ b/include/linux/wait_bit.h | |||
@@ -35,6 +35,7 @@ int out_of_line_wait_on_bit_timeout(void *word, int, wait_bit_action_f *action, | |||
35 | int out_of_line_wait_on_bit_lock(void *word, int, wait_bit_action_f *action, unsigned int mode); | 35 | int out_of_line_wait_on_bit_lock(void *word, int, wait_bit_action_f *action, unsigned int mode); |
36 | int out_of_line_wait_on_atomic_t(atomic_t *p, int (*)(atomic_t *), unsigned int mode); | 36 | int out_of_line_wait_on_atomic_t(atomic_t *p, int (*)(atomic_t *), unsigned int mode); |
37 | struct wait_queue_head *bit_waitqueue(void *word, int bit); | 37 | struct wait_queue_head *bit_waitqueue(void *word, int bit); |
38 | extern void __init wait_bit_init(void); | ||
38 | 39 | ||
39 | int wake_bit_function(struct wait_queue_entry *wq_entry, unsigned mode, int sync, void *key); | 40 | int wake_bit_function(struct wait_queue_entry *wq_entry, unsigned mode, int sync, void *key); |
40 | 41 | ||
diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 5b36644536ab..e7b9ef8df126 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c | |||
@@ -10,6 +10,7 @@ | |||
10 | #include <uapi/linux/sched/types.h> | 10 | #include <uapi/linux/sched/types.h> |
11 | #include <linux/sched/loadavg.h> | 11 | #include <linux/sched/loadavg.h> |
12 | #include <linux/sched/hotplug.h> | 12 | #include <linux/sched/hotplug.h> |
13 | #include <linux/wait_bit.h> | ||
13 | #include <linux/cpuset.h> | 14 | #include <linux/cpuset.h> |
14 | #include <linux/delayacct.h> | 15 | #include <linux/delayacct.h> |
15 | #include <linux/init_task.h> | 16 | #include <linux/init_task.h> |
@@ -6026,28 +6027,13 @@ static struct kmem_cache *task_group_cache __read_mostly; | |||
6026 | DECLARE_PER_CPU(cpumask_var_t, load_balance_mask); | 6027 | DECLARE_PER_CPU(cpumask_var_t, load_balance_mask); |
6027 | DECLARE_PER_CPU(cpumask_var_t, select_idle_mask); | 6028 | DECLARE_PER_CPU(cpumask_var_t, select_idle_mask); |
6028 | 6029 | ||
6029 | #define WAIT_TABLE_BITS 8 | ||
6030 | #define WAIT_TABLE_SIZE (1 << WAIT_TABLE_BITS) | ||
6031 | static wait_queue_head_t bit_wait_table[WAIT_TABLE_SIZE] __cacheline_aligned; | ||
6032 | |||
6033 | wait_queue_head_t *bit_waitqueue(void *word, int bit) | ||
6034 | { | ||
6035 | const int shift = BITS_PER_LONG == 32 ? 5 : 6; | ||
6036 | unsigned long val = (unsigned long)word << shift | bit; | ||
6037 | |||
6038 | return bit_wait_table + hash_long(val, WAIT_TABLE_BITS); | ||
6039 | } | ||
6040 | EXPORT_SYMBOL(bit_waitqueue); | ||
6041 | |||
6042 | void __init sched_init(void) | 6030 | void __init sched_init(void) |
6043 | { | 6031 | { |
6044 | int i, j; | 6032 | int i, j; |
6045 | unsigned long alloc_size = 0, ptr; | 6033 | unsigned long alloc_size = 0, ptr; |
6046 | 6034 | ||
6047 | sched_clock_init(); | 6035 | sched_clock_init(); |
6048 | 6036 | wait_bit_init(); | |
6049 | for (i = 0; i < WAIT_TABLE_SIZE; i++) | ||
6050 | init_waitqueue_head(bit_wait_table + i); | ||
6051 | 6037 | ||
6052 | #ifdef CONFIG_FAIR_GROUP_SCHED | 6038 | #ifdef CONFIG_FAIR_GROUP_SCHED |
6053 | alloc_size += 2 * nr_cpu_ids * sizeof(void **); | 6039 | alloc_size += 2 * nr_cpu_ids * sizeof(void **); |
diff --git a/kernel/sched/wait_bit.c b/kernel/sched/wait_bit.c index 463bac84dfd1..c891b34e1896 100644 --- a/kernel/sched/wait_bit.c +++ b/kernel/sched/wait_bit.c | |||
@@ -4,6 +4,21 @@ | |||
4 | #include <linux/wait_bit.h> | 4 | #include <linux/wait_bit.h> |
5 | #include <linux/sched/signal.h> | 5 | #include <linux/sched/signal.h> |
6 | #include <linux/sched/debug.h> | 6 | #include <linux/sched/debug.h> |
7 | #include <linux/hash.h> | ||
8 | |||
9 | #define WAIT_TABLE_BITS 8 | ||
10 | #define WAIT_TABLE_SIZE (1 << WAIT_TABLE_BITS) | ||
11 | |||
12 | static wait_queue_head_t bit_wait_table[WAIT_TABLE_SIZE] __cacheline_aligned; | ||
13 | |||
14 | wait_queue_head_t *bit_waitqueue(void *word, int bit) | ||
15 | { | ||
16 | const int shift = BITS_PER_LONG == 32 ? 5 : 6; | ||
17 | unsigned long val = (unsigned long)word << shift | bit; | ||
18 | |||
19 | return bit_wait_table + hash_long(val, WAIT_TABLE_BITS); | ||
20 | } | ||
21 | EXPORT_SYMBOL(bit_waitqueue); | ||
7 | 22 | ||
8 | int wake_bit_function(struct wait_queue_entry *wq_entry, unsigned mode, int sync, void *arg) | 23 | int wake_bit_function(struct wait_queue_entry *wq_entry, unsigned mode, int sync, void *arg) |
9 | { | 24 | { |
@@ -261,3 +276,11 @@ __sched int bit_wait_io_timeout(struct wait_bit_key *word, int mode) | |||
261 | return 0; | 276 | return 0; |
262 | } | 277 | } |
263 | EXPORT_SYMBOL_GPL(bit_wait_io_timeout); | 278 | EXPORT_SYMBOL_GPL(bit_wait_io_timeout); |
279 | |||
280 | void __init wait_bit_init(void) | ||
281 | { | ||
282 | int i; | ||
283 | |||
284 | for (i = 0; i < WAIT_TABLE_SIZE; i++) | ||
285 | init_waitqueue_head(bit_wait_table + i); | ||
286 | } | ||