> Thinking about SMP, both CURCPU() and curlwp could be the register - with the > other being indirected from it. I wonder which it used most? > curproc should be readable from either.
Some MIPS CPUs have "OS Scratch" registers. I use one to store curcpu since that is the one most useful in the exception handler. I just made the changes so that PowerPC kernels will keep curlwp in %r13 (I choose r13 over r2 because r2 is used for TOC in the PPC64 ABI). It has allowed me to remove several loads of curlwp in the assembly code let alone how many references in C code. text data bss dec hex filename 6652040 3805600 212056 10669696 a2ce80 before 6642116 3805600 212056 10659772 a2a7bc after That's nearly a reduction of 64KB. The loading of %r13 with curlwp is free since in all cases, curlwp would have eventually been loaded into a register at some point.