Andi Kleen | 2aae950 | 2007-07-21 17:10:01 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2006 Andi Kleen, SUSE Labs. |
| 3 | * Subject to the GNU Public License, v.2 |
| 4 | * |
| 5 | * Fast user context implementation of getcpu() |
| 6 | */ |
| 7 | |
| 8 | #include <linux/kernel.h> |
| 9 | #include <linux/getcpu.h> |
| 10 | #include <linux/jiffies.h> |
| 11 | #include <linux/time.h> |
| 12 | #include <asm/vsyscall.h> |
| 13 | #include <asm/vgtod.h> |
Andi Kleen | 2aae950 | 2007-07-21 17:10:01 +0200 | [diff] [blame] | 14 | |
Steven Rostedt | 23adec5 | 2008-05-12 21:20:41 +0200 | [diff] [blame] | 15 | notrace long |
| 16 | __vdso_getcpu(unsigned *cpu, unsigned *node, struct getcpu_cache *unused) |
Andi Kleen | 2aae950 | 2007-07-21 17:10:01 +0200 | [diff] [blame] | 17 | { |
Glauber de Oliveira Costa | 8f12dea | 2008-01-30 13:31:06 +0100 | [diff] [blame] | 18 | unsigned int p; |
Andi Kleen | 2aae950 | 2007-07-21 17:10:01 +0200 | [diff] [blame] | 19 | |
Marcelo Tosatti | 51c19b4 | 2012-11-27 23:28:57 -0200 | [diff] [blame] | 20 | p = __getcpu(); |
| 21 | |
Andi Kleen | 2aae950 | 2007-07-21 17:10:01 +0200 | [diff] [blame] | 22 | if (cpu) |
Marcelo Tosatti | 51c19b4 | 2012-11-27 23:28:57 -0200 | [diff] [blame] | 23 | *cpu = p & VGETCPU_CPU_MASK; |
Andi Kleen | 2aae950 | 2007-07-21 17:10:01 +0200 | [diff] [blame] | 24 | if (node) |
| 25 | *node = p >> 12; |
| 26 | return 0; |
| 27 | } |
| 28 | |
| 29 | long getcpu(unsigned *cpu, unsigned *node, struct getcpu_cache *tcache) |
| 30 | __attribute__((weak, alias("__vdso_getcpu"))); |