* Re: [PATCH 1/7] tcp: remove pointless .dsack/.num_sacks code [not found] <1237075675426-git-send-email-ilpo.jarvinen@helsinki.fi> @ 2009-03-16 3:10 ` David Miller [not found] ` <12370756753599-git-send-email-ilpo.jarvinen@helsinki.fi> 1 sibling, 0 replies; 11+ messages in thread From: David Miller @ 2009-03-16 3:10 UTC (permalink / raw) To: ilpo.jarvinen; +Cc: netdev From: "Ilpo Järvinen" <ilpo.jarvinen@helsinki.fi> Date: Sun, 15 Mar 2009 02:07:49 +0200 > In the pure assignment case, the earlier zeroing is > still in effect. > > David S. Miller raised concerns if the ifs are there to avoid > dirtying cachelines. I came to these conclusions: > > > We'll be dirty it anyway (now that I check), the first "real" statement > > in tcp_rcv_established is: > > > > tp->rx_opt.saw_tstamp = 0; > > > > ...that'll land on the same dword. :-/ > > > > I suppose the blocks are there just because they had more complexity > > inside when they had to calculate the eff_sacks too (maybe it would > > have been better to just remove them in that drop-patch so you would > > have had less head-ache :-)). > > Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@helsinki.fi> Applied. ^ permalink raw reply [flat|nested] 11+ messages in thread
[parent not found: <12370756753599-git-send-email-ilpo.jarvinen@helsinki.fi>]
* Re: [PATCH 2/7] tcp: kill dead end_seq variable in clean_rtx_queue [not found] ` <12370756753599-git-send-email-ilpo.jarvinen@helsinki.fi> @ 2009-03-16 3:10 ` David Miller [not found] ` <12370756754094-git-send-email-ilpo.jarvinen@helsinki.fi> 1 sibling, 0 replies; 11+ messages in thread From: David Miller @ 2009-03-16 3:10 UTC (permalink / raw) To: ilpo.jarvinen; +Cc: netdev From: "Ilpo Järvinen" <ilpo.jarvinen@helsinki.fi> Date: Sun, 15 Mar 2009 02:07:50 +0200 > I've already forgotten what for this was necessary, anyway > it's no longer used (if it ever was). > > Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@helsinki.fi> Applied. ^ permalink raw reply [flat|nested] 11+ messages in thread
[parent not found: <12370756754094-git-send-email-ilpo.jarvinen@helsinki.fi>]
* Re: [PATCH 3/7] tcp: consolidate paws check [not found] ` <12370756754094-git-send-email-ilpo.jarvinen@helsinki.fi> @ 2009-03-16 3:10 ` David Miller [not found] ` <12370756752410-git-send-email-ilpo.jarvinen@helsinki.fi> 1 sibling, 0 replies; 11+ messages in thread From: David Miller @ 2009-03-16 3:10 UTC (permalink / raw) To: ilpo.jarvinen; +Cc: netdev From: "Ilpo Järvinen" <ilpo.jarvinen@helsinki.fi> Date: Sun, 15 Mar 2009 02:07:51 +0200 > Wow, it was quite tricky to merge that stream of negations > but I think I finally got it right: > > check & replace_ts_recent: > (s32)(rcv_tsval - ts_recent) >= 0 => 0 > (s32)(ts_recent - rcv_tsval) <= 0 => 0 > > discard: > (s32)(ts_recent - rcv_tsval) > TCP_PAWS_WINDOW => 1 > (s32)(ts_recent - rcv_tsval) <= TCP_PAWS_WINDOW => 0 > > I toggled the return values of tcp_paws_check around since > the old encoding added yet-another negation making tracking > of truth-values really complicated. > > Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@helsinki.fi> Applied. ^ permalink raw reply [flat|nested] 11+ messages in thread
[parent not found: <12370756752410-git-send-email-ilpo.jarvinen@helsinki.fi>]
* Re: [PATCH 4/7] tcp: don't check mtu probe completion in the loop [not found] ` <12370756752410-git-send-email-ilpo.jarvinen@helsinki.fi> @ 2009-03-16 3:10 ` David Miller [not found] ` <12370756751028-git-send-email-ilpo.jarvinen@helsinki.fi> 1 sibling, 0 replies; 11+ messages in thread From: David Miller @ 2009-03-16 3:10 UTC (permalink / raw) To: ilpo.jarvinen; +Cc: netdev From: "Ilpo Järvinen" <ilpo.jarvinen@helsinki.fi> Date: Sun, 15 Mar 2009 02:07:52 +0200 > It seems that no variables clash such that we couldn't do > the check just once later on. Therefore move it. > > Also kill dead obvious comment, dead argument and add > unlikely since this mtu probe does not happen too often. > > Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@helsinki.fi> Applied. ^ permalink raw reply [flat|nested] 11+ messages in thread
[parent not found: <12370756751028-git-send-email-ilpo.jarvinen@helsinki.fi>]
[parent not found: <12370756752721-git-send-email-ilpo.jarvinen@helsinki.fi>]
* Re: [PATCH 6/7] tcp: cache result of earlier divides when mss-aligning things [not found] ` <12370756752721-git-send-email-ilpo.jarvinen@helsinki.fi> @ 2009-03-15 8:36 ` Evgeniy Polyakov 2009-03-15 8:45 ` Ilpo Järvinen [not found] ` <12370756754020-git-send-email-ilpo.jarvinen@helsinki.fi> 1 sibling, 1 reply; 11+ messages in thread From: Evgeniy Polyakov @ 2009-03-15 8:36 UTC (permalink / raw) To: Ilpo Järvinen; +Cc: David Miller, netdev, Ingo Molnar Hi Ilpo. On Sun, Mar 15, 2009 at 02:07:54AM +0200, Ilpo Järvinen (ilpo.jarvinen@helsinki.fi) 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 ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 6/7] tcp: cache result of earlier divides when mss-aligning things 2009-03-15 8:36 ` [PATCH 6/7] tcp: cache result of earlier divides when mss-aligning things Evgeniy Polyakov @ 2009-03-15 8:45 ` Ilpo Järvinen 2009-03-15 9:08 ` Evgeniy Polyakov 2009-03-16 3:11 ` David Miller 0 siblings, 2 replies; 11+ messages in thread From: Ilpo Järvinen @ 2009-03-15 8:45 UTC (permalink / raw) To: Evgeniy Polyakov; +Cc: David Miller, Netdev, Ingo Molnar [-- Attachment #1: Type: TEXT/PLAIN, Size: 2998 bytes --] On Sun, 15 Mar 2009, Evgeniy Polyakov wrote: > On Sun, Mar 15, 2009 at 02:07:54AM +0200, Ilpo Järvinen (ilpo.jarvinen@helsinki.fi) 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()? So gcc won't read my comment? :-) Updated below. -- i. -- [PATCHv2] tcp: cache result of earlier divides when mss-aligning things The results is very unlikely change every so often so we hardly need to divide again after doing that once for a connection. Yet, if divide still becomes necessary we detect that and do the right thing and again settle for non-divide state. Takes the u16 space which was previously taken by the plain xmit_size_goal. This should take care part of the tso vs non-tso difference we found earlier. Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@helsinki.fi> Cc: Evgeniy Polyakov <zbr@ioremap.net> Cc: Ingo Molnar <mingo@elte.hu> --- include/linux/tcp.h | 1 + net/ipv4/tcp.c | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/include/linux/tcp.h b/include/linux/tcp.h index ad2021c..9d5078b 100644 --- a/include/linux/tcp.h +++ b/include/linux/tcp.h @@ -248,6 +248,7 @@ struct tcp_sock { /* inet_connection_sock has to be the first member of tcp_sock */ struct inet_connection_sock inet_conn; u16 tcp_header_len; /* Bytes of tcp header to send */ + u16 xmit_size_goal_segs; /* Goal for segmenting output packets */ /* * Header prediction flags diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index 886596f..0db9f3b 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -665,7 +665,7 @@ static unsigned int tcp_xmit_size_goal(struct sock *sk, u32 mss_now, int large_allowed) { struct tcp_sock *tp = tcp_sk(sk); - u32 xmit_size_goal; + u32 xmit_size_goal, old_size_goal; xmit_size_goal = mss_now; @@ -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 (likely(old_size_goal <= xmit_size_goal && + old_size_goal + mss_now > xmit_size_goal)) { + xmit_size_goal = old_size_goal; + } 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 ^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH 6/7] tcp: cache result of earlier divides when mss-aligning things 2009-03-15 8:45 ` Ilpo Järvinen @ 2009-03-15 9:08 ` Evgeniy Polyakov 2009-03-16 3:11 ` David Miller 1 sibling, 0 replies; 11+ messages in thread From: Evgeniy Polyakov @ 2009-03-15 9:08 UTC (permalink / raw) To: Ilpo Järvinen; +Cc: David Miller, Netdev, Ingo Molnar On Sun, Mar 15, 2009 at 10:45:16AM +0200, Ilpo Järvinen (ilpo.jarvinen@helsinki.fi) 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()? > > So gcc won't read my comment? :-) I heared the next gcc version will be linked with the libastral.so, but we have to maintain backward compatibility. > Updated below. The whole series looks good. -- Evgeniy Polyakov ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 6/7] tcp: cache result of earlier divides when mss-aligning things 2009-03-15 8:45 ` Ilpo Järvinen 2009-03-15 9:08 ` Evgeniy Polyakov @ 2009-03-16 3:11 ` David Miller 1 sibling, 0 replies; 11+ messages in thread From: David Miller @ 2009-03-16 3:11 UTC (permalink / raw) To: ilpo.jarvinen; +Cc: zbr, netdev, mingo From: "Ilpo Järvinen" <ilpo.jarvinen@helsinki.fi> Date: Sun, 15 Mar 2009 10:45:16 +0200 (EET) > [PATCHv2] tcp: cache result of earlier divides when mss-aligning things > > The results is very unlikely change every so often so we > hardly need to divide again after doing that once for a > connection. Yet, if divide still becomes necessary we > detect that and do the right thing and again settle for > non-divide state. Takes the u16 space which was previously > taken by the plain xmit_size_goal. > > This should take care part of the tso vs non-tso difference > we found earlier. > > Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@helsinki.fi> Applied. ^ permalink raw reply [flat|nested] 11+ messages in thread
[parent not found: <12370756754020-git-send-email-ilpo.jarvinen@helsinki.fi>]
* Re: [PATCH 7/7] tcp: make sure xmit goal size never becomes zero [not found] ` <12370756754020-git-send-email-ilpo.jarvinen@helsinki.fi> @ 2009-03-16 3:11 ` David Miller 0 siblings, 0 replies; 11+ messages in thread From: David Miller @ 2009-03-16 3:11 UTC (permalink / raw) To: ilpo.jarvinen; +Cc: netdev, zbr, mingo From: "Ilpo Järvinen" <ilpo.jarvinen@helsinki.fi> Date: Sun, 15 Mar 2009 02:07:55 +0200 > It's not too likely to happen, would basically require crafted > packets (must hit the max guard in tcp_bound_to_half_wnd()). > It seems that nothing that bad would happen as there's tcp_mems > and congestion window that prevent runaway at some point from > hurting all too much (I'm not that sure what all those zero > sized segments we would generate do though in write queue). > Preventing it regardless is certainly the best way to go. > > Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@helsinki.fi> Applied. ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 5/7] tcp: simplify tcp_current_mss [not found] ` <12370756751028-git-send-email-ilpo.jarvinen@helsinki.fi> [not found] ` <12370756752721-git-send-email-ilpo.jarvinen@helsinki.fi> @ 2009-03-16 3:10 ` David Miller 1 sibling, 0 replies; 11+ messages in thread From: David Miller @ 2009-03-16 3:10 UTC (permalink / raw) To: ilpo.jarvinen; +Cc: netdev, zbr, mingo From: "Ilpo Järvinen" <ilpo.jarvinen@helsinki.fi> Date: Sun, 15 Mar 2009 02:07:53 +0200 > There's very little need for most of the callsites to get > tp->xmit_goal_size updated. That will cost us divide as is, > so slice the function in two. Also, the only users of the > tp->xmit_goal_size are directly behind tcp_current_mss(), > so there's no need to store that variable into tcp_sock > at all! The drop of xmit_goal_size currently leaves 16-bit > hole and some reorganization would again be necessary to > change that (but I'm aiming to fill that hole with u16 > xmit_goal_size_segs to cache the results of the remaining > divide to get that tso on regression). > > Bring xmit_goal_size parts into tcp.c > > Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@helsinki.fi> Applied. ^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 1/7] tcp: remove pointless .dsack/.num_sacks code @ 2009-03-15 0:23 Ilpo Järvinen 2009-03-15 0:23 ` [PATCH 2/7] tcp: kill dead end_seq variable in clean_rtx_queue Ilpo Järvinen 0 siblings, 1 reply; 11+ messages in thread From: Ilpo Järvinen @ 2009-03-15 0:23 UTC (permalink / raw) To: David Miller; +Cc: netdev In the pure assignment case, the earlier zeroing is still in effect. David S. Miller raised concerns if the ifs are there to avoid dirtying cachelines. I came to these conclusions: > We'll be dirty it anyway (now that I check), the first "real" statement > in tcp_rcv_established is: > > tp->rx_opt.saw_tstamp = 0; > > ...that'll land on the same dword. :-/ > > I suppose the blocks are there just because they had more complexity > inside when they had to calculate the eff_sacks too (maybe it would > have been better to just remove them in that drop-patch so you would > have had less head-ache :-)). Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@helsinki.fi> --- My apologies for the duplicated patches, I succeeded once again to make mess out of it with git-send-email and 8-bit chars in header which vger consistently is known to reject... Thus resending to get a copy to appear on netdev too. Grr, 3rd attempt, now with --no-signed-off-by-cc though it _should_ have worked without that too like it used to. net/ipv4/tcp_input.c | 7 ++----- net/ipv4/tcp_output.c | 3 +-- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index 5ecd7aa..cd39d1d 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -4248,8 +4248,7 @@ static void tcp_sack_remove(struct tcp_sock *tp) this_sack++; sp++; } - if (num_sacks != tp->rx_opt.num_sacks) - tp->rx_opt.num_sacks = num_sacks; + tp->rx_opt.num_sacks = num_sacks; } /* This one checks to see if we can put data from the @@ -4325,8 +4324,7 @@ static void tcp_data_queue(struct sock *sk, struct sk_buff *skb) TCP_ECN_accept_cwr(tp, skb); - if (tp->rx_opt.dsack) - tp->rx_opt.dsack = 0; + tp->rx_opt.dsack = 0; /* Queue data for delivery to the user. * Packets in sequence go to the receive queue. @@ -4445,7 +4443,6 @@ drop: /* Initial out of order segment, build 1 SACK. */ if (tcp_is_sack(tp)) { tp->rx_opt.num_sacks = 1; - tp->rx_opt.dsack = 0; tp->selective_acks[0].start_seq = TCP_SKB_CB(skb)->seq; tp->selective_acks[0].end_seq = TCP_SKB_CB(skb)->end_seq; diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index eb285be..3256580 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c @@ -441,8 +441,7 @@ static void tcp_options_write(__be32 *ptr, struct tcp_sock *tp, *ptr++ = htonl(sp[this_sack].end_seq); } - if (tp->rx_opt.dsack) - tp->rx_opt.dsack = 0; + tp->rx_opt.dsack = 0; } } -- 1.5.6.5 ^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 2/7] tcp: kill dead end_seq variable in clean_rtx_queue 2009-03-15 0:23 [PATCH 1/7] tcp: remove pointless .dsack/.num_sacks code Ilpo Järvinen @ 2009-03-15 0:23 ` Ilpo Järvinen 2009-03-15 0:23 ` [PATCH 3/7] tcp: consolidate paws check Ilpo Järvinen 0 siblings, 1 reply; 11+ messages in thread From: Ilpo Järvinen @ 2009-03-15 0:23 UTC (permalink / raw) To: David Miller; +Cc: netdev I've already forgotten what for this was necessary, anyway it's no longer used (if it ever was). Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@helsinki.fi> --- net/ipv4/tcp_input.c | 3 --- 1 files changed, 0 insertions(+), 3 deletions(-) diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index cd39d1d..f527a16 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -3201,7 +3201,6 @@ static int tcp_clean_rtx_queue(struct sock *sk, int prior_fackets, while ((skb = tcp_write_queue_head(sk)) && skb != tcp_send_head(sk)) { struct tcp_skb_cb *scb = TCP_SKB_CB(skb); - u32 end_seq; u32 acked_pcount; u8 sacked = scb->sacked; @@ -3216,10 +3215,8 @@ static int tcp_clean_rtx_queue(struct sock *sk, int prior_fackets, break; fully_acked = 0; - end_seq = tp->snd_una; } else { acked_pcount = tcp_skb_pcount(skb); - end_seq = scb->end_seq; } /* MTU probing checks */ -- 1.5.6.5 ^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 3/7] tcp: consolidate paws check 2009-03-15 0:23 ` [PATCH 2/7] tcp: kill dead end_seq variable in clean_rtx_queue Ilpo Järvinen @ 2009-03-15 0:23 ` Ilpo Järvinen 2009-03-15 0:23 ` [PATCH 4/7] tcp: don't check mtu probe completion in the loop Ilpo Järvinen 0 siblings, 1 reply; 11+ messages in thread From: Ilpo Järvinen @ 2009-03-15 0:23 UTC (permalink / raw) To: David Miller; +Cc: netdev Wow, it was quite tricky to merge that stream of negations but I think I finally got it right: check & replace_ts_recent: (s32)(rcv_tsval - ts_recent) >= 0 => 0 (s32)(ts_recent - rcv_tsval) <= 0 => 0 discard: (s32)(ts_recent - rcv_tsval) > TCP_PAWS_WINDOW => 1 (s32)(ts_recent - rcv_tsval) <= TCP_PAWS_WINDOW => 0 I toggled the return values of tcp_paws_check around since the old encoding added yet-another negation making tracking of truth-values really complicated. Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@helsinki.fi> --- include/net/tcp.h | 18 ++++++++++++++---- net/ipv4/tcp_input.c | 11 +++++------ net/ipv4/tcp_minisocks.c | 4 ++-- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/include/net/tcp.h b/include/net/tcp.h index d74ac30..255ca35 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h @@ -997,11 +997,21 @@ static inline int tcp_fin_time(const struct sock *sk) return fin_timeout; } -static inline int tcp_paws_check(const struct tcp_options_received *rx_opt, int rst) +static inline int tcp_paws_check(const struct tcp_options_received *rx_opt, + int paws_win) { - if ((s32)(rx_opt->rcv_tsval - rx_opt->ts_recent) >= 0) - return 0; - if (get_seconds() >= rx_opt->ts_recent_stamp + TCP_PAWS_24DAYS) + if ((s32)(rx_opt->ts_recent - rx_opt->rcv_tsval) <= paws_win) + return 1; + if (unlikely(get_seconds() >= rx_opt->ts_recent_stamp + TCP_PAWS_24DAYS)) + return 1; + + return 0; +} + +static inline int tcp_paws_reject(const struct tcp_options_received *rx_opt, + int rst) +{ + if (tcp_paws_check(rx_opt, 0)) return 0; /* RST segments are not recommended to carry timestamp, diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index f527a16..b7d02c5 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -3883,8 +3883,7 @@ static inline void tcp_replace_ts_recent(struct tcp_sock *tp, u32 seq) * Not only, also it occurs for expired timestamps. */ - if ((s32)(tp->rx_opt.rcv_tsval - tp->rx_opt.ts_recent) >= 0 || - get_seconds() >= tp->rx_opt.ts_recent_stamp + TCP_PAWS_24DAYS) + if (tcp_paws_check(&tp->rx_opt, 0)) tcp_store_ts_recent(tp); } } @@ -3936,9 +3935,9 @@ static inline int tcp_paws_discard(const struct sock *sk, const struct sk_buff *skb) { const struct tcp_sock *tp = tcp_sk(sk); - return ((s32)(tp->rx_opt.ts_recent - tp->rx_opt.rcv_tsval) > TCP_PAWS_WINDOW && - get_seconds() < tp->rx_opt.ts_recent_stamp + TCP_PAWS_24DAYS && - !tcp_disordered_ack(sk, skb)); + + return !tcp_paws_check(&tp->rx_opt, TCP_PAWS_WINDOW) && + !tcp_disordered_ack(sk, skb); } /* Check segment sequence number for validity. @@ -5513,7 +5512,7 @@ discard: /* PAWS check. */ if (tp->rx_opt.ts_recent_stamp && tp->rx_opt.saw_tstamp && - tcp_paws_check(&tp->rx_opt, 0)) + tcp_paws_reject(&tp->rx_opt, 0)) goto discard_and_undo; if (th->syn) { diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c index 4b0df3e..43bbba7 100644 --- a/net/ipv4/tcp_minisocks.c +++ b/net/ipv4/tcp_minisocks.c @@ -107,7 +107,7 @@ tcp_timewait_state_process(struct inet_timewait_sock *tw, struct sk_buff *skb, if (tmp_opt.saw_tstamp) { tmp_opt.ts_recent = tcptw->tw_ts_recent; tmp_opt.ts_recent_stamp = tcptw->tw_ts_recent_stamp; - paws_reject = tcp_paws_check(&tmp_opt, th->rst); + paws_reject = tcp_paws_reject(&tmp_opt, th->rst); } } @@ -511,7 +511,7 @@ struct sock *tcp_check_req(struct sock *sk, struct sk_buff *skb, * from another data. */ tmp_opt.ts_recent_stamp = get_seconds() - ((TCP_TIMEOUT_INIT/HZ)<<req->retrans); - paws_reject = tcp_paws_check(&tmp_opt, th->rst); + paws_reject = tcp_paws_reject(&tmp_opt, th->rst); } } -- 1.5.6.5 ^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 4/7] tcp: don't check mtu probe completion in the loop 2009-03-15 0:23 ` [PATCH 3/7] tcp: consolidate paws check Ilpo Järvinen @ 2009-03-15 0:23 ` Ilpo Järvinen 2009-03-15 0:23 ` [PATCH 5/7] tcp: simplify tcp_current_mss Ilpo Järvinen 0 siblings, 1 reply; 11+ messages in thread From: Ilpo Järvinen @ 2009-03-15 0:23 UTC (permalink / raw) To: David Miller; +Cc: netdev It seems that no variables clash such that we couldn't do the check just once later on. Therefore move it. Also kill dead obvious comment, dead argument and add unlikely since this mtu probe does not happen too often. Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@helsinki.fi> --- net/ipv4/tcp_input.c | 13 ++++++------- 1 files changed, 6 insertions(+), 7 deletions(-) diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index b7d02c5..311c30f 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -2836,7 +2836,7 @@ static void tcp_mtup_probe_failed(struct sock *sk) icsk->icsk_mtup.probe_size = 0; } -static void tcp_mtup_probe_success(struct sock *sk, struct sk_buff *skb) +static void tcp_mtup_probe_success(struct sock *sk) { struct tcp_sock *tp = tcp_sk(sk); struct inet_connection_sock *icsk = inet_csk(sk); @@ -3219,12 +3219,6 @@ static int tcp_clean_rtx_queue(struct sock *sk, int prior_fackets, acked_pcount = tcp_skb_pcount(skb); } - /* MTU probing checks */ - if (fully_acked && icsk->icsk_mtup.probe_size && - !after(tp->mtu_probe.probe_seq_end, scb->end_seq)) { - tcp_mtup_probe_success(sk, skb); - } - if (sacked & TCPCB_RETRANS) { if (sacked & TCPCB_SACKED_RETRANS) tp->retrans_out -= acked_pcount; @@ -3287,6 +3281,11 @@ static int tcp_clean_rtx_queue(struct sock *sk, int prior_fackets, const struct tcp_congestion_ops *ca_ops = inet_csk(sk)->icsk_ca_ops; + if (unlikely(icsk->icsk_mtup.probe_size && + !after(tp->mtu_probe.probe_seq_end, tp->snd_una))) { + tcp_mtup_probe_success(sk); + } + tcp_ack_update_rtt(sk, flag, seq_rtt); tcp_rearm_rto(sk); -- 1.5.6.5 ^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 5/7] tcp: simplify tcp_current_mss 2009-03-15 0:23 ` [PATCH 4/7] tcp: don't check mtu probe completion in the loop Ilpo Järvinen @ 2009-03-15 0:23 ` Ilpo Järvinen 0 siblings, 0 replies; 11+ messages in thread From: Ilpo Järvinen @ 2009-03-15 0:23 UTC (permalink / raw) To: David Miller; +Cc: netdev There's very little need for most of the callsites to get tp->xmit_goal_size updated. That will cost us divide as is, so slice the function in two. Also, the only users of the tp->xmit_goal_size are directly behind tcp_current_mss(), so there's no need to store that variable into tcp_sock at all! The drop of xmit_goal_size currently leaves 16-bit hole and some reorganization would again be necessary to change that (but I'm aiming to fill that hole with u16 xmit_goal_size_segs to cache the results of the remaining divide to get that tso on regression). Bring xmit_goal_size parts into tcp.c Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@helsinki.fi> Cc: Evgeniy Polyakov <zbr@ioremap.net> Cc: Ingo Molnar <mingo@elte.hu> --- include/linux/tcp.h | 1 - include/net/tcp.h | 13 +++++++++++-- net/ipv4/tcp.c | 43 +++++++++++++++++++++++++++++++++++-------- net/ipv4/tcp_input.c | 2 +- net/ipv4/tcp_output.c | 41 +++++++---------------------------------- 5 files changed, 54 insertions(+), 46 deletions(-) diff --git a/include/linux/tcp.h b/include/linux/tcp.h index 4b86ad7..ad2021c 100644 --- a/include/linux/tcp.h +++ b/include/linux/tcp.h @@ -248,7 +248,6 @@ struct tcp_sock { /* inet_connection_sock has to be the first member of tcp_sock */ struct inet_connection_sock inet_conn; u16 tcp_header_len; /* Bytes of tcp header to send */ - u16 xmit_size_goal; /* Goal for segmenting output packets */ /* * Header prediction flags diff --git a/include/net/tcp.h b/include/net/tcp.h index 255ca35..e54c76d 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h @@ -481,7 +481,16 @@ static inline void tcp_clear_xmit_timers(struct sock *sk) } extern unsigned int tcp_sync_mss(struct sock *sk, u32 pmtu); -extern unsigned int tcp_current_mss(struct sock *sk, int large); +extern unsigned int tcp_current_mss(struct sock *sk); + +/* Bound MSS / TSO packet size with the half of the window */ +static inline int tcp_bound_to_half_wnd(struct tcp_sock *tp, int pktsize) +{ + if (tp->max_window && pktsize > (tp->max_window >> 1)) + return max(tp->max_window >> 1, 68U - tp->tcp_header_len); + else + return pktsize; +} /* tcp.c */ extern void tcp_get_info(struct sock *, struct tcp_info *); @@ -822,7 +831,7 @@ static inline void tcp_push_pending_frames(struct sock *sk) { struct tcp_sock *tp = tcp_sk(sk); - __tcp_push_pending_frames(sk, tcp_current_mss(sk, 1), tp->nonagle); + __tcp_push_pending_frames(sk, tcp_current_mss(sk), tp->nonagle); } static inline void tcp_init_wl(struct tcp_sock *tp, u32 seq) diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index d3f9bee..886596f 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -661,6 +661,37 @@ struct sk_buff *sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp) return NULL; } +static unsigned int tcp_xmit_size_goal(struct sock *sk, u32 mss_now, + int large_allowed) +{ + struct tcp_sock *tp = tcp_sk(sk); + u32 xmit_size_goal; + + xmit_size_goal = mss_now; + + if (large_allowed && sk_can_gso(sk)) { + xmit_size_goal = ((sk->sk_gso_max_size - 1) - + inet_csk(sk)->icsk_af_ops->net_header_len - + inet_csk(sk)->icsk_ext_hdr_len - + tp->tcp_header_len); + + xmit_size_goal = tcp_bound_to_half_wnd(tp, xmit_size_goal); + xmit_size_goal -= (xmit_size_goal % mss_now); + } + + return xmit_size_goal; +} + +static int tcp_send_mss(struct sock *sk, int *size_goal, int flags) +{ + int mss_now; + + mss_now = tcp_current_mss(sk); + *size_goal = tcp_xmit_size_goal(sk, mss_now, !(flags & MSG_OOB)); + + return mss_now; +} + static ssize_t do_tcp_sendpages(struct sock *sk, struct page **pages, int poffset, size_t psize, int flags) { @@ -677,8 +708,7 @@ static ssize_t do_tcp_sendpages(struct sock *sk, struct page **pages, int poffse clear_bit(SOCK_ASYNC_NOSPACE, &sk->sk_socket->flags); - mss_now = tcp_current_mss(sk, !(flags&MSG_OOB)); - size_goal = tp->xmit_size_goal; + mss_now = tcp_send_mss(sk, &size_goal, flags); copied = 0; err = -EPIPE; @@ -761,8 +791,7 @@ wait_for_memory: if ((err = sk_stream_wait_memory(sk, &timeo)) != 0) goto do_error; - mss_now = tcp_current_mss(sk, !(flags&MSG_OOB)); - size_goal = tp->xmit_size_goal; + mss_now = tcp_send_mss(sk, &size_goal, flags); } out: @@ -844,8 +873,7 @@ int tcp_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg, /* This should be in poll */ clear_bit(SOCK_ASYNC_NOSPACE, &sk->sk_socket->flags); - mss_now = tcp_current_mss(sk, !(flags&MSG_OOB)); - size_goal = tp->xmit_size_goal; + mss_now = tcp_send_mss(sk, &size_goal, flags); /* Ok commence sending. */ iovlen = msg->msg_iovlen; @@ -1007,8 +1035,7 @@ wait_for_memory: if ((err = sk_stream_wait_memory(sk, &timeo)) != 0) goto do_error; - mss_now = tcp_current_mss(sk, !(flags&MSG_OOB)); - size_goal = tp->xmit_size_goal; + mss_now = tcp_send_mss(sk, &size_goal, flags); } } diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index 311c30f..fae78e3 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -2864,7 +2864,7 @@ void tcp_simple_retransmit(struct sock *sk) const struct inet_connection_sock *icsk = inet_csk(sk); struct tcp_sock *tp = tcp_sk(sk); struct sk_buff *skb; - unsigned int mss = tcp_current_mss(sk, 0); + unsigned int mss = tcp_current_mss(sk); u32 prior_lost = tp->lost_out; tcp_for_write_queue(skb, sk) { diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index 3256580..c1f259d 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c @@ -921,7 +921,7 @@ int tcp_trim_head(struct sock *sk, struct sk_buff *skb, u32 len) * factor and mss. */ if (tcp_skb_pcount(skb) > 1) - tcp_set_skb_tso_segs(sk, skb, tcp_current_mss(sk, 1)); + tcp_set_skb_tso_segs(sk, skb, tcp_current_mss(sk)); return 0; } @@ -982,15 +982,6 @@ void tcp_mtup_init(struct sock *sk) icsk->icsk_mtup.probe_size = 0; } -/* Bound MSS / TSO packet size with the half of the window */ -static int tcp_bound_to_half_wnd(struct tcp_sock *tp, int pktsize) -{ - if (tp->max_window && pktsize > (tp->max_window >> 1)) - return max(tp->max_window >> 1, 68U - tp->tcp_header_len); - else - return pktsize; -} - /* This function synchronize snd mss to current pmtu/exthdr set. tp->rx_opt.user_mss is mss set by user by TCP_MAXSEG. It does NOT counts @@ -1037,22 +1028,17 @@ unsigned int tcp_sync_mss(struct sock *sk, u32 pmtu) /* Compute the current effective MSS, taking SACKs and IP options, * and even PMTU discovery events into account. */ -unsigned int tcp_current_mss(struct sock *sk, int large_allowed) +unsigned int tcp_current_mss(struct sock *sk) { struct tcp_sock *tp = tcp_sk(sk); struct dst_entry *dst = __sk_dst_get(sk); u32 mss_now; - u16 xmit_size_goal; - int doing_tso = 0; unsigned header_len; struct tcp_out_options opts; struct tcp_md5sig_key *md5; mss_now = tp->mss_cache; - if (large_allowed && sk_can_gso(sk)) - doing_tso = 1; - if (dst) { u32 mtu = dst_mtu(dst); if (mtu != inet_csk(sk)->icsk_pmtu_cookie) @@ -1070,19 +1056,6 @@ unsigned int tcp_current_mss(struct sock *sk, int large_allowed) mss_now -= delta; } - xmit_size_goal = mss_now; - - if (doing_tso) { - xmit_size_goal = ((sk->sk_gso_max_size - 1) - - inet_csk(sk)->icsk_af_ops->net_header_len - - inet_csk(sk)->icsk_ext_hdr_len - - tp->tcp_header_len); - - xmit_size_goal = tcp_bound_to_half_wnd(tp, xmit_size_goal); - xmit_size_goal -= (xmit_size_goal % mss_now); - } - tp->xmit_size_goal = xmit_size_goal; - return mss_now; } @@ -1264,7 +1237,7 @@ int tcp_may_send_now(struct sock *sk) struct sk_buff *skb = tcp_send_head(sk); return (skb && - tcp_snd_test(sk, skb, tcp_current_mss(sk, 1), + tcp_snd_test(sk, skb, tcp_current_mss(sk), (tcp_skb_is_last(sk, skb) ? tp->nonagle : TCP_NAGLE_PUSH))); } @@ -1421,7 +1394,7 @@ static int tcp_mtu_probe(struct sock *sk) return -1; /* Very simple search strategy: just double the MSS. */ - mss_now = tcp_current_mss(sk, 0); + mss_now = tcp_current_mss(sk); probe_size = 2 * tp->mss_cache; size_needed = probe_size + (tp->reordering + 1) * tp->mss_cache; if (probe_size > tcp_mtu_to_mss(sk, icsk->icsk_mtup.search_high)) { @@ -1903,7 +1876,7 @@ int tcp_retransmit_skb(struct sock *sk, struct sk_buff *skb) if (inet_csk(sk)->icsk_af_ops->rebuild_header(sk)) return -EHOSTUNREACH; /* Routing failure or similar. */ - cur_mss = tcp_current_mss(sk, 0); + cur_mss = tcp_current_mss(sk); /* If receiver has shrunk his window, and skb is out of * new window, do not retransmit it. The exception is the @@ -2111,7 +2084,7 @@ void tcp_send_fin(struct sock *sk) * unsent frames. But be careful about outgoing SACKS * and IP options. */ - mss_now = tcp_current_mss(sk, 1); + mss_now = tcp_current_mss(sk); if (tcp_send_head(sk) != NULL) { TCP_SKB_CB(skb)->flags |= TCPCB_FLAG_FIN; @@ -2523,7 +2496,7 @@ int tcp_write_wakeup(struct sock *sk) if ((skb = tcp_send_head(sk)) != NULL && before(TCP_SKB_CB(skb)->seq, tcp_wnd_end(tp))) { int err; - unsigned int mss = tcp_current_mss(sk, 0); + unsigned int mss = tcp_current_mss(sk); unsigned int seg_size = tcp_wnd_end(tp) - TCP_SKB_CB(skb)->seq; if (before(tp->pushed_seq, TCP_SKB_CB(skb)->end_seq)) -- 1.5.6.5 ^ permalink raw reply related [flat|nested] 11+ messages in thread
end of thread, other threads:[~2009-03-16 3:11 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <1237075675426-git-send-email-ilpo.jarvinen@helsinki.fi>
2009-03-16 3:10 ` [PATCH 1/7] tcp: remove pointless .dsack/.num_sacks code David Miller
[not found] ` <12370756753599-git-send-email-ilpo.jarvinen@helsinki.fi>
2009-03-16 3:10 ` [PATCH 2/7] tcp: kill dead end_seq variable in clean_rtx_queue David Miller
[not found] ` <12370756754094-git-send-email-ilpo.jarvinen@helsinki.fi>
2009-03-16 3:10 ` [PATCH 3/7] tcp: consolidate paws check David Miller
[not found] ` <12370756752410-git-send-email-ilpo.jarvinen@helsinki.fi>
2009-03-16 3:10 ` [PATCH 4/7] tcp: don't check mtu probe completion in the loop David Miller
[not found] ` <12370756751028-git-send-email-ilpo.jarvinen@helsinki.fi>
[not found] ` <12370756752721-git-send-email-ilpo.jarvinen@helsinki.fi>
2009-03-15 8:36 ` [PATCH 6/7] tcp: cache result of earlier divides when mss-aligning things Evgeniy Polyakov
2009-03-15 8:45 ` Ilpo Järvinen
2009-03-15 9:08 ` Evgeniy Polyakov
2009-03-16 3:11 ` David Miller
[not found] ` <12370756754020-git-send-email-ilpo.jarvinen@helsinki.fi>
2009-03-16 3:11 ` [PATCH 7/7] tcp: make sure xmit goal size never becomes zero David Miller
2009-03-16 3:10 ` [PATCH 5/7] tcp: simplify tcp_current_mss David Miller
2009-03-15 0:23 [PATCH 1/7] tcp: remove pointless .dsack/.num_sacks code Ilpo Järvinen
2009-03-15 0:23 ` [PATCH 2/7] tcp: kill dead end_seq variable in clean_rtx_queue Ilpo Järvinen
2009-03-15 0:23 ` [PATCH 3/7] tcp: consolidate paws check Ilpo Järvinen
2009-03-15 0:23 ` [PATCH 4/7] tcp: don't check mtu probe completion in the loop Ilpo Järvinen
2009-03-15 0:23 ` [PATCH 5/7] tcp: simplify tcp_current_mss Ilpo Järvinen
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).