diff mbox

[2/2] tcp: bind() optimize port allocation

Message ID 1327516492-9045-2-git-send-email-fbl@redhat.com
State Accepted, archived
Delegated to: David Miller
Headers show

Commit Message

Flavio Leitner Jan. 25, 2012, 6:34 p.m. UTC
Port autoselection finds a port and then drop the lock,
then right after that, gets the hash bucket again and lock it.

Fix it to go direct.

Signed-off-by: Flavio Leitner <fbl@redhat.com>
---
 net/ipv4/inet_connection_sock.c |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)

Comments

Marcelo Leitner Jan. 25, 2012, 6:36 p.m. UTC | #1
On 01/25/2012 04:34 PM, Flavio Leitner wrote:
> Port autoselection finds a port and then drop the lock,
> then right after that, gets the hash bucket again and lock it.
>
> Fix it to go direct.
>
> Signed-off-by: Flavio Leitner<fbl@redhat.com>

Signed-off-by: Marcelo Ricardo Leitner <mleitner@redhat.com>

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Eric Dumazet Jan. 25, 2012, 6:48 p.m. UTC | #2
Le mercredi 25 janvier 2012 à 16:34 -0200, Flavio Leitner a écrit :
> Port autoselection finds a port and then drop the lock,
> then right after that, gets the hash bucket again and lock it.
> 
> Fix it to go direct.
> 
> Signed-off-by: Flavio Leitner <fbl@redhat.com>
> ---

Acked-by: Eric Dumazet <eric.dumazet@gmail.com>


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Miller Jan. 26, 2012, 2:51 a.m. UTC | #3
From: Flavio Leitner <fbl@redhat.com>
Date: Wed, 25 Jan 2012 16:34:52 -0200

> Port autoselection finds a port and then drop the lock,
> then right after that, gets the hash bucket again and lock it.
> 
> Fix it to go direct.
> 
> Signed-off-by: Flavio Leitner <fbl@redhat.com>

Applied, great work Flavio.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
index ecd19b5..19d66ce 100644
--- a/net/ipv4/inet_connection_sock.c
+++ b/net/ipv4/inet_connection_sock.c
@@ -123,15 +123,13 @@  again:
 						smallest_size = tb->num_owners;
 						smallest_rover = rover;
 						if (atomic_read(&hashinfo->bsockets) > (high - low) + 1) {
-							spin_unlock(&head->lock);
 							snum = smallest_rover;
-							goto have_snum;
+							goto tb_found;
 						}
 					}
 					if (!inet_csk(sk)->icsk_af_ops->bind_conflict(sk, tb)) {
-						spin_unlock(&head->lock);
 						snum = rover;
-						goto have_snum;
+						goto tb_found;
 					}
 					goto next;
 				}