Skip to content

Commit f1e3006

Browse files
edumazetkuba-moo
authored andcommitted
tcp/dccp: remove icsk->icsk_ack.timeout
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 <[email protected]> Reviewed-by: Kuniyuki Iwashima <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent a7c428e commit f1e3006

File tree

8 files changed

+18
-18
lines changed

8 files changed

+18
-18
lines changed

Documentation/networking/net_cachelines/inet_connection_sock.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ struct icsk_ack_u8 quick read_write w
3838
struct icsk_ack_u8 pingpong
3939
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,
4040
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
41-
struct icsk_ack_unsigned_long timeout read_write read_write inet_csk_reset_xmit_timer,tcp_connect
4241
struct icsk_ack_u32 lrcvtime read_write tcp_finish_connect,tcp_connect,tcp_event_data_sent,__tcp_transmit_skb
4342
struct icsk_ack_u16 rcv_mss write_mostly read_mostly __tcp_select_window,__tcp_cleanup_rbuf,tcp_initialize_rcv_mss,tcp_connect_init
4443
struct icsk_mtup_int search_high read_write tcp_mtup_init,tcp_sync_mss,tcp_connect_init,tcp_mtu_check_reprobe,tcp_write_xmit

include/net/inet_connection_sock.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@ struct inet_connection_sock {
113113
lrcv_flowlabel:20, /* last received ipv6 flowlabel */
114114
dst_quick_ack:1, /* cache dst RTAX_QUICKACK */
115115
unused:3;
116-
unsigned long timeout; /* Currently scheduled timeout */
117116
__u32 lrcvtime; /* timestamp of last received data packet */
118117
__u16 last_seg_size; /* Size of last incoming segment */
119118
__u16 rcv_mss; /* MSS used for delayed ACK decisions */
@@ -191,6 +190,12 @@ icsk_timeout(const struct inet_connection_sock *icsk)
191190
return READ_ONCE(icsk->icsk_retransmit_timer.expires);
192191
}
193192

193+
static inline unsigned long
194+
icsk_delack_timeout(const struct inet_connection_sock *icsk)
195+
{
196+
return READ_ONCE(icsk->icsk_delack_timer.expires);
197+
}
198+
194199
static inline void inet_csk_clear_xmit_timer(struct sock *sk, const int what)
195200
{
196201
struct inet_connection_sock *icsk = inet_csk(sk);
@@ -226,16 +231,15 @@ static inline void inet_csk_reset_xmit_timer(struct sock *sk, const int what,
226231
when = max_when;
227232
}
228233

234+
when += jiffies;
229235
if (what == ICSK_TIME_RETRANS || what == ICSK_TIME_PROBE0 ||
230236
what == ICSK_TIME_LOSS_PROBE || what == ICSK_TIME_REO_TIMEOUT) {
231237
smp_store_release(&icsk->icsk_pending, what);
232-
when += jiffies;
233238
sk_reset_timer(sk, &icsk->icsk_retransmit_timer, when);
234239
} else if (what == ICSK_TIME_DACK) {
235240
smp_store_release(&icsk->icsk_ack.pending,
236241
icsk->icsk_ack.pending | ICSK_ACK_TIMER);
237-
icsk->icsk_ack.timeout = jiffies + when;
238-
sk_reset_timer(sk, &icsk->icsk_delack_timer, icsk->icsk_ack.timeout);
242+
sk_reset_timer(sk, &icsk->icsk_delack_timer, when);
239243
} else {
240244
pr_debug("inet_csk BUG: unknown timer value\n");
241245
}

net/dccp/output.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -627,11 +627,10 @@ void dccp_send_delayed_ack(struct sock *sk)
627627
return;
628628
}
629629

630-
if (!time_before(timeout, icsk->icsk_ack.timeout))
631-
timeout = icsk->icsk_ack.timeout;
630+
if (!time_before(timeout, icsk_delack_timeout(icsk)))
631+
timeout = icsk_delack_timeout(icsk);
632632
}
633633
icsk->icsk_ack.pending |= ICSK_ACK_SCHED | ICSK_ACK_TIMER;
634-
icsk->icsk_ack.timeout = timeout;
635634
sk_reset_timer(sk, &icsk->icsk_delack_timer, timeout);
636635
}
637636
#endif

