svn commit: r255109 - head/sys/dev/virtio

Dimitry Andric dim at FreeBSD.org
Sun Sep 1 14:41:26 UTC 2013


On Sep 1, 2013, at 06:16, Bryan Venteicher <bryanv at 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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 203 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://lists.freebsd.org/pipermail/svn-src-head/attachments/20130901/1ad4ad61/attachment.sig>


More information about the svn-src-head mailing list