Skip to content

Commit

Permalink
net: use skb_queue_empty_lockless() in poll() handlers
Browse files Browse the repository at this point in the history
Many poll() handlers are lockless. Using skb_queue_empty_lockless()
instead of skb_queue_empty() is more appropriate.

Signed-off-by: Eric Dumazet <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Eric Dumazet authored and davem330 committed Oct 28, 2019
1 parent 137a0db commit 3ef7cf5
Show file tree
Hide file tree
Showing 14 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion drivers/isdn/capi/capi.c
Original file line number Diff line number Diff line change
Expand Up @@ -744,7 +744,7 @@ capi_poll(struct file *file, poll_table *wait)

poll_wait(file, &(cdev->recvwait), wait);
mask = EPOLLOUT | EPOLLWRNORM;
if (!skb_queue_empty(&cdev->recvqueue))
if (!skb_queue_empty_lockless(&cdev->recvqueue))
mask |= EPOLLIN | EPOLLRDNORM;
return mask;
}
Expand Down
2 changes: 1 addition & 1 deletion net/atm/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@ __poll_t vcc_poll(struct file *file, struct socket *sock, poll_table *wait)
mask |= EPOLLHUP;

/* readable? */
if (!skb_queue_empty(&sk->sk_receive_queue))
if (!skb_queue_empty_lockless(&sk->sk_receive_queue))
mask |= EPOLLIN | EPOLLRDNORM;