net/dccp/timer.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,9 @@ static void dccp_delack_timer(struct timer_list *t)
185185
if (sk->sk_state == DCCP_CLOSED ||
186186
!(icsk->icsk_ack.pending & ICSK_ACK_TIMER))
187187
goto out;
188-
if (time_after(icsk->icsk_ack.timeout, jiffies)) {
188+
if (time_after(icsk_delack_timeout(icsk), jiffies)) {
189189
sk_reset_timer(sk, &icsk->icsk_delack_timer,
190-
icsk->icsk_ack.timeout);
190+
icsk_delack_timeout(icsk));
191191
goto out;
192192
}
193193

net/ipv4/tcp_output.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4225,17 +4225,16 @@ void tcp_send_delayed_ack(struct sock *sk)
42254225
/* Use new timeout only if there wasn't a older one earlier. */
42264226
if (icsk->icsk_ack.pending & ICSK_ACK_TIMER) {
42274227
/* If delack timer is about to expire, send ACK now. */
4228-
if (time_before_eq(icsk->icsk_ack.timeout, jiffies + (ato >> 2))) {
4228+
if (time_before_eq(icsk_delack_timeout(icsk), jiffies + (ato >> 2))) {
42294229
tcp_send_ack(sk);
42304230
return;
42314231
}
42324232

4233-
if (!time_before(timeout, icsk->icsk_ack.timeout))
4234-
timeout = icsk->icsk_ack.timeout;
4233+
if (!time_before(timeout, icsk_delack_timeout(icsk)))
4234+
timeout = icsk_delack_timeout(icsk);
42354235
}
42364236
smp_store_release(&icsk->icsk_ack.pending,
42374237
icsk->icsk_ack.pending | ICSK_ACK_SCHED | ICSK_ACK_TIMER);
4238-
icsk->icsk_ack.timeout = timeout;
42394238
sk_reset_timer(sk, &icsk->icsk_delack_timer, timeout);
42404239
}
42414240

net/ipv4/tcp_timer.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,8 +322,9 @@ void tcp_delack_timer_handler(struct sock *sk)
322322
if (!(icsk->icsk_ack.pending & ICSK_ACK_TIMER))
323323
return;
324324

325-
if (time_after(icsk->icsk_ack.timeout, jiffies)) {
326-
sk_reset_timer(sk, &icsk->icsk_delack_timer, icsk->icsk_ack.timeout);
325+
if (time_after(icsk_delack_timeout(icsk), jiffies)) {
326+
sk_reset_timer(sk, &icsk->icsk_delack_timer,
327+
icsk_delack_timeout(icsk));
327328
return;
328329
}
329330
icsk->icsk_ack.pending &= ~ICSK_ACK_TIMER;

net/mptcp/options.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,6 @@ static void clear_3rdack_retransmission(struct sock *sk)
432432
struct inet_connection_sock *icsk = inet_csk(sk);
433433

434434
sk_stop_timer(sk, &icsk->icsk_delack_timer);
435-
icsk->icsk_ack.timeout = 0;
436435
icsk->icsk_ack.ato = 0;
437436
icsk->icsk_ack.pending &= ~(ICSK_ACK_SCHED | ICSK_ACK_TIMER);
438437
}

net/mptcp/protocol.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3420,7 +3420,6 @@ static void schedule_3rdack_retransmission(struct sock *ssk)
34203420
WARN_ON_ONCE(icsk->icsk_ack.pending & ICSK_ACK_TIMER);
34213421
smp_store_release(&icsk->icsk_ack.pending,
34223422
icsk->icsk_ack.pending | ICSK_ACK_SCHED | ICSK_ACK_TIMER);
3423-
icsk->icsk_ack.timeout = timeout;
34243423
sk_reset_timer(ssk, &icsk->icsk_delack_timer, timeout);
34253424
}
34263425

0 commit comments

Comments
 (0)