Received: from eggs.gnu.org ([2001:4830:134:3::10]:56084) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YSosT-0004Bc-E7 for qemu-devel@nongnu.org; Tue, 03 Mar 2015 10:36:58 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YSosQ-00087m-01 for qemu-devel@nongnu.org; Tue, 03 Mar 2015 10:36:57 -0500 Received: from mail-we0-x22a.google.com ([2a00:1450:400c:c03::22a]:42511) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YSosP-00087e-PM for qemu-devel@nongnu.org; Tue, 03 Mar 2015 10:36:53 -0500 Received: by wesw62 with SMTP id w62so40628764wes.9 for ; Tue, 03 Mar 2015 07:36:53 -0800 (PST) Date: Tue, 3 Mar 2015 09:36:48 -0600 From: Stefan Hajnoczi Message-ID: <20150303153648.GA15846@stefanha-thinkpad.redhat.com> References: <54F57D1C.50500@freescale.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="h31gzZEtNLTqOjlF" Content-Disposition: inline In-Reply-To: <54F57D1C.50500@freescale.com> Subject: Re: [Qemu-devel] [virtio-net] why does the tx virtqueue have a timer? List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Vasile Catalin-B50542 Cc: qemu-devel@nongnu.org --h31gzZEtNLTqOjlF Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Tue, Mar 03, 2015 at 11:21:32AM +0200, Vasile Catalin-B50542 wrote: > 1. Why does virtio-net have a timer to handle tx virtqueue? It's a performance optimization. By delaying tx virtqueue processing by 150 microseconds and turning guest->host virtqueue notifications off, QEMU is able to batch transmit. > 2. Why isn't the virtqueue kick enough? (I see that both are set to handle > jobs from virtqueue.) It is enough. The timer is not for functionality or correctness, it is purely a performance optimization. The optimization is a gamble, there are workloads where the extra 150 microseconds of latency causes worse performance. > 3. What is the difference between regular timers and bh (bottom halves)? Why > would you choose one over another? A bottom half is scheduled in the main loop "as soon as possible". A timer has a specific duration (150 microseconds by default in this case). 150 is a magic number. BH is another magic number, essentially. This is just a bet that performance will be better if we delay a bit to allow batching. Hope this helps, Stefan --h31gzZEtNLTqOjlF Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQEcBAEBAgAGBQJU9dUQAAoJEJykq7OBq3PInZoIAK7xFkCC+odxB8RKPgyBJ9KU YS06YMhhonEt2Ce4bWn+mKILHkpAEHVemkfce7G2/oq+VEJjnMRNr7vmjt+bAQLe 4+xywv/4dROndNXeITC2lLmr6zWyrg0Q7cvSJ4SWmmXkfgWtZSoVBL99TkUEy73C Soc7N+VaR8Xc9GgLTYLQ1XyLS+BoKUhhBpA1Z+Z3ZCr2Fr3EuC/6mOyPoBvQqJ/S I5rqiQrUzV/o1KOqoePv4i6ukqNo4631yMVFw8GwhM7d8rQ/aDmMo4cMKtfRh4Sg gCx3bokfoXVLaShdo3k6sS4PXQ7UACcpzrM4WKaJCzzgpWNCuPSTgx4No0E9nvs= =0KRB -----END PGP SIGNATURE----- --h31gzZEtNLTqOjlF--