fib: use __fls() on non null argument
authorEric Dumazet <edumazet@google.com>
Tue, 7 Aug 2012 10:45:47 +0000 (10:45 +0000)
committerDavid S. Miller <davem@davemloft.net>
Tue, 7 Aug 2012 23:24:55 +0000 (16:24 -0700)
__fls(x) is a bit faster than fls(x), granted we know x is non null.

As Ben Hutchings pointed out, fls(x) = __fls(x) + 1

Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Ben Hutchings <bhutchings@solarflare.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv4/fib_trie.c

index f0cdb30921c0bdb5b1639e15d05908dfde6586f9..f84a0e90d675e334a3010e0038a2ee85b9cf846c 100644 (file)
@@ -1550,7 +1550,8 @@ int fib_table_lookup(struct fib_table *tb, const struct flowi4 *flp,
                 * state.directly.
                 */
                if (pref_mismatch) {
-                       int mp = KEYLENGTH - fls(pref_mismatch);
+                       /* fls(x) = __fls(x) + 1 */
+                       int mp = KEYLENGTH - __fls(pref_mismatch) - 1;
 
                        if (tkey_extract_bits(cn->key, mp, cn->pos - mp) != 0)
                                goto backtrace;