diff mbox series

[net-next,v2,1/2] tcp: derive delack_max with tcp_rto_min helper

Message ID 20240530153436.2202800-2-yyd@google.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series tcp: add sysctl_tcp_rto_min_us | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 904 this patch: 904
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers warning 1 maintainers not CCed: dsahern@kernel.org
netdev/build_clang success Errors and warnings before: 908 this patch: 908
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 908 this patch: 908
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 18 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 1 this patch: 1
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-05-31--03-00 (tests: 1040)

Commit Message

Kevin Yang May 30, 2024, 3:34 p.m. UTC
Rto_min now has multiple souces, ordered by preprecedence high to
low: ip route option rto_min, icsk->icsk_rto_min.

When derive delack_max from rto_min, we should not only use ip
route option, but should use tcp_rto_min helper to get the correct
rto_min.

Signed-off-by: Kevin Yang <yyd@google.com>
Reviewed-by: Neal Cardwell <ncardwell@google.com>
Reviewed-by: Yuchung Cheng <ycheng@google.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Tony Lu <tonylu@linux.alibaba.com>
Reviewed-by: Jakub Kicinski <kuba@kernel.org>
---
 net/ipv4/tcp_output.c | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)

Comments

Simon Horman June 1, 2024, 1:28 p.m. UTC | #1
On Thu, May 30, 2024 at 03:34:35PM +0000, Kevin Yang wrote:
> Rto_min now has multiple souces, ordered by preprecedence high to
> low: ip route option rto_min, icsk->icsk_rto_min.

Hi Kevin,

If you have to respin for some other reason: souces -> sources

Flagged by checkpatch.pl --codespell

...
David Laight June 1, 2024, 2:56 p.m. UTC | #2
From: Kevin Yang
> Sent: 30 May 2024 16:35
> To: David Miller <davem@davemloft.net>; Eric Dumazet <edumazet@google.com>; Jakub Kicinski
> 
> Rto_min now has multiple souces, ordered by preprecedence high to
> low: ip route option rto_min, icsk->icsk_rto_min.
> 
> When derive delack_max from rto_min, we should not only use ip
> route option, but should use tcp_rto_min helper to get the correct
> rto_min.
...
> diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
> index f97e098f18a5..b44f639a9fa6 100644
> --- a/net/ipv4/tcp_output.c
> +++ b/net/ipv4/tcp_output.c
> @@ -4163,16 +4163,9 @@ EXPORT_SYMBOL(tcp_connect);
> 
>  u32 tcp_delack_max(const struct sock *sk)
>  {
> -	const struct dst_entry *dst = __sk_dst_get(sk);
> -	u32 delack_max = inet_csk(sk)->icsk_delack_max;
> -
> -	if (dst && dst_metric_locked(dst, RTAX_RTO_MIN)) {
> -		u32 rto_min = dst_metric_rtt(dst, RTAX_RTO_MIN);
> -		u32 delack_from_rto_min = max_t(int, 1, rto_min - 1);
> +	u32 delack_from_rto_min = max_t(int, 1, tcp_rto_min(sk) - 1);

That max_t() is more horrid than most.
Perhaps:
		= max(tcp_rto_min(sk), 2) - 1;

> 
> -		delack_max = min_t(u32, delack_max, delack_from_rto_min);
> -	}
> -	return delack_max;
> +	return min_t(u32, inet_csk(sk)->icsk_delack_max, delack_from_rto_min);

Can that just be a min() ??

	David

>  }
> 
>  /* Send out a delayed ack, the caller does the policy checking
> --
> 2.45.1.288.g0e0cd299f1-goog
> 

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
Kevin Yang June 3, 2024, 9:34 p.m. UTC | #3
thanks for the nice suggestions, sent v3
https://lore.kernel.org/netdev/20240603213054.3883725-1-yyd@google.com/

On Sat, Jun 1, 2024 at 10:56 AM David Laight <David.Laight@aculab.com> wrote:
>
> From: Kevin Yang
> > Sent: 30 May 2024 16:35
> > To: David Miller <davem@davemloft.net>; Eric Dumazet <edumazet@google.com>; Jakub Kicinski
> >
> > Rto_min now has multiple souces, ordered by preprecedence high to
> > low: ip route option rto_min, icsk->icsk_rto_min.
> >
> > When derive delack_max from rto_min, we should not only use ip
> > route option, but should use tcp_rto_min helper to get the correct
> > rto_min.
> ...
> > diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
> > index f97e098f18a5..b44f639a9fa6 100644
> > --- a/net/ipv4/tcp_output.c
> > +++ b/net/ipv4/tcp_output.c
> > @@ -4163,16 +4163,9 @@ EXPORT_SYMBOL(tcp_connect);
> >
> >  u32 tcp_delack_max(const struct sock *sk)
> >  {
> > -     const struct dst_entry *dst = __sk_dst_get(sk);
> > -     u32 delack_max = inet_csk(sk)->icsk_delack_max;
> > -
> > -     if (dst && dst_metric_locked(dst, RTAX_RTO_MIN)) {
> > -             u32 rto_min = dst_metric_rtt(dst, RTAX_RTO_MIN);
> > -             u32 delack_from_rto_min = max_t(int, 1, rto_min - 1);
> > +     u32 delack_from_rto_min = max_t(int, 1, tcp_rto_min(sk) - 1);
>
> That max_t() is more horrid than most.
> Perhaps:
>                 = max(tcp_rto_min(sk), 2) - 1;
>
> >
> > -             delack_max = min_t(u32, delack_max, delack_from_rto_min);
> > -     }
> > -     return delack_max;
> > +     return min_t(u32, inet_csk(sk)->icsk_delack_max, delack_from_rto_min);
>
> Can that just be a min() ??
>
>         David
>
> >  }
> >
> >  /* Send out a delayed ack, the caller does the policy checking
> > --
> > 2.45.1.288.g0e0cd299f1-goog
> >
>
> -
> Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
> Registration No: 1397386 (Wales)
diff mbox series

Patch

diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index f97e098f18a5..b44f639a9fa6 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -4163,16 +4163,9 @@  EXPORT_SYMBOL(tcp_connect);
 
 u32 tcp_delack_max(const struct sock *sk)
 {
-	const struct dst_entry *dst = __sk_dst_get(sk);
-	u32 delack_max = inet_csk(sk)->icsk_delack_max;
-
-	if (dst && dst_metric_locked(dst, RTAX_RTO_MIN)) {
-		u32 rto_min = dst_metric_rtt(dst, RTAX_RTO_MIN);
-		u32 delack_from_rto_min = max_t(int, 1, rto_min - 1);
+	u32 delack_from_rto_min = max_t(int, 1, tcp_rto_min(sk) - 1);
 
-		delack_max = min_t(u32, delack_max, delack_from_rto_min);
-	}
-	return delack_max;
+	return min_t(u32, inet_csk(sk)->icsk_delack_max, delack_from_rto_min);
 }
 
 /* Send out a delayed ack, the caller does the policy checking