All of lore.kernel.org
 help / color / mirror / Atom feed
From: Valentin Nechayev <netch@netch.kiev.ua>
To: Alan Cox <alan@lxorguk.ukuu.org.uk>, "H. Peter Anvin" <hpa@zytor.com>
Cc: Alexey Dobriyan <adobriyan@gmail.com>,
	akpm@linux-foundation.org, viro@zeniv.linux.org.uk,
	torvalds@linux-foundation.org, drepper@gmail.com,
	linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH] nextfd(2)
Date: Mon, 30 Apr 2012 12:58:35 +0300	[thread overview]
Message-ID: <20120430095835.GF51635@netch.kiev.ua> (raw)
In-Reply-To: <4F78D30B.4070205@zytor.com> <20120402010819.76d31790@pyramind.ukuu.org.uk>

 Sun, Apr 01, 2012 at 15:13:31, hpa wrote about "Re: [PATCH] nextfd(2)": 

> - There is a huge backwards compatibility problem with this for a
> substantial transition period; using /proc/self/fd has worked for a very
> long time already.
> 
> - Your nextfd() system call will require more system calls that the
> typical case for reading /proc/self/fd, because each getdents() system
> call handles multiple readdir() invocations.

First, your forecast is very doubtfully correct in typical case when a
process checks extra descriptors to close; seeing tools like sendmail
shows that typically the all this long cycle does no work. So, it will
reduce to one nextfd() which returns final error, instead of
open()+getdents()+close().

Second, the principal advantage of nextfd() approach that it doesn't
consumer additional resources for its work, compared with open() which
allocates yet another descriptor. So, it could fail unpredictably.

Typical Unix-like system has at least four kinds of critical resources;
"critical" means here that they could be requested even in case of
lack of such resource, to provide a kind of graceful shutdown. They
are virtual memory, file descriptors, threads and disk space, all
possibly limited per-system, per-user or per-process. The current lack
of a measure to provide work when a resource is exhausted gives only
one possible reaction - to die immediately; this is now typical
reaction to memory allocation failure. I'm already sick of seeing
a language runtime which crash with messages like "cannot allocate
500M" when doing GC; this isn't single example but common approach of
such a devil-may-care attitude to application stability.

It isn't hard to expand the current approach in two ways: 1) allowing
to allocate reserve pool which will be then used by compating or
shutdown actions; 2) making actions which are typical on such
compacting using minimum of resources, even with some loss of
uniformity, API orthogonality and simplicity. Yep, this way is long
and can spend decades - more long than /proc existence - but it is
good to achieve.

Seems all this was in mind of Alexey Dobriyan when he proposed
nextfd(); maybe not with the same level of details, but in general.

 Mon, Apr 02, 2012 at 01:08:19, alan wrote about "Re: [PATCH] nextfd(2)": 

> If I've rlimited you to no file handles then you already lost whichever
> approach you use. Just abort.

Well, this is the good illustration to my words. In real work I don't
want to use the world when abort() is not simply the only case for
complicated state, but the suggestion. My software isn't
samurai-inspired kamikaze.


-netch-

  reply	other threads:[~2012-04-30  9:59 UTC|newest]

