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

Stacey Son sson at FreeBSD.org
Tue Feb 18 18:03:50 UTC 2014


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.  

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

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

The final patch is for qemu system-mode that adds support for the ULRI:

http://people.freebsd.org/~sson/mips/ulri/ulri_qemu.diff

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

Best Regards,

-stacey.


More information about the freebsd-mips mailing list