Skip to content

Commit 494bc1d

Browse files
Jakub Kicinskidavem330
Jakub Kicinski
authored andcommitted
net/tcp: use deferred jump label for TCP acked data hook
User space can flip the clean_acked_data_enabled static branch on and off with TLS offload when CONFIG_TLS_DEVICE is enabled. jump_label.h suggests we use the delayed version in this case. Deferred branches now also don't take the branch mutex on decrement, so we avoid potential locking issues. Signed-off-by: Jakub Kicinski <[email protected]> Reviewed-by: Simon Horman <[email protected]> Reviewed-by: Eric Dumazet <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 70610c9 commit 494bc1d

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

include/net/tcp.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2198,7 +2198,7 @@ extern struct static_key_false tcp_have_smc;
21982198
void clean_acked_data_enable(struct inet_connection_sock *icsk,
21992199
void (*cad)(struct sock *sk, u32 ack_seq));
22002200
void clean_acked_data_disable(struct inet_connection_sock *icsk);
2201-
2201+
void clean_acked_data_flush(void);
22022202
#endif
22032203

22042204
#endif /* _TCP_H */

net/ipv4/tcp_input.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
#include <asm/unaligned.h>
7878
#include <linux/errqueue.h>
7979
#include <trace/events/tcp.h>
80-
#include <linux/static_key.h>
80+
#include <linux/jump_label_ratelimit.h>
8181
#include <net/busy_poll.h>
8282

8383
int sysctl_tcp_max_orphans __read_mostly = NR_FILE;
@@ -113,22 +113,28 @@ int sysctl_tcp_max_orphans __read_mostly = NR_FILE;
113113
#define REXMIT_NEW 2 /* FRTO-style transmit of unsent/new packets */
114114

115115
#if IS_ENABLED(CONFIG_TLS_DEVICE)
116-
static DEFINE_STATIC_KEY_FALSE(clean_acked_data_enabled);
116+
static DEFINE_STATIC_KEY_DEFERRED_FALSE(clean_acked_data_enabled, HZ);
117117

118118
void clean_acked_data_enable(struct inet_connection_sock *icsk,
119119
void (*cad)(struct sock *sk, u32 ack_seq))
120120
{
121121
icsk->icsk_clean_acked = cad;
122-
static_branch_inc(&clean_acked_data_enabled);
122+
static_branch_inc(&clean_acked_data_enabled.key);
123123
}
124124
EXPORT_SYMBOL_GPL(clean_acked_data_enable);
125125

126126
void clean_acked_data_disable(struct inet_connection_sock *icsk)
127127
{
128-
static_branch_dec(&clean_acked_data_enabled);
128+
static_branch_slow_dec_deferred(&clean_acked_data_enabled);
129129
icsk->icsk_clean_acked = NULL;
130130
}
131131
EXPORT_SYMBOL_GPL(clean_acked_data_disable);
132+
133+
void clean_acked_data_flush(void)
134+
{
135+
static_key_deferred_flush(&clean_acked_data_enabled);
136+
}
137+
EXPORT_SYMBOL_GPL(clean_acked_data_flush);
132138
#endif
133139

134140
static void tcp_gro_dev_warn(struct sock *sk, const struct sk_buff *skb,
@@ -3598,7 +3604,7 @@ static int tcp_ack(struct sock *sk, const struct sk_buff *skb, int flag)
35983604
icsk->icsk_retransmits = 0;
35993605

36003606
#if IS_ENABLED(CONFIG_TLS_DEVICE)
3601-
if (static_branch_unlikely(&clean_acked_data_enabled))
3607+
if (static_branch_unlikely(&clean_acked_data_enabled.key))
36023608
if (icsk->icsk_clean_acked)
36033609
icsk->icsk_clean_acked(sk, ack);
36043610
#endif

net/tls/tls_device.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1036,4 +1036,5 @@ void __exit tls_device_cleanup(void)
10361036
{
10371037
unregister_netdevice_notifier(&tls_dev_notifier);
10381038
flush_work(&tls_device_gc_work);
1039+
clean_acked_data_flush();
10391040
}

0 commit comments

Comments
 (0)