On 25.09.2016 13:03, Maciej Żenczykowski wrote:
> +static inline s32 rfc3315_s14_backoff_init(s32 initial)
> +{
> +     u32 r = (9 << 20) / 10 + (prandom_u32() % ((2 << 20) / 10 + 1));

^

> +     s32 v = initial * (u64)r >> 20;       /* ~ multiply by 0.9 .. 1.1 */
> +     return v;
> +}
> +
> +static inline s32 rfc3315_s14_backoff_update(s32 cur, s32 ceiling)
> +{
> +     u32 r = (19 << 20) / 10 + (prandom_u32() % ((2 << 20) / 10 + 1));

Please just use do_div here and go back to the first version of the
patch. Variable names could be more aligned with the RFC maybe?

> +     s32 v = cur * (u64)r >> 20;           /* ~ multiply by 1.9 .. 2.1 */
> +     if (v > ceiling) {
> +             r -= 1 << 20;
> +             v = ceiling * (u64)r >> 20;   /* ~ multiply by 0.9 .. 1.1 */
> +     }
> +     return v;
> +}

Thanks,
Hannes

Reply via email to