Re: Ugh in 2.1.60

Andi Kleen (ak@muc.de)
01 Nov 1997 07:29:24 +0100


hpa@transmeta.com (H. Peter Anvin) writes:

> Followup to: <k2en51uavl.fsf@zero.aec.at>
> By author: Andi Kleen <ak@muc.de>
> In newsgroup: linux.dev.kernel
> >
> > The problem of returning two values in get_user() can be simply solved
> > by using asm wrappers and the same trick that the syscalls use - just
> > set the carry bit on error and fetch the error from another register
> > then.
> >
>
> At least on the i386, syscall errors are handled by returning -errno,
> which means that negative values cannot be legitimately returned.

Ok, you're right - but more traditional Unix implementation used the
carry bit. I personally think that it doesn't matter: real fast path
code will use the inline fast_* or __* versions of the function. 95% of
the user mode accesses are ioctls or other config stuff which isn't
performance critical at all, so it's ok to only optimize for space. I think
even for the fast path code it doesn't matter that much. Coding for modern
CPUs should optimize for less memory accesses instead of less CPU cycles.
The penalty for a L1 cache miss is often 1:10, for a L2 cache miss 1:100
(or 1:1000 on a Alpha)[1] - this means you can do lots of cycles in the time
one cache miss costs. Saving code bloat should be a big priority because
of this.

-Andi

[1] See the recent thread 'Execution in the year 2000' in comp.arch for
more information about this.