Re: [PATCH] lib/int_sqrt.c: Optimize square root function

From: Linus Torvalds
Date: Mon Feb 02 2015 - 14:39:24 EST


On Mon, Feb 2, 2015 at 11:10 AM, Joe Perches <joe@xxxxxxxxxxx> wrote:
>
> Perhaps removing the while and using fls(x) would be better.

No. fls is often slow, and you then do have to also round it down to
an even bit number etc, so it gets somewhat complex too.

We *probably* have some argument range that we care more about, which
is why I'd like to know what the profile is that triggered this
optimization, and what the common argument range is.

For example, one user is the cpu frequency governor, which seems to
try to predict the length of the next sleep. The values can probably
be anything (it has protections for overflowing into "long long"), but
presumably the onyl time we care about performance is when it's called
very very often, in which case I'm going out on a limb and saying that
the intervals will be short, and the standard deviation of those
intervals will also be small. So *maybe* that function really only
cares about performance when we have small arguments. I dunno.

Linus
--
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/