All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] tcp: tcp_prequeue() cleanup
@ 2009-05-07 17:08 Eric Dumazet
  2009-05-07 17:20 ` [PATCH] tcp: tcp_prequeue() can use keyed wakeups Eric Dumazet
  2009-05-07 21:55 ` [PATCH] tcp: tcp_prequeue() cleanup David Miller
  0 siblings, 2 replies; 8+ messages in thread
From: Eric Dumazet @ 2009-05-07 17:08 UTC (permalink / raw)
  To: David S. Miller; +Cc: Linux Netdev List

Small cleanup patch to reduce line lengths, before a change in tcp_prequeue().

Signed-off-by: Eric Dumazet <dada1@cosmosbay.com>

diff --git a/include/net/tcp.h b/include/net/tcp.h
index b55b489..ac37228 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -890,30 +890,31 @@ static inline int tcp_prequeue(struct sock *sk, struct sk_buff *skb)
 {
 	struct tcp_sock *tp = tcp_sk(sk);
 
-	if (!sysctl_tcp_low_latency && tp->ucopy.task) {
-		__skb_queue_tail(&tp->ucopy.prequeue, skb);
-		tp->ucopy.memory += skb->truesize;
-		if (tp->ucopy.memory > sk->sk_rcvbuf) {
-			struct sk_buff *skb1;
-
-			BUG_ON(sock_owned_by_user(sk));
-
-			while ((skb1 = __skb_dequeue(&tp->ucopy.prequeue)) != NULL) {
-				sk_backlog_rcv(sk, skb1);
-				NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_TCPPREQUEUEDROPPED);
-			}
-
-			tp->ucopy.memory = 0;
-		} else if (skb_queue_len(&tp->ucopy.prequeue) == 1) {
-			wake_up_interruptible(sk->sk_sleep);
-			if (!inet_csk_ack_scheduled(sk))
-				inet_csk_reset_xmit_timer(sk, ICSK_TIME_DACK,
-						          (3 * TCP_RTO_MIN) / 4,
-							  TCP_RTO_MAX);
+	if (sysctl_tcp_low_latency || !tp->ucopy.task)
+		return 0;
+
+	__skb_queue_tail(&tp->ucopy.prequeue, skb);
+	tp->ucopy.memory += skb->truesize;
+	if (tp->ucopy.memory > sk->sk_rcvbuf) {
+		struct sk_buff *skb1;
+
+		BUG_ON(sock_owned_by_user(sk));
+
+		while ((skb1 = __skb_dequeue(&tp->ucopy.prequeue)) != NULL) {
+			sk_backlog_rcv(sk, skb1);
+			NET_INC_STATS_BH(sock_net(sk),
+					 LINUX_MIB_TCPPREQUEUEDROPPED);
 		}
-		return 1;
+
+		tp->ucopy.memory = 0;
+	} else if (skb_queue_len(&tp->ucopy.prequeue) == 1) {
+		wake_up_interruptible(sk->sk_sleep);
+		if (!inet_csk_ack_scheduled(sk))
+			inet_csk_reset_xmit_timer(sk, ICSK_TIME_DACK,
+						  (3 * TCP_RTO_MIN) / 4,
+						  TCP_RTO_MAX);
 	}
-	return 0;
+	return 1;
 }
 
 

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

* [PATCH] tcp: tcp_prequeue() can use keyed wakeups
  2009-05-07 17:08 [PATCH] tcp: tcp_prequeue() cleanup Eric Dumazet
@ 2009-05-07 17:20 ` Eric Dumazet
  2009-05-07 21:55   ` David Miller
  2009-05-13  1:34   ` John Dykstra
  2009-05-07 21:55 ` [PATCH] tcp: tcp_prequeue() cleanup David Miller
  1 sibling, 2 replies; 8+ messages in thread
From: Eric Dumazet @ 2009-05-07 17:20 UTC (permalink / raw)
  To: David S. Miller; +Cc: Linux Netdev List

We can avoid waking up tasks not interested in receive notifications,
using wake_up_interruptible_poll() instead of wake_up_interruptible()

Signed-off-by: Eric Dumazet <dada1@cosmosbay.com>


diff --git a/include/net/tcp.h b/include/net/tcp.h
index ac37228..87d210b 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -908,7 +908,8 @@ static inline int tcp_prequeue(struct sock *sk, struct sk_buff *skb)
 
 		tp->ucopy.memory = 0;
 	} else if (skb_queue_len(&tp->ucopy.prequeue) == 1) {
-		wake_up_interruptible(sk->sk_sleep);
+		wake_up_interruptible_poll(sk->sk_sleep,
+					   POLLIN | POLLRDNORM | POLLRDBAND);
 		if (!inet_csk_ack_scheduled(sk))
 			inet_csk_reset_xmit_timer(sk, ICSK_TIME_DACK,
 						  (3 * TCP_RTO_MIN) / 4,


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

* Re: [PATCH] tcp: tcp_prequeue() cleanup
  2009-05-07 17:08 [PATCH] tcp: tcp_prequeue() cleanup Eric Dumazet
  2009-05-07 17:20 ` [PATCH] tcp: tcp_prequeue() can use keyed wakeups Eric Dumazet
@ 2009-05-07 21:55 ` David Miller
  1 sibling, 0 replies; 8+ messages in thread
From: David Miller @ 2009-05-07 21:55 UTC (permalink / raw)
  To: dada1; +Cc: netdev

From: Eric Dumazet <dada1@cosmosbay.com>
Date: Thu, 07 May 2009 19:08:38 +0200

> Small cleanup patch to reduce line lengths, before a change in tcp_prequeue().
> 
> Signed-off-by: Eric Dumazet <dada1@cosmosbay.com>

Applied.

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

* Re: [PATCH] tcp: tcp_prequeue() can use keyed wakeups
  2009-05-07 17:20 ` [PATCH] tcp: tcp_prequeue() can use keyed wakeups Eric Dumazet
@ 2009-05-07 21:55   ` David Miller
  2009-05-13  1:34   ` John Dykstra
  1 sibling, 0 replies; 8+ messages in thread
From: David Miller @ 2009-05-07 21:55 UTC (permalink / raw)
  To: dada1; +Cc: netdev

From: Eric Dumazet <dada1@cosmosbay.com>
Date: Thu, 07 May 2009 19:20:39 +0200

> We can avoid waking up tasks not interested in receive notifications,
> using wake_up_interruptible_poll() instead of wake_up_interruptible()
> 
> Signed-off-by: Eric Dumazet <dada1@cosmosbay.com>

Nice work Eric, applied!

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

* Re: [PATCH] tcp: tcp_prequeue() can use keyed wakeups
  2009-05-07 17:20 ` [PATCH] tcp: tcp_prequeue() can use keyed wakeups Eric Dumazet
  2009-05-07 21:55   ` David Miller
@ 2009-05-13  1:34   ` John Dykstra
  2009-05-13  3:28     ` Eric Dumazet
  1 sibling, 1 reply; 8+ messages in thread
From: John Dykstra @ 2009-05-13  1:34 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: David S. Miller, Linux Netdev List

On Thu, 2009-05-07 at 19:20 +0200, Eric Dumazet wrote:
> We can avoid waking up tasks not interested in receive notifications,
> using wake_up_interruptible_poll() instead of wake_up_interruptible()

Is there any reason why we shouldn't do the same thing on the write
side?

Compile-tested only.

  --  John

---
[PATCH net-next-2.6] tcp: Don't wake up reading threads on write space 

When TCP frees up write buffer space, avoid waking up tasks that have
done a poll() or select() on the same socket specifying read-side
events.

This is an extension of a read-side patch by Eric Dumazet.

Signed-off-by: John Dykstra <john.dykstra1@gmail.com>
---
 net/core/stream.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/net/core/stream.c b/net/core/stream.c
index 8727cea..a37debf 100644
--- a/net/core/stream.c
+++ b/net/core/stream.c
@@ -33,7 +33,8 @@ void sk_stream_write_space(struct sock *sk)
 		clear_bit(SOCK_NOSPACE, &sock->flags);
 
 		if (sk->sk_sleep && waitqueue_active(sk->sk_sleep))
-			wake_up_interruptible(sk->sk_sleep);
+			wake_up_interruptible_poll(sk->sk_sleep, POLLOUT |
+						POLLWRNORM | POLLWRBAND);
 		if (sock->fasync_list && !(sk->sk_shutdown & SEND_SHUTDOWN))
 			sock_wake_async(sock, SOCK_WAKE_SPACE, POLL_OUT);
 	}
-- 
1.5.4.3




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

* Re: [PATCH] tcp: tcp_prequeue() can use keyed wakeups
  2009-05-13  1:34   ` John Dykstra
@ 2009-05-13  3:28     ` Eric Dumazet
  2009-05-13 15:05       ` John Dykstra
  0 siblings, 1 reply; 8+ messages in thread
From: Eric Dumazet @ 2009-05-13  3:28 UTC (permalink / raw)
  To: John Dykstra; +Cc: David S. Miller, Linux Netdev List

John Dykstra a écrit :
> On Thu, 2009-05-07 at 19:20 +0200, Eric Dumazet wrote:
>> We can avoid waking up tasks not interested in receive notifications,
>> using wake_up_interruptible_poll() instead of wake_up_interruptible()
> 
> Is there any reason why we shouldn't do the same thing on the write
> side?

No special reason, apart that this event is not so frequent.

(For tcp, sock_wfree() doesnt call ->sk_write_space())

I wonder if sk_stream_write_space() is actually called at all, I never got it in profiles :)

I see it is called from setsockopt(SO_SNFBUF),
and from tcp_new_space() only if SOCK_NOSPACE was set.

To see a benefit of this patch, we would need two threads, one blocked in a recv(),
one blocked in a send() on same socket (or a poll/epoll user with same bi-directional trafic)

Acked-by: Eric Dumazet <dada1@cosmosbay.com>

> 
> Compile-tested only.
> 
>   --  John
> 
> ---
> [PATCH net-next-2.6] tcp: Don't wake up reading threads on write space 
> 
> When TCP frees up write buffer space, avoid waking up tasks that have
> done a poll() or select() on the same socket specifying read-side
> events.
> 
> This is an extension of a read-side patch by Eric Dumazet.
> 
> Signed-off-by: John Dykstra <john.dykstra1@gmail.com>
> ---
>  net/core/stream.c |    3 ++-
>  1 files changed, 2 insertions(+), 1 deletions(-)
> 
> diff --git a/net/core/stream.c b/net/core/stream.c
> index 8727cea..a37debf 100644
> --- a/net/core/stream.c
> +++ b/net/core/stream.c
> @@ -33,7 +33,8 @@ void sk_stream_write_space(struct sock *sk)
>  		clear_bit(SOCK_NOSPACE, &sock->flags);
>  
>  		if (sk->sk_sleep && waitqueue_active(sk->sk_sleep))
> -			wake_up_interruptible(sk->sk_sleep);
> +			wake_up_interruptible_poll(sk->sk_sleep, POLLOUT |
> +						POLLWRNORM | POLLWRBAND);
>  		if (sock->fasync_list && !(sk->sk_shutdown & SEND_SHUTDOWN))
>  			sock_wake_async(sock, SOCK_WAKE_SPACE, POLL_OUT);
>  	}



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

