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

Warner Losh wlosh at bsdimp.com
Wed Feb 19 17:52:22 UTC 2014


On Feb 18, 2014, at 11:03 AM, Stacey Son wrote:

> Hi all:
> 
> Below are some links to patches that enables the use of the UserLocal Register Implementation (ULRI) for the Thread Local Storage (TLS) pointer.  

I'm loving this. Work was done on this a while ago, but never completed.

> The first code change is for the user level code to use the 'rdhwr $29' instruction to retrieve the TLS pointer instead of using the sysarch(MIPS_GET_TLS,...) system call.  For hardware that supports this instruction this should be much faster since it doesn't require the overhead of a system call.  For hardware that doesn't support this instruction the 'rdhwr $29' instruction is emulated by the trap() handler in sys/mips/mips/trap.c and the overhead should be about the same. (Actually, some quick micro benchmarks indicate that emulating the  'rdhwr' instruction is slightly faster than the sysarch() system call.)  For the patch, see: 
> 
> http://people.freebsd.org/~sson/mips/ulri/ulri_user.diff

These changes look great!

> The next code change probes for the UserLocal Register Implementation (ULRI) and, if found, will enable it (or actually disable it if not found) in the kernel code.  sysarch(MIPS_SET_TLS,...) calls also update the UserLocal register as well. For the patch, see:
> 
> http://people.freebsd.org/~sson/mips/ulri/ulri_kernel.diff

+/* Register numbers */
+#define	_V0	2
+#define	_A1	5
+#define	_T0	12
+#define	_RA	31

We already have defines for these registers elsewhere. Any reason why you chose not to use them? Also, is there any ABI difference to be worried about?
The rest looks generally good, apart from references to git versions that might be difficult to find in the future. Consider moving details inline instead.


> The final patch is for qemu system-mode that adds support for the ULRI:
> 
> http://people.freebsd.org/~sson/mips/ulri/ulri_qemu.diff

Can't say about these...

> For more information about the ULRI see "MIPS Architecture for Programmers Volume III"  section 9.9 UserLocal Register (CP0 Register 4, Select 2).

Thanks for doing this!

Warner

> Best Regards,
> 
> -stacey.
> _______________________________________________
> freebsd-mips at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-mips
> To unsubscribe, send any mail to "freebsd-mips-unsubscribe at freebsd.org"



More information about the freebsd-mips mailing list