Subject: Re: [PATCH 6/7] tcp: cache result of earlier divides when mss-aligning things

From: Evgeniy Polyakov <[email-masked]>
Date: Sun, 15 Mar 2009 11:36:42 +0300

Hi Ilpo.

On Sun, Mar 15, 2009 at 02:07:54AM +0200, Ilpo Järvinen ([email-masked]) wrote:
> @@ -676,7 +676,17 @@ static unsigned int tcp_xmit_size_goal(struct sock *sk, u32 mss_now,
>  				  tp->tcp_header_len);
>  
>  		xmit_size_goal = tcp_bound_to_half_wnd(tp, xmit_size_goal);
> -		xmit_size_goal -= (xmit_size_goal % mss_now);
> +
> +		/* We try hard to avoid divides here */
> +		old_size_goal = tp->xmit_size_goal_segs * mss_now;
> +
> +		if (old_size_goal <= xmit_size_goal &&
> +		    old_size_goal + mss_now > xmit_size_goal) {
> +			xmit_size_goal = old_size_goal;

If this is way more likely condition than changed xmit size, what about
wrapping it into likely()?

> +		} else {
> +			tp->xmit_size_goal_segs = xmit_size_goal / mss_now;
> +			xmit_size_goal = tp->xmit_size_goal_segs * mss_now;
> +		}
>  	}
>  
>  	return xmit_size_goal;
> -- 
> 1.5.6.5

-- 
	Evgeniy Polyakov