public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] lockdep: annotate sk_lock nesting in AF_BLUETOOTH
@ 2006-10-30  8:16 Peter Zijlstra
  2006-10-30  8:22 ` Marcel Holtmann
  2006-10-30 10:08 ` [PATCH] lockdep: annotate sk_lock nesting in AF_BLUETOOTH -v2 Peter Zijlstra
  0 siblings, 2 replies; 3+ messages in thread
From: Peter Zijlstra @ 2006-10-30  8:16 UTC (permalink / raw)
  To: linux-kernel, Andrew Morton; +Cc: Ingo Molnar, David Miller, Marcel Holtmann


=============================================
[ INFO: possible recursive locking detected ]
2.6.18-1.2726.fc6 #1
---------------------------------------------
hidd/2271 is trying to acquire lock:
 (sk_lock-AF_BLUETOOTH){--..}, at: [<f8d16241>] bt_accept_dequeue+0x26/0xc6
[bluetooth]

but task is already holding lock:
 (sk_lock-AF_BLUETOOTH){--..}, at: [<f8bce088>] l2cap_sock_accept+0x41/0x11e [l2cap]

other info that might help us debug this:
1 lock held by hidd/2271:
 #0:  (sk_lock-AF_BLUETOOTH){--..}, at: [<f8bce088>]
l2cap_sock_accept+0x41/0x11e [l2cap]

stack backtrace:
 [<c04051ed>] show_trace_log_lvl+0x58/0x16a
 [<c04057fa>] show_trace+0xd/0x10
 [<c0405913>] dump_stack+0x19/0x1b
 [<c043b7dc>] __lock_acquire+0x6ea/0x90d
 [<c043bf70>] lock_acquire+0x4b/0x6b
 [<c05b203b>] lock_sock+0xac/0xbc
 [<f8d16241>] bt_accept_dequeue+0x26/0xc6 [bluetooth]
 [<f8bce129>] l2cap_sock_accept+0xe2/0x11e [l2cap]
 [<c05b142e>] sys_accept+0xd8/0x179
 [<c05b1576>] sys_socketcall+0xa7/0x186
 [<c0403fb7>] syscall_call+0x7/0xb

classical case of nesting; bt_accept_dequeue() locks the children of the object
locked by l2cap_sock_accept().

Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
---
 include/net/sock.h    |   13 ++++++++++++-
 net/bluetooth/l2cap.c |    2 +-
 net/core/sock.c       |    6 +++---
 3 files changed, 16 insertions(+), 5 deletions(-)

Index: linux-2.6/include/net/sock.h
===================================================================
--- linux-2.6.orig/include/net/sock.h
+++ linux-2.6/include/net/sock.h
@@ -745,7 +745,18 @@ static inline int sk_stream_wmem_schedul
  */
 #define sock_owned_by_user(sk)	((sk)->sk_lock.owner)
 
-extern void FASTCALL(lock_sock(struct sock *sk));
+extern void FASTCALL(_lock_sock(struct sock *sk, int subclass));
+
+static inline void lock_sock(struct sock *sk)
+{
+	_lock_sock(sk, 0);
+}
+
+static inline void lock_sock_nested(struct sock *sk, int subclass)
+{
+	_lock_sock(sk, subclass);
+}
+
 extern void FASTCALL(release_sock(struct sock *sk));
 
 /* BH context may only use the following locking interface. */
