From patchwork Wed Nov 28 21:53:08 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 202562 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 316AE2C008E for ; Thu, 29 Nov 2012 08:50:56 +1100 (EST) Received: from localhost ([::1]:60699 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TdpWw-00030M-Ef for incoming@patchwork.ozlabs.org; Wed, 28 Nov 2012 16:50:54 -0500 Received: from eggs.gnu.org ([208.118.235.92]:49667) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TdpWn-0002zt-NK for qemu-devel@nongnu.org; Wed, 28 Nov 2012 16:50:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TdpWm-0005RJ-CK for qemu-devel@nongnu.org; Wed, 28 Nov 2012 16:50:45 -0500 Received: from mx1.redhat.com ([209.132.183.28]:5645) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TdpWm-0005R7-2s for qemu-devel@nongnu.org; Wed, 28 Nov 2012 16:50:44 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id qASLoZ0O002434 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 28 Nov 2012 16:50:37 -0500 Received: from redhat.com (vpn1-4-192.ams2.redhat.com [10.36.4.192]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id qASLoFNE025139; Wed, 28 Nov 2012 16:50:30 -0500 Date: Wed, 28 Nov 2012 23:53:08 +0200 From: "Michael S. Tsirkin" To: Amit Shah Message-ID: <20121128215308.GA23360@redhat.com> References: <20121022111824.GA6916@amit.redhat.com> <1350913800.90009.YahooMailClassic@web163904.mail.gq1.yahoo.com> <20121023125503.GG19977@stefanha-thinkpad.redhat.com> <20121101091918.GA19405@amit.redhat.com> <20121101120410.GC3993@redhat.com> <20121101160721.GA9176@redhat.com> <20121127162504.GA6210@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20121127162504.GA6210@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Stefan Hajnoczi , Bug 1066055 <1066055@bugs.launchpad.net>, qemu-devel@nongnu.org, Anthony Liguori , Edivaldo de Araujo Pereira Subject: Re: [Qemu-devel] [PATCH] virtio: limit avail bytes lookahead X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org On Tue, Nov 27, 2012 at 06:25:04PM +0200, Michael S. Tsirkin wrote: > On Thu, Nov 01, 2012 at 06:07:21PM +0200, Michael S. Tsirkin wrote: > > Commit 0d8d7690850eb0cf2b2b60933cf47669a6b6f18f introduced > > a regression in virtio-net performance because it looks > > into the ring aggressively while we really only care > > about a single packet worth of buffers. > > To fix, add parameters limiting lookahead, and > > use in virtqueue_avail_bytes. > > > > Signed-off-by: Michael S. Tsirkin > > Reported-by: Edivaldo de Araujo Pereira > > Ping. > Anthony - going to apply this? virtio rng was added since so naturally build broke. Here's a patch on top to fix it up. I never used virtio rng before so could not test at this hour, but it does fix the build. I'll take a look at how to test it tomorrow but any info would be appreciated. Amit could you pls review? diff --git a/hw/virtio-rng.c b/hw/virtio-rng.c index df329f2..a73ef8e 100644 --- a/hw/virtio-rng.c +++ b/hw/virtio-rng.c @@ -43,11 +43,11 @@ static bool is_guest_ready(VirtIORNG *vrng) return false; } -static size_t get_request_size(VirtQueue *vq) +static size_t get_request_size(VirtQueue *vq, unsigned quota) { unsigned int in, out; - virtqueue_get_avail_bytes(vq, &in, &out); + virtqueue_get_avail_bytes(vq, &in, &out, quota, 0); return in; } @@ -84,12 +84,18 @@ static void chr_read(void *opaque, const void *buf, size_t size) static void virtio_rng_process(VirtIORNG *vrng) { size_t size; + unsigned quota; if (!is_guest_ready(vrng)) { return; } - size = get_request_size(vrng->vq); + if (vrng->quota_remaining < 0) { + quota = 0; + } else { + quota = MIN((uint64_t)vrng->quota_remaining, (uint64_t)UINT32_MAX); + } + size = get_request_size(vrng->vq, quota); size = MIN(vrng->quota_remaining, size); if (size) { rng_backend_request_entropy(vrng->rng, size, chr_read, vrng);