Re: [PATCH] lib/div64: off by one in shift

From: Oleg Nesterov
Date: Mon Jan 28 2019 - 12:35:16 EST


On 01/28, Stanislaw Gruszka wrote:
>
> fls counts bits starting from 1 to 32 (returns 0 for zero argument).
> If we add 1 we shift right one bit more and loose precision

I forgot everything about this code, but I think this patch must be correct,

divisor >> n;

should have MSB == 1 or we loose the precision... Heh, I managed to find the
initial version of this code, see

https://lore.kernel.org/lkml/20101014121159.GA407@xxxxxxxxxx/

and note that it uses __fls(), not fls()! I didn't notice the final version
replaced __fls() with fls() which is __fls() + 1 if arg != 0.

Acked-by: Oleg Nesterov <oleg@xxxxxxxxxx>