netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 net-next 0/2] tcp/dccp: remove 16 bytes from icsk
@ 2025-03-18 15:43 Eric Dumazet
  2025-03-18 15:43 ` [PATCH v2 net-next 1/2] tcp/dccp: remove icsk->icsk_timeout Eric Dumazet
  2025-03-18 15:43 ` [PATCH v2 net-next 2/2] tcp/dccp: remove icsk->icsk_ack.timeout Eric Dumazet
  0 siblings, 2 replies; 8+ messages in thread
From: Eric Dumazet @ 2025-03-18 15:43 UTC (permalink / raw)
  To: David S . Miller, Jakub Kicinski, Paolo Abeni, Neal Cardwell
  Cc: Kuniyuki Iwashima, Simon Horman, netdev, eric.dumazet,
	Eric Dumazet

icsk->icsk_timeout and icsk->icsk_ack.timeout can be removed.

They mirror existing fields in icsk->icsk_retransmit_timer and
icsk->icsk_retransmit_timer.

v2: rebase, plus Kuniyuki tags.

Eric Dumazet (2):
  tcp/dccp: remove icsk->icsk_timeout
  tcp/dccp: remove icsk->icsk_ack.timeout

 .../net_cachelines/inet_connection_sock.rst   |  4 +---
 include/net/inet_connection_sock.h            | 22 +++++++++++++------
 net/dccp/output.c                             |  5 ++---
 net/dccp/timer.c                              |  8 +++----
 net/ipv4/inet_diag.c                          |  4 ++--
 net/ipv4/tcp_ipv4.c                           |  4 ++--
 net/ipv4/tcp_output.c                         |  7 +++---
 net/ipv4/tcp_timer.c                          | 16 ++++++++------
 net/ipv6/tcp_ipv6.c                           |  4 ++--
 net/mptcp/options.c                           |  1 -
 net/mptcp/protocol.c                          |  3 +--
 .../selftests/bpf/progs/bpf_iter_tcp4.c       |  4 ++--
 .../selftests/bpf/progs/bpf_iter_tcp6.c       |  4 ++--
 13 files changed, 45 insertions(+), 41 deletions(-)

-- 
2.49.0.rc1.451.g8f38331e32-goog


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v2 net-next 1/2] tcp/dccp: remove icsk->icsk_timeout
  2025-03-18 15:43 [PATCH v2 net-next 0/2] tcp/dccp: remove 16 bytes from icsk Eric Dumazet
@ 2025-03-18 15:43 ` Eric Dumazet
  2025-03-18 15:43 ` [PATCH v2 net-next 2/2] tcp/dccp: remove icsk->icsk_ack.timeout Eric Dumazet
  1 sibling, 0 replies; 8+ messages in thread
From: Eric Dumazet @ 2025-03-18 15:43 UTC (permalink / raw)
  To: David S . Miller, Jakub Kicinski, Paolo Abeni, Neal Cardwell
  Cc: Kuniyuki Iwashima, Simon Horman, netdev, eric.dumazet,
	Eric Dumazet

icsk->icsk_timeout can be replaced by icsk->icsk_retransmit_timer.expires

This saves 8 bytes in TCP/DCCP sockets and helps for better cache locality.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Kuniyuki Iwashima <kuniyu@amazon.com>
---
 .../net_cachelines/inet_connection_sock.rst          |  3 +--
 include/net/inet_connection_sock.h                   | 12 ++++++++----
 net/dccp/timer.c                                     |  4 ++--
 net/ipv4/inet_diag.c                                 |  4 ++--
 net/ipv4/tcp_ipv4.c                                  |  4 ++--
 net/ipv4/tcp_timer.c                                 | 11 ++++++-----
 net/ipv6/tcp_ipv6.c                                  |  4 ++--
 net/mptcp/protocol.c                                 |  2 +-
 tools/testing/selftests/bpf/progs/bpf_iter_tcp4.c    |  4 ++--
 tools/testing/selftests/bpf/progs/bpf_iter_tcp6.c    |  4 ++--
 10 files changed, 28 insertions(+), 24 deletions(-)

diff --git a/Documentation/networking/net_cachelines/inet_connection_sock.rst b/Documentation/networking/net_cachelines/inet_connection_sock.rst
index b2401aa7c45090b07c2262ac31a3584725f92233..5fb0dd70c9af76ca68b3406ce76d4b61957c7da9 100644
--- a/Documentation/networking/net_cachelines/inet_connection_sock.rst
+++ b/Documentation/networking/net_cachelines/inet_connection_sock.rst
@@ -12,8 +12,7 @@ struct inet_sock                    icsk_inet              read_mostly         r
 struct request_sock_queue           icsk_accept_queue
 struct inet_bind_bucket             icsk_bind_hash         read_mostly                             tcp_set_state
 struct inet_bind2_bucket            icsk_bind2_hash        read_mostly                             tcp_set_state,inet_put_port
