Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1523998imm; Tue, 22 May 2018 05:32:21 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqrZ4J6ifMniKcC0gK8fO14GWyYVlATIg7n7oHAP5sXJyR5vQaQ3bHRT8n7m4XHZQORE0UU X-Received: by 2002:a65:44c3:: with SMTP id g3-v6mr18894097pgs.428.1526992341562; Tue, 22 May 2018 05:32:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526992341; cv=none; d=google.com; s=arc-20160816; b=h5Oe9MGsj6drWzGg8IjUIgdSeB9MLJEQftSyiIMbdw9cdGVuLOhKVCAaIwQPjhzMTK fji86oHcAZqhK/DI6FBVYgfAvDhcpjNoakISmcHKIWZtCfNcuUfFsXM1vesMySjsGZVc Aeiox/XQQxIAdjUqW+SVKYiqKPel0CB0WLt6tf1qAIIz2WCnecyGnqwxA4SPZsPLSo8k OGPvYuaXTXuwBvc8jLeW6dv1oEgxb0Bch+byjWfegoDDvkaA9fMQMfZKrTBf4Rmh8OeH LO0wXTmtQNSPapfUDIW6s9Sh1h51MF6uO4OMUHGE5dipeLI+D9zfEQSMEBc3jdrCp5hB iLdg== 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=aMgFnAWwSz8PaL0CCHPU3SnOvTnOVln3JnNs5zbq0PA=; b=j7BuTgafAVrq/kP3V5HS161NCjWTyscASC6kJhiXsF7L6q5nBTdbdHXNjZ/DnB4nEL fhx8VLT/vAE3e7v29XUezvAlPOkK/nJ3lyehZTlV7NQVoW9Jt1oZ8vRBEzRlyebFW3n2 KfRak7MKmSLmv6qq3pNfNNezn79nCLotROhmoswDYbqRQHDnN5icD8uOJT4q2nlOZf6A iPiC2dJenJ09mTqntzPV5qnxhWF5S5fMRCwqWylSGs8G5NXBHtuz6wJOapPXElEoyFTb DFHsR0+CiSQMJfxgwu3wpNAHiCkXjWYnzK/0xg6yqn4Mhz7vBf30oxexHpydxYQbHrGJ stog== 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 w8-v6si12709018pgr.111.2018.05.22.05.32.06; Tue, 22 May 2018 05:32:21 -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 S1751425AbeEVMbs (ORCPT + 99 others); Tue, 22 May 2018 08:31:48 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:60744 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751172AbeEVMbp (ORCPT ); Tue, 22 May 2018 08:31:45 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4A9DF81663FD; Tue, 22 May 2018 12:31:45 +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 C64C12023585; Tue, 22 May 2018 12:31:42 +0000 (UTC) Subject: Re: [RFC PATCH net-next 03/12] vhost_net: introduce vhost_has_more_pkts() 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-4-git-send-email-jasowang@redhat.com> <20180521093908.00006747@intel.com> From: Jason Wang Message-ID: Date: Tue, 22 May 2018 20:31:40 +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: <20180521093908.00006747@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.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Tue, 22 May 2018 12:31:45 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Tue, 22 May 2018 12:31:45 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.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:39, Jesse Brandeburg wrote: > 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. Yes, so I'm consider to make it a macro in next version. > > >> +} >> + >> /* 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. Ok. > >> 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? Yes, will squash the above into previous one. Thanks > >> vhost_poll_queue(&vq->poll); >> break; >> }