Skip to content

Commit 1937a0b

Browse files
edumazetkuba-moo
authored andcommitted
tcp: move icsk_clean_acked to a better location
As a followup of my presentation in Zagreb for netdev 0x19: icsk_clean_acked is only used by TCP when/if CONFIG_TLS_DEVICE is enabled from tcp_ack(). Rename it to tcp_clean_acked, move it to tcp_sock structure in the tcp_sock_read_rx for better cache locality in TCP fast path. Define this field only when CONFIG_TLS_DEVICE is enabled saving 8 bytes on configs not using it. Signed-off-by: Eric Dumazet <[email protected]> Reviewed-by: Neal Cardwell <[email protected]> Reviewed-by: Sabrina Dubroca <[email protected]> Reviewed-by: Kuniyuki Iwashima <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 8fa649f commit 1937a0b

File tree

7 files changed

+21
-14
lines changed

7 files changed

+21
-14
lines changed

Documentation/networking/net_cachelines/tcp_sock.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ u32 dsack_dups
2727
u32 snd_una read_mostly read_write tcp_wnd_end,tcp_urg_mode,tcp_minshall_check,tcp_cwnd_validate(tx);tcp_ack,tcp_may_update_window,tcp_clean_rtx_queue(write),tcp_ack_tstamp(rx)
2828
u32 snd_sml read_write tcp_minshall_check,tcp_minshall_update
2929
u32 rcv_tstamp read_mostly tcp_ack
30+
void * tcp_clean_acked read_mostly tcp_ack
3031
u32 lsndtime read_write tcp_slow_start_after_idle_check,tcp_event_data_sent
3132
u32 last_oow_ack_time
3233
u32 compressed_ack_rcv_nxt

include/linux/tcp.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,9 @@ struct tcp_sock {
244244
struct minmax rtt_min;
245245
/* OOO segments go in this rbtree. Socket lock must be held. */
246246
struct rb_root out_of_order_queue;
247+
#if defined(CONFIG_TLS_DEVICE)
248+
void (*tcp_clean_acked)(struct sock *sk, u32 acked_seq);
249+
#endif
247250
u32 snd_ssthresh; /* Slow start size threshold */
248251
u8 recvmsg_inq : 1;/* Indicate # of bytes in queue upon recvmsg */
249252
__cacheline_group_end(tcp_sock_read_rx);

include/net/inet_connection_sock.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ struct inet_connection_sock_af_ops {
6666
* @icsk_af_ops Operations which are AF_INET{4,6} specific
6767
* @icsk_ulp_ops Pluggable ULP control hook
6868
* @icsk_ulp_data ULP private data
69-
* @icsk_clean_acked Clean acked data hook
7069
* @icsk_ca_state: Congestion control state
7170
* @icsk_retransmits: Number of unrecovered [RTO] timeouts
7271
* @icsk_pending: Scheduled timer event
@@ -97,7 +96,6 @@ struct inet_connection_sock {
9796
const struct inet_connection_sock_af_ops *icsk_af_ops;
9897
const struct tcp_ulp_ops *icsk_ulp_ops;
9998
void __rcu *icsk_ulp_data;
100-
void (*icsk_clean_acked)(struct sock *sk, u32 acked_seq);
10199
unsigned int (*icsk_sync_mss)(struct sock *sk, u32 pmtu);
102100
__u8 icsk_ca_state:5,
103101
icsk_ca_initialized:1,

include/net/tcp.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2815,9 +2815,9 @@ extern struct static_key_false tcp_have_smc;
28152815
#endif
28162816

28172817
#if IS_ENABLED(CONFIG_TLS_DEVICE)
2818-
void clean_acked_data_enable(struct inet_connection_sock *icsk,
2818+
void clean_acked_data_enable(struct tcp_sock *tp,
28192819
void (*cad)(struct sock *sk, u32 ack_seq));
2820-
void clean_acked_data_disable(struct inet_connection_sock *icsk);
2820+
void clean_acked_data_disable(struct tcp_sock *tp);
28212821
void clean_acked_data_flush(void);
28222822
#endif
28232823

net/ipv4/tcp.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5026,7 +5026,12 @@ static void __init tcp_struct_check(void)
50265026
CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_read_rx, rtt_min);
50275027
CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_read_rx, out_of_order_queue);
50285028
CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_read_rx, snd_ssthresh);
5029+
#if IS_ENABLED(CONFIG_TLS_DEVICE)
5030+
CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_read_rx, tcp_clean_acked);
5031+
CACHELINE_ASSERT_GROUP_SIZE(struct tcp_sock, tcp_sock_read_rx, 77);
5032+
#else
50295033
CACHELINE_ASSERT_GROUP_SIZE(struct tcp_sock, tcp_sock_read_rx, 69);
5034+
#endif
50305035

