Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp526690ybl; Fri, 23 Aug 2019 04:39:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqxUG2sT2TrKOFTfPqGfTB107Towz3r/TkxLNrQbQ5ni+mSORw6XRciNi3/KK3W1EQkUlTCC X-Received: by 2002:a65:608e:: with SMTP id t14mr3571854pgu.373.1566560350628; Fri, 23 Aug 2019 04:39:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566560350; cv=none; d=google.com; s=arc-20160816; b=yiBEJWDv9GZqlScIpBHoL6VY19bmK53gJO5gYtmZTuYHJr7j0HJ3a/NSe9VlAr+Bs/ J30ZAQJ5pOU23PTVA/rIHo4G7DLsRyOO6imm76OIrKQxdmNDvK+OliFIEMSRYn9lSa82 WGPkRXEGVwEzQh8nG3SVjqjCPqV1JNhazHs3buVY6nF4BiNeXcAbUal9zNGV/+mi/dLi ZGO3NC+C/2/0WHWlNThPkrNHafn2qvuX3PnHKHUVb1qluSslPgxD5r7C2MBnZTybKc/y tO0vA7FdlMxRcnwgsUdm2Wz+sKQhn0NRnMEWhV3zuJ8CoffGWlBvhmrshsNcx+M7ZV1a N+lA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=XZ+IwMup5YfpFqYUncJHlpxoZQ8pQsdzVdJ5N6IOQfI=; b=P5W86D30Z32WF+JkYZfdcR3fPcihr5AgvMktwGOLX6yyLb8GGlnygMOv1ydmn0pOJx +E/dsRjC1MNOX2E+Uv83pfY+aq+4AZ7Xnqo8DuxCgmsd18S8GKOdoG4b22AIjgeI336K 3u2Dg4dCLxAJ0DjNpNAouCS5MPYPZZiRDnho4ZS4FlJ8sBuRJGtzkBJb9MmzVJ6lM/aS KZR85aKiyUykwDrfM/Va73MgbBmPrtGC/xqTSA0RlCMRvl6Snl/0hnjPgnQrMYhw0j7p 047lPDUMb/GyNyLgT6gE+T5gtbPRkM83WiK8PpO8kGuGADxnHvd+bh6JeGuN7xWDgcf+ 4+cA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="wTbup/c0"; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p22si2295431pli.255.2019.08.23.04.38.55; Fri, 23 Aug 2019 04:39:10 -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; dkim=pass header.i=@kernel.org header.s=default header.b="wTbup/c0"; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2392674AbfHVRnx (ORCPT + 99 others); Thu, 22 Aug 2019 13:43:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:44022 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391587AbfHVRXl (ORCPT ); Thu, 22 Aug 2019 13:23:41 -0400 Received: from localhost (wsip-184-188-36-2.sd.sd.cox.net [184.188.36.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B7C0823431; Thu, 22 Aug 2019 17:23:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1566494620; bh=giSa+3AeMObBMalEXDvba3j57DZkWuSWwoFfgjSx5Hk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wTbup/c0VKMpMicCbP4yRQQuiOvNBENmXJ2rzUGxKLL7qR4XTk4La/3O8tDJLeqgF ErWFiZVC7PbmFhSI4E3tls19sXxKzBBEmm0QH0mG4OF8p+VqyMm8qg0r5/Y2naTJ5W 0Gt6R82vg0SaGjv//++Bq/BOrv027xlPM8pv6DGs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jason Wang , "David S. Miller" , Ben Hutchings Subject: [PATCH 4.9 050/103] vhost_net: introduce vhost_exceeds_weight() Date: Thu, 22 Aug 2019 10:18:38 -0700 Message-Id: <20190822171730.822103500@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190822171728.445189830@linuxfoundation.org> References: <20190822171728.445189830@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jason Wang commit 272f35cba53d088085e5952fd81d7a133ab90789 upstream. Signed-off-by: Jason Wang Signed-off-by: David S. Miller [bwh: Backported to 4.9: adjust context] Signed-off-by: Ben Hutchings Signed-off-by: Greg Kroah-Hartman --- drivers/vhost/net.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) --- a/drivers/vhost/net.c +++ b/drivers/vhost/net.c @@ -357,6 +357,12 @@ static int vhost_net_tx_get_vq_desc(stru return r; } +static bool vhost_exceeds_weight(int pkts, int total_len) +{ + return total_len >= VHOST_NET_WEIGHT || + pkts >= VHOST_NET_PKT_WEIGHT; +} + /* 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) @@ -481,8 +487,7 @@ static void handle_tx(struct vhost_net * vhost_zerocopy_signal_used(net, vq); total_len += len; 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; } @@ -763,8 +768,7 @@ static void handle_rx(struct vhost_net * vhost_log_write(vq, vq_log, log, vhost_len, vq->iov, in); 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; }