Re: [PATCH] mm: slab.h: use ilog2() in kmalloc_index()

From: Christoph Lameter
Date: Wed Jun 22 2016 - 09:29:15 EST


On Wed, 22 Jun 2016, Yury Norov wrote:

>
> There will be no fls() for constant at runtime because ilog2() calculates
> constant values at compile-time as well. From this point of view,
> this patch removes code duplication, as we already have compile-time
> log() calculation in kernel, and should re-use it whenever possible.\

The reason not to use ilog there was that the constant folding did not
work correctly with one or the other architectures/compilers. If you want
to do this then please verify that all arches reliably do produce a
constant there.