All of lore.kernel.org
 help / color / mirror / Atom feed
* tun: Only wake up writers
@ 2009-06-03  3:33 Herbert Xu
  2009-06-03 12:36 ` Herbert Xu
  0 siblings, 1 reply; 3+ messages in thread
From: Herbert Xu @ 2009-06-03  3:33 UTC (permalink / raw)
  To: David S. Miller, netdev

Hi:

tun: Only wake up writers

Recently net/core/sock.c was updated so that when we free an skb
that has been transmitted we only wake up writers instead of waking
up both readers and writers.

This patch does the same thing for tun as this code is identical
to that in net/core/sock.c

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index 735bf41..7ca43b8 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -841,7 +841,9 @@ static void tun_sock_write_space(struct sock *sk)
 		return;
 
 	if (sk->sk_sleep && waitqueue_active(sk->sk_sleep))
-		wake_up_interruptible_sync(sk->sk_sleep);
+		wake_up_interruptible_sync_poll(sk->sk_sleep,
+						POLLOUT | POLLWRNORM |
+						POLLWRBAND);
 
 	if (!test_and_clear_bit(SOCK_ASYNC_NOSPACE, &sk->sk_socket->flags))
 		return;

Thanks,
-- 
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

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

* Re: tun: Only wake up writers
  2009-06-03  3:33 tun: Only wake up writers Herbert Xu
@ 2009-06-03 12:36 ` Herbert Xu
  2009-06-04  4:46   ` David Miller
  0 siblings, 1 reply; 3+ messages in thread
From: Herbert Xu @ 2009-06-03 12:36 UTC (permalink / raw)
  To: David S. Miller, netdev

On Wed, Jun 03, 2009 at 01:33:03PM +1000, Herbert Xu wrote:
> 
> tun: Only wake up writers
> 
> Recently net/core/sock.c was updated so that when we free an skb
> that has been transmitted we only wake up writers instead of waking
> up both readers and writers.
> 
> This patch does the same thing for tun as this code is identical
> to that in net/core/sock.c
> 
> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

Scratch that.  It doesn't actually work because our poll(2) doesn't
use this extra info.  Here's a patch that actually works:

tun: Only wake up writers

When I added socket accounting to tun I inadvertently introduced
spurious wake-up events that kills qemu performance.  The problem
occurs when qemu polls on the tun fd for read, and then transmits
packets.  For each packet transmitted, we will wake up qemu even
if it only cares about read events.

Now this affects all sockets, but it is only a new problem for
tun.  So this patch tries to fix it for tun first and we can then
look at the problem in general.
 
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index 735bf41..eeb8af5 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -840,12 +840,12 @@ static void tun_sock_write_space(struct sock *sk)
 	if (!sock_writeable(sk))
 		return;
 
-	if (sk->sk_sleep && waitqueue_active(sk->sk_sleep))
-		wake_up_interruptible_sync(sk->sk_sleep);
-
 	if (!test_and_clear_bit(SOCK_ASYNC_NOSPACE, &sk->sk_socket->flags))
 		return;
 
+	if (sk->sk_sleep && waitqueue_active(sk->sk_sleep))
+		wake_up_interruptible_sync(sk->sk_sleep);
+
 	tun = container_of(sk, struct tun_sock, sk)->tun;
 	kill_fasync(&tun->fasync, SIGIO, POLL_OUT);
 }

Thanks,
-- 
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

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

* Re: tun: Only wake up writers
  2009-06-03 12:36 ` Herbert Xu
@ 2009-06-04  4:46   ` David Miller
  0 siblings, 0 replies; 3+ messages in thread
From: David Miller @ 2009-06-04  4:46 UTC (permalink / raw)
  To: herbert; +Cc: netdev

From: Herbert Xu <herbert@gondor.apana.org.au>
Date: Wed, 3 Jun 2009 22:36:55 +1000

> tun: Only wake up writers
> 
> When I added socket accounting to tun I inadvertently introduced
> spurious wake-up events that kills qemu performance.  The problem
> occurs when qemu polls on the tun fd for read, and then transmits
> packets.  For each packet transmitted, we will wake up qemu even
> if it only cares about read events.
> 
> Now this affects all sockets, but it is only a new problem for
> tun.  So this patch tries to fix it for tun first and we can then
> look at the problem in general.
>  
> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

Applied to net-next-2.6, thanks Herbert!

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

end of thread, other threads:[~2009-06-04  4:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-06-03  3:33 tun: Only wake up writers Herbert Xu
2009-06-03 12:36 ` Herbert Xu
2009-06-04  4:46   ` 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.