netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@redhat.com>
To: Caitlin Bestler <caitlin.bestler@gmail.com>
Cc: David Miller <davem@davemloft.net>,
	netdev@vger.kernel.org, Chris Van Hoof <vanhoof@redhat.com>,
	Clark Williams <williams@redhat.com>
Subject: Re: [RFC 1/2] net: Introduce recvmmsg socket syscall
Date: Thu, 21 May 2009 13:55:15 -0300	[thread overview]
Message-ID: <20090521165515.GK5956@ghostprotocols.net> (raw)
In-Reply-To: <469958e00905210938s371b5dect28c7b1f8bb751ad1@mail.gmail.com>

Em Thu, May 21, 2009 at 09:38:47AM -0700, Caitlin Bestler escreveu:
> > +
> > +       while (datagrams < vlen) {
> > +               err = __sys_recvmsg(sock, (struct msghdr __user *)entry, flags);
> > +               if (err < 0)
> > +                       goto out_put;
> > +               err = __put_user(err, &entry->msg_len);
> > +               if (err)
> > +                       goto out_put;
> > +               ++entry;
> > +               ++datagrams;
> > +       }
> >  out_put:
> >        fput_light(sock->file, fput_needed);
> >  out:
> > +       /*
> > +        * We may return less entries than requested (vlen) if the
> > +        * sock is non block and there aren't enough datagrams.
> > +        */
> > +       if (err == 0 || (err == -EAGAIN && (flags & MSG_DONTWAIT)))
> > +               return datagrams;
> >        return err;
> >  }
> >
 
> There is an assumption here that unless MSG_DONTWAIT is set, or there
> is an error, that the caller will be willing to wait indefinitely for
> N messages to show up -- and that it is never worth waking up the
> caller earlier with less than N messages.
 
> I think an application would more typically want to wait at most m
> msecs after the first message is received to see if any other messages
> can be delivered at the same time.

> A busy server could simply use DONTWAIT in a polling loop every cycle,
> but it would be nice to be able to wait indefinitely for *any* of your
> clients to send you a message.
 
> Further, with some sockets there are some messages that are more equal
> than others.

> Although valid messages, with no errors, they should be delivered to
> user-mode immediately.

> The example that leaps to my mind immediately are SCTP Events,
> particularly with one-to-many sockets. You could be waiting for N
> messages, knowing that a specific peer has been asked to send N
> messages. The 2nd message could be an SCTP event announcing that the
> specific association has been torn down (and hence the remaining
> messages will not be arriving).  Waiting for a different association
> to send enough messages to complete the request will not provide very
> prompt service.

Good points, that will require some sort of change to sk->sk_rcvtimeo
handling so that the timeout for each datagram are deduced from the
configured timeout for the socket, so that the existing code doesn't
have to be changed.

I.e. recvmmsg would save the value of sk->sk_rcvtimeo at entry and
restore at exit, and would somehow go on subtracting the time
sock_recvmsg() took from it so that the following call finds a reduced
sk->sk_rcvtimeo iif it was configured in the first place and the socket
is in blocking mode.

How does that sound?

- Arnaldo

  reply	other threads:[~2009-05-21 16:55 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-20 23:06 [RFC 1/2] net: Introduce recvmmsg socket syscall Arnaldo Carvalho de Melo
2009-05-21  0:46 ` Neil Horman
2009-05-21  2:05   ` Arnaldo Carvalho de Melo
2009-05-21  2:26     ` Neil Horman
2009-05-21  3:50       ` David Miller
2009-05-21 10:40         ` Neil Horman
2009-05-21 14:16 ` Paul Moore
2009-05-21 14:47   ` Arnaldo Carvalho de Melo
2009-05-21 15:03     ` Paul Moore
2009-05-21 15:11       ` Arnaldo Carvalho de Melo
2009-05-21 15:24         ` Paul Moore
2009-05-21 16:10 ` Evgeniy Polyakov
2009-05-21 16:27   ` Arnaldo Carvalho de Melo
2009-05-21 16:33     ` Steven Whitehouse
2009-05-21 16:45       ` Arnaldo Carvalho de Melo
2009-05-21 16:38 ` Caitlin Bestler
2009-05-21 16:55   ` Arnaldo Carvalho de Melo [this message]
2009-05-21 17:26     ` Caitlin Bestler
2009-05-21 17:51       ` Arnaldo Carvalho de Melo
2009-05-22  8:32         ` steve
2009-05-22  7:22 ` Rémi Denis-Courmont
2009-05-22  8:31   ` steve
2009-05-22 16:39   ` Caitlin Bestler
2009-05-22 20:06 ` Neil Horman
2009-06-04  1:44   ` Andrew Grover
2009-06-04  1:46     ` Arnaldo Carvalho de Melo
2009-06-04 10:47     ` Neil Horman

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=20090521165515.GK5956@ghostprotocols.net \
    --to=acme@redhat.com \
    --cc=caitlin.bestler@gmail.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=vanhoof@redhat.com \
    --cc=williams@redhat.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).