* Re: [PATCH] tcp: tcp_prequeue() can use keyed wakeups
  2009-05-13  3:28     ` Eric Dumazet
@ 2009-05-13 15:05       ` John Dykstra
  2009-05-18  3:45         ` David Miller
  0 siblings, 1 reply; 8+ messages in thread
From: John Dykstra @ 2009-05-13 15:05 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: David S. Miller, Linux Netdev List

On Wed, 2009-05-13 at 05:28 +0200, Eric Dumazet wrote:

> To see a benefit of this patch, we would need two threads, one blocked
> in a recv(),
> one blocked in a send() on same socket (or a poll/epoll user with same
> bi-directional trafic)

Agreed.

  --  John


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

* Re: [PATCH] tcp: tcp_prequeue() can use keyed wakeups
  2009-05-13 15:05       ` John Dykstra
@ 2009-05-18  3:45         ` David Miller
  0 siblings, 0 replies; 8+ messages in thread
From: David Miller @ 2009-05-18  3:45 UTC (permalink / raw)
  To: john.dykstra1; +Cc: dada1, netdev

From: John Dykstra <john.dykstra1@gmail.com>
Date: Wed, 13 May 2009 10:05:07 -0500

> On Wed, 2009-05-13 at 05:28 +0200, Eric Dumazet wrote:
> 
>> To see a benefit of this patch, we would need two threads, one blocked
>> in a recv(),
>> one blocked in a send() on same socket (or a poll/epoll user with same
>> bi-directional trafic)
> 
> Agreed.

I've applied this to net-next-2.6, thanks.

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

end of thread, other threads:[~2009-05-18  3:45 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-05-07 17:08 [PATCH] tcp: tcp_prequeue() cleanup Eric Dumazet
2009-05-07 17:20 ` [PATCH] tcp: tcp_prequeue() can use keyed wakeups Eric Dumazet
2009-05-07 21:55   ` David Miller
2009-05-13  1:34   ` John Dykstra
2009-05-13  3:28     ` Eric Dumazet
2009-05-13 15:05       ` John Dykstra
2009-05-18  3:45         ` David Miller
2009-05-07 21:55 ` [PATCH] tcp: tcp_prequeue() cleanup David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.