Look at the end of include/linux/smp.h : smp_processor_id() gives you the number of the current executable CPU. get_cpu() will do the same, and also turn off prevention so that you stay that the processor until put_cpu() is called.
From user space, you can use sched_getcpu() or getcpu() to get the same information.
Gnurou
source share