net: use skb_queue_empty_lockless() in poll() handlers
authorEric Dumazet <edumazet@google.com>
Thu, 24 Oct 2019 05:44:50 +0000 (22:44 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 10 Nov 2019 10:25:34 +0000 (11:25 +0100)
[ Upstream commit 3ef7cf57c72f32f61e97f8fa401bc39ea1f1a5d4 ]

Many poll() handlers are lockless. Using skb_queue_empty_lockless()
instead of skb_queue_empty() is more appropriate.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
13 files changed:
drivers/isdn/capi/capi.c
net/atm/common.c
net/bluetooth/af_bluetooth.c
net/caif/caif_socket.c
net/core/datagram.c
net/ipv4/tcp.c
net/ipv4/udp.c
net/nfc/llcp_sock.c
net/phonet/socket.c
net/sctp/socket.c
net/tipc/socket.c
net/unix/af_unix.c
net/vmw_vsock/af_vsock.c

index 91efbf0f19f928542fe361ef949ebbd46c01a5dd..da45049de97e3ce8164a5d77051786904fa33774 100644 (file)
@@ -743,7 +743,7 @@ capi_poll(struct file *file, poll_table *wait)
 
        poll_wait(file, &(cdev->recvwait), wait);
        mask = POLLOUT | POLLWRNORM;
-       if (!skb_queue_empty(&cdev->recvqueue))
+       if (!skb_queue_empty_lockless(&cdev->recvqueue))
                mask |= POLLIN | POLLRDNORM;
        return mask;
 }
index 9e812c782a372d03e30ef5b97f4ef2c69cfa9100..0fd2d26d4c6e4a6ed938bf48d3fab68436ff99c7 100644 (file)
@@ -667,7 +667,7 @@ unsigned int vcc_poll(struct file *file, struct socket *sock, poll_table *wait)
                mask |= POLLHUP;
 
        /* readable? */
-       if (!skb_queue_empty(&sk->sk_receive_queue))
+       if (!skb_queue_empty_lockless(&sk->sk_receive_queue))
                mask |= POLLIN | POLLRDNORM;
 
        /* writable? */
index b216e697deac80ed57515b7ce9db1bf580190291..b48d54783e5d925acd8264879493ea2a6e483479 100644 (file)
@@ -460,7 +460,7 @@ unsigned int 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 |= POLLERR |
                        (sock_flag(sk, SOCK_SELECT_ERR_QUEUE) ? POLLPRI : 0);
 
