Re: [PATCH] af_unix: use shift instead of integer division
On Tuesday 07 February 2006 15:54, Benjamin LaHaise wrote: > + if (size > ((sk->sk_sndbuf >> 1) - 64)) > + size = (sk->sk_sndbuf >> 1) - 64; This is really surprising. Are you double plus sure gcc doesn't do this automatically? -Andi - To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] af_unix: use shift instead of integer division
On Tue, Feb 07, 2006 at 04:15:31PM +0100, Andi Kleen wrote: > On Tuesday 07 February 2006 15:54, Benjamin LaHaise wrote: > > > + if (size > ((sk->sk_sndbuf >> 1) - 64)) > > + size = (sk->sk_sndbuf >> 1) - 64; > > This is really surprising. Are you double plus sure gcc doesn't > do this automatically? As I said, sk_sndbuf is a signed integer, so gcc can't use an arithmetic shift (which would round to infinity if the result is negative -- gcc has no way of knowing that sk_sndbuf will be positive). The alternative would be to convert sk_sndbuf to unsigned, but that would mean rechecking all the users for side effects. -ben - To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] af_unix: use shift instead of integer division
From: Benjamin LaHaise <[EMAIL PROTECTED]> Date: Tue, 7 Feb 2006 06:54:44 -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 <[EMAIL PROTECTED]> Applied, thanks. - To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html