Thread overview: 78+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-01 12:57 [PATCH] nextfd(2) Alexey Dobriyan
2012-04-01 13:58 ` Konstantin Khlebnikov
2012-04-01 21:30   ` Alexey Dobriyan
2012-04-02  0:09   ` Alan Cox
2012-04-02  8:38     ` Konstantin Khlebnikov
2012-04-02  9:26       ` Cyrill Gorcunov
2012-04-01 15:43 ` Eric Dumazet
2012-04-01 21:31   ` Alexey Dobriyan
2012-04-01 21:36   ` Alan Cox
2012-04-01 17:20 ` Linus Torvalds
2012-04-01 18:28 ` Valentin Nechayev
2012-04-01 21:33   ` Alexey Dobriyan
2012-04-01 19:21 ` Arnd Bergmann
2012-04-01 21:35   ` Alexey Dobriyan
2012-04-01 22:05   ` H. Peter Anvin
2012-04-04 12:13     ` Arnd Bergmann
2012-04-01 22:03 ` H. Peter Anvin
2012-04-01 22:13   ` H. Peter Anvin
2012-04-02  0:08   ` Alan Cox
2012-04-30  9:58     ` Valentin Nechayev [this message]
2012-04-02  1:19   ` Kyle Moffett
2012-04-02  1:19     ` Kyle Moffett
2012-04-02  1:37     ` H. Peter Anvin
2012-04-02 11:37     ` Ulrich Drepper
2012-04-06  9:54   ` Alexey Dobriyan
2012-04-06  9:54     ` Alexey Dobriyan
2012-04-06 15:27     ` Colin Walters
2012-04-06 16:14     ` H. Peter Anvin
2012-04-06 20:16       ` Alexey Dobriyan
2012-04-06 20:33         ` H. Peter Anvin
2012-04-06 21:02         ` H. Peter Anvin
2012-04-12 10:54           ` Alexey Dobriyan
2012-04-12 10:54             ` Alexey Dobriyan
2012-04-12 11:11             ` Alan Cox
2012-04-12 11:11               ` Alan Cox
2012-04-12 13:35               ` Alexey Dobriyan
2012-04-12 13:51                 ` H. Peter Anvin
2012-04-12 19:21                   ` Alexey Dobriyan
2012-04-12 14:09               ` Eric Dumazet
2012-04-06 16:23     ` H. Peter Anvin
2012-04-07 21:21       ` Ben Pfaff
2012-04-11  0:12         ` KOSAKI Motohiro
2012-04-11  0:12           ` KOSAKI Motohiro
2012-04-11  0:09       ` KOSAKI Motohiro
2012-04-11 17:58         ` H. Peter Anvin
2012-04-11 18:04           ` Linus Torvalds
2012-04-11 18:04             ` Linus Torvalds
2012-04-11 18:11             ` H. Peter Anvin
2012-04-11 19:46               ` KOSAKI Motohiro
2012-04-11 19:46                 ` KOSAKI Motohiro
2012-04-11 19:49                 ` H. Peter Anvin
2012-04-11 20:23                   ` KOSAKI Motohiro
2012-04-11 20:32                     ` H. Peter Anvin
2012-04-17 18:12                       ` KOSAKI Motohiro
2012-04-11 18:00         ` H. Peter Anvin
2012-04-11 19:20           ` KOSAKI Motohiro
2012-04-11 19:20             ` KOSAKI Motohiro
2012-04-11 19:22             ` H. Peter Anvin
2012-04-11 19:26               ` KOSAKI Motohiro
2012-04-11 19:28                 ` H. Peter Anvin
2012-04-11 19:31                   ` KOSAKI Motohiro
2012-04-11 19:32                     ` H. Peter Anvin
2012-04-02 23:17 ` KOSAKI Motohiro
2012-04-02 23:56   ` H. Peter Anvin
2012-04-04 11:51     ` Ulrich Drepper
2012-04-04 16:38       ` KOSAKI Motohiro
2012-04-04 16:43         ` Ulrich Drepper
2012-04-04 17:07           ` KOSAKI Motohiro
2012-04-04 17:49             ` Ulrich Drepper
2012-04-04 18:08               ` KOSAKI Motohiro
2012-04-04 16:31     ` KOSAKI Motohiro
2012-04-04 17:10       ` Colin Walters
2012-04-04 17:25         ` Colin Walters
2012-04-04 23:35         ` KOSAKI Motohiro
2012-04-04 18:44       ` H. Peter Anvin
2012-04-03 19:21   ` Colin Walters
2012-04-04  3:01 ` Al Viro
2012-04-04 17:10   ` KOSAKI Motohiro

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=20120430095835.GF51635@netch.kiev.ua \
    --to=netch@netch.kiev.ua \
    --cc=adobriyan@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=drepper@gmail.com \
    --cc=hpa@zytor.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    --cc=viro@zeniv.linux.org.uk \
    /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.