Linux/mipsに於けるsmp_processor_id()の謎
Linuxのsmp_processor_id()がどう実装されているか調べてみた。
include/linux/smp.h
# define smp_processor_id() raw_smp_processor_id()
include/asm-mips/smp.h
#define raw_smp_processor_id() (current_thread_info()->cpu)
include/asm-mips/thread_info.h
/* How to get the thread information struct from C. */ register struct thread_info *__current_thread_info __asm__("$28"); #define current_thread_info() __current_thread_info
と言う訳で、ハードウェアからID番号を貰っているかとおもいきや、$28(gp)にstruct thread_info *を置いといてここから番号を引っ張り出すようだ。