/* writable? */
Expand Down
4 changes: 2 additions & 2 deletions net/bluetooth/af_bluetooth.c
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ __poll_t bt_sock_poll(struct file *file, struct socket *sock,
if (sk->sk_state == BT_LISTEN)
return bt_accept_poll(sk);

if (sk->sk_err || !skb_queue_empty(&sk->sk_error_queue))
if (sk->sk_err || !skb_queue_empty_lockless(&sk->sk_error_queue))
mask |= EPOLLERR |
(sock_flag(sk, SOCK_SELECT_ERR_QUEUE) ? EPOLLPRI : 0);

Expand All @@ -470,7 +470,7 @@ __poll_t bt_sock_poll(struct file *file, struct socket *sock,
if (sk->sk_shutdown == SHUTDOWN_MASK)
mask |= EPOLLHUP;

if (!skb_queue_empty(&sk->sk_receive_queue))
if (!skb_queue_empty_lockless(&sk->sk_receive_queue))
mask |= EPOLLIN | EPOLLRDNORM;

if (sk->sk_state == BT_CLOSED)
Expand Down
2 changes: 1 addition & 1 deletion net/caif/caif_socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -953,7 +953,7 @@ static __poll_t caif_poll(struct file *file,
mask |= EPOLLRDHUP;

/* readable? */
if (!skb_queue_empty(&sk->sk_receive_queue) ||
if (!skb_queue_empty_lockless(&sk->sk_receive_queue) ||
(sk->sk_shutdown & RCV_SHUTDOWN))
mask |= EPOLLIN | EPOLLRDNORM;

Expand Down
4 changes: 2 additions & 2 deletions net/core/datagram.c
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,7 @@ __poll_t datagram_poll(struct file *file, struct socket *sock,
mask = 0;

/* exceptional events? */
if (sk->sk_err || !skb_queue_empty(&sk->sk_error_queue))
if (sk->sk_err || !skb_queue_empty_lockless(&sk->sk_error_queue))
mask |= EPOLLERR |
(sock_flag(sk, SOCK_SELECT_ERR_QUEUE) ? EPOLLPRI : 0);

Expand All @@ -777,7 +777,7 @@ __poll_t datagram_poll(struct file *file, struct socket *sock,
mask |= EPOLLHUP;

/* readable? */
if (!skb_queue_empty(&sk->sk_receive_queue))
if (!skb_queue_empty_lockless(&sk->sk_receive_queue))
mask |= EPOLLIN | EPOLLRDNORM;

/* Connection-based need to check for termination and startup */
Expand Down
2 changes: 1 addition & 1 deletion net/decnet/af_decnet.c
Original file line number Diff line number Diff line change
Expand Up @@ -1205,7 +1205,7 @@ static __poll_t dn_poll(struct file *file, struct socket *sock, poll_table *wai
struct dn_scp *scp = DN_SK(sk);
__poll_t mask = datagram_poll(file, sock, wait);

if (!skb_queue_empty(&scp->other_receive_queue))
if (!skb_queue_empty_lockless(&scp->other_receive_queue))
mask |= EPOLLRDBAND;

return mask;
Expand Down
2 changes: 1 addition & 1 deletion net/ipv4/tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ __poll_t tcp_poll(struct file *file, struct socket *sock, poll_table *wait)
}
/* This barrier is coupled with smp_wmb() in tcp_reset() */
smp_rmb();
if (sk->sk_err || !skb_queue_empty(&sk->sk_error_queue))
if (sk->sk_err || !skb_queue_empty_lockless(&sk->sk_error_queue))
mask |= EPOLLERR;

return mask;
Expand Down
2 changes: 1 addition & 1 deletion net/ipv4/udp.c
Original file line number Diff line number Diff line change
Expand Up @@ -2712,7 +2712,7 @@ __poll_t udp_poll(struct file *file, struct socket *sock, poll_table *wait)
__poll_t mask = datagram_poll(file, sock, wait);
struct sock *sk = sock->sk;

if (!skb_queue_empty(&udp_sk(sk)->reader_queue))
if (!skb_queue_empty_lockless(&udp_sk(sk)->reader_queue))
mask |= EPOLLIN | EPOLLRDNORM;

/* Check for false positives due to checksum errors */
Expand Down
4 changes: 2 additions & 2 deletions net/nfc/llcp_sock.c
Original file line number Diff line number Diff line change
Expand Up @@ -554,11 +554,11 @@ static __poll_t llcp_sock_poll(struct file *file, struct socket *sock,
if (sk->sk_state == LLCP_LISTEN)
return llcp_accept_poll(sk);

if (sk->sk_err || !skb_queue_empty(&sk->sk_error_queue))
if (sk->sk_err || !skb_queue_empty_lockless(&sk->sk_error_queue))
mask |= EPOLLERR |
(sock_flag(sk, SOCK_SELECT_ERR_QUEUE) ? EPOLLPRI : 0);

if (!skb_queue_empty(&sk->sk_receive_queue))
if (!skb_queue_empty_lockless(&sk->sk_receive_queue))
mask |= EPOLLIN | EPOLLRDNORM;

if (sk->sk_state == LLCP_CLOSED)
Expand Down
4 changes: 2 additions & 2 deletions net/phonet/socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -338,9 +338,9 @@ static __poll_t pn_socket_poll(struct file *file, struct socket *sock,

if (sk->sk_state == TCP_CLOSE)
return EPOLLERR;
if (!skb_queue_empty(&sk->sk_receive_queue))
if (!skb_queue_empty_lockless(&sk->sk_receive_queue))
mask |= EPOLLIN | EPOLLRDNORM;
if (!skb_queue_empty(&pn->ctrlreq_queue))
if (!skb_queue_empty_lockless(&pn->ctrlreq_queue))
mask |= EPOLLPRI;
if (!mask && sk->sk_state == TCP_CLOSE_WAIT)
return EPOLLHUP;
Expand Down
4 changes: 2 additions & 2 deletions net/sctp/socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -8476,7 +8476,7 @@ __poll_t sctp_poll(struct file *file, struct socket *sock, poll_table *wait)
mask = 0;

/* Is there any exceptional events? */
if (sk->sk_err || !skb_queue_empty(&sk->sk_error_queue))
if (sk->sk_err || !skb_queue_empty_lockless(&sk->sk_error_queue))
mask |= EPOLLERR |
(sock_flag(sk, SOCK_SELECT_ERR_QUEUE) ? EPOLLPRI : 0);
if (sk->sk_shutdown & RCV_SHUTDOWN)
Expand All @@ -8485,7 +8485,7 @@ __poll_t sctp_poll(struct file *file, struct socket *sock, poll_table *wait)
mask |= EPOLLHUP;

/* Is it readable? Reconsider this code with TCP-style support. */
if (!skb_queue_empty(&sk->sk_receive_queue))
if (!skb_queue_empty_lockless(&sk->sk_receive_queue))
mask |= EPOLLIN | EPOLLRDNORM;

/* The association is either gone or not ready. */
Expand Down
4 changes: 2 additions & 2 deletions net/tipc/socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -740,15 +740,15 @@ static __poll_t tipc_poll(struct file *file, struct socket *sock,
/* fall through */
case TIPC_LISTEN:
case TIPC_CONNECTING:
if (!skb_queue_empty(&sk->sk_receive_queue))
if (!skb_queue_empty_lockless(&sk->sk_receive_queue))
revents |= EPOLLIN | EPOLLRDNORM;
break;
case TIPC_OPEN:
if (tsk->group_is_open && !tsk->cong_link_cnt)
revents |= EPOLLOUT;
if (!tipc_sk_type_connectionless(sk))
break;
if (skb_queue_empty(&sk->sk_receive_queue))
if (skb_queue_empty_lockless(&sk->sk_receive_queue))
break;
revents |= EPOLLIN | EPOLLRDNORM;
break;
Expand Down
6 changes: 3 additions & 3 deletions net/unix/af_unix.c
Original file line number Diff line number Diff line change
Expand Up @@ -2599,7 +2599,7 @@ static __poll_t unix_poll(struct file *file, struct socket *sock, poll_table *wa
mask |= EPOLLRDHUP | EPOLLIN | EPOLLRDNORM;

/* readable? */
if (!skb_queue_empty(&sk->sk_receive_queue))
if (!skb_queue_empty_lockless(&sk->sk_receive_queue))
mask |= EPOLLIN | EPOLLRDNORM;

/* Connection-based need to check for termination and startup */
Expand Down Expand Up @@ -2628,7 +2628,7 @@ static __poll_t unix_dgram_poll(struct file *file, struct socket *sock,
mask = 0;

/* exceptional events? */
if (sk->sk_err || !skb_queue_empty(&sk->sk_error_queue))
if (sk->sk_err || !skb_queue_empty_lockless(&sk->sk_error_queue))
mask |= EPOLLERR |
(sock_flag(sk, SOCK_SELECT_ERR_QUEUE) ? EPOLLPRI : 0);

Expand All @@ -2638,7 +2638,7 @@ static __poll_t unix_dgram_poll(struct file *file, struct socket *sock,
mask |= EPOLLHUP;

/* readable? */
if (!skb_queue_empty(&sk->sk_receive_queue))
if (!skb_queue_empty_lockless(&sk->sk_receive_queue))
mask |= EPOLLIN | EPOLLRDNORM;

/* Connection-based need to check for termination and startup */
Expand Down
2 changes: 1 addition & 1 deletion net/vmw_vsock/af_vsock.c
Original file line number Diff line number Diff line change
Expand Up @@ -870,7 +870,7 @@ static __poll_t vsock_poll(struct file *file, struct socket *sock,
* the queue and write as long as the socket isn't shutdown for
* sending.
*/
if (!skb_queue_empty(&sk->sk_receive_queue) ||
if (!skb_queue_empty_lockless(&sk->sk_receive_queue) ||
(sk->sk_shutdown & RCV_SHUTDOWN)) {
mask |= EPOLLIN | EPOLLRDNORM;
}
Expand Down

0 comments on commit 3ef7cf5

Please sign in to comment.