Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3f926af3 authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller
Browse files

net: use skb_queue_empty_lockless() in busy poll contexts



Busy polling usually runs without locks.
Let's use skb_queue_empty_lockless() instead of skb_queue_empty()

Also uses READ_ONCE() in __skb_try_recv_datagram() to address
a similar potential problem.

Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 3ef7cf57
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1702,7 +1702,7 @@ int chtls_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
		return peekmsg(sk, msg, len, nonblock, flags);

	if (sk_can_busy_loop(sk) &&
	    skb_queue_empty(&sk->sk_receive_queue) &&
	    skb_queue_empty_lockless(&sk->sk_receive_queue) &&
	    sk->sk_state == TCP_ESTABLISHED)
		sk_busy_loop(sk, nonblock);

+1 −1
Original line number Diff line number Diff line
@@ -2219,7 +2219,7 @@ static int nvme_tcp_poll(struct blk_mq_hw_ctx *hctx)
	struct nvme_tcp_queue *queue = hctx->driver_data;
	struct sock *sk = queue->sock->sk;

	if (sk_can_busy_loop(sk) && skb_queue_empty(&sk->sk_receive_queue))
	if (sk_can_busy_loop(sk) && skb_queue_empty_lockless(&sk->sk_receive_queue))
		sk_busy_loop(sk, true);
	nvme_tcp_try_recv(queue);
	return queue->nr_cqe;
+1 −1
Original line number Diff line number Diff line
@@ -278,7 +278,7 @@ struct sk_buff *__skb_try_recv_datagram(struct sock *sk, unsigned int flags,
			break;

		sk_busy_loop(sk, flags & MSG_DONTWAIT);
	} while (sk->sk_receive_queue.prev != *last);
	} while (READ_ONCE(sk->sk_receive_queue.prev) != *last);

	error = -EAGAIN;

+1 −1
Original line number Diff line number Diff line
@@ -3600,7 +3600,7 @@ bool sk_busy_loop_end(void *p, unsigned long start_time)
{
	struct sock *sk = p;

	return !skb_queue_empty(&sk->sk_receive_queue) ||
	return !skb_queue_empty_lockless(&sk->sk_receive_queue) ||
	       sk_busy_loop_timeout(sk, start_time);
}
EXPORT_SYMBOL(sk_busy_loop_end);
+1 −1
Original line number Diff line number Diff line
@@ -1964,7 +1964,7 @@ int tcp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, int nonblock,
	if (unlikely(flags & MSG_ERRQUEUE))
		return inet_recv_error(sk, msg, len, addr_len);

	if (sk_can_busy_loop(sk) && skb_queue_empty(&sk->sk_receive_queue) &&
	if (sk_can_busy_loop(sk) && skb_queue_empty_lockless(&sk->sk_receive_queue) &&
	    (sk->sk_state == TCP_ESTABLISHED))
		sk_busy_loop(sk, nonblock);

Loading