diff options
author | Jakub Kicinski <jakub.kicinski@netronome.com> | 2019-05-08 19:46:14 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2019-05-09 14:13:57 -0400 |
commit | 494bc1d281b5a9f02a81249fa566d8c7e390c50c (patch) | |
tree | 2633fb42d8ca311f6fa75b4c60b90f7e3514ed68 /net/ipv4/tcp_input.c | |
parent | 70610c922bae2f3f974eef955ef254defb7755ce (diff) |
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 <jakub.kicinski@netronome.com>
Reviewed-by: Simon Horman <simon.horman@netronome.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/tcp_input.c')
-rw-r--r-- | net/ipv4/tcp_input.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index 077d9abdfcf5..20f6fac5882e 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c | |||
@@ -77,7 +77,7 @@ | |||
77 | #include <asm/unaligned.h> | 77 | #include <asm/unaligned.h> |
78 | #include <linux/errqueue.h> | 78 | #include <linux/errqueue.h> |
79 | #include <trace/events/tcp.h> | 79 | #include <trace/events/tcp.h> |
80 | #include <linux/static_key.h> | 80 | #include <linux/jump_label_ratelimit.h> |
81 | #include <net/busy_poll.h> | 81 | #include <net/busy_poll.h> |
82 | 82 | ||
83 | int sysctl_tcp_max_orphans __read_mostly = NR_FILE; | 83 | int sysctl_tcp_max_orphans __read_mostly = NR_FILE; |
@@ -113,22 +113,28 @@ int sysctl_tcp_max_orphans __read_mostly = NR_FILE; | |||
113 | #define REXMIT_NEW 2 /* FRTO-style transmit of unsent/new packets */ | 113 | #define REXMIT_NEW 2 /* FRTO-style transmit of unsent/new packets */ |
114 | 114 | ||
115 | #if IS_ENABLED(CONFIG_TLS_DEVICE) | 115 | #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); |
117 | 117 | ||
118 | void clean_acked_data_enable(struct inet_connection_sock *icsk, | 118 | void clean_acked_data_enable(struct inet_connection_sock *icsk, |
119 | void (*cad)(struct sock *sk, u32 ack_seq)) | 119 | void (*cad)(struct sock *sk, u32 ack_seq)) |
120 | { | 120 | { |
121 | icsk->icsk_clean_acked = cad; | 121 | icsk->icsk_clean_acked = cad; |
122 | static_branch_inc(&clean_acked_data_enabled); | 122 | static_branch_inc(&clean_acked_data_enabled.key); |
123 | } | 123 | } |
124 | EXPORT_SYMBOL_GPL(clean_acked_data_enable); | 124 | EXPORT_SYMBOL_GPL(clean_acked_data_enable); |
125 | 125 | ||
126 | void clean_acked_data_disable(struct inet_connection_sock *icsk) | 126 | void clean_acked_data_disable(struct inet_connection_sock *icsk) |
127 | { | 127 | { |
128 | static_branch_dec(&clean_acked_data_enabled); | 128 | static_branch_slow_dec_deferred(&clean_acked_data_enabled); |
129 | icsk->icsk_clean_acked = NULL; | 129 | icsk->icsk_clean_acked = NULL; |
130 | } | 130 | } |
131 | EXPORT_SYMBOL_GPL(clean_acked_data_disable); | 131 | 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); | ||
132 | #endif | 138 | #endif |
133 | 139 | ||
134 | static void tcp_gro_dev_warn(struct sock *sk, const struct sk_buff *skb, | 140 | 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) | |||
3598 | icsk->icsk_retransmits = 0; | 3604 | icsk->icsk_retransmits = 0; |
3599 | 3605 | ||
3600 | #if IS_ENABLED(CONFIG_TLS_DEVICE) | 3606 | #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)) |
3602 | if (icsk->icsk_clean_acked) | 3608 | if (icsk->icsk_clean_acked) |
3603 | icsk->icsk_clean_acked(sk, ack); | 3609 | icsk->icsk_clean_acked(sk, ack); |
3604 | #endif | 3610 | #endif |