Skip to contentSkip to conversation

INFO: inconsistent lock state

DISCUSSION Arne Ahrend 2 participants 2 messages Jul 9, 2006 Bluetooth

lore
Share & tools
lore
#0 lore raw

include/linux/skbuff.h extern struct lock_class_key skb_queue_l · line 614

Quoted 12 lines · Arjan van de Ven

Arne: Can you try this patch and verify it makes the message go away? [...]

include/linux/skbuff.h +0 -1
@@ -609,7 +609,6 @@ extern struct lock_class_key skb_queue_l
 static inline void skb_queue_head_init(struct sk_buff_head *list)
 {
 	spin_lock_init(&list->lock);
-	lockdep_set_class(&list->lock, &skb_queue_lock_key);
 	list->prev = list->next = (struct sk_buff *)list;
 	list->qlen = 0;
 }

With this patch the message at boot goes away. However, I have had one instance of the following message at shutdown, but not always. This particular one happened with the above patch applied.

Arne

[ INFO: inconsistent lock state ]
---------------------------------
inconsistent {in-softirq-W} -> {softirq-on-W} usage.
kbnepd bnep0/2098 [HC0[0]:SC0[0]:HE1:SE1] takes:
(&conn->lock){-+..}, at: [<e29dea5f>] __l2cap_sock_close+0xb9/0x111 [l2cap]
{in-softirq-W} state was registered at:

  [<c012a05e>] lock_acquire+0x4f/0x6d
  [<c0265e61>] _spin_lock+0x24/0x32
  [<e29df9f6>] l2cap_connect_cfm+0x8d/0x12a [l2cap]
  [<e2921d6b>] hci_event_packet+0x65e/0xddb [bluetooth]
  [<e291f279>] hci_rx_task+0x77/0x22f [bluetooth]
  [<c011786f>] tasklet_action+0x45/0x75
  [<c0117a76>] __do_softirq+0x45/0x9f
  [<c010480e>] do_softirq+0x4d/0xab
irq event stamp: 208973
hardirqs last  enabled at (208973): [<c02661f0>] _spin_unlock_irqrestore+0x36/0x55
hardirqs last disabled at (208972): [<c0265c4b>] _spin_lock_irqsave+0xf/0x3c
softirqs last  enabled at (208970): [<c021367d>] lock_sock+0xad/0xb8
softirqs last disabled at (208968): [<c0265cbb>] _spin_lock_bh+0xb/0x37

other info that might help us debug this:
2 locks held by kbnepd bnep0/2098:
#0: (bnep_session_sem){----}, at: [<e29e59b6>] bnep_session+0x67b/0x6b5 [bnep] #1: (sk_lock-AF_BLUETOOTH){--..}, at: [<e29dff7b>] l2cap_sock_shutdown+0x18/0x6b [l2cap]

stack backtrace:
 [<c0103433>] show_trace+0x16/0x19
 [<c0103913>] dump_stack+0x1a/0x1f
 [<c01284b8>] print_usage_bug+0x1d0/0x1da
 [<c0128a62>] mark_lock+0x23c/0x35a
 [<c01295f7>] __lock_acquire+0x41b/0x929
 [<c012a05e>] lock_acquire+0x4f/0x6d
 [<c0265e61>] _spin_lock+0x24/0x32
 [<e29dea5f>] __l2cap_sock_close+0xb9/0x111 [l2cap]
 [<e29dff98>] l2cap_sock_shutdown+0x35/0x6b [l2cap]
 [<e29e00a2>] l2cap_sock_release+0x20/0x5f [l2cap]
 [<c02120b9>] sock_release+0x16/0xab
 [<c02123de>] sock_close+0x30/0x3a
 [<c014ec5d>] __fput+0xa8/0x18a
 [<c014ee08>] fput+0x2e/0x33
 [<e29e59cc>] bnep_session+0x691/0x6b5 [bnep]
 [<c01006e9>] kernel_thread_helper+0x5/0xb

