Skip to contentSkip to conversation

Disable softirqs when taking the socket queue lock

PATCH In review Dan Smith 2 participants 2 messages Mar 24, 2010 – Mar 30, 2010 1 message not in the archive Networking

lore
Share & tools
lore

Dan Smith

author
#0 lore raw

PATCH 1/1 Disable softirqs when taking the socket queue lock

This prevents the lockdep report (and potential deadlock) if we get unlucky while traversing the queues.

---
 net/checkpoint.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
net/checkpoint.c +4 -4
index 0eb8860..9197671 100644
@@ -44,10 +44,10 @@ static int sock_copy_buffers(struct sk_buff_head *from,
 
 	*total_bytes = 0;
 
-	spin_lock(&from->lock);
+	spin_lock_bh(&from->lock);
 	skb_queue_walk(from, skb)
 		count1++;
-	spin_unlock(&from->lock);
+	spin_unlock_bh(&from->lock);
 
 	skbs = kzalloc(sizeof(*skbs) * count1, GFP_KERNEL);
 	if (!skbs)
@@ -60,7 +60,7 @@ static int sock_copy_buffers(struct sk_buff_head *from,
 	}
 
 	i = 0;
-	spin_lock(&from->lock);
+	spin_lock_bh(&from->lock);
 	skb_queue_walk(from, skb) {
 		if (++count2 > count1)
 			break; /* The queue changed as we read it */
@@ -72,7 +72,7 @@ static int sock_copy_buffers(struct sk_buff_head *from,
 		*total_bytes += skb->len;
 		i++;
 	}
-	spin_unlock(&from->lock);
+	spin_unlock_bh(&from->lock);
 
 	if (count1 != count2)
 		goto err;
Signature · 1 line
1.6.2.5
#2 lore raw
In reply to a message not in the archive

Applied for ckpt-v21, thanks.

Quoted 43 lines · Dan Smith

This prevents the lockdep report (and potential deadlock) if we get unlucky while traversing the queues.

---
 net/checkpoint.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
net/checkpoint.c +4 -4
index 0eb8860..9197671 100644
@@ -44,10 +44,10 @@ static int sock_copy_buffers(struct sk_buff_head *from,
 
 	*total_bytes = 0;
 
-	spin_lock(&from->lock);
+	spin_lock_bh(&from->lock);
 	skb_queue_walk(from, skb)
 		count1++;
-	spin_unlock(&from->lock);
+	spin_unlock_bh(&from->lock);
 
 	skbs = kzalloc(sizeof(*skbs) * count1, GFP_KERNEL);
 	if (!skbs)
@@ -60,7 +60,7 @@ static int sock_copy_buffers(struct sk_buff_head *from,
 	}
 
 	i = 0;
-	spin_lock(&from->lock);
+	spin_lock_bh(&from->lock);
 	skb_queue_walk(from, skb) {
 		if (++count2 > count1)
 			break; /* The queue changed as we read it */
@@ -72,7 +72,7 @@ static int sock_copy_buffers(struct sk_buff_head *from,
 		*total_bytes += skb->len;
 		i++;
 	}
-	spin_unlock(&from->lock);
+	spin_unlock_bh(&from->lock);
 
 	if (count1 != count2)
 		goto err;