> +/* update queue busy with EWMA (7/8 * ewma(t)  + 1/8 * busy(t + 1)) */
> +static void blk_mq_update_hctx_busy(struct blk_mq_hw_ctx *hctx, unsigned int 
> busy)

Overly long line.  Also busy really is a bool, so I think we should
pass it as such.

Also I think this needs a much better comment describing why we
are using this algorith.  Also expanding the EWMA acronym would help,
I had to look it up first.

> +     const unsigned weight = 8;
> +     const unsigned factor = 4;

Where do these magic constants come from?

> +     unsigned int ewma;
> +
> +     if (hctx->queue->elevator)
> +             return;
> +
> +     ewma = READ_ONCE(hctx->busy);
> +
> +     ewma *= weight - 1;
> +     ewma += busy << factor;

With the bool parameter and expanding the "factor" which really is
a shift value this would be:

        if (busy)
                ewma += 16;

which at least is a little more understandable, although still not
great.

Reply via email to