From: "Michael S. Tsirkin" <mst@redhat.com>
To: Jason Wang <jasowang@redhat.com>
Cc: Xi Wang <xii@google.com>, "David S. Miller" <davem@davemloft.net>,
netdev@vger.kernel.org, Maxim Krasnyansky <maxk@qti.qualcomm.com>,
Neal Cardwell <ncardwell@google.com>,
Eric Dumazet <edumazet@google.com>
Subject: Re: [PATCH v2] net-tun: restructure tun_do_read for better sleep/wakeup efficiency
Date: Mon, 19 May 2014 19:06:52 +0300 [thread overview]
Message-ID: <20140519160652.GE31595@redhat.com> (raw)
In-Reply-To: <5379CE8D.2030405@redhat.com>
On Mon, May 19, 2014 at 05:27:41PM +0800, Jason Wang wrote:
> > @@ -1330,47 +1329,26 @@ done:
> > static ssize_t tun_do_read(struct tun_struct *tun, struct tun_file *tfile,
> > const struct iovec *iv, ssize_t len, int noblock)
> > {
> > - DECLARE_WAITQUEUE(wait, current);
> > struct sk_buff *skb;
> > ssize_t ret = 0;
> > + int peeked, err, off = 0;
> >
> > tun_debug(KERN_INFO, tun, "tun_do_read\n");
> >
> > - if (unlikely(!noblock))
> > - add_wait_queue(&tfile->wq.wait, &wait);
> > - while (len) {
> > - if (unlikely(!noblock))
> > - current->state = TASK_INTERRUPTIBLE;
> > + if (!len)
> > + return ret;
> >
> > - /* Read frames from the queue */
> > - if (!(skb = skb_dequeue(&tfile->socket.sk->sk_receive_queue))) {
> > - if (noblock) {
> > - ret = -EAGAIN;
> > - break;
> > - }
> > - if (signal_pending(current)) {
> > - ret = -ERESTARTSYS;
> > - break;
> > - }
> > - if (tun->dev->reg_state != NETREG_REGISTERED) {
> > - ret = -EIO;
> > - break;
> > - }
> > -
> > - /* Nothing to read, let's sleep */
> > - schedule();
> > - continue;
> > - }
> > + if (tun->dev->reg_state != NETREG_REGISTERED)
> > + return -EIO;
> >
> > + /* Read frames from queue */
> > + skb = __skb_recv_datagram(tfile->socket.sk, noblock ? MSG_DONTWAIT : 0,
> > + &peeked, &off, &err);
> > + if (skb) {
>
> Still a little bit difference. We check the reg_state after we're sure
> there's nothing left in sk_receive_queue. But this patch returns -EIO
> before trying to dequeue skb.
Yes but what's the concern here? What does userspace do
to notice the change in behaviour?
tun_detach calls tun_queue_purge before unregister_netdevice
so apparently there's never anything in queue when
state isn't registered.
Did I miss something?
--
MST
next prev parent reply other threads:[~2014-05-19 16:08 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-16 22:11 [PATCH v2] net-tun: restructure tun_do_read for better sleep/wakeup efficiency Xi Wang
2014-05-19 9:27 ` Jason Wang
2014-05-19 14:09 ` Eric Dumazet
2014-05-20 4:44 ` Jason Wang
2014-05-20 4:52 ` Eric Dumazet
2014-05-20 6:35 ` Michael S. Tsirkin
2014-05-20 5:11 ` Eric Dumazet
2014-05-20 6:03 ` Jason Wang
2014-05-20 6:34 ` Michael S. Tsirkin
2014-05-20 6:55 ` Jason Wang
2014-05-20 13:59 ` Eric Dumazet
2014-05-21 4:45 ` Jason Wang
2014-05-19 16:06 ` Michael S. Tsirkin [this message]
2014-05-20 4:51 ` Jason Wang
2014-05-20 6:22 ` Michael S. Tsirkin
2014-05-20 6:40 ` Jason Wang
2014-05-21 7:54 ` Michael S. Tsirkin
2014-05-21 19:51 ` 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=20140519160652.GE31595@redhat.com \
--to=mst@redhat.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=jasowang@redhat.com \
--cc=maxk@qti.qualcomm.com \
--cc=ncardwell@google.com \
--cc=netdev@vger.kernel.org \
--cc=xii@google.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).