Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp7148635ybi; Mon, 8 Jul 2019 15:37:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqyuaLTpCKVLNfWmJJc55HDcQOrZtTtjxBLdhSygRrodjfB/cZRk/58ZL1gLIf6G1sQCAr09 X-Received: by 2002:a17:902:b48c:: with SMTP id y12mr27656964plr.202.1562625432332; Mon, 08 Jul 2019 15:37:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562625432; cv=none; d=google.com; s=arc-20160816; b=LzeHKnbQe6W69anwSzojGvHIFB8pdI1csvuQROii/3ePa0C28hMemO4yrLWoEdk0IA uvuJxaHkv1H+AZnI7EKBMaPY8lZ6K852fLX9htJfOfqo2BY47pY/04iFJMhu/e5LCDIS eDccrC4Tv3ALndykVkdy6QOR6MRWF2NDtihLBs0yWStfDpvrtT51ZKsgQK74ZmWj8sy1 xYGafpKiFLXhn2Om+e8f1TTp/6yPUVckHYT8mb3SV2f9i2KG/jKtENw91n990MCOBHQP hZgDgEIqK8iXR5//S2sczw2HoZHZoLJb41c65EBx13cR/uCPLn3yu2FFvHJr8rw/JdLD sJYw== 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=1izJPaereruvTG0ggggbr6yP1C3Uv6UTl3fUjJRYLqc=; b=q671ssAv/4vPLBm4oCVvzlxtpBWMPn99N5nbN9qW/7/uPJLYOvYTfi9HkC0uuN2YkE EhM+flB9QrkzCPoDireA7iudYb8hsrsq4SRguRzEF7OiCdpussmY45fkkeDKyEehorrK L4BoTlAuKw437weGib/ftnVWXVoRMmQOytv56YYC4FnJB+gHBAYGvs0L9fbTalhb0KzB 0+yl3r2czLxAgBMOGY80ULBPiwoE6tR9EgniokzrJiEabdtUJJA7gofhMpQIS3f65Dnz CSr8xJ+1vfOJMHM1fBIQDQ+BpTmv1xTWXYS+lkfXdKv08mNZfHQ2HdCp/8zZWdM3ADx1 Gkbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=oQDKm6Sq; 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 m68si20962655pfb.75.2019.07.08.15.36.57; Mon, 08 Jul 2019 15:37:12 -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=oQDKm6Sq; 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 S2388591AbfGHPZ0 (ORCPT + 99 others); Mon, 8 Jul 2019 11:25:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:52846 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388571AbfGHPZX (ORCPT ); Mon, 8 Jul 2019 11:25:23 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 68471216C4; Mon, 8 Jul 2019 15:25:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1562599522; bh=K6PGeGX2uGzbM2XUPHDUbzymPuucyvKYsiYoANA47CQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oQDKm6SqvFhgP2reQ3G2J7Win5IagIyoVGI+/aT/JzprphtMXvH1zbXEjAg3m1agE qedGF2WCbEx79osHfL67trpO60MjpHXlFJC6rppv0ss60lEzorGn4ydq1426W0oJMy d89/qYTtxL24U4KUBv4iOioYs5sActQPXXOYw8k0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jason Wang , "David S. Miller" , Balbir Singh Subject: [PATCH 4.14 43/56] vhost_net: introduce vhost_exceeds_weight() Date: Mon, 8 Jul 2019 17:13:35 +0200 Message-Id: <20190708150523.719177265@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190708150514.376317156@linuxfoundation.org> References: <20190708150514.376317156@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 Signed-off-by: Balbir Singh Signed-off-by: Greg Kroah-Hartman --- drivers/vhost/net.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) --- a/drivers/vhost/net.c +++ b/drivers/vhost/net.c @@ -446,6 +446,12 @@ static bool vhost_exceeds_maxpend(struct == nvq->done_idx; } +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) @@ -550,7 +556,6 @@ static void handle_tx(struct vhost_net * msg.msg_control = NULL; ubufs = NULL; } - total_len += len; if (total_len < VHOST_NET_WEIGHT && !vhost_vq_avail_empty(&net->dev, vq) && @@ -579,8 +584,7 @@ static void handle_tx(struct vhost_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; } @@ -863,8 +867,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; }