diff options
author | Ingo Molnar <mingo@elte.hu> | 2006-07-03 03:25:12 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-07-03 18:27:07 -0400 |
commit | da21f24dd73954c2ed0cd39a698e2c9916c05d71 (patch) | |
tree | 22829e3791f0602d284b8f5398526b228faa9501 | |
parent | 543655244866b8ec648fea1eb9c32a35ffba5721 (diff) |
[PATCH] lockdep: annotate sock_lock_init()
Teach special (multi-initialized, per-address-family) locking code to the lock
validator. Has no effect on non-lockdep kernels.
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Arjan van de Ven <arjan@linux.intel.com>
Cc: "David S. Miller" <davem@davemloft.net>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r-- | include/net/sock.h | 4 | ||||
-rw-r--r-- | net/core/sock.c | 16 |
2 files changed, 20 insertions, 0 deletions
diff --git a/include/net/sock.h b/include/net/sock.h index 7b3d6b856946..83805feea880 100644 --- a/include/net/sock.h +++ b/include/net/sock.h | |||
@@ -80,8 +80,12 @@ typedef struct { | |||
80 | wait_queue_head_t wq; | 80 | wait_queue_head_t wq; |
81 | } socket_lock_t; | 81 | } socket_lock_t; |
82 | 82 | ||
83 | extern struct lock_class_key af_family_keys[AF_MAX]; | ||
84 | |||
83 | #define sock_lock_init(__sk) \ | 85 | #define sock_lock_init(__sk) \ |
84 | do { spin_lock_init(&((__sk)->sk_lock.slock)); \ | 86 | do { spin_lock_init(&((__sk)->sk_lock.slock)); \ |
87 | lockdep_set_class(&(__sk)->sk_lock.slock, \ | ||
88 | af_family_keys + (__sk)->sk_family); \ | ||
85 | (__sk)->sk_lock.owner = NULL; \ | 89 | (__sk)->sk_lock.owner = NULL; \ |
86 | init_waitqueue_head(&((__sk)->sk_lock.wq)); \ | 90 | init_waitqueue_head(&((__sk)->sk_lock.wq)); \ |
87 | } while(0) | 91 | } while(0) |
diff --git a/net/core/sock.c b/net/core/sock.c index 533b9317144b..0b4d5d25b23c 100644 --- a/net/core/sock.c +++ b/net/core/sock.c | |||
@@ -129,6 +129,18 @@ | |||
129 | #include <net/tcp.h> | 129 | #include <net/tcp.h> |
130 | #endif | 130 | #endif |
131 | 131 | ||
132 | /* | ||
133 | * Each address family might have different locking rules, so we have | ||
134 | * one slock key per address family: | ||
135 | */ | ||
136 | struct lock_class_key af_family_keys[AF_MAX]; | ||
137 | |||
138 | /* | ||
139 | * sk_callback_lock locking rules are per-address-family, | ||
140 | * so split the lock classes by using a per-AF key: | ||
141 | */ | ||
142 | static struct lock_class_key af_callback_keys[AF_MAX]; | ||
143 | |||
132 | /* Take into consideration the size of the struct sk_buff overhead in the | 144 | /* Take into consideration the size of the struct sk_buff overhead in the |
133 | * determination of these values, since that is non-constant across | 145 | * determination of these values, since that is non-constant across |
134 | * platforms. This makes socket queueing behavior and performance | 146 | * platforms. This makes socket queueing behavior and performance |
@@ -848,6 +860,8 @@ struct sock *sk_clone(const struct sock *sk, const gfp_t priority) | |||
848 | 860 | ||
849 | rwlock_init(&newsk->sk_dst_lock); | 861 | rwlock_init(&newsk->sk_dst_lock); |
850 | rwlock_init(&newsk->sk_callback_lock); | 862 | rwlock_init(&newsk->sk_callback_lock); |
863 | lockdep_set_class(&newsk->sk_callback_lock, | ||
864 | af_callback_keys + newsk->sk_family); | ||
851 | 865 | ||
852 | newsk->sk_dst_cache = NULL; | 866 | newsk->sk_dst_cache = NULL; |
853 | newsk->sk_wmem_queued = 0; | 867 | newsk->sk_wmem_queued = 0; |
@@ -1422,6 +1436,8 @@ void sock_init_data(struct socket *sock, struct sock *sk) | |||
1422 | 1436 | ||
1423 | rwlock_init(&sk->sk_dst_lock); | 1437 | rwlock_init(&sk->sk_dst_lock); |
1424 | rwlock_init(&sk->sk_callback_lock); | 1438 | rwlock_init(&sk->sk_callback_lock); |
1439 | lockdep_set_class(&sk->sk_callback_lock, | ||
1440 | af_callback_keys + sk->sk_family); | ||
1425 | 1441 | ||
1426 | sk->sk_state_change = sock_def_wakeup; | 1442 | sk->sk_state_change = sock_def_wakeup; |
1427 | sk->sk_data_ready = sock_def_readable; | 1443 | sk->sk_data_ready = sock_def_readable; |