Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp59548imm; Mon, 21 May 2018 02:10:43 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoWD/Mosec18Zgn/7VzFa07HDxdzTc3USCihIHx0eqTCypyRgjxycfLkZasys8BiBbyLDsH X-Received: by 2002:a17:902:5309:: with SMTP id b9-v6mr20029468pli.187.1526893843303; Mon, 21 May 2018 02:10:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526893843; cv=none; d=google.com; s=arc-20160816; b=eY4nmB21X6BNHMtU3+uC7cWEPEyZRR3HEk+Ajbg5zCxDrel/VOFAS/gUuSEJBRQsQp 0ESUcuXXzbczGhGbZKxDCnPMCacvzIM330NHfFP3nZd7eouuWRUI8YtRAy0aNPo7b0wT 3xPoOsMdEQYrfNvDnL+zzHRUlGVf3vFvAI4G/ppaqjZ4jz6ATAZCjbVVf6x3Hj+xDkCo bF+7HAweeYYTD/ISfR7Y3ZReumhDXyeji5X4UERro1mntT9ing7FlKaf2Hzvw+sF4OzN /WkWxPUowWC0JmurxHrj2uhWx5vSZ7B8lFAzlZarp4fU+XretLfC6oqhI6H65IpW575+ J4kg== 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=kS40BPiuj6mBSGGCqGySybdWTNhJm6UgUgiKzkxsrIY=; b=0RJe57r7t4vM4VHADnBUjlC62m5jIgoaN2jC/qy7dkMMwa/UeiXrD5e13zBaIWSTAo 9owTxKGDsZipIk5nZDlR4i3j4ioh6n/eg9nt/RLxlpaBUn9OukjsDlzvLO3XynrQHRja FiK1+V+s+FxQM0q4V08WvFgh6zNb3m4pZOcWFW75YzalQF6mdza1u6zFwUAoUF2Mu9a3 7JydYJMxTWkHfX3Ec1QAwm6Hfg5KzOM+6imMWanpfDy4L/Qb8h4AeYX41m2xmx81GZ0H oG9sVjIfmawnxfxypnsnNORTkRVqcU7dhTmF/vuyibXn2QdlqUE/yFLenkeDg7Y3whHS UqgA== 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 p13-v6si10258658pgv.182.2018.05.21.02.10.29; Mon, 21 May 2018 02:10:43 -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 S1752746AbeEUJIu (ORCPT + 99 others); Mon, 21 May 2018 05:08:50 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:39974 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751778AbeEUJEw (ORCPT ); Mon, 21 May 2018 05:04:52 -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 0B54281663DD; Mon, 21 May 2018 09:04:52 +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 4D1BF76C0; Mon, 21 May 2018 09:04:48 +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 03/12] vhost_net: introduce vhost_has_more_pkts() Date: Mon, 21 May 2018 17:04:24 +0800 Message-Id: <1526893473-20128-4-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.8]); Mon, 21 May 2018 09:04:52 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Mon, 21 May 2018 09:04:52 +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 Signed-off-by: Jason Wang --- drivers/vhost/net.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c index de544ee..4ebac76 100644 --- a/drivers/vhost/net.c +++ b/drivers/vhost/net.c @@ -485,6 +485,13 @@ static bool vhost_exceeds_weight(int pkts, int total_len) unlikely(pkts >= VHOST_NET_PKT_WEIGHT); } +static bool vhost_has_more_pkts(struct vhost_net *net, + struct vhost_virtqueue *vq) +{ + return !vhost_vq_avail_empty(&net->dev, vq) && + likely(!vhost_exceeds_maxpend(net)); +} + /* Expects to be always run from workqueue - which acts as * read-size critical section for our kind of RCU. */ static void handle_tx(struct vhost_net *net) @@ -578,8 +585,7 @@ static void handle_tx(struct vhost_net *net) } total_len += len; if (total_len < VHOST_NET_WEIGHT && - !vhost_vq_avail_empty(&net->dev, vq) && - likely(!vhost_exceeds_maxpend(net))) { + vhost_has_more_pkts(net, vq)) { msg.msg_flags |= MSG_MORE; } else { msg.msg_flags &= ~MSG_MORE; @@ -605,7 +611,7 @@ static void handle_tx(struct vhost_net *net) else vhost_zerocopy_signal_used(net, vq); vhost_net_tx_packet(net); - if (unlikely(vhost_exceeds_weight(++sent_pkts, total_len))) { + if (vhost_exceeds_weight(++sent_pkts, total_len)) { vhost_poll_queue(&vq->poll); break; } -- 2.7.4