-unsigned_long                       icsk_timeout           read_mostly                             inet_csk_reset_xmit_timer,tcp_connect
-struct timer_list                   icsk_retransmit_timer  read_mostly                             inet_csk_reset_xmit_timer,tcp_connect
+struct timer_list                   icsk_retransmit_timer  read_write                              inet_csk_reset_xmit_timer,tcp_connect
 struct timer_list                   icsk_delack_timer      read_mostly                             inet_csk_reset_xmit_timer,tcp_connect
 u32                                 icsk_rto               read_write                              tcp_cwnd_validate,tcp_schedule_loss_probe,tcp_connect_init,tcp_connect,tcp_write_xmit,tcp_push_one
 u32                                 icsk_rto_min
diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h
index f736d3097e43d97ee32f5d31f0e566536fe05a35..018118da0ce15c5ba5e3b7fcc1b36425794ec9a1 100644
--- a/include/net/inet_connection_sock.h
+++ b/include/net/inet_connection_sock.h
@@ -58,7 +58,6 @@ struct inet_connection_sock_af_ops {
  * @icsk_accept_queue:	   FIFO of established children
  * @icsk_bind_hash:	   Bind node
  * @icsk_bind2_hash:	   Bind node in the bhash2 table
- * @icsk_timeout:	   Timeout
  * @icsk_retransmit_timer: Resend (no ack)
  * @icsk_rto:		   Retransmit timeout
  * @icsk_pmtu_cookie	   Last pmtu seen by socket
@@ -85,7 +84,6 @@ struct inet_connection_sock {
 	struct request_sock_queue icsk_accept_queue;
 	struct inet_bind_bucket	  *icsk_bind_hash;
 	struct inet_bind2_bucket  *icsk_bind2_hash;
-	unsigned long		  icsk_timeout;
  	struct timer_list	  icsk_retransmit_timer;
  	struct timer_list	  icsk_delack_timer;
 	__u32			  icsk_rto;
@@ -191,6 +189,12 @@ static inline void inet_csk_delack_init(struct sock *sk)
 	memset(&inet_csk(sk)->icsk_ack, 0, sizeof(inet_csk(sk)->icsk_ack));
 }
 
+static inline unsigned long
+icsk_timeout(const struct inet_connection_sock *icsk)
+{
+	return READ_ONCE(icsk->icsk_retransmit_timer.expires);
+}
+
 static inline void inet_csk_clear_xmit_timer(struct sock *sk, const int what)
 {
 	struct inet_connection_sock *icsk = inet_csk(sk);
@@ -229,8 +233,8 @@ static inline void inet_csk_reset_xmit_timer(struct sock *sk, const int what,
 	if (what == ICSK_TIME_RETRANS || what == ICSK_TIME_PROBE0 ||
 	    what == ICSK_TIME_LOSS_PROBE || what == ICSK_TIME_REO_TIMEOUT) {
 		smp_store_release(&icsk->icsk_pending, what);
-		icsk->icsk_timeout = jiffies + when;
-		sk_reset_timer(sk, &icsk->icsk_retransmit_timer, icsk->icsk_timeout);
+		when += jiffies;
+		sk_reset_timer(sk, &icsk->icsk_retransmit_timer, when);
 	} else if (what == ICSK_TIME_DACK) {
 		smp_store_release(&icsk->icsk_ack.pending,
 				  icsk->icsk_ack.pending | ICSK_ACK_TIMER);
diff --git a/net/dccp/timer.c b/net/dccp/timer.c
index a4cfb47b60e523bd4a8f1f47cfedc11e633945c6..9fd14a3361893d5f2d9f0ad18a65cff963cc7e22 100644
--- a/net/dccp/timer.c
+++ b/net/dccp/timer.c
@@ -139,9 +139,9 @@ static void dccp_write_timer(struct timer_list *t)
 	if (sk->sk_state == DCCP_CLOSED || !icsk->icsk_pending)
 		goto out;
 
-	if (time_after(icsk->icsk_timeout, jiffies)) {
+	if (time_after(icsk_timeout(icsk), jiffies)) {
 		sk_reset_timer(sk, &icsk->icsk_retransmit_timer,
-			       icsk->icsk_timeout);
+			       icsk_timeout(icsk));
 		goto out;
 	}
 
diff --git a/net/ipv4/inet_diag.c b/net/ipv4/inet_diag.c
index efe2a085cf68e90cd1e79b5556e667a0fd044bfd..c2bb91d9e9ffd1fc7dc9bf048c1d6bbd75462997 100644
--- a/net/ipv4/inet_diag.c
+++ b/net/ipv4/inet_diag.c
@@ -315,12 +315,12 @@ int inet_sk_diag_fill(struct sock *sk, struct inet_connection_sock *icsk,
 		r->idiag_timer = 1;
 		r->idiag_retrans = icsk->icsk_retransmits;
 		r->idiag_expires =
-			jiffies_delta_to_msecs(icsk->icsk_timeout - jiffies);
+			jiffies_delta_to_msecs(icsk_timeout(icsk) - jiffies);
 	} else if (icsk_pending == ICSK_TIME_PROBE0) {
 		r->idiag_timer = 4;
 		r->idiag_retrans = icsk->icsk_probes_out;
 		r->idiag_expires =
-			jiffies_delta_to_msecs(icsk->icsk_timeout - jiffies);
+			jiffies_delta_to_msecs(icsk_timeout(icsk) - jiffies);
 	} else if (timer_pending(&sk->sk_timer)) {
 		r->idiag_timer = 2;
 		r->idiag_retrans = icsk->icsk_probes_out;
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index 4fa4fbb0ad12dba8b99f5698c74793743ba1bdaf..4ffc41990b6d271a356d9c5f208a9a927da39874 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -2925,10 +2925,10 @@ static void get_tcp4_sock(struct sock *sk, struct seq_file *f, int i)
 	    icsk_pending == ICSK_TIME_REO_TIMEOUT ||
 	    icsk_pending == ICSK_TIME_LOSS_PROBE) {
 		timer_active	= 1;
-		timer_expires	= icsk->icsk_timeout;
+		timer_expires	= icsk_timeout(icsk);
 	} else if (icsk_pending == ICSK_TIME_PROBE0) {
 		timer_active	= 4;
-		timer_expires	= icsk->icsk_timeout;
+		timer_expires	= icsk_timeout(icsk);
 	} else if (timer_pending(&sk->sk_timer)) {
 		timer_active	= 2;
 		timer_expires	= sk->sk_timer.expires;
diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
index 728bce01ccd3ddb1f374fa96b86434a415dbe2cb..d828b74c3e73d75cdae777645e8e8856c0751201 100644
--- a/net/ipv4/tcp_timer.c
+++ b/net/ipv4/tcp_timer.c
@@ -509,7 +509,7 @@ static bool tcp_rtx_probe0_timed_out(const struct sock *sk,
 	 * and tp->rcv_tstamp might very well have been written recently.
 	 * rcv_delta can thus be negative.
 	 */
-	rcv_delta = icsk->icsk_timeout - tp->rcv_tstamp;
+	rcv_delta = icsk_timeout(icsk) - tp->rcv_tstamp;
 	if (rcv_delta <= timeout)
 		return false;
 
@@ -685,7 +685,8 @@ out:;
 }
 
 /* Called with bottom-half processing disabled.
-   Called by tcp_write_timer() */
+ * Called by tcp_write_timer() and tcp_release_cb().
+ */
 void tcp_write_timer_handler(struct sock *sk)
 {
 	struct inet_connection_sock *icsk = inet_csk(sk);
@@ -695,11 +696,11 @@ void tcp_write_timer_handler(struct sock *sk)
 	    !icsk->icsk_pending)
 		return;
 
-	if (time_after(icsk->icsk_timeout, jiffies)) {
-		sk_reset_timer(sk, &icsk->icsk_retransmit_timer, icsk->icsk_timeout);
+	if (time_after(icsk_timeout(icsk), jiffies)) {
+		sk_reset_timer(sk, &icsk->icsk_retransmit_timer,
+			       icsk_timeout(icsk));
 		return;
 	}
-
 	tcp_mstamp_refresh(tcp_sk(sk));
 	event = icsk->icsk_pending;
 
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index e182ee0a233046468b14832b0e4730b2846e1d43..988111f09a3e2c8850a0ac551c3a50cf3bb22824 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -2199,10 +2199,10 @@ static void get_tcp6_sock(struct seq_file *seq, struct sock *sp, int i)
 	    icsk_pending == ICSK_TIME_REO_TIMEOUT ||
 	    icsk_pending == ICSK_TIME_LOSS_PROBE) {
 		timer_active	= 1;
-		timer_expires	= icsk->icsk_timeout;
+		timer_expires	= icsk_timeout(icsk);
 	} else if (icsk_pending == ICSK_TIME_PROBE0) {
 		timer_active	= 4;
-		timer_expires	= icsk->icsk_timeout;
+		timer_expires	= icsk_timeout(icsk);
 	} else if (timer_pending(&sp->sk_timer)) {
 		timer_active	= 2;
 		timer_expires	= sp->sk_timer.expires;
diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
index ad780ae1d30dcb6ff72960b340e1472a1400618a..1ac378ba1d67cd17449ab6c4b4793b65d520ec44 100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -422,7 +422,7 @@ static long mptcp_timeout_from_subflow(const struct mptcp_subflow_context *subfl
 	const struct sock *ssk = mptcp_subflow_tcp_sock(subflow);
 
 	return inet_csk(ssk)->icsk_pending && !subflow->stale_count ?
-	       inet_csk(ssk)->icsk_timeout - jiffies : 0;
+	       icsk_timeout(inet_csk(ssk)) - jiffies : 0;
 }
 
 static void mptcp_set_timeout(struct sock *sk)
diff --git a/tools/testing/selftests/bpf/progs/bpf_iter_tcp4.c b/tools/testing/selftests/bpf/progs/bpf_iter_tcp4.c
index d22449c69363afe3c3aaae158f0ef0c6ef65916c..164640db3a29cf720e193453cab79f4bc317917c 100644
--- a/tools/testing/selftests/bpf/progs/bpf_iter_tcp4.c
+++ b/tools/testing/selftests/bpf/progs/bpf_iter_tcp4.c
@@ -99,10 +99,10 @@ static int dump_tcp_sock(struct seq_file *seq, struct tcp_sock *tp,
 	    icsk->icsk_pending == ICSK_TIME_REO_TIMEOUT ||
 	    icsk->icsk_pending == ICSK_TIME_LOSS_PROBE) {
 		timer_active = 1;
-		timer_expires = icsk->icsk_timeout;
+		timer_expires = icsk->icsk_retransmit_timer.expires;
 	} else if (icsk->icsk_pending == ICSK_TIME_PROBE0) {
 		timer_active = 4;
-		timer_expires = icsk->icsk_timeout;
+		timer_expires = icsk->icsk_retransmit_timer.expires;
 	} else if (timer_pending(&sp->sk_timer)) {
 		timer_active = 2;
 		timer_expires = sp->sk_timer.expires;
diff --git a/tools/testing/selftests/bpf/progs/bpf_iter_tcp6.c b/tools/testing/selftests/bpf/progs/bpf_iter_tcp6.c
index 8b072666f9d9a0ce023e7cb2c2716bf4a5bd3905..591c703f5032f024e4b511a6af8d63d1233a042a 100644
--- a/tools/testing/selftests/bpf/progs/bpf_iter_tcp6.c
+++ b/tools/testing/selftests/bpf/progs/bpf_iter_tcp6.c
@@ -99,10 +99,10 @@ static int dump_tcp6_sock(struct seq_file *seq, struct tcp6_sock *tp,
 	    icsk->icsk_pending == ICSK_TIME_REO_TIMEOUT ||
 	    icsk->icsk_pending == ICSK_TIME_LOSS_PROBE) {
 		timer_active = 1;
-		timer_expires = icsk->icsk_timeout;
+		timer_expires = icsk->icsk_retransmit_timer.expires;
 	} else if (icsk->icsk_pending == ICSK_TIME_PROBE0) {
 		timer_active = 4;
-		timer_expires = icsk->icsk_timeout;
+		timer_expires = icsk->icsk_retransmit_timer.expires;
 	} else if (timer_pending(&sp->sk_timer)) {
 		timer_active = 2;
 		timer_expires = sp->sk_timer.expires;
-- 
2.49.0.rc1.451.g8f38331e32-goog


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v2 net-next 2/2] tcp/dccp: remove icsk->icsk_ack.timeout
  2025-03-18 15:43 [PATCH v2 net-next 0/2] tcp/dccp: remove 16 bytes from icsk Eric Dumazet
  2025-03-18 15:43 ` [PATCH v2 net-next 1/2] tcp/dccp: remove icsk->icsk_timeout Eric Dumazet
@ 2025-03-18 15:43 ` Eric Dumazet
  2025-03-20 18:38   ` Simon Horman
  2025-03-24 19:38   ` Jakub Kicinski
  1 sibling, 2 replies; 8+ messages in thread
From: Eric Dumazet @ 2025-03-18 15:43 UTC (permalink / raw)
  To: David S . Miller, Jakub Kicinski, Paolo Abeni, Neal Cardwell
  Cc: Kuniyuki Iwashima, Simon Horman, netdev, eric.dumazet,
	Eric Dumazet

icsk->icsk_ack.timeout can be replaced by icsk->csk_delack_timer.expires

This saves 8 bytes in TCP/DCCP sockets and helps for better cache locality.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Kuniyuki Iwashima <kuniyu@amazon.com>
---
v2: rebase after "tcp: cache RTAX_QUICKACK metric in a hot cache line"

 .../net_cachelines/inet_connection_sock.rst		  |  1 -
 include/net/inet_connection_sock.h 				  | 12 ++++++++----
 net/dccp/output.c									  |  5 ++---
 net/dccp/timer.c									  |  4 ++--
 net/ipv4/tcp_output.c								  |  7 +++----
 net/ipv4/tcp_timer.c								  |  5 +++--
 net/mptcp/options.c								  |  1 -
 net/mptcp/protocol.c								  |  1 -
 8 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/Documentation/networking/net_cachelines/inet_connection_sock.rst b/Documentation/networking/net_cachelines/inet_connection_sock.rst
index 5fb0dd70c9af76ca68b3406ce76d4b61957c7da9..8fae85ebb773085b249c606ce37872e0566b70b4 100644
--- a/Documentation/networking/net_cachelines/inet_connection_sock.rst
+++ b/Documentation/networking/net_cachelines/inet_connection_sock.rst
@@ -38,7 +38,6 @@ struct icsk_ack_u8				  quick 				 read_write 		 w
 struct icsk_ack_u8 				 pingpong
 struct icsk_ack_u8 				 retry					write_mostly		read_write			inet_csk_clear_xmit_timer,tcp_rearm_rto,tcp_event_new_data_sent,tcp_write_xmit,__tcp_send_ack,tcp_send_ack,
 struct icsk_ack_u8 				 ato					read_mostly 		write_mostly		tcp_dec_quickack_mode,tcp_event_ack_sent,__tcp_transmit_skb,__tcp_send_ack,tcp_send_ack
-struct icsk_ack_unsigned_long		 timeout				read_write			read_write			inet_csk_reset_xmit_timer,tcp_connect
 struct icsk_ack_u32				 lrcvtime				read_write								tcp_finish_connect,tcp_connect,tcp_event_data_sent,__tcp_transmit_skb
 struct icsk_ack_u16				 rcv_mss				write_mostly		read_mostly 		__tcp_select_window,__tcp_cleanup_rbuf,tcp_initialize_rcv_mss,tcp_connect_init
 struct icsk_mtup_int				 search_high			read_write								tcp_mtup_init,tcp_sync_mss,tcp_connect_init,tcp_mtu_check_reprobe,tcp_write_xmit
diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h
index 018118da0ce15c5ba5e3b7fcc1b36425794ec9a1..597f2b98dcf565a8512e815d9eae2b521bac7807 100644
--- a/include/net/inet_connection_sock.h
+++ b/include/net/inet_connection_sock.h
@@ -117,7 +117,6 @@ struct inet_connection_sock {
				  lrcv_flowlabel:20, /* last received ipv6 flowlabel	   */
				  dst_quick_ack:1, /* cache dst RTAX_QUICKACK		   */
				  unused:3;
-		unsigned long	  timeout;	 /* Currently scheduled timeout		   */
		__u32		  lrcvtime;	 /* timestamp of last received data packet */
		__u16		  last_seg_size; /* Size of last incoming segment	   */
		__u16		  rcv_mss;	 /* MSS used for delayed ACK decisions	   */
@@ -195,6 +194,12 @@ icsk_timeout(const struct inet_connection_sock *icsk)
	return READ_ONCE(icsk->icsk_retransmit_timer.expires);
 }

+static inline unsigned long
+icsk_delack_timeout(const struct inet_connection_sock *icsk)
+{
+	return READ_ONCE(icsk->icsk_delack_timer.expires);
+}
+
 static inline void inet_csk_clear_xmit_timer(struct sock *sk, const int what)
 {
	struct inet_connection_sock *icsk = inet_csk(sk);
@@ -230,16 +235,15 @@ static inline void inet_csk_reset_xmit_timer(struct sock *sk, const int what,
		when = max_when;
	}

+	when += jiffies;
	if (what == ICSK_TIME_RETRANS || what == ICSK_TIME_PROBE0 ||
		what == ICSK_TIME_LOSS_PROBE || what == ICSK_TIME_REO_TIMEOUT) {
		smp_store_release(&icsk->icsk_pending, what);
-		when += jiffies;
		sk_reset_timer(sk, &icsk->icsk_retransmit_timer, when);
	} else if (what == ICSK_TIME_DACK) {
		smp_store_release(&icsk->icsk_ack.pending,
				  icsk->icsk_ack.pending | ICSK_ACK_TIMER);
-		icsk->icsk_ack.timeout = jiffies + when;
-		sk_reset_timer(sk, &icsk->icsk_delack_timer, icsk->icsk_ack.timeout);
+		sk_reset_timer(sk, &icsk->icsk_delack_timer, when);
	} else {
		pr_debug("inet_csk BUG: unknown timer value\n");
	}
diff --git a/net/dccp/output.c b/net/dccp/output.c
index 5c2e24f3c39b7ff4ee1d5d96d5e406c96609a022..39cf3430177ac597b0a9fd40bf0d8dfbff5fd92d 100644
--- a/net/dccp/output.c
+++ b/net/dccp/output.c
@@ -627,11 +627,10 @@ void dccp_send_delayed_ack(struct sock *sk)
			return;
		}

-		if (!time_before(timeout, icsk->icsk_ack.timeout))
-			timeout = icsk->icsk_ack.timeout;
+		if (!time_before(timeout, icsk_delack_timeout(icsk)))
+			timeout = icsk_delack_timeout(icsk);
	}
	icsk->icsk_ack.pending |= ICSK_ACK_SCHED | ICSK_ACK_TIMER;
-	icsk->icsk_ack.timeout = timeout;
	sk_reset_timer(sk, &icsk->icsk_delack_timer, timeout);
 }
 #endif
diff --git a/net/dccp/timer.c b/net/dccp/timer.c
index 9fd14a3361893d5f2d9f0ad18a65cff963cc7e22..232ac4ae0a73ff31beca730c14d8b02107aeb926 100644
--- a/net/dccp/timer.c
+++ b/net/dccp/timer.c
@@ -185,9 +185,9 @@ static void dccp_delack_timer(struct timer_list *t)
	if (sk->sk_state == DCCP_CLOSED ||
		!(icsk->icsk_ack.pending & ICSK_ACK_TIMER))
		goto out;
-	if (time_after(icsk->icsk_ack.timeout, jiffies)) {
+	if (time_after(icsk_delack_timeout(icsk), jiffies)) {
		sk_reset_timer(sk, &icsk->icsk_delack_timer,
-				   icsk->icsk_ack.timeout);
+				   icsk_delack_timeout(icsk));
		goto out;
	}

diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index e0a4e5432399a3874e471f2d908bf976350f2696..c29e689d966097fabb83876f21d54201989b444d 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -4225,17 +4225,16 @@ void tcp_send_delayed_ack(struct sock *sk)
	/* Use new timeout only if there wasn't a older one earlier. */
	if (icsk->icsk_ack.pending & ICSK_ACK_TIMER) {
		/* If delack timer is about to expire, send ACK now. */
-		if (time_before_eq(icsk->icsk_ack.timeout, jiffies + (ato >> 2))) {
+		if (time_before_eq(icsk_delack_timeout(icsk), jiffies + (ato >> 2))) {
			tcp_send_ack(sk);
			return;
		}

-		if (!time_before(timeout, icsk->icsk_ack.timeout))
-			timeout = icsk->icsk_ack.timeout;
+		if (!time_before(timeout, icsk_delack_timeout(icsk)))
+			timeout = icsk_delack_timeout(icsk);
	}
	smp_store_release(&icsk->icsk_ack.pending,
			  icsk->icsk_ack.pending | ICSK_ACK_SCHED | ICSK_ACK_TIMER);
-	icsk->icsk_ack.timeout = timeout;
	sk_reset_timer(sk, &icsk->icsk_delack_timer, timeout);
 }

diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
index d828b74c3e73d75cdae777645e8e8856c0751201..d64383b06a295affb735f60edd4dfd64ad5fb1c8 100644
--- a/net/ipv4/tcp_timer.c
+++ b/net/ipv4/tcp_timer.c
@@ -322,8 +322,9 @@ void tcp_delack_timer_handler(struct sock *sk)
	if (!(icsk->icsk_ack.pending & ICSK_ACK_TIMER))
		return;

-	if (time_after(icsk->icsk_ack.timeout, jiffies)) {
-		sk_reset_timer(sk, &icsk->icsk_delack_timer, icsk->icsk_ack.timeout);
+	if (time_after(icsk_delack_timeout(icsk), jiffies)) {
+		sk_reset_timer(sk, &icsk->icsk_delack_timer,
+				   icsk_delack_timeout(icsk));
		return;
	}
	icsk->icsk_ack.pending &= ~ICSK_ACK_TIMER;
diff --git a/net/mptcp/options.c b/net/mptcp/options.c
index fd2de185bc939f8730e87a63ac02a015e610e99c..ad1413e9062d54e60a8441deb12406ed63e4aa72 100644
--- a/net/mptcp/options.c
+++ b/net/mptcp/options.c
@@ -432,7 +432,6 @@ static void clear_3rdack_retransmission(struct sock *sk)
	struct inet_connection_sock *icsk = inet_csk(sk);

	sk_stop_timer(sk, &icsk->icsk_delack_timer);
-	icsk->icsk_ack.timeout = 0;
	icsk->icsk_ack.ato = 0;
	icsk->icsk_ack.pending &= ~(ICSK_ACK_SCHED | ICSK_ACK_TIMER);
 }
diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
index 1ac378ba1d67cd17449ab6c4b4793b65d520ec44..44f7ab463d7550ad728651bad2b1aeb4cd4dea05 100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -3420,7 +3420,6 @@ static void schedule_3rdack_retransmission(struct sock *ssk)
	WARN_ON_ONCE(icsk->icsk_ack.pending & ICSK_ACK_TIMER);
	smp_store_release(&icsk->icsk_ack.pending,
			  icsk->icsk_ack.pending | ICSK_ACK_SCHED | ICSK_ACK_TIMER);
-	icsk->icsk_ack.timeout = timeout;
	sk_reset_timer(ssk, &icsk->icsk_delack_timer, timeout);
 }

--
2.49.0.rc1.451.g8f38331e32-goog


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 net-next 2/2] tcp/dccp: remove icsk->icsk_ack.timeout
  2025-03-18 15:43 ` [PATCH v2 net-next 2/2] tcp/dccp: remove icsk->icsk_ack.timeout Eric Dumazet
@ 2025-03-20 18:38   ` Simon Horman
  2025-03-20 19:00     ` Eric Dumazet
  2025-03-24 19:38   ` Jakub Kicinski
  1 sibling, 1 reply; 8+ messages in thread
From: Simon Horman @ 2025-03-20 18:38 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: David S. Miller, Jakub Kicinski, Paolo Abeni, Neal Cardwell,
	Kuniyuki Iwashima, netdev, eric.dumazet

On Tue, Mar 18, 2025 at 03:43:59PM +0000, Eric Dumazet wrote:
> icsk->icsk_ack.timeout can be replaced by icsk->csk_delack_timer.expires
> 
> This saves 8 bytes in TCP/DCCP sockets and helps for better cache locality.
> 
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> Reviewed-by: Kuniyuki Iwashima <kuniyu@amazon.com>
> ---
> v2: rebase after "tcp: cache RTAX_QUICKACK metric in a hot cache line"

Hi Eric,

I hate to be a bore, but patch 2/2 does seem to apply to net-next.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 net-next 2/2] tcp/dccp: remove icsk->icsk_ack.timeout
  2025-03-20 18:38   ` Simon Horman
@ 2025-03-20 19:00     ` Eric Dumazet
  2025-03-20 20:10       ` Simon Horman
  0 siblings, 1 reply; 8+ messages in thread
From: Eric Dumazet @ 2025-03-20 19:00 UTC (permalink / raw)
  To: Simon Horman
  Cc: David S. Miller, Jakub Kicinski, Paolo Abeni, Neal Cardwell,
	Kuniyuki Iwashima, netdev, eric.dumazet

On Thu, Mar 20, 2025 at 7:39 PM Simon Horman <horms@kernel.org> wrote:
>
> On Tue, Mar 18, 2025 at 03:43:59PM +0000, Eric Dumazet wrote:
> > icsk->icsk_ack.timeout can be replaced by icsk->csk_delack_timer.expires
> >
> > This saves 8 bytes in TCP/DCCP sockets and helps for better cache locality.
> >
> > Signed-off-by: Eric Dumazet <edumazet@google.com>
> > Reviewed-by: Kuniyuki Iwashima <kuniyu@amazon.com>
> > ---
> > v2: rebase after "tcp: cache RTAX_QUICKACK metric in a hot cache line"
>
> Hi Eric,
>
> I hate to be a bore, but patch 2/2 does seem to apply to net-next.

Hmm, what is the message you have ?

It applies fine here.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 net-next 2/2] tcp/dccp: remove icsk->icsk_ack.timeout
  2025-03-20 19:00     ` Eric Dumazet
@ 2025-03-20 20:10       ` Simon Horman
  0 siblings, 0 replies; 8+ messages in thread
From: Simon Horman @ 2025-03-20 20:10 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: David S. Miller, Jakub Kicinski, Paolo Abeni, Neal Cardwell,
	Kuniyuki Iwashima, netdev, eric.dumazet

On Thu, Mar 20, 2025 at 08:00:29PM +0100, Eric Dumazet wrote:
> On Thu, Mar 20, 2025 at 7:39 PM Simon Horman <horms@kernel.org> wrote:
> >
> > On Tue, Mar 18, 2025 at 03:43:59PM +0000, Eric Dumazet wrote:
> > > icsk->icsk_ack.timeout can be replaced by icsk->csk_delack_timer.expires
> > >
> > > This saves 8 bytes in TCP/DCCP sockets and helps for better cache locality.
> > >
> > > Signed-off-by: Eric Dumazet <edumazet@google.com>
> > > Reviewed-by: Kuniyuki Iwashima <kuniyu@amazon.com>
> > > ---
> > > v2: rebase after "tcp: cache RTAX_QUICKACK metric in a hot cache line"
> >
> > Hi Eric,
> >
> > I hate to be a bore, but patch 2/2 does seem to apply to net-next.
> 
> Hmm, what is the message you have ?
> 
> It applies fine here.

Ok, there must be something weird going on in my environment.

FTR, I see this:

$ git checkout net-next/main
HEAD is now at 6855b9be9cf7 Merge branch 'mptcp-pm-prep-work-for-new-ops-and-sysctl-knobs'

$ b4 mbox 20250318154359.778438-1-edumazet@google.com
Grabbing thread from lore.kernel.org/all/20250318154359.778438-1-edumazet@google.com/t.mbox.gz
5 messages in the thread
Saved ./20250318154359.778438-1-edumazet@google.com.mbx

$ git am ./20250318154359.778438-1-edumazet@google.com.mbx
Applying: tcp/dccp: remove icsk->icsk_ack.timeout
error: corrupt patch at line 31
Patch failed at 0001 tcp/dccp: remove icsk->icsk_ack.timeout
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config advice.mergeConflict false"

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 net-next 2/2] tcp/dccp: remove icsk->icsk_ack.timeout
  2025-03-18 15:43 ` [PATCH v2 net-next 2/2] tcp/dccp: remove icsk->icsk_ack.timeout Eric Dumazet
  2025-03-20 18:38   ` Simon Horman
@ 2025-03-24 19:38   ` Jakub Kicinski
  2025-03-24 19:44     ` Eric Dumazet
  1 sibling, 1 reply; 8+ messages in thread
From: Jakub Kicinski @ 2025-03-24 19:38 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: David S . Miller, Paolo Abeni, Neal Cardwell, Kuniyuki Iwashima,
	Simon Horman, netdev, eric.dumazet

On Tue, 18 Mar 2025 15:43:59 +0000 Eric Dumazet wrote:
> diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h
> index 018118da0ce15c5ba5e3b7fcc1b36425794ec9a1..597f2b98dcf565a8512e815d9eae2b521bac7807 100644
> --- a/include/net/inet_connection_sock.h
> +++ b/include/net/inet_connection_sock.h
> @@ -117,7 +117,6 @@ struct inet_connection_sock {
> 				  lrcv_flowlabel:20, /* last received ipv6 flowlabel	   */
> 				  dst_quick_ack:1, /* cache dst RTAX_QUICKACK		   */
> 				  unused:3;
> -		unsigned long	  timeout;	 /* Currently scheduled timeout		   */
> 		__u32		  lrcvtime;	 /* timestamp of last received data packet */
> 		__u16		  last_seg_size; /* Size of last incoming segment	   */
> 		__u16		  rcv_mss;	 /* MSS used for delayed ACK decisions	   */

I get the same errors as Simon, something ate the leading spaces 
in the patch.
-- 
pw-bot: cr

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 net-next 2/2] tcp/dccp: remove icsk->icsk_ack.timeout
  2025-03-24 19:38   ` Jakub Kicinski
@ 2025-03-24 19:44     ` Eric Dumazet
  0 siblings, 0 replies; 8+ messages in thread
From: Eric Dumazet @ 2025-03-24 19:44 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: David S . Miller, Paolo Abeni, Neal Cardwell, Kuniyuki Iwashima,
	Simon Horman, netdev, eric.dumazet

On Mon, Mar 24, 2025 at 8:38 PM Jakub Kicinski <kuba@kernel.org> wrote:
>
> On Tue, 18 Mar 2025 15:43:59 +0000 Eric Dumazet wrote:
> > diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h
> > index 018118da0ce15c5ba5e3b7fcc1b36425794ec9a1..597f2b98dcf565a8512e815d9eae2b521bac7807 100644
> > --- a/include/net/inet_connection_sock.h
> > +++ b/include/net/inet_connection_sock.h
> > @@ -117,7 +117,6 @@ struct inet_connection_sock {
> >                                 lrcv_flowlabel:20, /* last received ipv6 flowlabel       */
> >                                 dst_quick_ack:1, /* cache dst RTAX_QUICKACK              */
> >                                 unused:3;
> > -             unsigned long     timeout;       /* Currently scheduled timeout            */
> >               __u32             lrcvtime;      /* timestamp of last received data packet */
> >               __u16             last_seg_size; /* Size of last incoming segment          */
> >               __u16             rcv_mss;       /* MSS used for delayed ACK decisions     */
>
> I get the same errors as Simon, something ate the leading spaces
> in the patch.

OK, I will resend.

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2025-03-24 19:45 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-18 15:43 [PATCH v2 net-next 0/2] tcp/dccp: remove 16 bytes from icsk Eric Dumazet
2025-03-18 15:43 ` [PATCH v2 net-next 1/2] tcp/dccp: remove icsk->icsk_timeout Eric Dumazet
2025-03-18 15:43 ` [PATCH v2 net-next 2/2] tcp/dccp: remove icsk->icsk_ack.timeout Eric Dumazet
2025-03-20 18:38   ` Simon Horman
2025-03-20 19:00     ` Eric Dumazet
2025-03-20 20:10       ` Simon Horman
2025-03-24 19:38   ` Jakub Kicinski
2025-03-24 19:44     ` Eric Dumazet

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).