On Jun 3, 2011, at 12:45 AM, Martin Husemann wrote: > On Thu, Jun 02, 2011 at 09:21:11PM +0100, David Laight wrote: >> 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. > > I wonder on what archs we would be able to do the MIPS curlwp optimization > (place curlwp in a reserved register). > > Sparc64 and sparc will likely follow this in the near future (needs some audit > and will do some benchmarks first; it closely resembles TLS for userland). > > What's the cost on other archs and what optimizations are possible?
I thought about for PPC. Could even use the same register (%r2) for it. curcpu is already fairly cheap to get (mfsprg0). on 85xx, I also store curlwp in sprg2. Haven't modified the kernel to fetch it from there yet. Regardless, on mpc85xx (booke) I could easily add a mfsprg2 %r2 in the exception prologues. Putting curlwp in %r2 on context switch would almost be free. Neither arm or vax (or probably m68k) have enough registers to make the dedicated register method practical.