powerpc: Add VDSO version of getcpu
authorAnton Blanchard <anton@samba.org>
Wed, 4 Jul 2012 20:37:11 +0000 (20:37 +0000)
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>
Wed, 11 Jul 2012 04:18:40 +0000 (14:18 +1000)
commit18ad51dd342a7eb09dbcd059d0b451b616d4dafc
tree94809605669eb3b5e4e049501958a2fa93ae2de7
parente6a74c6ea331b79c86e1898c504790b3dadc591d
powerpc: Add VDSO version of getcpu

We have a request for a fast method of getting CPU and NUMA node IDs
from userspace. This patch implements a getcpu VDSO function,
similar to x86.

Ben suggested we use SPRG3 which is userspace readable. SPRG3 can be
modified by a KVM guest, so we save the SPRG3 value in the paca and
restore it when transitioning from the guest to the host.

I have a glibc patch that implements sched_getcpu on top of this.
Testing on a POWER7:

baseline: 538 cycles
vdso:      30 cycles

Signed-off-by: Anton Blanchard <anton@samba.org>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
13 files changed:
arch/powerpc/include/asm/kvm_book3s_asm.h
arch/powerpc/include/asm/reg.h
arch/powerpc/include/asm/vdso.h
arch/powerpc/kernel/asm-offsets.c
arch/powerpc/kernel/smp.c
arch/powerpc/kernel/vdso.c
arch/powerpc/kernel/vdso32/Makefile
arch/powerpc/kernel/vdso32/getcpu.S [new file with mode: 0644]
arch/powerpc/kernel/vdso32/vdso32.lds.S
arch/powerpc/kernel/vdso64/Makefile
arch/powerpc/kernel/vdso64/getcpu.S [new file with mode: 0644]
arch/powerpc/kernel/vdso64/vdso64.lds.S
arch/powerpc/kvm/book3s_hv_rmhandlers.S