Index: linux-2.6/net/bluetooth/l2cap.c
===================================================================
--- linux-2.6.orig/net/bluetooth/l2cap.c
+++ linux-2.6/net/bluetooth/l2cap.c
@@ -770,7 +770,7 @@ static int l2cap_sock_accept(struct sock
 	long timeo;
 	int err = 0;
 
-	lock_sock(sk);
+	lock_sock_nested(sk, SINGLE_DEPTH_NESTING);
 
 	if (sk->sk_state != BT_LISTEN) {
 		err = -EBADFD;
Index: linux-2.6/net/core/sock.c
===================================================================
--- linux-2.6.orig/net/core/sock.c
+++ linux-2.6/net/core/sock.c
@@ -1527,7 +1527,7 @@ void sock_init_data(struct socket *sock,
 	atomic_set(&sk->sk_refcnt, 1);
 }
 
-void fastcall lock_sock(struct sock *sk)
+void fastcall _lock_sock(struct sock *sk, int subclass)
 {
 	might_sleep();
 	spin_lock_bh(&sk->sk_lock.slock);
@@ -1538,11 +1538,11 @@ void fastcall lock_sock(struct sock *sk)
 	/*
 	 * The sk_lock has mutex_lock() semantics here:
 	 */
-	mutex_acquire(&sk->sk_lock.dep_map, 0, 0, _RET_IP_);
+	mutex_acquire(&sk->sk_lock.dep_map, subclass, 0, _RET_IP_);
 	local_bh_enable();
 }
 
-EXPORT_SYMBOL(lock_sock);
+EXPORT_SYMBOL(_lock_sock);
 
 void fastcall release_sock(struct sock *sk)
 {



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] lockdep: annotate sk_lock nesting in AF_BLUETOOTH
  2006-10-30  8:16 [PATCH] lockdep: annotate sk_lock nesting in AF_BLUETOOTH Peter Zijlstra
@ 2006-10-30  8:22 ` Marcel Holtmann
  2006-10-30 10:08 ` [PATCH] lockdep: annotate sk_lock nesting in AF_BLUETOOTH -v2 Peter Zijlstra
  1 sibling, 0 replies; 3+ messages in thread
From: Marcel Holtmann @ 2006-10-30  8:22 UTC (permalink / raw)
  To: Peter Zijlstra; +Cc: linux-kernel, Andrew Morton, Ingo Molnar, David Miller

Hi Peter,

> =============================================
> [ INFO: possible recursive locking detected ]
> 2.6.18-1.2726.fc6 #1
> ---------------------------------------------
> hidd/2271 is trying to acquire lock:
>  (sk_lock-AF_BLUETOOTH){--..}, at: [<f8d16241>] bt_accept_dequeue+0x26/0xc6
> [bluetooth]
> 
> but task is already holding lock:
>  (sk_lock-AF_BLUETOOTH){--..}, at: [<f8bce088>] l2cap_sock_accept+0x41/0x11e [l2cap]
> 
> other info that might help us debug this:
> 1 lock held by hidd/2271:
>  #0:  (sk_lock-AF_BLUETOOTH){--..}, at: [<f8bce088>]
> l2cap_sock_accept+0x41/0x11e [l2cap]
> 
> stack backtrace:
>  [<c04051ed>] show_trace_log_lvl+0x58/0x16a
>  [<c04057fa>] show_trace+0xd/0x10
>  [<c0405913>] dump_stack+0x19/0x1b
>  [<c043b7dc>] __lock_acquire+0x6ea/0x90d
>  [<c043bf70>] lock_acquire+0x4b/0x6b
>  [<c05b203b>] lock_sock+0xac/0xbc
>  [<f8d16241>] bt_accept_dequeue+0x26/0xc6 [bluetooth]
>  [<f8bce129>] l2cap_sock_accept+0xe2/0x11e [l2cap]
>  [<c05b142e>] sys_accept+0xd8/0x179
>  [<c05b1576>] sys_socketcall+0xa7/0x186
>  [<c0403fb7>] syscall_call+0x7/0xb
> 
> classical case of nesting; bt_accept_dequeue() locks the children of the object
> locked by l2cap_sock_accept().
> 
> Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
> ---
>  include/net/sock.h    |   13 ++++++++++++-
>  net/bluetooth/l2cap.c |    2 +-
>  net/core/sock.c       |    6 +++---
>  3 files changed, 16 insertions(+), 5 deletions(-)
> 
> Index: linux-2.6/include/net/sock.h
> ===================================================================
> --- linux-2.6.orig/include/net/sock.h
> +++ linux-2.6/include/net/sock.h
> @@ -745,7 +745,18 @@ static inline int sk_stream_wmem_schedul
>   */
>  #define sock_owned_by_user(sk)	((sk)->sk_lock.owner)
>  
> -extern void FASTCALL(lock_sock(struct sock *sk));
> +extern void FASTCALL(_lock_sock(struct sock *sk, int subclass));
> +
> +static inline void lock_sock(struct sock *sk)
> +{
> +	_lock_sock(sk, 0);
> +}
> +
> +static inline void lock_sock_nested(struct sock *sk, int subclass)
> +{
> +	_lock_sock(sk, subclass);
> +}
> +
>  extern void FASTCALL(release_sock(struct sock *sk));
>  
>  /* BH context may only use the following locking interface. */
> Index: linux-2.6/net/bluetooth/l2cap.c
> ===================================================================
> --- linux-2.6.orig/net/bluetooth/l2cap.c
> +++ linux-2.6/net/bluetooth/l2cap.c
> @@ -770,7 +770,7 @@ static int l2cap_sock_accept(struct sock
>  	long timeo;
>  	int err = 0;
>  
> -	lock_sock(sk);
> +	lock_sock_nested(sk, SINGLE_DEPTH_NESTING);
>  
>  	if (sk->sk_state != BT_LISTEN) {
>  		err = -EBADFD;
> Index: linux-2.6/net/core/sock.c
> ===================================================================
> --- linux-2.6.orig/net/core/sock.c
> +++ linux-2.6/net/core/sock.c
> @@ -1527,7 +1527,7 @@ void sock_init_data(struct socket *sock,
>  	atomic_set(&sk->sk_refcnt, 1);
>  }
>  
> -void fastcall lock_sock(struct sock *sk)
> +void fastcall _lock_sock(struct sock *sk, int subclass)
>  {
>  	might_sleep();
>  	spin_lock_bh(&sk->sk_lock.slock);
> @@ -1538,11 +1538,11 @@ void fastcall lock_sock(struct sock *sk)
>  	/*
>  	 * The sk_lock has mutex_lock() semantics here:
>  	 */
> -	mutex_acquire(&sk->sk_lock.dep_map, 0, 0, _RET_IP_);
> +	mutex_acquire(&sk->sk_lock.dep_map, subclass, 0, _RET_IP_);
>  	local_bh_enable();
>  }
>  
> -EXPORT_SYMBOL(lock_sock);
> +EXPORT_SYMBOL(_lock_sock);
>  
>  void fastcall release_sock(struct sock *sk)
>  {

for the Bluetooth subsystem part of this patch:

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>

Regards

Marcel



^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH] lockdep: annotate sk_lock nesting in AF_BLUETOOTH -v2
  2006-10-30  8:16 [PATCH] lockdep: annotate sk_lock nesting in AF_BLUETOOTH Peter Zijlstra
  2006-10-30  8:22 ` Marcel Holtmann
@ 2006-10-30 10:08 ` Peter Zijlstra
  1 sibling, 0 replies; 3+ messages in thread
From: Peter Zijlstra @ 2006-10-30 10:08 UTC (permalink / raw)
  To: linux-kernel; +Cc: Andrew Morton, Ingo Molnar, David Miller, Marcel Holtmann

Today I suck, in an attempt to avoid more damage this shall be my last
patch for today.

---

=============================================
[ INFO: possible recursive locking detected ]
2.6.18-1.2726.fc6 #1
---------------------------------------------
hidd/2271 is trying to acquire lock:
 (sk_lock-AF_BLUETOOTH){--..}, at: [<f8d16241>] bt_accept_dequeue+0x26/0xc6
[bluetooth]

but task is already holding lock:
 (sk_lock-AF_BLUETOOTH){--..}, at: [<f8bce088>] l2cap_sock_accept+0x41/0x11e [l2cap]

other info that might help us debug this:
1 lock held by hidd/2271:
 #0:  (sk_lock-AF_BLUETOOTH){--..}, at: [<f8bce088>]
l2cap_sock_accept+0x41/0x11e [l2cap]

stack backtrace:
 [<c04051ed>] show_trace_log_lvl+0x58/0x16a
 [<c04057fa>] show_trace+0xd/0x10
 [<c0405913>] dump_stack+0x19/0x1b
 [<c043b7dc>] __lock_acquire+0x6ea/0x90d
 [<c043bf70>] lock_acquire+0x4b/0x6b
 [<c05b203b>] lock_sock+0xac/0xbc
 [<f8d16241>] bt_accept_dequeue+0x26/0xc6 [bluetooth]
 [<f8bce129>] l2cap_sock_accept+0xe2/0x11e [l2cap]
 [<c05b142e>] sys_accept+0xd8/0x179
 [<c05b1576>] sys_socketcall+0xa7/0x186
 [<c0403fb7>] syscall_call+0x7/0xb

classical case of nesting; bt_accept_dequeue() locks the children of the object
locked by l2cap_sock_accept().

Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
---
 include/net/sock.h    |    8 +++++++-
 net/bluetooth/l2cap.c |    4 ++--
 net/core/sock.c       |    6 +++---
 3 files changed, 12 insertions(+), 6 deletions(-)

Index: linux-2.6/include/net/sock.h
===================================================================
--- linux-2.6.orig/include/net/sock.h
+++ linux-2.6/include/net/sock.h
@@ -745,7 +745,13 @@ static inline int sk_stream_wmem_schedul
  */
 #define sock_owned_by_user(sk)	((sk)->sk_lock.owner)
 
-extern void FASTCALL(lock_sock(struct sock *sk));
+extern void FASTCALL(lock_sock_nested(struct sock *sk, int subclass));
+
+static inline void lock_sock(struct sock *sk)
+{
+	lock_sock_nested(sk, 0);
+}
+
 extern void FASTCALL(release_sock(struct sock *sk));
 
 /* BH context may only use the following locking interface. */
Index: linux-2.6/net/bluetooth/l2cap.c
===================================================================
--- linux-2.6.orig/net/bluetooth/l2cap.c
+++ linux-2.6/net/bluetooth/l2cap.c
@@ -770,7 +770,7 @@ static int l2cap_sock_accept(struct sock
 	long timeo;
 	int err = 0;
 
-	lock_sock(sk);
+	lock_sock_nested(sk, SINGLE_DEPTH_NESTING);
 
 	if (sk->sk_state != BT_LISTEN) {
 		err = -EBADFD;
@@ -792,7 +792,7 @@ static int l2cap_sock_accept(struct sock
 
 		release_sock(sk);
 		timeo = schedule_timeout(timeo);
-		lock_sock(sk);
+		lock_sock_nested(sk, SINGLE_DEPTH_NESTING);
 
 		if (sk->sk_state != BT_LISTEN) {
 			err = -EBADFD;
Index: linux-2.6/net/core/sock.c
===================================================================
--- linux-2.6.orig/net/core/sock.c
+++ linux-2.6/net/core/sock.c
@@ -1527,7 +1527,7 @@ void sock_init_data(struct socket *sock,
 	atomic_set(&sk->sk_refcnt, 1);
 }
 
-void fastcall lock_sock(struct sock *sk)
+void fastcall lock_sock_nested(struct sock *sk, int subclass)
 {
 	might_sleep();
 	spin_lock_bh(&sk->sk_lock.slock);
@@ -1538,11 +1538,11 @@ void fastcall lock_sock(struct sock *sk)
 	/*
 	 * The sk_lock has mutex_lock() semantics here:
 	 */
-	mutex_acquire(&sk->sk_lock.dep_map, 0, 0, _RET_IP_);
+	mutex_acquire(&sk->sk_lock.dep_map, subclass, 0, _RET_IP_);
 	local_bh_enable();
 }
 
-EXPORT_SYMBOL(lock_sock);
+EXPORT_SYMBOL(lock_sock_nested);
 
 void fastcall release_sock(struct sock *sk)
 {



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2006-10-30 10:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-10-30  8:16 [PATCH] lockdep: annotate sk_lock nesting in AF_BLUETOOTH Peter Zijlstra
2006-10-30  8:22 ` Marcel Holtmann
2006-10-30 10:08 ` [PATCH] lockdep: annotate sk_lock nesting in AF_BLUETOOTH -v2 Peter Zijlstra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox