From: "Chris Friesen" <cfriesen@nortel.com>
To: Brandon Black <blblack@gmail.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>,
linux-kernel@vger.kernel.org, netdev@vger.kernel.org
Subject: Re: behavior of recvmmsg() on blocking sockets
Date: Mon, 29 Mar 2010 11:48:22 -0600 [thread overview]
Message-ID: <4BB0E7E6.6030304@nortel.com> (raw)
In-Reply-To: <84621a61003291024r38121763o546e0f09e2d63bc3@mail.gmail.com>
On 03/29/2010 11:24 AM, Brandon Black wrote:
> On Mon, Mar 29, 2010 at 11:18 AM, Chris Friesen <cfriesen@nortel.com> wrote:
>>
>> prev = current time
>> loop forever
>> cur = current time
>> timeout = max_latency - (cur - prev)
>> recvmmsg(timeout)
>> process all received messages
>> prev = cur
>>
>>
>> Basically you determine the max latency you're willing to wait for a
>> packet to be handled, then subtract the amount of time you spent
>> processing messages from that and pass it into the recvmmsg() call as
>> the timeout. That way no messages will be delayed for longer than the
>> max latency. (Not considering scheduling delays.)
>
> With a blocking socket, you'd also need to set SO_RCVTIMEO on the
> underlying socket to some value that makes sense and is below your max
> latency, because recvmmsg()'s timeout argument only applies in-between
> underlying recvmsg() calls, not during them.
Hmm...that's a good point. For some reason I had been under the
impression that the timeout affected the underlying recvmsg() calls as
well. It think it would make more sense for the kernel to abort a
blocking recvmsg() call once the timeout expires.
As for spending a lot of time spinning if there are gaps in the input
stream...in the cases where the time-based usage makes sense the normal
situation is that there are a lot of packets coming in. A 10gig
ethernet pipe can theoretically receive something like 19 packets per
usec. Doesn't take much of a delay before you probably have packets
waiting.
Chris
prev parent reply other threads:[~2010-03-29 17:50 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-24 16:15 behavior of recvmmsg() on blocking sockets Brandon Black
2010-03-24 17:41 ` Chris Friesen
2010-03-24 18:28 ` Brandon Black
2010-03-24 18:34 ` drepper
2010-03-24 23:35 ` Brandon Black
2010-03-26 12:00 ` Ulrich Drepper
2010-03-26 14:20 ` Eric Dumazet
2010-03-24 19:36 ` Chris Friesen
2010-03-24 19:55 ` Brandon Black
2010-03-27 13:19 ` Brandon Black
2010-03-27 14:26 ` Arnaldo Carvalho de Melo
2010-03-29 16:18 ` Chris Friesen
2010-03-29 17:24 ` Brandon Black
2010-03-29 17:48 ` Chris Friesen [this message]
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=4BB0E7E6.6030304@nortel.com \
--to=cfriesen@nortel.com \
--cc=acme@redhat.com \
--cc=blblack@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.