Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1408803 > unrolled thread
| Started by | Jason Wang <jasowang@redhat.com> |
|---|---|
| First post | 2016-05-30 08:50 +0200 |
| Last post | 2016-05-31 05:30 +0200 |
| Articles | 4 — 2 participants |
Back to article view | Back to linux.kernel
[PATCH V2 0/2] vhost_net polling optimization Jason Wang <jasowang@redhat.com> - 2016-05-30 08:50 +0200
[PATCH V2 2/2] vhost_net: conditionally enable tx polling Jason Wang <jasowang@redhat.com> - 2016-05-30 08:50 +0200
Re: [PATCH V2 2/2] vhost_net: conditionally enable tx polling "Michael S. Tsirkin" <mst@redhat.com> - 2016-05-30 18:00 +0200
Re: [PATCH V2 2/2] vhost_net: conditionally enable tx polling Jason Wang <jasowang@redhat.com> - 2016-05-31 05:30 +0200
| From | Jason Wang <jasowang@redhat.com> |
|---|---|
| Date | 2016-05-30 08:50 +0200 |
| Subject | [PATCH V2 0/2] vhost_net polling optimization |
| Message-ID | <rEpbs-B4-15@gated-at.bofh.it> |
Hi: This series tries to optimize vhost_net polling at two points: - Stop rx polling for reduicng the unnecessary wakeups during handle_rx(). - Conditonally enable tx polling for reducing the unnecessary traversing and spinlock touching. Test shows about 17% improvement on rx pps. Please review Changes from V1: - use vhost_net_disable_vq()/vhost_net_enable_vq() instead of open coding. - Add a new patch for conditionally enable tx polling. Jason Wang (2): vhost_net: stop polling socket during rx processing vhost_net: conditionally enable tx polling drivers/vhost/net.c | 59 +++++++++++++++++++++++++++++------------------------ 1 file changed, 32 insertions(+), 27 deletions(-) -- 1.8.3.1
[toc] | [next] | [standalone]
| From | Jason Wang <jasowang@redhat.com> |
|---|---|
| Date | 2016-05-30 08:50 +0200 |
| Subject | [PATCH V2 2/2] vhost_net: conditionally enable tx polling |
| Message-ID | <rEpbs-B4-29@gated-at.bofh.it> |
| In reply to | #1408803 |
We always poll tx for socket, this is sub optimal since:
- it will be only used when we exceed the sndbuf of the socket.
- since we use two independent polls for tx and vq, this will slightly
increase the waitqueue traversing time and more important, vhost
could not benefit from commit
9e641bdcfa4ef4d6e2fbaa59c1be0ad5d1551fd5 ("net-tun: restructure
tun_do_read for better sleep/wakeup efficiency") even if we've
stopped rx polling during handle_rx since tx poll were still left in
the waitqueue.
Fix this by conditionally enable tx polling only when -EAGAIN were
met.
Test shows about 8% improvement on guest rx pps.
Before: ~1350000
After: ~1460000
Signed-off-by: Jason Wang <jasowang@redhat.com>
---
drivers/vhost/net.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c
index e91603b..5a05fa0 100644
--- a/drivers/vhost/net.c
+++ b/drivers/vhost/net.c
@@ -378,6 +378,7 @@ static void handle_tx(struct vhost_net *net)
goto out;
vhost_disable_notify(&net->dev, vq);
+ vhost_net_disable_vq(net, vq);
hdr_size = nvq->vhost_hlen;
zcopy = nvq->ubufs;
@@ -459,6 +460,8 @@ static void handle_tx(struct vhost_net *net)
% UIO_MAXIOV;
}
vhost_discard_vq_desc(vq, 1);
+ if (err == -EAGAIN)
+ vhost_net_enable_vq(net, vq);
break;
}
if (err != len)
--
1.8.3.1
[toc] | [prev] | [next] | [standalone]
| From | "Michael S. Tsirkin" <mst@redhat.com> |
|---|---|
| Date | 2016-05-30 18:00 +0200 |
| Subject | Re: [PATCH V2 2/2] vhost_net: conditionally enable tx polling |
| Message-ID | <rExLI-6b9-15@gated-at.bofh.it> |
| In reply to | #1408804 |
On Mon, May 30, 2016 at 02:47:54AM -0400, Jason Wang wrote:
> We always poll tx for socket, this is sub optimal since:
>
> - it will be only used when we exceed the sndbuf of the socket.
> - since we use two independent polls for tx and vq, this will slightly
> increase the waitqueue traversing time and more important, vhost
> could not benefit from commit
> 9e641bdcfa4ef4d6e2fbaa59c1be0ad5d1551fd5 ("net-tun: restructure
> tun_do_read for better sleep/wakeup efficiency") even if we've
> stopped rx polling during handle_rx since tx poll were still left in
> the waitqueue.
Why is this an issue?
sock_def_write_space only wakes up when queue is half empty,
not on each packet.
if ((atomic_read(&sk->sk_wmem_alloc) << 1) <= sk->sk_sndbuf)
I suspect the issue is with your previous patch,
it now pokes at the spinlock on data path
where it used not to.
Is that right?
>
> Fix this by conditionally enable tx polling only when -EAGAIN were
> met.
>
> Test shows about 8% improvement on guest rx pps.
>
> Before: ~1350000
> After: ~1460000
>
> Signed-off-by: Jason Wang <jasowang@redhat.com>
> ---
> drivers/vhost/net.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c
> index e91603b..5a05fa0 100644
> --- a/drivers/vhost/net.c
> +++ b/drivers/vhost/net.c
> @@ -378,6 +378,7 @@ static void handle_tx(struct vhost_net *net)
> goto out;
>
> vhost_disable_notify(&net->dev, vq);
> + vhost_net_disable_vq(net, vq);
>
> hdr_size = nvq->vhost_hlen;
> zcopy = nvq->ubufs;
> @@ -459,6 +460,8 @@ static void handle_tx(struct vhost_net *net)
> % UIO_MAXIOV;
> }
> vhost_discard_vq_desc(vq, 1);
> + if (err == -EAGAIN)
> + vhost_net_enable_vq(net, vq);
> break;
> }
> if (err != len)
> --
> 1.8.3.1
[toc] | [prev] | [next] | [standalone]
| From | Jason Wang <jasowang@redhat.com> |
|---|---|
| Date | 2016-05-31 05:30 +0200 |
| Subject | Re: [PATCH V2 2/2] vhost_net: conditionally enable tx polling |
| Message-ID | <rEIxr-5ko-5@gated-at.bofh.it> |
| In reply to | #1409251 |
On 2016年05月30日 23:55, Michael S. Tsirkin wrote:
> On Mon, May 30, 2016 at 02:47:54AM -0400, Jason Wang wrote:
>> We always poll tx for socket, this is sub optimal since:
>>
>> - it will be only used when we exceed the sndbuf of the socket.
>> - since we use two independent polls for tx and vq, this will slightly
>> increase the waitqueue traversing time and more important, vhost
>> could not benefit from commit
>> 9e641bdcfa4ef4d6e2fbaa59c1be0ad5d1551fd5 ("net-tun: restructure
>> tun_do_read for better sleep/wakeup efficiency") even if we've
>> stopped rx polling during handle_rx since tx poll were still left in
>> the waitqueue.
> Why is this an issue?
> sock_def_write_space only wakes up when queue is half empty,
> not on each packet.
> if ((atomic_read(&sk->sk_wmem_alloc) << 1) <= sk->sk_sndbuf)
>
> I suspect the issue is with your previous patch,
> it now pokes at the spinlock on data path
> where it used not to.
>
> Is that right?
The problem is not tx wake up but still rx wake up. Patch 1 removes rx
poll, but still left tx poll. So in sock_def_readable(),
skwq_has_sleeper() returns true, we still need to traverse waitqueue and
touch spinlocks. With this patch, unless a heavy tx load, tx poll were
disabled, sock_def_readable() can return finish very soon.
>
>
>> Fix this by conditionally enable tx polling only when -EAGAIN were
>> met.
>>
>> Test shows about 8% improvement on guest rx pps.
>>
>> Before: ~1350000
>> After: ~1460000
>>
>> Signed-off-by: Jason Wang <jasowang@redhat.com>
>> ---
>> drivers/vhost/net.c | 3 +++
>> 1 file changed, 3 insertions(+)
>>
>> diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c
>> index e91603b..5a05fa0 100644
>> --- a/drivers/vhost/net.c
>> +++ b/drivers/vhost/net.c
>> @@ -378,6 +378,7 @@ static void handle_tx(struct vhost_net *net)
>> goto out;
>>
>> vhost_disable_notify(&net->dev, vq);
>> + vhost_net_disable_vq(net, vq);
>>
>> hdr_size = nvq->vhost_hlen;
>> zcopy = nvq->ubufs;
>> @@ -459,6 +460,8 @@ static void handle_tx(struct vhost_net *net)
>> % UIO_MAXIOV;
>> }
>> vhost_discard_vq_desc(vq, 1);
>> + if (err == -EAGAIN)
>> + vhost_net_enable_vq(net, vq);
>> break;
>> }
>> if (err != len)
>> --
>> 1.8.3.1
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web