From owner-svn-src-head@FreeBSD.ORG Sun Sep 1 14:41:26 2013 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 5C197233; Sun, 1 Sep 2013 14:41:26 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from tensor.andric.com (tensor.andric.com [87.251.56.140]) (using TLSv1 with cipher ADH-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 178092FDD; Sun, 1 Sep 2013 14:41:25 +0000 (UTC) Received: from [IPv6:2001:7b8:3a7::8586:302a:e3e8:3a34] (unknown [IPv6:2001:7b8:3a7:0:8586:302a:e3e8:3a34]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by tensor.andric.com (Postfix) with ESMTPSA id 764815C44; Sun, 1 Sep 2013 16:41:22 +0200 (CEST) Content-Type: multipart/signed; boundary="Apple-Mail=_DC5DA71F-0540-4A2F-B7C2-CFE6096797B2"; protocol="application/pgp-signature"; micalg=pgp-sha1 Mime-Version: 1.0 (Mac OS X Mail 6.5 \(1508\)) Subject: Re: svn commit: r255109 - head/sys/dev/virtio From: Dimitry Andric In-Reply-To: <201309010416.r814Ghqh095053@svn.freebsd.org> Date: Sun, 1 Sep 2013 16:41:08 +0200 Message-Id: <3395F274-DA3F-41DA-A4C2-8A6C181D890D@FreeBSD.org> References: <201309010416.r814Ghqh095053@svn.freebsd.org> To: Bryan Venteicher X-Mailer: Apple Mail (2.1508) Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 01 Sep 2013 14:41:26 -0000 --Apple-Mail=_DC5DA71F-0540-4A2F-B7C2-CFE6096797B2 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii On Sep 1, 2013, at 06:16, Bryan Venteicher wrote: > Author: bryanv > Date: Sun Sep 1 04:16:43 2013 > New Revision: 255109 > URL: http://svnweb.freebsd.org/changeset/base/255109 > > Log: > Add support for postponing VirtIO virtqueue interrupts > > Partial support for the EVENT_IDX feature was added a while ago, > but this commit adds an interface for the device driver to hint > how long (in terms of descriptors) the next interrupt should be > delayed. > > The first user of this will be used to reduce VirtIO net's Tx > completion interrupts. ... > int > -virtqueue_postpone_intr(struct virtqueue *vq) > +virtqueue_postpone_intr(struct virtqueue *vq, vq_postpone_t hint) > { > uint16_t ndesc, avail_idx; > > - /* > - * Request the next interrupt be postponed until at least half > - * of the available descriptors have been consumed. > - */ > avail_idx = vq->vq_ring.avail->idx; > - ndesc = (uint16_t)(avail_idx - vq->vq_used_cons_idx) / 2; > + ndesc = (uint16_t)(avail_idx - vq->vq_used_cons_idx); > + > + switch (hint) { > + case VQ_POSTPONE_SHORT: > + ndesc /= 4; > + break; > + case VQ_POSTPONE_LONG: > + ndesc *= 3 / 4; > + break; The compiler will fold the "3 / 4" expression to zero, so ndesc will always end up as zero because of this. I assume that what you want is this instead: ndesc = (ndesc * 3) / 4; or if you want rounding: ndesc = (ndesc * 3 + 2) / 4; -Dimitry --Apple-Mail=_DC5DA71F-0540-4A2F-B7C2-CFE6096797B2 Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=signature.asc Content-Type: application/pgp-signature; name=signature.asc Content-Description: Message signed with OpenPGP using GPGMail -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.0.20 (Darwin) iEYEARECAAYFAlIjUg8ACgkQsF6jCi4glqN38gCdF0IJWMfB0oXgkA8opTaX5LWP pmYAoMCWnSEPY6rn9sp6FS+9mR1pksum =r4WU -----END PGP SIGNATURE----- --Apple-Mail=_DC5DA71F-0540-4A2F-B7C2-CFE6096797B2--