* open(2) manpage and O_NONBLOCK
@ 2016-03-21 20:23 Jörn Engel
2016-03-28 3:58 ` Michael Kerrisk (man-pages)
0 siblings, 1 reply; 4+ messages in thread
From: Jörn Engel @ 2016-03-21 20:23 UTC (permalink / raw)
To: Michael Kerrisk (man-pages); +Cc: linux-man, linux-fsdevel
In open(2), we seem to promise more than the kernel can deliver:
O_NONBLOCK or O_NDELAY
When possible, the file is opened in nonblocking mode.
Neither the open() nor any subsequent operations on the
file descriptor which is returned will cause the
calling process to wait.
Clearly you can question whether every last device driver correctly
supports O_NONBLOCK in its open routine. But even if that was the case,
we still cannot guarantee nonblocking behaviour for open().
get_empty_filp() has to be called for every open() and contains a
blocking memory allocation:
f = kmem_cache_zalloc(filp_cachep, GFP_KERNEL);
As such I would propose to change the documentation and keep the code.
The open() itself may very well block, but subsequent operations should
not.
J�rn
--
Why do musicians compose symphonies and poets write poems?
They do it because life wouldn't have any meaning for them if they didn't.
That's why I draw cartoons. It's my life.
-- Charles Shultz
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: open(2) manpage and O_NONBLOCK
2016-03-21 20:23 open(2) manpage and O_NONBLOCK Jörn Engel
@ 2016-03-28 3:58 ` Michael Kerrisk (man-pages)
2016-03-28 4:08 ` Al Viro
0 siblings, 1 reply; 4+ messages in thread
From: Michael Kerrisk (man-pages) @ 2016-03-28 3:58 UTC (permalink / raw)
To: Jörn Engel; +Cc: linux-man, linux-fsdevel@vger.kernel.org
Hello Jörn,
On 22 March 2016 at 09:23, Jörn Engel <joern@purestorage.com> wrote:
> In open(2), we seem to promise more than the kernel can deliver:
> O_NONBLOCK or O_NDELAY
> When possible, the file is opened in nonblocking mode.
> Neither the open() nor any subsequent operations on the
> file descriptor which is returned will cause the
> calling process to wait.
>
> Clearly you can question whether every last device driver correctly
> supports O_NONBLOCK in its open routine. But even if that was the case,
> we still cannot guarantee nonblocking behaviour for open().
> get_empty_filp() has to be called for every open() and contains a
> blocking memory allocation:
> f = kmem_cache_zalloc(filp_cachep, GFP_KERNEL);
For how long might this block, though?
> As such I would propose to change the documentation and keep the code.
> The open() itself may very well block, but subsequent operations should
> not.
I think the most obvious userland case that's being covered here is
O_NONBLOCK with FIFOs. The "Wen possible" text is, I imagine, there to
deal with cases such as drivers that do not support O_NONBLOCK.
Cheers,
Michael
--
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: open(2) manpage and O_NONBLOCK
2016-03-28 3:58 ` Michael Kerrisk (man-pages)
@ 2016-03-28 4:08 ` Al Viro
2016-03-28 5:04 ` Jörn Engel
0 siblings, 1 reply; 4+ messages in thread
From: Al Viro @ 2016-03-28 4:08 UTC (permalink / raw)
To: Michael Kerrisk (man-pages)
Cc: Jörn Engel, linux-man, linux-fsdevel@vger.kernel.org
On Mon, Mar 28, 2016 at 04:58:33PM +1300, Michael Kerrisk (man-pages) wrote:
> > blocking memory allocation:
> > f = kmem_cache_zalloc(filp_cachep, GFP_KERNEL);
>
> For how long might this block, though?
Not much, usually. Finding the file, though, can bloody well take a _long_
time - put it behind an automount from a slow server and we might be easily
talking about minutes, if not longer.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: open(2) manpage and O_NONBLOCK
2016-03-28 4:08 ` Al Viro
@ 2016-03-28 5:04 ` Jörn Engel
0 siblings, 0 replies; 4+ messages in thread
From: Jörn Engel @ 2016-03-28 5:04 UTC (permalink / raw)
To: Al Viro
Cc: Michael Kerrisk (man-pages), linux-man,
linux-fsdevel@vger.kernel.org
On Mon, Mar 28, 2016 at 05:08:45AM +0100, Al Viro wrote:
> On Mon, Mar 28, 2016 at 04:58:33PM +1300, Michael Kerrisk (man-pages) wrote:
> > > blocking memory allocation:
> > > f = kmem_cache_zalloc(filp_cachep, GFP_KERNEL);
> >
> > For how long might this block, though?
>
> Not much, usually. Finding the file, though, can bloody well take a _long_
> time - put it behind an automount from a slow server and we might be easily
> talking about minutes, if not longer.
Another example that bit me in the past is scsi devices checking for
media presence. If any part of your storage stack drops the cdb, you
have to wait for a scsi timeout, usually 30s.
Disk events commonly cause delays around the half-second mark. I
haven't gone through the code yet to see what the actual limits are.
Half a second might already be too long for some realtime
applications.
J�rn
--
When I am working on a problem I never think about beauty. I think
only how to solve the problem. But when I have finished, if the
solution is not beautiful, I know it is wrong.
-- R. Buckminster Fuller
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-03-28 5:04 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-21 20:23 open(2) manpage and O_NONBLOCK Jörn Engel
2016-03-28 3:58 ` Michael Kerrisk (man-pages)
2016-03-28 4:08 ` Al Viro
2016-03-28 5:04 ` Jörn Engel
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).