]> err.no Git - linux-2.6/commitdiff
[AF_UNIX]: use shift instead of integer division
authorBenjamin LaHaise <benjamin.c.lahaise@intel.com>
Tue, 21 Mar 2006 05:29:05 +0000 (21:29 -0800)
committerDavid S. Miller <davem@davemloft.net>
Tue, 21 Mar 2006 05:29:05 +0000 (21:29 -0800)
The patch below replaces a divide by 2 with a shift -- sk_sndbuf is an
integer, so gcc emits an idiv, which takes 10x longer than a shift by 1.
This improves af_unix bandwidth by ~6-10K/s.  Also, tidy up the comment
to fit in 80 columns while we're at it.

Signed-off-by: Benjamin LaHaise <benjamin.c.lahaise@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/unix/af_unix.c

index c323cc6a28b0e3f6042058879ead5dd9d5d36aaa..2b00460f2886e1a10eb5e5bccc785f6f370eba71 100644 (file)
@@ -1427,15 +1427,15 @@ static int unix_stream_sendmsg(struct kiocb *kiocb, struct socket *sock,
        while(sent < len)
        {
                /*
-                *      Optimisation for the fact that under 0.01% of X messages typically
-                *      need breaking up.
+                *      Optimisation for the fact that under 0.01% of X
+                *      messages typically need breaking up.
                 */
 
-               size=len-sent;
+               size = len-sent;
 
                /* Keep two messages in the pipe so it schedules better */
-               if (size > sk->sk_sndbuf / 2 - 64)
-                       size = sk->sk_sndbuf / 2 - 64;
+               if (size > ((sk->sk_sndbuf >> 1) - 64))
+                       size = (sk->sk_sndbuf >> 1) - 64;
 
                if (size > SKB_MAX_ALLOC)
                        size = SKB_MAX_ALLOC;