Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp57999imm; Mon, 21 May 2018 02:08:47 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrmLRukrUit1RN1GvXOEcTgyXEuCmD2vnI2T8Gt7ga1hvBxepILyCX8Ani9rD189xOF41SD X-Received: by 2002:a17:902:622:: with SMTP id 31-v6mr11831580plg.135.1526893727111; Mon, 21 May 2018 02:08:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526893727; cv=none; d=google.com; s=arc-20160816; b=OnMaP7kkdn84kKyQvDMHM5+Mk/llzzJHrKSKIUQ0WX/FTtYxK4ju+qOpyLur+uezHU g2C9YnI5VgN89IoZ9bEuEfCX/Mh0d5jh6lGNPl7g+hrXb4R7U7DXXT6xRGgcVqbvrkcj Idd7+kFPUpqnC6goVosojWmP/Njbapm1ETbUB2dZ+8TSWucmeGxG9ZjEsD8nlAezPRP6 nQCmj2VltZb3n9wEtIJ4AFk9YpocegjvTCB0zmJ3yHc9BjCWpnoVNeTbL2kui945gAG/ zqKi2yAQjQfgWZ0t+6S+z4Mt1zkXW9vMa76VHIaXnMB1HsI79I6ttRcYw3CGH04hBkE4 gQMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=tcq8nzJLn1cr+SpVOqkjmjfO+0Xb1qUKQe7CEBOFs1k=; b=xzG0wM5BF0awie2NCaZ728+1ijCB8V3lJtV0f5ebPZ+vrIRkXRRdCGIcEM46qCl95Z Plimjzs3Cfz/R6PNY7kqJ1Llc1D+6LBZ02ZXpEDfxhaRU4lWuNvwlcjEYVnKaTzlsjYh sg6/MhW030DMCjjySFG1x8v20rk4MaV9OmhFpuqq6naDWfMKBmd9NMq+Ej4ceVBwZDhF dxrkZy7k4VZ0z9P/FU2C4bwQGNfC5CIIsTSdW6Xd+wmzpg2o0V/Wd2O605RcCgPRwfyr LPxkJfwjCBUThR4NYuicXv1Wo/xUx0iHqiCfB0WjiSIW4T4AxC2yKJnNKIGP2UrMKHLs OkEQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e22-v6si13819022plj.311.2018.05.21.02.08.33; Mon, 21 May 2018 02:08:47 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752641AbeEUJFF (ORCPT + 99 others); Mon, 21 May 2018 05:05:05 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:41294 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751727AbeEUJFC (ORCPT ); Mon, 21 May 2018 05:05:02 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 92B9D401DEA6; Mon, 21 May 2018 09:05:01 +0000 (UTC) Received: from jason-ThinkPad-T450s.redhat.com (ovpn-12-30.pek2.redhat.com [10.72.12.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id C94E04AF1; Mon, 21 May 2018 09:04:56 +0000 (UTC) From: Jason Wang To: mst@redhat.com, jasowang@redhat.com Cc: kvm@vger.kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH net-next 05/12] vhost_net: batch update used ring for datacopy TX Date: Mon, 21 May 2018 17:04:26 +0800 Message-Id: <1526893473-20128-6-git-send-email-jasowang@redhat.com> In-Reply-To: <1526893473-20128-1-git-send-email-jasowang@redhat.com> References: <1526893473-20128-1-git-send-email-jasowang@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Mon, 21 May 2018 09:05:01 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Mon, 21 May 2018 09:05:01 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'jasowang@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Like commit e2b3b35eb989 ("vhost_net: batch used ring update in rx"), this patches implements batch used ring update for datacopy TX (zerocopy has already done some kind of batching). Testpmd transmission from guest to ixgbe via XDP_REDIRECT shows about 15% improvement from 2.8Mpps to 3.2Mpps. Signed-off-by: Jason Wang --- drivers/vhost/net.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c index 4682fcc..f0639d7 100644 --- a/drivers/vhost/net.c +++ b/drivers/vhost/net.c @@ -511,6 +511,7 @@ static void handle_tx_copy(struct vhost_net *net) struct socket *sock; struct vhost_net_ubuf_ref *uninitialized_var(ubufs); int sent_pkts = 0; + s16 nheads = 0; mutex_lock(&vq->mutex); sock = vq->private_data; @@ -550,6 +551,9 @@ static void handle_tx_copy(struct vhost_net *net) if (len < 0) break; + vq->heads[nheads].id = cpu_to_vhost32(vq, head); + vq->heads[nheads].len = 0; + total_len += len; if (total_len < VHOST_NET_WEIGHT && vhost_has_more_pkts(net, vq)) { @@ -568,13 +572,20 @@ static void handle_tx_copy(struct vhost_net *net) if (err != len) pr_debug("Truncated TX packet: " " len %d != %zd\n", err, len); - vhost_add_used_and_signal(&net->dev, vq, head, 0); + if (++nheads == VHOST_RX_BATCH) { + vhost_add_used_and_signal_n(&net->dev, vq, vq->heads, + nheads); + nheads = 0; + } if (vhost_exceeds_weight(++sent_pkts, total_len)) { vhost_poll_queue(&vq->poll); break; } } out: + if (nheads) + vhost_add_used_and_signal_n(&net->dev, vq, vq->heads, + nheads); mutex_unlock(&vq->mutex); } -- 2.7.4