tcp: tcp_prequeue() cleanup
Subsystems (3)
PATCH 1/1 tcp: tcp_prequeue() cleanup
Small cleanup patch to reduce line lengths, before a change in tcp_prequeue().
include/net/tcp.h +23 -22
@@ -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 ; }
PATCH 1/1 tcp: tcp_prequeue() can use keyed wakeups
We can avoid waking up tasks not interested in receive notifications, using wake_up_interruptible_poll() instead of wake_up_interruptible()
include/net/tcp.h +2 -1
@@ -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,
David Miller
maintainerRe: [PATCH] tcp: tcp_prequeue() can use keyed wakeups
From: Eric Dumazet <[email protected]>
Date: Thu, 07 May 2009 19:20:39 +0200
Quoted 4 lines
We can avoid waking up tasks not interested in receive notifications, using
wake_up_interruptible_poll()instead ofwake_up_interruptible()Signed-off-by Eric Dumazet <[email protected]>
Nice work Eric, applied!
Re: [PATCH] tcp: tcp_prequeue() can use keyed wakeups
In reply to Eric DumazetQuoted 2 lines · Eric Dumazet
We can avoid waking up tasks not interested in receive notifications, using
wake_up_interruptible_poll()instead ofwake_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.
--- net/core/stream.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
net/core/stream.c +2 -1
@@ -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 ); }
Signature · 1 line
1.5.4.3
Eric Dumazet
Acked-byRe: [PATCH] tcp: tcp_prequeue() can use keyed wakeups
Quoted 6 lines · John Dykstra
Quoted 2 lines · Eric Dumazet
We can avoid waking up tasks not interested in receive notifications, using
wake_up_interruptible_poll()instead ofwake_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)
Quoted 33 lines
Compile-tested only.
-- John
---
[PATCH net-next-2.6] tcp: Don't wake up reading threads on write spaceWhen TCP frees up write buffer space, avoid waking up tasks that have done a
poll()orselect()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 <[email protected]>--- net/core/stream.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)net/core/stream.c +2
-1@@ -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 ); }
Re: [PATCH] tcp: tcp_prequeue() can use keyed wakeups
Quoted 4 lines · Eric Dumazet
To see a benefit of this patch, we would need two threads, one blocked in a
recv(),
one blocked in asend()on same socket (or a poll/epoll user with same bi-directional trafic)
Agreed.
-- John
Re: [PATCH] tcp: tcp_prequeue() can use keyed wakeups
From: John Dykstra <[email protected]>
Date: Wed, 13 May 2009 10:05:07 -0500
Quoted 8 lines · Eric Dumazet
Quoted 5 lines
To see a benefit of this patch, we would need two threads, one blocked in a
recv(),
one blocked in asend()on same socket (or a poll/epoll user with same bi-directional trafic)Agreed.
I've applied this to net-next-2.6, thanks.
From: Eric Dumazet <[email protected]>
Date: Thu, 07 May 2009 19:08:38 +0200
Quoted 3 lines
Small cleanup patch to reduce line lengths, before a change in
tcp_prequeue().Signed-off-by Eric Dumazet <[email protected]>
Applied.