From: Jason Wang <jasowang@redhat.com>
To: "Michael S. Tsirkin" <mst@redhat.com>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: "David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Pavel Emelyanov <xemul@parallels.com>
Subject: Re: [PATCH] tun: don't look at current when non-blocking
Date: Tue, 08 Oct 2013 10:50:23 +0800 [thread overview]
Message-ID: <525372EF.9090307@redhat.com> (raw)
In-Reply-To: <20131006182512.GA16504@redhat.com>
On 10/07/2013 02:25 AM, Michael S. Tsirkin wrote:
> We play with a wait queue even if socket is
> non blocking. This is an obvious waste.
> Besides, it will prevent calling the non blocking
> variant when current is not valid.
>
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> ---
Acked-by: Jason Wang <jasowang@redhat.com>
> drivers/net/tun.c | 8 +++++---
> 1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/net/tun.c b/drivers/net/tun.c
> index 807815f..7cb105c 100644
> --- a/drivers/net/tun.c
> +++ b/drivers/net/tun.c
> @@ -1293,7 +1293,8 @@ static ssize_t tun_do_read(struct tun_struct *tun, struct tun_file *tfile,
> if (unlikely(!noblock))
> add_wait_queue(&tfile->wq.wait, &wait);
> while (len) {
> - current->state = TASK_INTERRUPTIBLE;
> + if (unlikely(!noblock))
> + current->state = TASK_INTERRUPTIBLE;
>
> /* Read frames from the queue */
> if (!(skb = skb_dequeue(&tfile->socket.sk->sk_receive_queue))) {
> @@ -1320,9 +1321,10 @@ static ssize_t tun_do_read(struct tun_struct *tun, struct tun_file *tfile,
> break;
> }
>
> - current->state = TASK_RUNNING;
> - if (unlikely(!noblock))
> + if (unlikely(!noblock)) {
> + current->state = TASK_RUNNING;
> remove_wait_queue(&tfile->wq.wait, &wait);
> + }
>
> return ret;
> }
next prev parent reply other threads:[~2013-10-08 2:50 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-06 18:25 [PATCH] tun: don't look at current when non-blocking Michael S. Tsirkin
2013-10-08 2:50 ` Jason Wang [this message]
2013-10-08 19:46 ` David Miller
2013-10-09 6:25 ` Jason Wang
2013-10-09 8:13 ` Michael S. Tsirkin
2013-10-09 17:14 ` David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=525372EF.9090307@redhat.com \
--to=jasowang@redhat.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mst@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=xemul@parallels.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).