lkml.org 
[lkml]   [2010]   [Dec]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    SubjectRe: [PATCH 2/3] lib: Improve EWMA efficiency by using bitshifts
    From
    Date
    On Thu, 2010-12-02 at 19:12 +0900, Bruno Randolf wrote:

    > + /* get bitshift for weight */
    > + for (n = 0; !(weight & 1); n++)
    > + weight = weight >> 1;
    > + WARN_ON(weight > 1 || n < 1);

    I'm sure there's something like log2() (and is_power_of_2() for the
    warning) in the kernel already -- no need to reimplement it...

    johannes



    \
     
     \ /
      Last update: 2010-12-02 11:23    [W:3.345 / U:1.012 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site