* [PATCH] tun: don't look at current when non-blocking
@ 2013-10-06 18:25 Michael S. Tsirkin
2013-10-08 2:50 ` Jason Wang
2013-10-08 19:46 ` David Miller
0 siblings, 2 replies; 6+ messages in thread
From: Michael S. Tsirkin @ 2013-10-06 18:25 UTC (permalink / raw)
To: netdev, linux-kernel
Cc: David S. Miller, Jason Wang, Eric Dumazet, Pavel Emelyanov
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>
---
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;
}
--
MST
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] tun: don't look at current when non-blocking
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
2013-10-08 19:46 ` David Miller
1 sibling, 0 replies; 6+ messages in thread
From: Jason Wang @ 2013-10-08 2:50 UTC (permalink / raw)
To: Michael S. Tsirkin, netdev, linux-kernel
Cc: David S. Miller, Eric Dumazet, Pavel Emelyanov
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;
> }
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] tun: don't look at current when non-blocking
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
@ 2013-10-08 19:46 ` David Miller
2013-10-09 6:25 ` Jason Wang
1 sibling, 1 reply; 6+ messages in thread
From: David Miller @ 2013-10-08 19:46 UTC (permalink / raw)
To: mst; +Cc: netdev, linux-kernel, jasowang, edumazet, xemul
From: "Michael S. Tsirkin" <mst@redhat.com>
Date: Sun, 6 Oct 2013 21:25:12 +0300
> 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>
Applied and queued up for -stable, thanks.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] tun: don't look at current when non-blocking
2013-10-08 19:46 ` David Miller
@ 2013-10-09 6:25 ` Jason Wang
2013-10-09 8:13 ` Michael S. Tsirkin
0 siblings, 1 reply; 6+ messages in thread
From: Jason Wang @ 2013-10-09 6:25 UTC (permalink / raw)
To: David Miller, mst; +Cc: netdev, linux-kernel, edumazet, xemul
On 10/09/2013 03:46 AM, David Miller wrote:
> From: "Michael S. Tsirkin" <mst@redhat.com>
> Date: Sun, 6 Oct 2013 21:25:12 +0300
>
>> 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>
> Applied and queued up for -stable, thanks.
> --
Michael, I believe this is just an optimization or a required patch of
your following patches. So no need go for stable?
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] tun: don't look at current when non-blocking
2013-10-09 6:25 ` Jason Wang
@ 2013-10-09 8:13 ` Michael S. Tsirkin
2013-10-09 17:14 ` David Miller
0 siblings, 1 reply; 6+ messages in thread
From: Michael S. Tsirkin @ 2013-10-09 8:13 UTC (permalink / raw)
To: Jason Wang; +Cc: David Miller, netdev, linux-kernel, edumazet, xemul
On Wed, Oct 09, 2013 at 02:25:19PM +0800, Jason Wang wrote:
> On 10/09/2013 03:46 AM, David Miller wrote:
> > From: "Michael S. Tsirkin" <mst@redhat.com>
> > Date: Sun, 6 Oct 2013 21:25:12 +0300
> >
> >> 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>
> > Applied and queued up for -stable, thanks.
> > --
>
> Michael, I believe this is just an optimization or a required patch of
> your following patches. So no need go for stable?
I don't think it's required for stable.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] tun: don't look at current when non-blocking
2013-10-09 8:13 ` Michael S. Tsirkin
@ 2013-10-09 17:14 ` David Miller
0 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2013-10-09 17:14 UTC (permalink / raw)
To: mst; +Cc: jasowang, netdev, linux-kernel, edumazet, xemul
From: "Michael S. Tsirkin" <mst@redhat.com>
Date: Wed, 9 Oct 2013 11:13:54 +0300
> On Wed, Oct 09, 2013 at 02:25:19PM +0800, Jason Wang wrote:
>> On 10/09/2013 03:46 AM, David Miller wrote:
>> > From: "Michael S. Tsirkin" <mst@redhat.com>
>> > Date: Sun, 6 Oct 2013 21:25:12 +0300
>> >
>> >> 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>
>> > Applied and queued up for -stable, thanks.
>> > --
>>
>> Michael, I believe this is just an optimization or a required patch of
>> your following patches. So no need go for stable?
>
> I don't think it's required for stable.
Ok, removed from the -stable queue. Thanks.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2013-10-09 17:14 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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
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).