@@ -470,7 +470,7 @@ unsigned int bt_sock_poll(struct file *file, struct socket *sock,
        if (sk->sk_shutdown == SHUTDOWN_MASK)
                mask |= POLLHUP;
 
-       if (!skb_queue_empty(&sk->sk_receive_queue))
+       if (!skb_queue_empty_lockless(&sk->sk_receive_queue))
                mask |= POLLIN | POLLRDNORM;
 
        if (sk->sk_state == BT_CLOSED)
index 632d5a416d973306aa01552acc0a8bf80b2177aa..df936d2f58bdd9885c2279ee03b5dfb229a98d70 100644 (file)
@@ -953,7 +953,7 @@ static unsigned int caif_poll(struct file *file,
                mask |= POLLRDHUP;
 
        /* readable? */
-       if (!skb_queue_empty(&sk->sk_receive_queue) ||
+       if (!skb_queue_empty_lockless(&sk->sk_receive_queue) ||
                (sk->sk_shutdown & RCV_SHUTDOWN))
                mask |= POLLIN | POLLRDNORM;
 
index 632adc4301e27b54b71ba59a3a066c65913aca41..4336c720ce4bfbc75038d5d0c3c3eadbd1bbdbbe 100644 (file)
@@ -844,7 +844,7 @@ unsigned int 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 |= POLLERR |
                        (sock_flag(sk, SOCK_SELECT_ERR_QUEUE) ? POLLPRI : 0);
 
@@ -854,7 +854,7 @@ unsigned int datagram_poll(struct file *file, struct socket *sock,
                mask |= POLLHUP;
 
        /* readable? */
-       if (!skb_queue_empty(&sk->sk_receive_queue))
+       if (!skb_queue_empty_lockless(&sk->sk_receive_queue))
                mask |= POLLIN | POLLRDNORM;
 
        /* Connection-based need to check for termination and startup */
index c1f59a53f68fdd7115c0b9d12bcb905833d6d6e7..ee0669d0d867141f338229e17d4ea9fe95c2ed6e 100644 (file)
@@ -574,7 +574,7 @@ unsigned int 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 |= POLLERR;
 
        return mask;
index b88456a6b69b0b3fb8ae569f9ec5579a30a23eb0..ab3f272a0884d7e4b618416a8c942f30ac8efca4 100644 (file)
@@ -2550,7 +2550,7 @@ unsigned int udp_poll(struct file *file, struct socket *sock, poll_table *wait)
        unsigned int 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 |= POLLIN | POLLRDNORM;
 
        sock_rps_record_flow(sk);
index a51bfba19b9ef60e98d12545062391b7c9c75f17..694a43c05eb9b322b44c1bb94a57ecec2808f9cd 100644 (file)
@@ -567,11 +567,11 @@ static unsigned int 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 |= POLLERR |
                        (sock_flag(sk, SOCK_SELECT_ERR_QUEUE) ? POLLPRI : 0);
 
-       if (!skb_queue_empty(&sk->sk_receive_queue))
+       if (!skb_queue_empty_lockless(&sk->sk_receive_queue))
                mask |= POLLIN | POLLRDNORM;
 
        if (sk->sk_state == LLCP_CLOSED)
index 1b050dd17393c1289d3b04628b440d9011e5eb37..a1df36f3bb6ef596b55dce99bf0b49a4ab135ab1 100644 (file)
@@ -352,9 +352,9 @@ static unsigned int pn_socket_poll(struct file *file, struct socket *sock,
 
        if (sk->sk_state == TCP_CLOSE)
                return POLLERR;
-       if (!skb_queue_empty(&sk->sk_receive_queue))
+       if (!skb_queue_empty_lockless(&sk->sk_receive_queue))
                mask |= POLLIN | POLLRDNORM;
-       if (!skb_queue_empty(&pn->ctrlreq_queue))
+       if (!skb_queue_empty_lockless(&pn->ctrlreq_queue))
                mask |= POLLPRI;
        if (!mask && sk->sk_state == TCP_CLOSE_WAIT)
                return POLLHUP;
index 4045d203b7d491b8e0d64894684ea99856537a56..8bcce38521dacb3fb57ded876ed03bb07e737fb6 100644 (file)
@@ -7371,7 +7371,7 @@ unsigned int 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 |= POLLERR |
                        (sock_flag(sk, SOCK_SELECT_ERR_QUEUE) ? POLLPRI : 0);
        if (sk->sk_shutdown & RCV_SHUTDOWN)
@@ -7380,7 +7380,7 @@ unsigned int sctp_poll(struct file *file, struct socket *sock, poll_table *wait)
                mask |= POLLHUP;
 
        /* 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 |= POLLIN | POLLRDNORM;
 
        /* The association is either gone or not ready.  */
index f13fb607c5631e7cfa231c2283ca7cd9945d591b..21929ba196eb781de91b7f641d15766dcd22d1f8 100644 (file)
@@ -714,14 +714,14 @@ static unsigned int tipc_poll(struct file *file, struct socket *sock,
                /* fall thru' */
        case TIPC_LISTEN:
        case TIPC_CONNECTING:
-               if (!skb_queue_empty(&sk->sk_receive_queue))
+               if (!skb_queue_empty_lockless(&sk->sk_receive_queue))
                        mask |= (POLLIN | POLLRDNORM);
                break;
        case TIPC_OPEN:
                if (!tsk->cong_link_cnt)
                        mask |= POLLOUT;
                if (tipc_sk_type_connectionless(sk) &&
-                   (!skb_queue_empty(&sk->sk_receive_queue)))
+                   (!skb_queue_empty_lockless(&sk->sk_receive_queue)))
                        mask |= (POLLIN | POLLRDNORM);
                break;
        case TIPC_DISCONNECTING:
index 2adfcc6dec5a4be3f911a59755f85294f9fd1832..4de9dfd14d09dd3bd94c67a9f87a34c6bbc0468b 100644 (file)
@@ -2665,7 +2665,7 @@ static unsigned int unix_poll(struct file *file, struct socket *sock, poll_table
                mask |= POLLRDHUP | POLLIN | POLLRDNORM;
 
        /* readable? */
-       if (!skb_queue_empty(&sk->sk_receive_queue))
+       if (!skb_queue_empty_lockless(&sk->sk_receive_queue))
                mask |= POLLIN | POLLRDNORM;
 
        /* Connection-based need to check for termination and startup */
@@ -2693,7 +2693,7 @@ static unsigned int 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 |= POLLERR |
                        (sock_flag(sk, SOCK_SELECT_ERR_QUEUE) ? POLLPRI : 0);
 
@@ -2703,7 +2703,7 @@ static unsigned int unix_dgram_poll(struct file *file, struct socket *sock,
                mask |= POLLHUP;
 
        /* readable? */
-       if (!skb_queue_empty(&sk->sk_receive_queue))
+       if (!skb_queue_empty_lockless(&sk->sk_receive_queue))
                mask |= POLLIN | POLLRDNORM;
 
        /* Connection-based need to check for termination and startup */
index 148c949cdfe751d73adb1ebb706709f3859fe9f2..1939b77e98b72d308c2d85e9b0e2afaeb4bb6fef 100644 (file)
@@ -880,7 +880,7 @@ static unsigned int 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 |= POLLIN | POLLRDNORM;
                }