From: Linus Torvalds <torvalds@linux-foundation.org>
To: "H. Peter Anvin" <hpa@zytor.com>
Cc: Ulrich Drepper <drepper@redhat.com>,
David Miller <davem@davemloft.net>,
linux-kernel@vger.kernel.org, akpm@linux-foundation.org,
mingo@elte.hu, tglx@linutronix.de
Subject: Re: [PATCHv4 5/6] Allow setting O_NONBLOCK flag for new sockets
Date: Mon, 26 Nov 2007 18:14:40 -0800 (PST) [thread overview]
Message-ID: <alpine.LFD.0.9999.0711261801390.5869@woody.linux-foundation.org> (raw)
In-Reply-To: <474B1C6D.6080405@zytor.com>
On Mon, 26 Nov 2007, H. Peter Anvin wrote:
>
> I'm presuming you're not talking about some sort of syslets/fibrils/threadlets
> here (executing an interpreted thread of execution in kernel space). That's a
> whole separate ball of wax.
Indeed.
I'm hoping that just dies. It's too complex. But the "do this single
system call asynchronously" isn't, and has lots of historical
implementations, ranging from VMS to the braindead POSIX "aio" setup.
I do think that more complex threadlets could be useful in theory, I just
doubt they'd be used in practice..
> > So the choice is basically one of:
> >
> > - come up with a totally new interface to system calls, and effectively
> > duplicating the whole system call table.
> >
> > I'd hate to do this. We already have duplicated system call tables due
> > to compat stuff, it's painful.
>
> This would be the right thing to do if we were to redesign the system call
> interface from the ground up, which it doesn't exactly sound like we are
> intending.
Yeah. I'm also not sure it's the right thing even if we did redesign from
scratch.
The current system call interface may look less than regular, but it has
some very solid foundation: it's fast. Passing arguments in registers is
by definition a lot faster *and*safer* than passing them any other way.
There are no subtle security issues with people playing games with the
argument base pointer (ie usually the stack pointer) and trying to fool
the kernel into accessing kernel memory etc.
Immediately when you do anything but registers, it is much *much* more
costly. The "get_user()" and "copy_from_user()" stuff is not exactly slow,
but it's quite noticeable overhead for simple system calls. It gets worse
if this all is described by some indirect table setup.
In the system call path, right now, for some system calls, the biggest two
overheads are
- the CPU system call overhead itself. We can't do much about this, but
the CPU designers do seem to be slowly getting it fixed (ie it's slower
than it should need to be, but it's a hell of a lot faster than a P4
used to be ;)
- the cost of just the single indirect - and unpredictable - call.
(The second cost is actually often totally hidden in the trivial system
call benchmarks people run: if the benchmark just does "getppid()" a
million times in a tight loop, the indirect call on the system call number
seems really quite fast, but outside of benchmarks it is generally totally
unpredictable indeed, and a real cost for real-life system call usage).
Everything else in the system call path is generally as fast as we can
make it. Doing more indirection and conditionals would be really quite
nasty.
Of course, for *most* of system calls, the work the kernel actually does
ends up being so big that it doesn't much matter, but I was literally
chasing down why a page fault had slowed down by ~70 cycles two weeks ago.
And it doesn't take more than a couple of unpredictable jumps to do things
like that!
> The 6-word limit is a red herring. There is at least two ways to deal with it
> (and this doesn't mean wiping the legacy stuff we already have):
>
> - Let each architecture pick a calling convention and redefine the
> architecture-independent bits to take an arbitrary number of arguments. This
> is a one-time panarchitectural change.
Not applicable on x86-32.
The six-word limit is effectively a hardware limit there. Once it goes
past that limit, one of the words needs to be a pointer to extended
information that is fundamentally slower to access. Happily, only very
rare system calls do that (and none of them are of the simple variety
where we see a few cycles easily).
On other architectures, we could more easily just use more registers. But
x86-32 is still a big part (bulk) of what matters for most people.
Linus
next prev parent reply other threads:[~2007-11-27 2:15 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-20 6:53 Ulrich Drepper
2007-11-20 7:59 ` David Miller
2007-11-20 16:04 ` Ulrich Drepper
2007-11-20 18:13 ` H. Peter Anvin
2007-11-20 18:24 ` Zach Brown
2007-11-20 19:12 ` H. Peter Anvin
2007-11-20 22:22 ` Ingo Molnar
2007-11-20 22:33 ` Davide Libenzi
2007-11-20 22:42 ` Ingo Molnar
2007-11-20 23:25 ` H. Peter Anvin
2007-11-20 23:41 ` Ingo Molnar
2007-11-20 23:57 ` H. Peter Anvin
2007-11-26 18:17 ` Linus Torvalds
2007-11-26 18:45 ` Ingo Molnar
2007-11-26 19:07 ` H. Peter Anvin
2007-11-26 19:55 ` Davide Libenzi
2007-11-26 19:20 ` H. Peter Anvin
2007-11-26 23:25 ` Ulrich Drepper
2007-11-27 0:14 ` H. Peter Anvin
2007-11-27 0:42 ` Ulrich Drepper
2007-11-27 1:23 ` H. Peter Anvin
2007-11-27 2:14 ` Linus Torvalds [this message]
2007-11-27 2:38 ` H. Peter Anvin
2007-11-20 21:48 ` David Miller
2007-11-20 21:55 ` Zach Brown
2007-11-20 22:36 ` David Miller
2007-11-20 17:54 ` Zach Brown
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=alpine.LFD.0.9999.0711261801390.5869@woody.linux-foundation.org \
--to=torvalds@linux-foundation.org \
--cc=akpm@linux-foundation.org \
--cc=davem@davemloft.net \
--cc=drepper@redhat.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=tglx@linutronix.de \
/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®