]> err.no Git - linux-2.6/commitdiff
[INET]: Avoid an integer divide in rt_garbage_collect()
authorEric Dumazet <dada1@cosmosbay.com>
Fri, 21 Dec 2007 09:49:07 +0000 (01:49 -0800)
committerDavid S. Miller <davem@davemloft.net>
Mon, 28 Jan 2008 22:59:57 +0000 (14:59 -0800)
Since 'goal' is a signed int, compiler may emit an integer divide
to compute goal/2.

Using a right shift is OK here and less expensive.

Signed-off-by: Eric Dumazet <dada1@cosmosbay.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv4/route.c

index 1cc6c23cf7588e316d222cb952b8ab63e6eebdf6..933b093721eab5afa49978ba7bdf102561316830 100644 (file)
@@ -851,14 +851,14 @@ static int rt_garbage_collect(void)
                        equilibrium = ipv4_dst_ops.gc_thresh;
                goal = atomic_read(&ipv4_dst_ops.entries) - equilibrium;
                if (goal > 0) {
-                       equilibrium += min_t(unsigned int, goal / 2, rt_hash_mask + 1);
+                       equilibrium += min_t(unsigned int, goal >> 1, rt_hash_mask + 1);
                        goal = atomic_read(&ipv4_dst_ops.entries) - equilibrium;
                }
        } else {
                /* We are in dangerous area. Try to reduce cache really
                 * aggressively.
                 */
-               goal = max_t(unsigned int, goal / 2, rt_hash_mask + 1);
+               goal = max_t(unsigned int, goal >> 1, rt_hash_mask + 1);
                equilibrium = atomic_read(&ipv4_dst_ops.entries) - goal;
        }