Re: CVS commit: src/sys/kern

2011-06-05 Thread David Holland
On Thu, Jun 02, 2011 at 09:21:11PM +0100, David Laight wrote:
 > Actually I've thought about this some more.
 > While, on the face of it, removing the 'struct lwp *' parameter to
 > all system calls might seem an optimisation, I suspect that,
 > especially on systems where arguments are passed in registers, it
 > is a pessimisation.

I doubt it. It's not actually particularly useful to pass around
curlwp unless you pass it around *everywhere*.

Meanwhile, on systems where arguments are passed in registers, at
least in theory if you don't need to insert curlwp and shift all the
other arguments over by one, you can avoid rearranging the arguments
at all in the syscall trap handler.

 > Recovering curlwp may involve a function call, and is, at best, a real
 > memory access of global data (possibly via an asm statement) that will
 > be slow and multiple accesses might need caching in a local anyway.

Not really.

We've been steadily removing the 4.4-era code for passing curproc/
curlwp around ever since we started adding real multiprocessor
support. It was added in the first place based on the belief that
retrieving curproc would be expensive in a multiprocessor world, but
this turns out not to be true. There's too much crap that accesses it,
so it's necessary to put a scheme in place to make it fast.

-- 
David A. Holland
dholl...@netbsd.org


Re: CVS commit: src/sys/kern

2011-06-05 Thread Matt Thomas

On Jun 5, 2011, at 9:58 AM, Warner Losh wrote:

> 
> On Jun 5, 2011, at 2:15 AM, Joerg Sonnenberger wrote:
> 
>> On Sat, Jun 04, 2011 at 02:47:53PM +0100, David Laight wrote:
>>> IIRC the arm ABI defines standard uses for a lot of the registers, one must 
>>> be for
>>> thread data - so could be used in the kernel for curlwp.
>> 
>> Only for newer ARM generations. The old one have no native TLS register.
> 
> That's ARMv5e and newer, right?

No, armv6 and latter.  And not all armv6 have them.  There is code in place to 
use them but none of the arm11s i have ever supported them.  I suppose armv7 
(cortex) should have them.

Re: CVS commit: src/sys/kern

2011-06-05 Thread Warner Losh

On Jun 5, 2011, at 2:15 AM, Joerg Sonnenberger wrote:

> On Sat, Jun 04, 2011 at 02:47:53PM +0100, David Laight wrote:
>> IIRC the arm ABI defines standard uses for a lot of the registers, one must 
>> be for
>> thread data - so could be used in the kernel for curlwp.
> 
> Only for newer ARM generations. The old one have no native TLS register.

That's ARMv5e and newer, right?

Warner

Re: CVS commit: src/sys/kern

2011-06-05 Thread David Laight
On Thu, Jun 02, 2011 at 09:21:11PM +0100, David Laight wrote:
> On Thu, Jun 02, 2011 at 06:54:44PM +, David Laight wrote:
> > Module Name:src
> > Committed By:   dsl
> > Date:   Thu Jun  2 18:54:44 UTC 2011
> > 
> > Modified Files:
> > src/sys/kern: vfs_syscalls.c
> > 
> > Log Message:
> > Fix type in comment
> > (before I replace the 'l' with 'curlwp')
> 
> Actually I've thought about this some more.
> While, on the face of it, removing the 'struct lwp *' parameter to all system
> calls might seem an optimisation, I suspect that, especially on systems where
> arguments are passed in registers, it is a pessimisation.
> 
> Passing 'l' is a register rename (or copy) so is almost zero cost.
> 
> Recovering curlwp may involve a function call, and is, at best, a real
> memory access of global data (possibly via an asm statement) that will
> be slow and multiple accesses might need caching in a local anyway.

Well, an amd64 GENERIC kernel grows by 1.5k, and I've given up trying to get
an i386 MONOLITHIC to compile - too much crap in compat.

David

-- 
David Laight: da...@l8s.co.uk


Re: CVS commit: src/sys/kern

2011-06-05 Thread Joerg Sonnenberger
On Sun, Jun 05, 2011 at 10:42:30AM +0200, Martin Husemann wrote:
> On Sun, Jun 05, 2011 at 10:15:45AM +0200, Joerg Sonnenberger wrote:
> > Only for newer ARM generations. The old one have no native TLS register.
> 
> Should we have a userland build option to make use of that?

It might be useful, but the standard TLS ABI for ARM requires a call
anyway (see patches I dropped to port-arm a bit ago), so ld.elf_so can
provide the optimal runtime code.

Joerg


Re: CVS commit: src/sys/kern

2011-06-05 Thread Martin Husemann
On Sun, Jun 05, 2011 at 10:15:45AM +0200, Joerg Sonnenberger wrote:
> Only for newer ARM generations. The old one have no native TLS register.

Should we have a userland build option to make use of that?

Martin


Re: CVS commit: src/sys/kern

2011-06-05 Thread Joerg Sonnenberger
On Sat, Jun 04, 2011 at 02:47:53PM +0100, David Laight wrote:
> IIRC the arm ABI defines standard uses for a lot of the registers, one must 
> be for
> thread data - so could be used in the kernel for curlwp.

Only for newer ARM generations. The old one have no native TLS register.

Joerg