* [PATCH] tun: do not put self in waitq if doing a nonblock read
@ 2011-06-08 23:46 Amos Kong
2011-06-09 7:27 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Amos Kong @ 2011-06-08 23:46 UTC (permalink / raw)
To: netdev; +Cc: jasowang, davem, kvm, mst
Perf shows a relatively high rate (about 8%) race in
spin_lock_irqsave() when doing netperf between external host and
guest. It's mainly becuase the lock contention between the
tun_do_read() and tun_xmit_skb(), so this patch do not put self into
waitqueue to reduce this kind of race. After this patch, it drops to
4%.
Signed-off-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: Amos Kong <akong@redhat.com>
---
drivers/net/tun.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index 74e9405..95dbff4 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -817,7 +817,8 @@ static ssize_t tun_do_read(struct tun_struct *tun,
tun_debug(KERN_INFO, tun, "tun_chr_read\n");
- add_wait_queue(&tun->wq.wait, &wait);
+ if (unlikely(!noblock))
+ add_wait_queue(&tun->wq.wait, &wait);
while (len) {
current->state = TASK_INTERRUPTIBLE;
@@ -848,7 +849,8 @@ static ssize_t tun_do_read(struct tun_struct *tun,
}
current->state = TASK_RUNNING;
- remove_wait_queue(&tun->wq.wait, &wait);
+ if (unlikely(!noblock))
+ remove_wait_queue(&tun->wq.wait, &wait);
return ret;
}
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] tun: do not put self in waitq if doing a nonblock read
2011-06-08 23:46 [PATCH] tun: do not put self in waitq if doing a nonblock read Amos Kong
@ 2011-06-09 7:27 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2011-06-09 7:27 UTC (permalink / raw)
To: akong; +Cc: netdev, jasowang, kvm, mst
From: Amos Kong <akong@redhat.com>
Date: Thu, 09 Jun 2011 07:46:06 +0800
> Perf shows a relatively high rate (about 8%) race in
> spin_lock_irqsave() when doing netperf between external host and
> guest. It's mainly becuase the lock contention between the
> tun_do_read() and tun_xmit_skb(), so this patch do not put self into
> waitqueue to reduce this kind of race. After this patch, it drops to
> 4%.
>
> Signed-off-by: Jason Wang <jasowang@redhat.com>
> Signed-off-by: Amos Kong <akong@redhat.com>
Applied, thanks.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-06-09 7:27 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-08 23:46 [PATCH] tun: do not put self in waitq if doing a nonblock read Amos Kong
2011-06-09 7:27 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).