Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1520371imm; Tue, 22 May 2018 05:29:27 -0700 (PDT) X-Google-Smtp-Source: AB8JxZriPhNtpdN4mnnBxyaG9e9ZtUeSamWWw7VJn+j5m+UDCqekQClBM23du5xUIgthjcBu5y7A X-Received: by 2002:a65:6119:: with SMTP id z25-v6mr3697271pgu.139.1526992167359; Tue, 22 May 2018 05:29:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526992167; cv=none; d=google.com; s=arc-20160816; b=dUJBHZkhpKNzR1j5UEAnCrq+23NFFkTFHsKw/0lCXa5UrJTRWtRYYIGNkCg4vhBFtw fa7eUN5nIOXNXrBZZgZmzvahs/yz3lA4ZkaIG9kMq57TQyvqMOUFNkHDLrDmHPw+a5zk ztWr+TagNpNKAyHkHGeWY9AaTXMyQnsaonbFf/9E0Mn3O66tjAxALH1OwIq/HAJ4zOoJ BszLZu/yH36LOsF9wxfG1aG2jLFsjwOVms6vUJn6LicKC8rvb1dwtD+5goXQXwMcHLh5 ZE2ZjbLagMav1sX+AClKXfROdHb7hF+2ccaaISSWd0UdtjjYMjHSIZYTQpMuhiEpP6U8 wZdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=tzTOk461pCavJJjnd0SHs1BeaLoKNNTUThUeaoKLw98=; b=cueiPAieaZgdcD4so28/aJJEECqzGsWlq+D2Mw7gSdU91L4i9slpALKBeoGflPGwaB g096tKWBYBi8SkS2xMt9mv9gr0F+IXivFhDFJvTXhm6Q6oqC5JworKkFNfyOCERvYTAi bulA3r6q2yyDCgZhUiHAk77SLM9eApaepCvdlSqFEUyz+1LG7swVhTV8C1NMAfVXbiEk lFcWPXn/4zQUHClG5MUOi4Qr/OFdhPVHCkY073UybMs3LP4NAAS4mjVZ4fISvFjj2+v3 qIrai9LNoDdDYeI+j8fuMDkSWxUkzs0907S0QskZ3Fxr6xhMwyrPYoZlJtJWSgttyADf Qq8w== 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 a87-v6si15955571pfl.165.2018.05.22.05.29.12; Tue, 22 May 2018 05:29:27 -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 S1751441AbeEVM2A (ORCPT + 99 others); Tue, 22 May 2018 08:28:00 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:45624 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751161AbeEVM15 (ORCPT ); Tue, 22 May 2018 08:27:57 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5AE39406DE36; Tue, 22 May 2018 12:27:57 +0000 (UTC) Received: from [10.72.12.75] (ovpn-12-75.pek2.redhat.com [10.72.12.75]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 895D9215CDA7; Tue, 22 May 2018 12:27:54 +0000 (UTC) Subject: Re: [RFC PATCH net-next 02/12] vhost_net: introduce vhost_exceeds_weight() To: Jesse Brandeburg Cc: mst@redhat.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, virtualization@lists.linux-foundation.org References: <1526893473-20128-1-git-send-email-jasowang@redhat.com> <1526893473-20128-3-git-send-email-jasowang@redhat.com> <20180521092923.00005cec@intel.com> From: Jason Wang Message-ID: Date: Tue, 22 May 2018 20:27:51 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <20180521092923.00005cec@intel.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Tue, 22 May 2018 12:27:57 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Tue, 22 May 2018 12:27:57 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.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 On 2018年05月22日 00:29, Jesse Brandeburg wrote: > On Mon, 21 May 2018 17:04:23 +0800 Jason wrote: >> Signed-off-by: Jason Wang >> --- >> drivers/vhost/net.c | 13 ++++++++----- >> 1 file changed, 8 insertions(+), 5 deletions(-) >> >> diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c >> index 15d191a..de544ee 100644 >> --- a/drivers/vhost/net.c >> +++ b/drivers/vhost/net.c >> @@ -479,6 +479,12 @@ static size_t init_iov_iter(struct vhost_virtqueue *vq, struct iov_iter *iter, >> return len; >> } >> >> +static bool vhost_exceeds_weight(int pkts, int total_len) >> +{ >> + return unlikely(total_len >= VHOST_NET_WEIGHT) || >> + unlikely(pkts >= VHOST_NET_PKT_WEIGHT); > I was going to say just one unlikely, but then the caller of this > function also says unlikely(vhost_exceeds...), so I think you should > just drop the unlikely statements here (both of them) Ok. > >> +} >> + >> /* 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) >> @@ -570,7 +576,6 @@ static void handle_tx(struct vhost_net *net) >> msg.msg_control = NULL; >> ubufs = NULL; >> } >> - > unrelated whitespace changes? Yes. Thanks > >> total_len += len; >> if (total_len < VHOST_NET_WEIGHT && >> !vhost_vq_avail_empty(&net->dev, vq) && >> @@ -600,8 +605,7 @@ static void handle_tx(struct vhost_net *net) >> else >> vhost_zerocopy_signal_used(net, vq); >> vhost_net_tx_packet(net); >> - if (unlikely(total_len >= VHOST_NET_WEIGHT) || >> - unlikely(++sent_pkts >= VHOST_NET_PKT_WEIGHT)) { >> + if (unlikely(vhost_exceeds_weight(++sent_pkts, total_len))) { >> vhost_poll_queue(&vq->poll); >> break; >> } >> @@ -887,8 +891,7 @@ static void handle_rx(struct vhost_net *net) >> if (unlikely(vq_log)) >> vhost_log_write(vq, vq_log, log, vhost_len); >> total_len += vhost_len; >> - if (unlikely(total_len >= VHOST_NET_WEIGHT) || >> - unlikely(++recv_pkts >= VHOST_NET_PKT_WEIGHT)) { >> + if (unlikely(vhost_exceeds_weight(++recv_pkts, total_len))) { >> vhost_poll_queue(&vq->poll); >> goto out; >> }