From: Herbert Xu <herbert.xu@redhat.com> Date: Thu, 4 Jun 2009 14:51:06 +1000 Subject: [net] tun: only wake up writers Message-id: 20090604045106.GA24975@gondor.apana.org.au O-Subject: [RHEL5.4 PATCH] tun: Only wake up writers Bugzilla: 503191 RH-Acked-by: David Miller <davem@redhat.com> RH-Acked-by: Rik van Riel <riel@redhat.com> Hi: RHEL5 bugzilla 503191 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 3a4afe0..6e66894 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c @@ -641,12 +641,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); }