From: Jason Wang <jasowang@redhat.com>
To: "Michael S. Tsirkin" <mst@redhat.com>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
kvm@vger.kernel.org, virtualization@lists.linux-foundation.org
Subject: Re: [PATCH V3 2/2] vhost_net: conditionally enable tx polling
Date: Wed, 8 Jun 2016 14:48:18 +0800 [thread overview]
Message-ID: <5757BFB2.6020400@redhat.com> (raw)
In-Reply-To: <20160607152407-mutt-send-email-mst@redhat.com>
On 2016年06月07日 20:26, Michael S. Tsirkin wrote:
> On Wed, Jun 01, 2016 at 01:56:34AM -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.
>>
>> 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 1d3e45f..e75ffcc 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)
> This seems rather risky. What if TX failed for some other reason?
> Polling won't ever be re-enabled ...
>
But why we need to enable tx poll in this case? Even if we enable it, we
wont' get any wakeup.
>> --
>> 1.8.3.1
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
WARNING: multiple messages have this Message-ID (diff)
From: Jason Wang <jasowang@redhat.com>
To: "Michael S. Tsirkin" <mst@redhat.com>
Cc: kvm@vger.kernel.org, virtualization@lists.linux-foundation.org,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH V3 2/2] vhost_net: conditionally enable tx polling
Date: Wed, 8 Jun 2016 14:48:18 +0800 [thread overview]
Message-ID: <5757BFB2.6020400@redhat.com> (raw)
In-Reply-To: <20160607152407-mutt-send-email-mst@redhat.com>
On 2016年06月07日 20:26, Michael S. Tsirkin wrote:
> On Wed, Jun 01, 2016 at 01:56:34AM -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.
>>
>> 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 1d3e45f..e75ffcc 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)
> This seems rather risky. What if TX failed for some other reason?
> Polling won't ever be re-enabled ...
>
But why we need to enable tx poll in this case? Even if we enable it, we
wont' get any wakeup.
>> --
>> 1.8.3.1
next prev parent reply other threads:[~2016-06-08 6:48 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-01 5:56 [PATCH V3 0/2] vhost_net polling optimization Jason Wang
2016-06-01 5:56 ` [PATCH V3 1/2] vhost_net: stop polling socket during rx processing Jason Wang
2016-06-01 5:56 ` Jason Wang
2016-06-07 12:23 ` Michael S. Tsirkin
2016-06-07 12:23 ` Michael S. Tsirkin
2016-06-07 21:46 ` David Miller
2016-06-07 21:46 ` David Miller
2016-06-01 5:56 ` [PATCH V3 2/2] vhost_net: conditionally enable tx polling Jason Wang
2016-06-01 5:56 ` Jason Wang
2016-06-07 12:26 ` Michael S. Tsirkin
2016-06-07 12:26 ` Michael S. Tsirkin
2016-06-08 6:48 ` Jason Wang [this message]
2016-06-08 6:48 ` Jason Wang
2016-06-02 19:08 ` [PATCH V3 0/2] vhost_net polling optimization David Miller
2016-06-02 19:08 ` David Miller
2016-06-03 13:03 ` Michael S. Tsirkin
2016-06-03 13:03 ` Michael S. Tsirkin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5757BFB2.6020400@redhat.com \
--to=jasowang@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mst@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=virtualization@lists.linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.