netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Rainer Weikusat <rweikusat@mobileactivedefense.com>
To: David Laight <David.Laight@ACULAB.COM>
Cc: Eric Dumazet <eric.dumazet@gmail.com>,
	David Miller <davem@davemloft.net>,
	netdev <netdev@vger.kernel.org>
Subject: Re: [PATCH] net: unix: non blocking recvmsg() should not return -EINTR
Date: Thu, 27 Mar 2014 13:29:41 +0000	[thread overview]
Message-ID: <878urvpy62.fsf@sable.mobileactivedefense.com> (raw)
In-Reply-To: <063D6719AE5E284EB5DD2968C1650D6D0F6EA7FB@AcuExch.aculab.com> (David Laight's message of "Thu, 27 Mar 2014 12:53:58 +0000")

David Laight <David.Laight@ACULAB.COM> writes:
> From: Rainer Weikusat 
>> Considering all of this, the trylock-approach seems best to me. OTOH,
>
> No - using trylock() is definitely wrong.
> If there are two messages queued and two processes/threads try to
> read them, you don't want one of them being given EAGAIN.

I'd consider this acceptable because a second message could also come in
at the very moment the 2nd reader gives up. This is the 'next simplest
approach' after 'returning EAGAIN instead of EINTR' and I think it is a
little less non-desirable because it avoids the mixed blocking/
non-blocking problem (presently, I don't see why this shouldn't work,
ie, a process which inherited a socket ought to be able to switch that
to non-blocking mode and then call recv without risking to stop
executing for 'a long time'), and it is still reasonably simple (although
the problem is likely rather contrived).

Anything beyond that would involve priorising non-blocking readers over
blocking ones and let them wait uninterruptedly in case the lock is
presently held by another non-blocking reader. But this would be a whole
lot more complicated and even waiting for a blocking reader might work
just fine if a message arrives soon enough. Which then again means "it
should wait some time uninterruptedly in any case" but how much time?

The whole issue would neatly "not exist" if only one process could ever
be executing kernel code at any given time, but since is not the case
anymore, some kind of 'heuristic solution based on a tradeoff' is
necessary.

  reply	other threads:[~2014-03-27 13:29 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-26  1:42 [PATCH] net: unix: non blocking recvmsg() should not return -EINTR Eric Dumazet
2014-03-26 13:17 ` Rainer Weikusat
2014-03-26 13:57   ` Rainer Weikusat
2014-03-26 14:09   ` Eric Dumazet
2014-03-26 14:25     ` Rainer Weikusat
2014-03-26 15:00 ` David Laight
2014-03-26 15:13   ` Rainer Weikusat
2014-03-26 15:25     ` Eric Dumazet
2014-03-26 15:33       ` Eric Dumazet
2014-03-26 19:46       ` Rainer Weikusat
2014-03-26 21:04         ` Rainer Weikusat
2014-03-27  9:36           ` David Laight
2014-03-27 12:40             ` Rainer Weikusat
2014-03-27 12:49               ` Jamal Hadi Salim
2014-03-27 13:02                 ` Rainer Weikusat
2014-03-27 12:53               ` David Laight
2014-03-27 13:29                 ` Rainer Weikusat [this message]
2014-03-26 21:05         ` David Miller
2014-03-26 21:21           ` Rainer Weikusat
2014-03-26 21:44             ` Eric Dumazet
2014-03-26 22:06               ` Rainer Weikusat
2014-03-26 22:35                 ` Eric Dumazet
2014-03-26 22:51                   ` Rainer Weikusat
2014-03-26 22:58                     ` Eric Dumazet
2014-03-28 20:35             ` Rainer Weikusat

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=878urvpy62.fsf@sable.mobileactivedefense.com \
    --to=rweikusat@mobileactivedefense.com \
    --cc=David.Laight@ACULAB.COM \
    --cc=davem@davemloft.net \
    --cc=eric.dumazet@gmail.com \
    --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 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).