Skip to content

Commit 071ccde

Browse files
committed
Merge branch 'tcp-dccp-remove-16-bytes-from-icsk'
Eric Dumazet says: ==================== tcp/dccp: remove 16 bytes from icsk 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. ==================== Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2 parents 7bd2e6b + f1e3006 commit 071ccde

File tree

13 files changed

+45
-41
lines changed

13 files changed

+45
-41
lines changed

Documentation/networking/net_cachelines/inet_connection_sock.rst

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ struct inet_sock icsk_inet read_mostly r
1212
struct request_sock_queue icsk_accept_queue
1313
struct inet_bind_bucket icsk_bind_hash read_mostly tcp_set_state
1414
struct inet_bind2_bucket icsk_bind2_hash read_mostly tcp_set_state,inet_put_port
15-
unsigned_long icsk_timeout read_mostly inet_csk_reset_xmit_timer,tcp_connect
16-
struct timer_list icsk_retransmit_timer read_mostly inet_csk_reset_xmit_timer,tcp_connect
15+
struct timer_list icsk_retransmit_timer read_write inet_csk_reset_xmit_timer,tcp_connect
1716
struct timer_list icsk_delack_timer read_mostly inet_csk_reset_xmit_timer,tcp_connect
1817
u32 icsk_rto read_write tcp_cwnd_validate,tcp_schedule_loss_probe,tcp_connect_init,tcp_connect,tcp_write_xmit,tcp_push_one
1918
u32 icsk_rto_min
@@ -39,7 +38,6 @@ struct icsk_ack_u8 quick read_write w
3938
struct icsk_ack_u8 pingpong
4039
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,
4140
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
42-
struct icsk_ack_unsigned_long timeout read_write read_write inet_csk_reset_xmit_timer,tcp_connect
4341
struct icsk_ack_u32 lrcvtime read_write tcp_finish_connect,tcp_connect,tcp_event_data_sent,__tcp_transmit_skb
4442
struct icsk_ack_u16 rcv_mss write_mostly read_mostly __tcp_select_window,__tcp_cleanup_rbuf,tcp_initialize_rcv_mss,tcp_connect_init
4543
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: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ struct inet_connection_sock_af_ops {
5656
* @icsk_accept_queue: FIFO of established children
5757
* @icsk_bind_hash: Bind node
5858
* @icsk_bind2_hash: Bind node in the bhash2 table
59-
* @icsk_timeout: Timeout
6059
* @icsk_retransmit_timer: Resend (no ack)
6160
* @icsk_rto: Retransmit timeout
6261
* @icsk_pmtu_cookie Last pmtu seen by socket
@@ -82,7 +81,6 @@ struct inet_connection_sock {
8281
struct request_sock_queue icsk_accept_queue;
8382
struct inet_bind_bucket *icsk_bind_hash;
8483
struct inet_bind2_bucket *icsk_bind2_hash;
85-
unsigned long icsk_timeout;
8684
struct timer_list icsk_retransmit_timer;
8785
struct timer_list icsk_delack_timer;
8886
__u32 icsk_rto;
@@ -115,7 +113,6 @@ struct inet_connection_sock {
115113
lrcv_flowlabel:20, /* last received ipv6 flowlabel */
116114
dst_quick_ack:1, /* cache dst RTAX_QUICKACK */
117115
unused:3;
118-
unsigned long timeout; /* Currently scheduled timeout */
119116
__u32 lrcvtime; /* timestamp of last received data packet */
120117
__u16 last_seg_size; /* Size of last incoming segment */
121118
__u16 rcv_mss; /* MSS used for delayed ACK decisions */
@@ -187,6 +184,18 @@ static inline void inet_csk_delack_init(struct sock *sk)
187184
memset(&inet_csk(sk)->icsk_ack, 0, sizeof(inet_csk(sk)->icsk_ack));
188185
}
189186

187+
static inline unsigned long
188+
icsk_timeout(const struct inet_connection_sock *icsk)
189+
{
190+
return READ_ONCE(icsk->icsk_retransmit_timer.expires);
191+
}
192+
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+
190199
static inline void inet_csk_clear_xmit_timer(struct sock *sk, const int what)
191200
{
192201
struct inet_connection_sock *icsk = inet_csk(sk);
@@ -222,16 +231,15 @@ static inline void inet_csk_reset_xmit_timer(struct sock *sk, const int what,
222231
when = max_when;
223232
}
224233

234+
when += jiffies;
225235
if (what == ICSK_TIME_RETRANS || what == ICSK_TIME_PROBE0 ||
226236
what == ICSK_TIME_LOSS_PROBE || what == ICSK_TIME_REO_TIMEOUT) {
227237
smp_store_release(&icsk->icsk_pending, what);
228-
icsk->icsk_timeout = jiffies + when;
229-
sk_reset_timer(sk, &icsk->icsk_retransmit_timer, icsk->icsk_timeout);
238+
sk_reset_timer(sk, &icsk->icsk_retransmit_timer, when);
230239
} else if (what == ICSK_TIME_DACK) {
231240
smp_store_release(&icsk->icsk_ack.pending,
232241
icsk->icsk_ack.pending | ICSK_ACK_TIMER);
233-
icsk->icsk_ack.timeout = jiffies + when;
234-
sk_reset_timer(sk, &icsk->icsk_delack_timer, icsk->icsk_ack.timeout);
242+
sk_reset_timer(sk, &icsk->icsk_delack_timer, when);
235243
} else {
236244
pr_debug("inet_csk BUG: unknown timer value\n");
237245
}

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: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,9 @@ static void dccp_write_timer(struct timer_list *t)
139139
if (sk->sk_state == DCCP_CLOSED || !icsk->icsk_pending)
140140
goto out;
141141

142-
if (time_after(icsk->icsk_timeout, jiffies)) {
142+
if (time_after(icsk_timeout(icsk), jiffies)) {
143143
sk_reset_timer(sk, &icsk->icsk_retransmit_timer,
144-
icsk->icsk_timeout);
144+
icsk_timeout(icsk));
145145
goto out;
146146
}
147147

@@ -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/inet_diag.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,12 +315,12 @@ int inet_sk_diag_fill(struct sock *sk, struct inet_connection_sock *icsk,
315315
r->idiag_timer = 1;
316316
r->idiag_retrans = icsk->icsk_retransmits;
317317
r->idiag_expires =
318-
jiffies_delta_to_msecs(icsk->icsk_timeout - jiffies);
318+
jiffies_delta_to_msecs(icsk_timeout(icsk) - jiffies);
319319
} else if (icsk_pending == ICSK_TIME_PROBE0) {
320320
r->idiag_timer = 4;
321321
r->idiag_retrans = icsk->icsk_probes_out;
322322
r->idiag_expires =
323-
jiffies_delta_to_msecs(icsk->icsk_timeout - jiffies);
323+
jiffies_delta_to_msecs(icsk_timeout(icsk) - jiffies);
324324
} else if (timer_pending(&sk->sk_timer)) {
325325
r->idiag_timer = 2;
326326
r->idiag_retrans = icsk->icsk_probes_out;

net/ipv4/tcp_ipv4.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2923,10 +2923,10 @@ static void get_tcp4_sock(struct sock *sk, struct seq_file *f, int i)
29232923
icsk_pending == ICSK_TIME_REO_TIMEOUT ||
29242924
icsk_pending == ICSK_TIME_LOSS_PROBE) {
29252925
timer_active = 1;
2926-
timer_expires = icsk->icsk_timeout;
2926+
timer_expires = icsk_timeout(icsk);
29272927
} else if (icsk_pending == ICSK_TIME_PROBE0) {
29282928
timer_active = 4;
2929-
timer_expires = icsk->icsk_timeout;
2929+
timer_expires = icsk_timeout(icsk);
29302930
} else if (timer_pending(&sk->sk_timer)) {
29312931
timer_active = 2;
29322932
timer_expires = sk->sk_timer.expires;

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: 9 additions & 7 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;
@@ -509,7 +510,7 @@ static bool tcp_rtx_probe0_timed_out(const struct sock *sk,
509510
* and tp->rcv_tstamp might very well have been written recently.
510511
* rcv_delta can thus be negative.
511512
*/
512-
rcv_delta = icsk->icsk_timeout - tp->rcv_tstamp;
513+
rcv_delta = icsk_timeout(icsk) - tp->rcv_tstamp;
513514
if (rcv_delta <= timeout)
514515
return false;
515516

@@ -685,7 +686,8 @@ out:;
685686
}
686687

687688
/* Called with bottom-half processing disabled.
688-
Called by tcp_write_timer() */
689+
* Called by tcp_write_timer() and tcp_release_cb().
690+
*/
689691
void tcp_write_timer_handler(struct sock *sk)
690692
{
691693
struct inet_connection_sock *icsk = inet_csk(sk);
@@ -695,11 +697,11 @@ void tcp_write_timer_handler(struct sock *sk)
695697
!icsk->icsk_pending)
696698
return;
697699

698-
if (time_after(icsk->icsk_timeout, jiffies)) {
699-
sk_reset_timer(sk, &icsk->icsk_retransmit_timer, icsk->icsk_timeout);
700+
if (time_after(icsk_timeout(icsk), jiffies)) {
701+
sk_reset_timer(sk, &icsk->icsk_retransmit_timer,
702+
icsk_timeout(icsk));
700703
return;
701704
}
702-
703705
tcp_mstamp_refresh(tcp_sk(sk));
704706
event = icsk->icsk_pending;
705707

net/ipv6/tcp_ipv6.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2195,10 +2195,10 @@ static void get_tcp6_sock(struct seq_file *seq, struct sock *sp, int i)
21952195
icsk_pending == ICSK_TIME_REO_TIMEOUT ||
21962196
icsk_pending == ICSK_TIME_LOSS_PROBE) {
21972197
timer_active = 1;
2198-
timer_expires = icsk->icsk_timeout;
2198+
timer_expires = icsk_timeout(icsk);
21992199
} else if (icsk_pending == ICSK_TIME_PROBE0) {
22002200
timer_active = 4;
2201-
timer_expires = icsk->icsk_timeout;
2201+
timer_expires = icsk_timeout(icsk);
22022202
} else if (timer_pending(&sp->sk_timer)) {
22032203
timer_active = 2;
22042204
timer_expires = sp->sk_timer.expires;

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
}

0 commit comments

Comments
 (0)