]> git.samba.org - sfrench/cifs-2.6.git/commitdiff
[PATCH] lockdep: annotate sock_lock_init()
authorIngo Molnar <mingo@elte.hu>
Mon, 3 Jul 2006 07:25:12 +0000 (00:25 -0700)
committerLinus Torvalds <torvalds@g5.osdl.org>
Mon, 3 Jul 2006 22:27:07 +0000 (15:27 -0700)
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>
include/net/sock.h
net/core/sock.c

index 7b3d6b856946d7689aa430e157927bef0741eff2..83805feea8800581a7477b08fc754e3bbb0b44fa 100644 (file)
@@ -80,8 +80,12 @@ typedef struct {
        wait_queue_head_t       wq;
 } socket_lock_t;
 
+extern struct lock_class_key af_family_keys[AF_MAX];
+
 #define sock_lock_init(__sk) \
 do {   spin_lock_init(&((__sk)->sk_lock.slock)); \
+       lockdep_set_class(&(__sk)->sk_lock.slock, \
+                         af_family_keys + (__sk)->sk_family); \
        (__sk)->sk_lock.owner = NULL; \
        init_waitqueue_head(&((__sk)->sk_lock.wq)); \
 } while(0)
index 533b9317144ba82d46a8243aa5df93a5cc29f913..0b4d5d25b23c5e09d2ca8391eac8b4252f4b3785 100644 (file)
 #include <net/tcp.h>
 #endif
 
+/*
+ * Each address family might have different locking rules, so we have
+ * one slock key per address family:
+ */
+struct lock_class_key af_family_keys[AF_MAX];
+
+/*
+ * sk_callback_lock locking rules are per-address-family,
+ * so split the lock classes by using a per-AF key:
+ */
+static struct lock_class_key af_callback_keys[AF_MAX];
+
 /* Take into consideration the size of the struct sk_buff overhead in the
  * determination of these values, since that is non-constant across
  * platforms.  This makes socket queueing behavior and performance
@@ -848,6 +860,8 @@ struct sock *sk_clone(const struct sock *sk, const gfp_t priority)
 
                rwlock_init(&newsk->sk_dst_lock);
                rwlock_init(&newsk->sk_callback_lock);
+               lockdep_set_class(&newsk->sk_callback_lock,
+                                  af_callback_keys + newsk->sk_family);
 
                newsk->sk_dst_cache     = NULL;
                newsk->sk_wmem_queued   = 0;
@@ -1422,6 +1436,8 @@ void sock_init_data(struct socket *sock, struct sock *sk)
 
        rwlock_init(&sk->sk_dst_lock);
        rwlock_init(&sk->sk_callback_lock);
+       lockdep_set_class(&sk->sk_callback_lock,
+                          af_callback_keys + sk->sk_family);
 
        sk->sk_state_change     =       sock_def_wakeup;
        sk->sk_data_ready       =       sock_def_readable;