From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F2A4DC3A589 for ; Sun, 18 Aug 2019 07:10:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CDFF821773 for ; Sun, 18 Aug 2019 07:10:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726208AbfHRHKp (ORCPT ); Sun, 18 Aug 2019 03:10:45 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44172 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726175AbfHRHKo (ORCPT ); Sun, 18 Aug 2019 03:10:44 -0400 Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 383AC3DBC2 for ; Sun, 18 Aug 2019 07:10:44 +0000 (UTC) Received: by mail-qk1-f200.google.com with SMTP id g125so355372qkd.7 for ; Sun, 18 Aug 2019 00:10:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=pG67TpAucqj+QXErTkQVEhnyrRaRpklq4dlSH5XWxbY=; b=uU7Xi/nwQo4ImnzV0sP3BCg5Ck6I376ZeUXrMU5GV285IE9OeXUnwV/a6Y/t/3eBYM O0kjRfWxOtpT16j1uoUodvIPjgXSW99spVf5ZzLnxjhRkWJr37fixagj+au2rVragmaR 896I8jTwazLHECoqzbclpARxJyZuq5r43T6fporQ2+iunxPXGXf4LY8MbF5sFc8/wNA+ V+mD4hPXMx3CyO9pNRIjLfy/Rt+UYB4J4H02wBRiS308iOhZyhhzUKphfjSmK27F3GZH rDuMN5a5920mKBw3RqAHXH8y5tU81Csqzl4uubnkE/bduUddLitZMV0Ia1FNpqhQMhSj TkxQ== X-Gm-Message-State: APjAAAUMZ72L0XRFOityUlKe8Q/e51d3kgJgtmK8CxguqLigy7q0uifV LEyUnphDS9Xk9bn3cvvc6e7elX60EIdxN6woCka3s1/WhFmDc/hFN/icwTeKL0UWVEe69pcca0v olzZtmK70NA7T X-Received: by 2002:a37:a013:: with SMTP id j19mr16437438qke.401.1566112243570; Sun, 18 Aug 2019 00:10:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqw+lwpHXPdpc20v/W4ahvahjXp7xvnN6kcPiBu5Jkb2fdOBr/0eK82rKArgosyck6pKhjs7pA== X-Received: by 2002:a37:a013:: with SMTP id j19mr16437415qke.401.1566112243373; Sun, 18 Aug 2019 00:10:43 -0700 (PDT) Received: from redhat.com (bzq-79-180-62-110.red.bezeqint.net. [79.180.62.110]) by smtp.gmail.com with ESMTPSA id h4sm4900625qtq.82.2019.08.18.00.10.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Aug 2019 00:10:42 -0700 (PDT) Date: Sun, 18 Aug 2019 03:10:35 -0400 From: "Michael S. Tsirkin" To: ? jiang Cc: "jasowang@redhat.com" , "davem@davemloft.net" , "ast@kernel.org" , "daniel@iogearbox.net" , "jakub.kicinski@netronome.com" , "hawk@kernel.org" , "john.fastabend@gmail.com" , "kafai@fb.com" , "songliubraving@fb.com" , "yhs@fb.com" , "virtualization@lists.linux-foundation.org" , "netdev@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "xdp-newbies@vger.kernel.org" , "bpf@vger.kernel.org" , "jiangran.jr@alibaba-inc.com" Subject: Re: [PATCH v2] virtio-net: lower min ring num_free for efficiency Message-ID: <20190818030410-mutt-send-email-mst@kernel.org> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: bpf-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org On Thu, Aug 15, 2019 at 09:42:40AM +0000, ? jiang wrote: > This change lowers ring buffer reclaim threshold from 1/2*queue to budget > for better performance. According to our test with qemu + dpdk, packet > dropping happens when the guest is not able to provide free buffer in > avail ring timely with default 1/2*queue. The value in the patch has been > tested and does show better performance. > > Test setup: iperf3 to generate packets to guest (total 30mins, pps 400k, UDP) > avg packets drop before: 2842 > avg packets drop after: 360(-87.3%) > > Signed-off-by: jiangkidd To add to that: Further, current code suffers from a starvation problem: the amount of work done by try_fill_recv is not bounded by the budget parameter, thus (with large queues) once in a while userspace gets blocked for a long time while queue is being refilled. Trigger refills earlier to make sure the amount of work to do is limited. With this addition to the log: Acked-by: Michael S. Tsirkin > --- > drivers/net/virtio_net.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c > index 0d4115c9e20b..bc08be7925eb 100644 > --- a/drivers/net/virtio_net.c > +++ b/drivers/net/virtio_net.c > @@ -1331,7 +1331,7 @@ static int virtnet_receive(struct receive_queue *rq, int budget, > } > } > > - if (rq->vq->num_free > virtqueue_get_vring_size(rq->vq) / 2) { > + if (rq->vq->num_free > min((unsigned int)budget, virtqueue_get_vring_size(rq->vq)) / 2) { > if (!try_fill_recv(vi, rq, GFP_ATOMIC)) > schedule_delayed_work(&vi->refill, 0); > } > -- > 2.11.0 From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Michael S. Tsirkin" Subject: Re: [PATCH v2] virtio-net: lower min ring num_free for efficiency Date: Sun, 18 Aug 2019 03:10:35 -0400 Message-ID: <20190818030410-mutt-send-email-mst@kernel.org> References: Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Content-Disposition: inline In-Reply-To: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: virtualization-bounces@lists.linux-foundation.org Errors-To: virtualization-bounces@lists.linux-foundation.org To: ? jiang Cc: "xdp-newbies@vger.kernel.org" , "songliubraving@fb.com" , "jakub.kicinski@netronome.com" , "hawk@kernel.org" , "daniel@iogearbox.net" , "jiangran.jr@alibaba-inc.com" , "netdev@vger.kernel.org" , "john.fastabend@gmail.com" , "ast@kernel.org" , "kafai@fb.com" , "yhs@fb.com" , "bpf@vger.kernel.org" , "virtualization@lists.linux-foundation.org" , "davem@davemloft.net" , "linux-kernel@vger.kernel.org" List-Id: virtualization@lists.linuxfoundation.org On Thu, Aug 15, 2019 at 09:42:40AM +0000, ? jiang wrote: > This change lowers ring buffer reclaim threshold from 1/2*queue to budget > for better performance. According to our test with qemu + dpdk, packet > dropping happens when the guest is not able to provide free buffer in > avail ring timely with default 1/2*queue. The value in the patch has been > tested and does show better performance. > > Test setup: iperf3 to generate packets to guest (total 30mins, pps 400k, UDP) > avg packets drop before: 2842 > avg packets drop after: 360(-87.3%) > > Signed-off-by: jiangkidd To add to that: Further, current code suffers from a starvation problem: the amount of work done by try_fill_recv is not bounded by the budget parameter, thus (with large queues) once in a while userspace gets blocked for a long time while queue is being refilled. Trigger refills earlier to make sure the amount of work to do is limited. With this addition to the log: Acked-by: Michael S. Tsirkin > --- > drivers/net/virtio_net.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c > index 0d4115c9e20b..bc08be7925eb 100644 > --- a/drivers/net/virtio_net.c > +++ b/drivers/net/virtio_net.c > @@ -1331,7 +1331,7 @@ static int virtnet_receive(struct receive_queue *rq, int budget, > } > } > > - if (rq->vq->num_free > virtqueue_get_vring_size(rq->vq) / 2) { > + if (rq->vq->num_free > min((unsigned int)budget, virtqueue_get_vring_size(rq->vq)) / 2) { > if (!try_fill_recv(vi, rq, GFP_ATOMIC)) > schedule_delayed_work(&vi->refill, 0); > } > -- > 2.11.0