__________________________________________________________________________
Erweitern Sie FreeMail zu einem noch leistungsstärkeren E-Mail-Postfach! Mehr Infos unter http://freemail.web.de/home/landingpad/?mc=021131

#1 lore raw
Quoted 18 lines · Arne Ahrend

include/linux/skbuff.h extern struct lock_class_key skb_queue_l · line 614

Quoted 12 lines · Arjan van de Ven

Arne: Can you try this patch and verify it makes the message go away? [...]

include/linux/skbuff.h +0 -1
@@ -609,7 +609,6 @@ extern struct lock_class_key skb_queue_l
 static inline void skb_queue_head_init(struct sk_buff_head *list)
 {
 	spin_lock_init(&list->lock);
-	lockdep_set_class(&list->lock, &skb_queue_lock_key);
 	list->prev = list->next = (struct sk_buff *)list;
 	list->qlen = 0;
 }

With this patch the message at boot goes away. However, I have had one instance of the following message at shutdown, but not always. This particular one happened with the above patch applied.

I think this is a real bug, well in fact there seem to be 2:

there are 2 locks that have dodgy locking, one is a spinlock one is a rwlock. Both are used in softirq context, but neither had the proper _bh marking. The patch below corrects this

---
 net/bluetooth/l2cap.c |   16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
net/bluetooth/l2cap.c +8 -8
Index: linux-2.6.17-mm6/net/bluetooth/l2cap.c
===================================================================
@@ -167,9 +167,9 @@ static int l2cap_conn_del(struct hci_con
 static inline void l2cap_chan_add(struct l2cap_conn *conn, struct sock *sk, struct sock *parent)
 {
 	struct l2cap_chan_list *l = &conn->chan_list;
-	write_lock(&l->lock);
+	write_lock_bh(&l->lock);
 	__l2cap_chan_add(conn, sk, parent);
-	write_unlock(&l->lock);
+	write_unlock_bh(&l->lock);
 }
 
 static inline u8 l2cap_get_ident(struct l2cap_conn *conn)
@@ -182,14 +182,14 @@ static inline u8 l2cap_get_ident(struct 
 	 *  200 - 254 are used by utilities like l2ping, etc.
 	 */
 
-	spin_lock(&conn->lock);
+	spin_lock_bh(&conn->lock);
 
 	if (++conn->tx_ident > 128)
 		conn->tx_ident = 1;
 
 	id = conn->tx_ident;
 
-	spin_unlock(&conn->lock);
+	spin_unlock_bh(&conn->lock);
 
 	return id;
 }
@@ -1006,7 +1006,7 @@ static inline void l2cap_chan_unlink(str
 {
 	struct sock *next = l2cap_pi(sk)->next_c, *prev = l2cap_pi(sk)->prev_c;
 
-	write_lock(&l->lock);
+	write_lock_bh(&l->lock);
 	if (sk == l->head)
 		l->head = next;
 
@@ -1014,7 +1014,7 @@ static inline void l2cap_chan_unlink(str
 		l2cap_pi(next)->prev_c = prev;
 	if (prev)
 		l2cap_pi(prev)->next_c = next;
-	write_unlock(&l->lock);
+	write_unlock_bh(&l->lock);
 
 	__sock_put(sk);
 }
@@ -1424,7 +1424,7 @@ static inline int l2cap_connect_req(stru
 	if (!sk)
 		goto response;
 
-	write_lock(&list->lock);
+	write_lock_bh(&list->lock);
 
 	/* Check if we already have channel with that dcid */
 	if (__l2cap_get_chan_by_dcid(list, scid)) {
@@ -1466,7 +1466,7 @@ static inline int l2cap_connect_req(stru
 	result = status = 0;
 
 done:
-	write_unlock(&list->lock);
+	write_unlock_bh(&list->lock);
 
 response:
 	bh_unlock_sock(parent);