Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 1 Sep 2013 16:41:08 +0200
From:      Dimitry Andric <dim@FreeBSD.org>
To:        Bryan Venteicher <bryanv@freebsd.org>
Cc:        svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org
Subject:   Re: svn commit: r255109 - head/sys/dev/virtio
Message-ID:  <3395F274-DA3F-41DA-A4C2-8A6C181D890D@FreeBSD.org>
In-Reply-To: <201309010416.r814Ghqh095053@svn.freebsd.org>
References:  <201309010416.r814Ghqh095053@svn.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help

--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 <bryanv@freebsd.org> 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--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3395F274-DA3F-41DA-A4C2-8A6C181D890D>