Skip to content

Commit 57fc4f4

Browse files
Eric DumazetNipaLocal
authored andcommitted
tcp: tcp_gro_dev_warn() cleanup
Use DO_ONCE_LITE_IF() and __cold attribute to put tcp_gro_dev_warn() out of line. This also allows the message to be printed again after a "echo 1 > /sys/kernel/debug/clear_warn_once" Also add a READ_ONCE() when reading device mtu, as it could be changed concurrently. Signed-off-by: Eric Dumazet <edumazet@google.com> Signed-off-by: NipaLocal <nipa@local>
1 parent 826d032 commit 57fc4f4

File tree

1 file changed

+10
-17
lines changed

1 file changed

+10
-17
lines changed

net/ipv4/tcp_input.c

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -202,23 +202,17 @@ static void bpf_skops_established(struct sock *sk, int bpf_op,
202202
}
203203
#endif
204204

205-
static void tcp_gro_dev_warn(struct sock *sk, const struct sk_buff *skb,
205+
static __cold void tcp_gro_dev_warn(const struct sock *sk, const struct sk_buff *skb,
206206
unsigned int len)
207207
{
208-
static bool __once __read_mostly;
208+
struct net_device *dev;
209209

210-
if (!__once) {
211-
struct net_device *dev;
212-
213-
__once = true;
214-
215-
rcu_read_lock();
216-
dev = dev_get_by_index_rcu(sock_net(sk), skb->skb_iif);
217-
if (!dev || len >= dev->mtu)
218-
pr_warn("%s: Driver has suspect GRO implementation, TCP performance may be compromised.\n",
219-
dev ? dev->name : "Unknown driver");
220-
rcu_read_unlock();
221-
}
210+
rcu_read_lock();
211+
dev = dev_get_by_index_rcu(sock_net(sk), skb->skb_iif);
212+
if (!dev || len >= READ_ONCE(dev->mtu))
213+
pr_warn("%s: Driver has suspect GRO implementation, TCP performance may be compromised.\n",
214+
dev ? dev->name : "Unknown driver");
215+
rcu_read_unlock();
222216
}
223217

224218
/* Adapt the MSS value used to make delayed ack decision to the
@@ -250,9 +244,8 @@ static void tcp_measure_rcv_mss(struct sock *sk, const struct sk_buff *skb)
250244
icsk->icsk_ack.rcv_mss = min_t(unsigned int, len,
251245
tcp_sk(sk)->advmss);
252246
/* Account for possibly-removed options */
253-
if (unlikely(len > icsk->icsk_ack.rcv_mss +
254-
MAX_TCP_OPTION_SPACE))
255-
tcp_gro_dev_warn(sk, skb, len);
247+
DO_ONCE_LITE_IF(len > icsk->icsk_ack.rcv_mss + MAX_TCP_OPTION_SPACE,
248+
tcp_gro_dev_warn, sk, skb, len);
256249
/* If the skb has a len of exactly 1*MSS and has the PSH bit
257250
* set then it is likely the end of an application write. So
258251
* more data may not be arriving soon, and yet the data sender

0 commit comments

Comments
 (0)