locking, sched: Give waitqueue spinlocks their own lockdep classes

Give waitqueue spinlocks their own lockdep classes when they
are initialised from init_waitqueue_head(). This means that
struct wait_queue::func functions can operate other waitqueues.

This is used by CacheFiles to catch the page from a backing fs
being unlocked and to wake up another thread to take a copy of
it.

Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Signed-off-by: David Howells <dhowells@redhat.com>
Tested-by: Takashi Iwai <tiwai@suse.de>
Cc: linux-cachefs@redhat.com
Cc: torvalds@osdl.org
Cc: akpm@linux-foundation.org
LKML-Reference: <20090810113305.17284.81508.stgit@warthog.procyon.org.uk>
Signed-off-by: Ingo Molnar <mingo@elte.hu>

authored by Peter Zijlstra and committed by Ingo Molnar 2fc39111 beda2c7e

+11 -3
+8 -1
include/linux/wait.h
··· 77 #define __WAIT_BIT_KEY_INITIALIZER(word, bit) \ 78 { .flags = word, .bit_nr = bit, } 79 80 - extern void init_waitqueue_head(wait_queue_head_t *q); 81 82 #ifdef CONFIG_LOCKDEP 83 # define __WAIT_QUEUE_HEAD_INIT_ONSTACK(name) \
··· 77 #define __WAIT_BIT_KEY_INITIALIZER(word, bit) \ 78 { .flags = word, .bit_nr = bit, } 79 80 + extern void __init_waitqueue_head(wait_queue_head_t *q, struct lock_class_key *); 81 + 82 + #define init_waitqueue_head(q) \ 83 + do { \ 84 + static struct lock_class_key __key; \ 85 + \ 86 + __init_waitqueue_head((q), &__key); \ 87 + } while (0) 88 89 #ifdef CONFIG_LOCKDEP 90 # define __WAIT_QUEUE_HEAD_INIT_ONSTACK(name) \
+3 -2
kernel/wait.c
··· 10 #include <linux/wait.h> 11 #include <linux/hash.h> 12 13 - void init_waitqueue_head(wait_queue_head_t *q) 14 { 15 spin_lock_init(&q->lock); 16 INIT_LIST_HEAD(&q->task_list); 17 } 18 19 - EXPORT_SYMBOL(init_waitqueue_head); 20 21 void add_wait_queue(wait_queue_head_t *q, wait_queue_t *wait) 22 {
··· 10 #include <linux/wait.h> 11 #include <linux/hash.h> 12 13 + void __init_waitqueue_head(wait_queue_head_t *q, struct lock_class_key *key) 14 { 15 spin_lock_init(&q->lock); 16 + lockdep_set_class(&q->lock, key); 17 INIT_LIST_HEAD(&q->task_list); 18 } 19 20 + EXPORT_SYMBOL(__init_waitqueue_head); 21 22 void add_wait_queue(wait_queue_head_t *q, wait_queue_t *wait) 23 {