summaryrefslogtreecommitdiff
path: root/kernel/sched/wait_bit.c
diff options
context:
space:
mode:
authorIngo Molnar <mingo@kernel.org>2017-03-05 15:09:07 +0300
committerIngo Molnar <mingo@kernel.org>2017-06-20 13:19:14 +0300
commit5822a454d6d22297c5fcd66264120587b2ec21cd (patch)
tree0c05d2c4c95dc1d6c234b5d5f030dc35147a6676 /kernel/sched/wait_bit.c
parent5dd43ce2f69d42a71dcacdb13d17d8c0ac1fe8f7 (diff)
downloadlinux-5822a454d6d22297c5fcd66264120587b2ec21cd.tar.xz
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>
Diffstat (limited to 'kernel/sched/wait_bit.c')
-rw-r--r--kernel/sched/wait_bit.c23
1 files changed, 23 insertions, 0 deletions
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 @@
#include <linux/wait_bit.h>
#include <linux/sched/signal.h>
#include <linux/sched/debug.h>
+#include <linux/hash.h>
+
+#define WAIT_TABLE_BITS 8
+#define WAIT_TABLE_SIZE (1 << WAIT_TABLE_BITS)
+
+static wait_queue_head_t bit_wait_table[WAIT_TABLE_SIZE] __cacheline_aligned;
+
+wait_queue_head_t *bit_waitqueue(void *word, int bit)
+{
+ const int shift = BITS_PER_LONG == 32 ? 5 : 6;
+ unsigned long val = (unsigned long)word << shift | bit;
+
+ return bit_wait_table + hash_long(val, WAIT_TABLE_BITS);
+}
+EXPORT_SYMBOL(bit_waitqueue);
int wake_bit_function(struct wait_queue_entry *wq_entry, unsigned mode, int sync, void *arg)
{
@@ -261,3 +276,11 @@ __sched int bit_wait_io_timeout(struct wait_bit_key *word, int mode)
return 0;
}
EXPORT_SYMBOL_GPL(bit_wait_io_timeout);
+
+void __init wait_bit_init(void)
+{
+ int i;
+
+ for (i = 0; i < WAIT_TABLE_SIZE; i++)
+ init_waitqueue_head(bit_wait_table + i);
+}