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