]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commitdiff
macvtap: do not add self to waitqueue if doing a nonblock read
authorJason Wang <jasowang@redhat.com>
Wed, 5 Jun 2013 23:54:34 +0000 (23:54 +0000)
committerDavid S. Miller <davem@davemloft.net>
Sat, 8 Jun 2013 06:49:08 +0000 (23:49 -0700)
There's no need to add self to waitqueue if doing a nonblock read. This could
help to avoid the spinlock contention.

Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/macvtap.c

index 5e485e30742414337e2f5d98b7aaf16a2bd4eda9..8949631c080c6145bd5abbfd1e92e59f304e5ade 100644 (file)
@@ -845,7 +845,9 @@ static ssize_t macvtap_do_read(struct macvtap_queue *q, struct kiocb *iocb,
        ssize_t ret = 0;
 
        while (len) {
-               prepare_to_wait(sk_sleep(&q->sk), &wait, TASK_INTERRUPTIBLE);
+               if (!noblock)
+                       prepare_to_wait(sk_sleep(&q->sk), &wait,
+                                       TASK_INTERRUPTIBLE);
 
                /* Read frames from the queue */
                skb = skb_dequeue(&q->sk.sk_receive_queue);
@@ -867,7 +869,8 @@ static ssize_t macvtap_do_read(struct macvtap_queue *q, struct kiocb *iocb,
                break;
        }
 
-       finish_wait(sk_sleep(&q->sk), &wait);
+       if (!noblock)
+               finish_wait(sk_sleep(&q->sk), &wait);
        return ret;
 }