50315036
/* TX read-write hotpath cache lines */
50325037
CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_write_tx, segs_out);

net/ipv4/tcp_input.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,18 +119,18 @@ int sysctl_tcp_max_orphans __read_mostly = NR_FILE;
119119
#if IS_ENABLED(CONFIG_TLS_DEVICE)
120120
static DEFINE_STATIC_KEY_DEFERRED_FALSE(clean_acked_data_enabled, HZ);
121121

122-
void clean_acked_data_enable(struct inet_connection_sock *icsk,
122+
void clean_acked_data_enable(struct tcp_sock *tp,
123123
void (*cad)(struct sock *sk, u32 ack_seq))
124124
{
125-
icsk->icsk_clean_acked = cad;
125+
tp->tcp_clean_acked = cad;
126126
static_branch_deferred_inc(&clean_acked_data_enabled);
127127
}
128128
EXPORT_SYMBOL_GPL(clean_acked_data_enable);
129129

130-
void clean_acked_data_disable(struct inet_connection_sock *icsk)
130+
void clean_acked_data_disable(struct tcp_sock *tp)
131131
{
132132
static_branch_slow_dec_deferred(&clean_acked_data_enabled);
133-
icsk->icsk_clean_acked = NULL;
133+
tp->tcp_clean_acked = NULL;
134134
}
135135
EXPORT_SYMBOL_GPL(clean_acked_data_disable);
136136

@@ -3987,8 +3987,8 @@ static int tcp_ack(struct sock *sk, const struct sk_buff *skb, int flag)
39873987

39883988
#if IS_ENABLED(CONFIG_TLS_DEVICE)
39893989
if (static_branch_unlikely(&clean_acked_data_enabled.key))
3990-
if (icsk->icsk_clean_acked)
3991-
icsk->icsk_clean_acked(sk, ack);
3990+
if (tp->tcp_clean_acked)
3991+
tp->tcp_clean_acked(sk, ack);
39923992
#endif
39933993
}
39943994

net/tls/tls_device.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ static void delete_all_records(struct tls_offload_context_tx *offload_ctx)
157157
offload_ctx->retransmit_hint = NULL;
158158
}
159159

160-
static void tls_icsk_clean_acked(struct sock *sk, u32 acked_seq)
160+
static void tls_tcp_clean_acked(struct sock *sk, u32 acked_seq)
161161
{
162162
struct tls_context *tls_ctx = tls_get_ctx(sk);
163163
struct tls_record_info *info, *temp;
@@ -204,7 +204,7 @@ void tls_device_sk_destruct(struct sock *sk)
204204
destroy_record(ctx->open_record);
205205
delete_all_records(ctx);
206206
crypto_free_aead(ctx->aead_send);
207-
clean_acked_data_disable(inet_csk(sk));
207+
clean_acked_data_disable(tcp_sk(sk));
208208
}
209209

210210
tls_device_queue_ctx_destruction(tls_ctx);
@@ -1126,7 +1126,7 @@ int tls_set_device_offload(struct sock *sk)
11261126
start_marker_record->num_frags = 0;
11271127
list_add_tail(&start_marker_record->list, &offload_ctx->records_list);
11281128

1129-
clean_acked_data_enable(inet_csk(sk), &tls_icsk_clean_acked);
1129+
clean_acked_data_enable(tcp_sk(sk), &tls_tcp_clean_acked);
11301130
ctx->push_pending_record = tls_device_push_pending_record;
11311131

11321132
/* TLS offload is greatly simplified if we don't send
@@ -1172,7 +1172,7 @@ int tls_set_device_offload(struct sock *sk)
11721172

11731173
release_lock:
11741174
up_read(&device_offload_lock);
1175-
clean_acked_data_disable(inet_csk(sk));
1175+
clean_acked_data_disable(tcp_sk(sk));
11761176
crypto_free_aead(offload_ctx->aead_send);
11771177
free_offload_ctx:
11781178
kfree(offload_ctx);

0 commit comments

Comments
 (0)