{"id":809888,"url":"http://patchwork.ozlabs.org/api/1.2/patches/809888/?format=json","web_url":"http://patchwork.ozlabs.org/project/netdev/patch/1504574525-4711-1-git-send-email-jasowang@redhat.com/","project":{"id":7,"url":"http://patchwork.ozlabs.org/api/1.2/projects/7/?format=json","name":"Linux network development","link_name":"netdev","list_id":"netdev.vger.kernel.org","list_email":"netdev@vger.kernel.org","web_url":null,"scm_url":null,"webscm_url":null,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<1504574525-4711-1-git-send-email-jasowang@redhat.com>","list_archive_url":null,"date":"2017-09-05T01:22:05","name":"[net,V2] vhost_net: correctly check tx avail during rx busy polling","commit_ref":null,"pull_url":null,"state":"accepted","archived":true,"hash":"a8a1549bdb0b1c9726443f40fae4a5bcd0efd669","submitter":{"id":5225,"url":"http://patchwork.ozlabs.org/api/1.2/people/5225/?format=json","name":"Jason Wang","email":"jasowang@redhat.com"},"delegate":{"id":34,"url":"http://patchwork.ozlabs.org/api/1.2/users/34/?format=json","username":"davem","first_name":"David","last_name":"Miller","email":"davem@davemloft.net"},"mbox":"http://patchwork.ozlabs.org/project/netdev/patch/1504574525-4711-1-git-send-email-jasowang@redhat.com/mbox/","series":[{"id":1476,"url":"http://patchwork.ozlabs.org/api/1.2/series/1476/?format=json","web_url":"http://patchwork.ozlabs.org/project/netdev/list/?series=1476","date":"2017-09-05T01:22:05","name":"[net,V2] vhost_net: correctly check tx avail during rx busy polling","version":2,"mbox":"http://patchwork.ozlabs.org/series/1476/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/809888/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/809888/checks/","tags":{},"related":[],"headers":{"Return-Path":"<netdev-owner@vger.kernel.org>","X-Original-To":"patchwork-incoming@ozlabs.org","Delivered-To":"patchwork-incoming@ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=vger.kernel.org\n\t(client-ip=209.132.180.67; helo=vger.kernel.org;\n\tenvelope-from=netdev-owner@vger.kernel.org;\n\treceiver=<UNKNOWN>)","ext-mx02.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com","ext-mx02.extmail.prod.ext.phx2.redhat.com;\n\tspf=fail smtp.mailfrom=jasowang@redhat.com"],"Received":["from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3xmTV334QKz9s7f\n\tfor <patchwork-incoming@ozlabs.org>;\n\tTue,  5 Sep 2017 11:22:35 +1000 (AEST)","(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1754085AbdIEBWO (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tMon, 4 Sep 2017 21:22:14 -0400","from mx1.redhat.com ([209.132.183.28]:56114 \"EHLO mx1.redhat.com\"\n\trhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP\n\tid S1754066AbdIEBWN (ORCPT <rfc822;netdev@vger.kernel.org>);\n\tMon, 4 Sep 2017 21:22:13 -0400","from smtp.corp.redhat.com\n\t(int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14])\n\t(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby mx1.redhat.com (Postfix) with ESMTPS id 02F87806D2;\n\tTue,  5 Sep 2017 01:22:13 +0000 (UTC)","from jason-ThinkPad-T450s.redhat.com (ovpn-12-71.pek2.redhat.com\n\t[10.72.12.71])\n\tby smtp.corp.redhat.com (Postfix) with ESMTP id 4A7F55D722;\n\tTue,  5 Sep 2017 01:22:08 +0000 (UTC)"],"DMARC-Filter":"OpenDMARC Filter v1.3.2 mx1.redhat.com 02F87806D2","From":"Jason Wang <jasowang@redhat.com>","To":"mst@redhat.com, jasowang@redhat.com, netdev@vger.kernel.org","Cc":"kvm@vger.kernel.org, virtualization@lists.linux-foundation.org,\n\tlinux-kernel@vger.kernel.org","Subject":"[PATCH net V2] vhost_net: correctly check tx avail during rx busy\n\tpolling","Date":"Tue,  5 Sep 2017 09:22:05 +0800","Message-Id":"<1504574525-4711-1-git-send-email-jasowang@redhat.com>","X-Scanned-By":"MIMEDefang 2.79 on 10.5.11.14","X-Greylist":"Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.26]);\n\tTue, 05 Sep 2017 01:22:13 +0000 (UTC)","Sender":"netdev-owner@vger.kernel.org","Precedence":"bulk","List-ID":"<netdev.vger.kernel.org>","X-Mailing-List":"netdev@vger.kernel.org"},"content":"We check tx avail through vhost_enable_notify() in the past which is\nwrong since it only checks whether or not guest has filled more\navailable buffer since last avail idx synchronization which was just\ndone by vhost_vq_avail_empty() before. What we really want is checking\npending buffers in the avail ring. Fix this by calling\nvhost_vq_avail_empty() instead.\n\nThis issue could be noticed by doing netperf TCP_RR benchmark as\nclient from guest (but not host). With this fix, TCP_RR from guest to\nlocalhost restores from 1375.91 trans per sec to 55235.28 trans per\nsec on my laptop (Intel(R) Core(TM) i7-5600U CPU @ 2.60GHz).\n\nFixes: 030881372460 (\"vhost_net: basic polling support\")\nSigned-off-by: Jason Wang <jasowang@redhat.com>\n---\n- The patch is needed for -stable\n- Changes from V1: enable vq notification when needed\n---\n drivers/vhost/net.c | 7 ++++++-\n 1 file changed, 6 insertions(+), 1 deletion(-)","diff":"diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c\nindex 06d0448..1c75572 100644\n--- a/drivers/vhost/net.c\n+++ b/drivers/vhost/net.c\n@@ -634,8 +634,13 @@ static int vhost_net_rx_peek_head_len(struct vhost_net *net, struct sock *sk)\n \n \t\tpreempt_enable();\n \n-\t\tif (vhost_enable_notify(&net->dev, vq))\n+\t\tif (!vhost_vq_avail_empty(&net->dev, vq))\n \t\t\tvhost_poll_queue(&vq->poll);\n+\t\telse if (unlikely(vhost_enable_notify(&net->dev, vq))) {\n+\t\t\tvhost_disable_notify(&net->dev, vq);\n+\t\t\tvhost_poll_queue(&vq->poll);\n+\t\t}\n+\n \t\tmutex_unlock(&vq->mutex);\n \n \t\tlen = peek_head_len(rvq, sk);\n","prefixes":["net","V2"]}