From: Ingo Molnar 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 Signed-off-by: Arjan van de Ven Cc: "David S. Miller" Signed-off-by: Andrew Morton --- include/net/sock.h | 4 ++++ net/core/sock.c | 16 ++++++++++++++++ 2 files changed, 20 insertions(+) diff -puN include/net/sock.h~lockdep-annotate-sock_lock_init include/net/sock.h --- a/include/net/sock.h~lockdep-annotate-sock_lock_init +++ a/include/net/sock.h @@ -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) diff -puN net/core/sock.c~lockdep-annotate-sock_lock_init net/core/sock.c --- a/net/core/sock.c~lockdep-annotate-sock_lock_init +++ a/net/core/sock.c @@ -130,6 +130,18 @@ #include #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 @@ -838,6 +850,8 @@ struct sock *sk_clone(const struct sock 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; @@ -1412,6 +1426,8 @@ void sock_init_data(struct socket *sock, 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; _