Re: [PATCH 2/3] lib: Improve EWMA efficiency by using bitshifts

From: Johannes Berg
Date: Thu Dec 02 2010 - 05:20:48 EST


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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/