Commit 3ef7cf57 authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller

net: use skb_queue_empty_lockless() in poll() handlers

Many poll() handlers are lockless. Using skb_queue_empty_lockless()
instead of skb_queue_empty() is more appropriate.
Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 137a0dbe
...@@ -744,7 +744,7 @@ capi_poll(struct file *file, poll_table *wait) ...@@ -744,7 +744,7 @@ capi_poll(struct file *file, poll_table *wait)
poll_wait(file, &(cdev->recvwait), wait); poll_wait(file, &(cdev->recvwait), wait);
mask = EPOLLOUT | EPOLLWRNORM; mask = EPOLLOUT | EPOLLWRNORM;
if (!skb_queue_empty(&cdev->recvqueue)) if (!skb_queue_empty_lockless(&cdev->recvqueue))
mask |= EPOLLIN | EPOLLRDNORM; mask |= EPOLLIN | EPOLLRDNORM;
return mask; return mask;
} }
......
...@@ -668,7 +668,7 @@ __poll_t vcc_poll(struct file *file, struct socket *sock, poll_table *wait) ...@@ -668,7 +668,7 @@ __poll_t vcc_poll(struct file *file, struct socket *sock, poll_table *wait)
mask |= EPOLLHUP; mask |= EPOLLHUP;
/* readable? */ /* readable? */
if (!skb_queue_empty(&sk->sk_receive_queue)) if (!skb_queue_empty_lockless(&sk->sk_receive_queue))
mask |= EPOLLIN | EPOLLRDNORM; mask |= EPOLLIN | EPOLLRDNORM;
/* writable? */ /* writable? */
......
...@@ -460,7 +460,7 @@ __poll_t bt_sock_poll(struct file *file, struct socket *sock, ...@@ -460,7 +460,7 @@ __poll_t bt_sock_poll(struct file *file, struct socket *sock,
if (sk->sk_state == BT_LISTEN) if (sk->sk_state == BT_LISTEN)
return bt_accept_poll(sk); 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 | mask |= EPOLLERR |
(sock_flag(sk, SOCK_SELECT_ERR_QUEUE) ? EPOLLPRI : 0); (sock_flag(sk, SOCK_SELECT_ERR_QUEUE) ? EPOLLPRI : 0);
...@@ -470,7 +470,7 @@ __poll_t bt_sock_poll(struct file *file, struct socket *sock, ...@@ -470,7 +470,7 @@ __poll_t bt_sock_poll(struct file *file, struct socket *sock,
if (sk->sk_shutdown == SHUTDOWN_MASK) if (sk->sk_shutdown == SHUTDOWN_MASK)
mask |= EPOLLHUP; mask |= EPOLLHUP;
if (!skb_queue_empty(&sk->sk_receive_queue)) if (!skb_queue_empty_lockless(&sk->sk_receive_queue))
mask |= EPOLLIN | EPOLLRDNORM; mask |= EPOLLIN | EPOLLRDNORM;
if (sk->sk_state == BT_CLOSED) if (sk->sk_state == BT_CLOSED)
......
...@@ -953,7 +953,7 @@ static __poll_t caif_poll(struct file *file, ...@@ -953,7 +953,7 @@ static __poll_t caif_poll(struct file *file,
mask |= EPOLLRDHUP; mask |= EPOLLRDHUP;
/* readable? */ /* readable? */
if (!skb_queue_empty(&sk->sk_receive_queue) || if (!skb_queue_empty_lockless(&sk->sk_receive_queue) ||
(sk->sk_shutdown & RCV_SHUTDOWN)) (sk->sk_shutdown & RCV_SHUTDOWN))
mask |= EPOLLIN | EPOLLRDNORM; mask |= EPOLLIN | EPOLLRDNORM;
......
...@@ -767,7 +767,7 @@ __poll_t datagram_poll(struct file *file, struct socket *sock, ...@@ -767,7 +767,7 @@ __poll_t datagram_poll(struct file *file, struct socket *sock,
mask = 0; mask = 0;
/* exceptional events? */ /* 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 | mask |= EPOLLERR |
(sock_flag(sk, SOCK_SELECT_ERR_QUEUE) ? EPOLLPRI : 0); (sock_flag(sk, SOCK_SELECT_ERR_QUEUE) ? EPOLLPRI : 0);
...@@ -777,7 +777,7 @@ __poll_t datagram_poll(struct file *file, struct socket *sock, ...@@ -777,7 +777,7 @@ __poll_t datagram_poll(struct file *file, struct socket *sock,
mask |= EPOLLHUP; mask |= EPOLLHUP;
/* readable? */ /* readable? */
if (!skb_queue_empty(&sk->sk_receive_queue)) if (!skb_queue_empty_lockless(&sk->sk_receive_queue))
mask |= EPOLLIN | EPOLLRDNORM; mask |= EPOLLIN | EPOLLRDNORM;
/* Connection-based need to check for termination and startup */ /* Connection-based need to check for termination and startup */
......
...@@ -1205,7 +1205,7 @@ static __poll_t dn_poll(struct file *file, struct socket *sock, poll_table *wai ...@@ -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); struct dn_scp *scp = DN_SK(sk);
__poll_t mask = datagram_poll(file, sock, wait); __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; mask |= EPOLLRDBAND;
return mask; return mask;
......
...@@ -584,7 +584,7 @@ __poll_t tcp_poll(struct file *file, struct socket *sock, poll_table *wait) ...@@ -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() */ /* This barrier is coupled with smp_wmb() in tcp_reset() */
smp_rmb(); 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; mask |= EPOLLERR;
return mask; return mask;
......
...@@ -2712,7 +2712,7 @@ __poll_t udp_poll(struct file *file, struct socket *sock, poll_table *wait) ...@@ -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); __poll_t mask = datagram_poll(file, sock, wait);
struct sock *sk = sock->sk; 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; mask |= EPOLLIN | EPOLLRDNORM;
/* Check for false positives due to checksum errors */ /* Check for false positives due to checksum errors */
......
...@@ -554,11 +554,11 @@ static __poll_t llcp_sock_poll(struct file *file, struct socket *sock, ...@@ -554,11 +554,11 @@ static __poll_t llcp_sock_poll(struct file *file, struct socket *sock,
if (sk->sk_state == LLCP_LISTEN) if (sk->sk_state == LLCP_LISTEN)
return llcp_accept_poll(sk); 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 | mask |= EPOLLERR |
(sock_flag(sk, SOCK_SELECT_ERR_QUEUE) ? EPOLLPRI : 0); (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; mask |= EPOLLIN | EPOLLRDNORM;
if (sk->sk_state == LLCP_CLOSED) if (sk->sk_state == LLCP_CLOSED)
......
...@@ -338,9 +338,9 @@ static __poll_t pn_socket_poll(struct file *file, struct socket *sock, ...@@ -338,9 +338,9 @@ static __poll_t pn_socket_poll(struct file *file, struct socket *sock,
if (sk->sk_state == TCP_CLOSE) if (sk->sk_state == TCP_CLOSE)
return EPOLLERR; return EPOLLERR;
if (!skb_queue_empty(&sk->sk_receive_queue)) if (!skb_queue_empty_lockless(&sk->sk_receive_queue))
mask |= EPOLLIN | EPOLLRDNORM; mask |= EPOLLIN | EPOLLRDNORM;
if (!skb_queue_empty(&pn->ctrlreq_queue)) if (!skb_queue_empty_lockless(&pn->ctrlreq_queue))
mask |= EPOLLPRI; mask |= EPOLLPRI;
if (!mask && sk->sk_state == TCP_CLOSE_WAIT) if (!mask && sk->sk_state == TCP_CLOSE_WAIT)
return EPOLLHUP; return EPOLLHUP;
......
...@@ -8476,7 +8476,7 @@ __poll_t sctp_poll(struct file *file, struct socket *sock, poll_table *wait) ...@@ -8476,7 +8476,7 @@ __poll_t sctp_poll(struct file *file, struct socket *sock, poll_table *wait)
mask = 0; mask = 0;
/* Is there any exceptional events? */ /* 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 | mask |= EPOLLERR |
(sock_flag(sk, SOCK_SELECT_ERR_QUEUE) ? EPOLLPRI : 0); (sock_flag(sk, SOCK_SELECT_ERR_QUEUE) ? EPOLLPRI : 0);
if (sk->sk_shutdown & RCV_SHUTDOWN) if (sk->sk_shutdown & RCV_SHUTDOWN)
...@@ -8485,7 +8485,7 @@ __poll_t sctp_poll(struct file *file, struct socket *sock, poll_table *wait) ...@@ -8485,7 +8485,7 @@ __poll_t sctp_poll(struct file *file, struct socket *sock, poll_table *wait)
mask |= EPOLLHUP; mask |= EPOLLHUP;
/* Is it readable? Reconsider this code with TCP-style support. */ /* 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; mask |= EPOLLIN | EPOLLRDNORM;
/* The association is either gone or not ready. */ /* The association is either gone or not ready. */
......
...@@ -740,7 +740,7 @@ static __poll_t tipc_poll(struct file *file, struct socket *sock, ...@@ -740,7 +740,7 @@ static __poll_t tipc_poll(struct file *file, struct socket *sock,
/* fall through */ /* fall through */
case TIPC_LISTEN: case TIPC_LISTEN:
case TIPC_CONNECTING: case TIPC_CONNECTING:
if (!skb_queue_empty(&sk->sk_receive_queue)) if (!skb_queue_empty_lockless(&sk->sk_receive_queue))
revents |= EPOLLIN | EPOLLRDNORM; revents |= EPOLLIN | EPOLLRDNORM;
break; break;
case TIPC_OPEN: case TIPC_OPEN:
...@@ -748,7 +748,7 @@ static __poll_t tipc_poll(struct file *file, struct socket *sock, ...@@ -748,7 +748,7 @@ static __poll_t tipc_poll(struct file *file, struct socket *sock,
revents |= EPOLLOUT; revents |= EPOLLOUT;
if (!tipc_sk_type_connectionless(sk)) if (!tipc_sk_type_connectionless(sk))
break; break;
if (skb_queue_empty(&sk->sk_receive_queue)) if (skb_queue_empty_lockless(&sk->sk_receive_queue))
break; break;
revents |= EPOLLIN | EPOLLRDNORM; revents |= EPOLLIN | EPOLLRDNORM;
break; break;
......
...@@ -2599,7 +2599,7 @@ static __poll_t unix_poll(struct file *file, struct socket *sock, poll_table *wa ...@@ -2599,7 +2599,7 @@ static __poll_t unix_poll(struct file *file, struct socket *sock, poll_table *wa
mask |= EPOLLRDHUP | EPOLLIN | EPOLLRDNORM; mask |= EPOLLRDHUP | EPOLLIN | EPOLLRDNORM;
/* readable? */ /* readable? */
if (!skb_queue_empty(&sk->sk_receive_queue)) if (!skb_queue_empty_lockless(&sk->sk_receive_queue))
mask |= EPOLLIN | EPOLLRDNORM; mask |= EPOLLIN | EPOLLRDNORM;
/* Connection-based need to check for termination and startup */ /* Connection-based need to check for termination and startup */
...@@ -2628,7 +2628,7 @@ static __poll_t unix_dgram_poll(struct file *file, struct socket *sock, ...@@ -2628,7 +2628,7 @@ static __poll_t unix_dgram_poll(struct file *file, struct socket *sock,
mask = 0; mask = 0;
/* exceptional events? */ /* 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 | mask |= EPOLLERR |
(sock_flag(sk, SOCK_SELECT_ERR_QUEUE) ? EPOLLPRI : 0); (sock_flag(sk, SOCK_SELECT_ERR_QUEUE) ? EPOLLPRI : 0);
...@@ -2638,7 +2638,7 @@ static __poll_t unix_dgram_poll(struct file *file, struct socket *sock, ...@@ -2638,7 +2638,7 @@ static __poll_t unix_dgram_poll(struct file *file, struct socket *sock,
mask |= EPOLLHUP; mask |= EPOLLHUP;
/* readable? */ /* readable? */
if (!skb_queue_empty(&sk->sk_receive_queue)) if (!skb_queue_empty_lockless(&sk->sk_receive_queue))
mask |= EPOLLIN | EPOLLRDNORM; mask |= EPOLLIN | EPOLLRDNORM;
/* Connection-based need to check for termination and startup */ /* Connection-based need to check for termination and startup */
......
...@@ -870,7 +870,7 @@ static __poll_t vsock_poll(struct file *file, struct socket *sock, ...@@ -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 * the queue and write as long as the socket isn't shutdown for
* sending. * sending.
*/ */
if (!skb_queue_empty(&sk->sk_receive_queue) || if (!skb_queue_empty_lockless(&sk->sk_receive_queue) ||
(sk->sk_shutdown & RCV_SHUTDOWN)) { (sk->sk_shutdown & RCV_SHUTDOWN)) {
mask |= EPOLLIN | EPOLLRDNORM; mask |= EPOLLIN | EPOLLRDNORM;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment