[RFC] Enable use of UserLocal Register (ULRI) if detected (patches)

Robert Watson rwatson at FreeBSD.org
Mon Feb 24 18:02:22 UTC 2014


On Wed, 19 Feb 2014, Warner Losh wrote:

>> I would note, BTW, that the current use of TLS in malloc()/free() and 
>> today's MIPS exception handler for TLS implementation do introduce a very 
>> measurable overhead.  I'm left wondering if there is something we can do 
>> for unthreaded processes to avoid taking kernel traps on every memory 
>> allocation and free for MIPSes without ULRI.  (Note that that problem is 
>> present before Stacey's patch: the reason we added ULRI support is that our 
>> hardware does support ULRI, and we can therefore avoid that nasty overhead 
>> ...)  I understand there's work on a new MIPS ABI that specifies a TLS 
>> register not requiring a trap to read on non-ULRI hardware, but I'm not 
>> sure how far that is from being available.  Certainly it will require 
>> compiler/OS/etc work before it becomes useful to us.
>
> One could easily have a global, static TLS value that gets set at startup, 
> and cleared when the first thread is forked. The gettls calls then become 
> something akin to
>
> if (global_tls) return global_tls; else return _get_tls();
>
> without changes to the ABI at all...

Our measurements suggest that the overhead of instruction emulation here is a 
significant overhead due to per-malloc/free costs in userspace.  However, our 
platform is a CPU-poor compared to memory speed due to being FPGA-based 
research processor, so it might be a less significant factor on conventional 
silicon.  It might be interesting for someone developing on a more 
conventional system to do a quick but casual experiment and see if it might 
make a difference.

Robert


More information about the freebsd-mips mailing list