From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755105AbcFHGs0 (ORCPT ); Wed, 8 Jun 2016 02:48:26 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33279 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754210AbcFHGsY (ORCPT ); Wed, 8 Jun 2016 02:48:24 -0400 Subject: Re: [PATCH V3 2/2] vhost_net: conditionally enable tx polling To: "Michael S. Tsirkin" References: <1464760594-30326-1-git-send-email-jasowang@redhat.com> <1464760594-30326-3-git-send-email-jasowang@redhat.com> <20160607152407-mutt-send-email-mst@redhat.com> Cc: kvm@vger.kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org From: Jason Wang Message-ID: <5757BFB2.6020400@redhat.com> Date: Wed, 8 Jun 2016 14:48:18 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.8.0 MIME-Version: 1.0 In-Reply-To: <20160607152407-mutt-send-email-mst@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Wed, 08 Jun 2016 06:48:23 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 >> --- >> 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