lkml.org 
[lkml]   [2019]   [Jan]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [PATCH] lib/div64: off by one in shift
    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@redhat.com/

    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@redhat.com>

    \
     
     \ /
      Last update: 2019-01-28 18:36    [W:3.104 / U:0.088 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site