Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp516437imm; Mon, 21 May 2018 09:39:40 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqvm/pyD9UL+rEjBmosWqXIkF1mzOd1RvKSR1rJYRbWRpYQOWkKbpFNq+Dl/OBYyE+AAe5g X-Received: by 2002:a17:902:8f82:: with SMTP id z2-v6mr21219494plo.350.1526920780029; Mon, 21 May 2018 09:39:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526920780; cv=none; d=google.com; s=arc-20160816; b=aTMr1S4vHrXuHZVGG3oqUWQiWYxbVi/kn1JSxvCMr4fcGvzflCo1ckmLTt5F/kZPFy kMTRMLnKVcDLdgkZQo96K2Pjj+hw4iD92pmny8I4SZmB5INE+VB9RinHgVVueFri5243 aKg1jVM6y9DPhrg11eeXp8GbbZIzSHpNQxXkh2E48dG+c4vSpwCayCIly3yLUx7tcthx LrYcFdPmBlJvFab+sylrE5Wq9PXURDgQpciiFoqtUsvyD9mMwcJ4gARQTLpjxvHUsiW3 fGG+Ygy5E1Eh1kDZ12RbJ83yVFj4+7HWB6nyVFjW1EqV+fkCW1eQbbb8gaHbMVNiMQKa PKZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :arc-authentication-results; bh=3ep/rTYgTlwlfGgeptBfPInocgleE2bop9oxDpzB/gE=; b=R6IV2WMf/sKZ8w92cRfJd5uFnInTKTz7pcwJXwK1j03uesmwHvxfo3gZYJ23zI1i0R 0IKGxHEbaDRINt/7WBRtSB9hWJu3zlRz1SdCuZCm/pA+BXdo9dBJTh1yJuta4oyFrJ1K Uj1VAG0pwWk14MNt1x7ifJCaVPWYRlNpeMJUhtWm8NEhjuWmaoSstQenevQhXjKwRn68 fzhsdfgEAu/qgRmm0ofY6J6fsiLxz3FfpdObrd8wzQr8+o0A3QmA1MfG/wWjWydm+SGM LhZmAYNybR8K8pFg4Cdfh4DLdMNGtK/2Bp0tLQSpaLyTvNWbTdkiF3BfT/VbkGIaunvO xTjQ== 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=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r5-v6si14443081pls.227.2018.05.21.09.39.25; Mon, 21 May 2018 09:39:39 -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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753239AbeEUQjM (ORCPT + 99 others); Mon, 21 May 2018 12:39:12 -0400 Received: from mga02.intel.com ([134.134.136.20]:52232 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752803AbeEUQjJ (ORCPT ); Mon, 21 May 2018 12:39:09 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 May 2018 09:39:09 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,426,1520924400"; d="scan'208";a="57752271" Received: from jesse-tab.amr.corp.intel.com (HELO localhost) ([10.166.244.182]) by orsmga001.jf.intel.com with ESMTP; 21 May 2018 09:39:09 -0700 Date: Mon, 21 May 2018 09:39:08 -0700 From: Jesse Brandeburg To: Jason Wang Cc: , , , , , jesse.brandeburg@intel.com Subject: Re: [RFC PATCH net-next 03/12] vhost_net: introduce vhost_has_more_pkts() Message-ID: <20180521093908.00006747@intel.com> In-Reply-To: <1526893473-20128-4-git-send-email-jasowang@redhat.com> References: <1526893473-20128-1-git-send-email-jasowang@redhat.com> <1526893473-20128-4-git-send-email-jasowang@redhat.com> X-Mailer: Claws Mail 3.14.0 (GTK+ 2.24.30; i686-w64-mingw32) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 21 May 2018 17:04:24 +0800 Jason wrote: > 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)); This really seems like mis-use of likely/unlikely, in the middle of a sequence of operations that will always be run when this function is called. I think you should remove the likely from this helper, especially, and control the branch from the branch point. > +} > + > /* 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)) { Yes, I know it came from here, but likely/unlikely are for branch control, so they should encapsulate everything inside the if, unless I'm mistaken. > 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)) { You should have kept the unlikely here, and not had it inside the helper (as per the previous patch. Also, why wasn't this change part of the previous patch? > vhost_poll_queue(&vq->poll); > break; > }