From: David Laight <David.Laight@ACULAB.COM>
To: 'richard clark' <richard.xnu.clark@gmail.com>,
Linus Torvalds <torvalds@linux-foundation.org>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: RE: Question about select and poll system call
Date: Sat, 18 Mar 2023 12:40:01 +0000 [thread overview]
Message-ID: <7a0033e7db3f4acb9d70b173d063b4d2@AcuMS.aculab.com> (raw)
In-Reply-To: <CAJNi4rO+gdRH4Hsx3gOOBS3m=wiH=uroPh7iJ5QgP1iqvNEd_Q@mail.gmail.com>
> On Fri, Mar 17, 2023 at 2:15 AM Linus Torvalds
> <torvalds@linux-foundation.org> wrote:
> >
...
> > And back then, we had this:
> >
> > typedef unsigned long fd_set;
> >
> > which may seem a bit limiting today ("Only 32 bits??!?"), but to put
> > that in perspective, back then we also had this:
> >
> > #define NR_OPEN 20
That is the historic limit for SYSV (and probably BSD).
I suspect you just copied it.
Quite why it was 20 and not 16 or 32 I don't know.
But 20 open files was assumed to be 'plenty'!
The first SYSV kernel that supported fd >= 20 actually used
a linked list to hold the internal data (mostly a pointer).
So accessing a big fd number was O(fd).
Calling poll() O(numfd**2) and getting that many open sockets
in a network server process O(n**3).
Don't even think about how slowly a process trying to
use 2000 sockets was!
The 20 fd limit also made them a limited resource.
Demons couldn't really afford to dup() /dev/null onto 0, 1 and 2,
instead they'd just close the fd.
An accidental printf() that should have been sprintf() then
slowly fills the stdout buffer, when that eventually fills
the write to fd 1 has side effects that are rather difficult
to debug.
(Someone should have noticed that the tracing was incorrect)
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
prev parent reply other threads:[~2023-03-18 12:41 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-14 2:28 richard clark
2023-03-14 2:31 ` richard clark
2023-03-15 3:31 ` richard clark
2023-03-15 8:59 ` David Laight
2023-03-16 0:56 ` richard clark
2023-03-16 9:34 ` David Laight
2023-03-16 18:15 ` Linus Torvalds
2023-03-17 8:26 ` richard clark
2023-03-18 12:40 ` David Laight [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=7a0033e7db3f4acb9d70b173d063b4d2@AcuMS.aculab.com \
--to=david.laight@aculab.com \
--cc=linux-kernel@vger.kernel.org \
--cc=richard.xnu.clark@gmail.com \
--cc=torvalds@linux-foundation.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
all inboxes | Powered by JetHome®