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

Attachment: signature.asc
Description: Message signed with OpenPGP using GPGMail

Reply via email to