blob: 2f94b039e55b6c2da8f40616af7445e0f8454a27 [file] [log] [blame]
Andi Kleen2aae9502007-07-21 17:10:01 +02001/*
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 Kleen2aae9502007-07-21 17:10:01 +020014
Steven Rostedt23adec52008-05-12 21:20:41 +020015notrace long
16__vdso_getcpu(unsigned *cpu, unsigned *node, struct getcpu_cache *unused)
Andi Kleen2aae9502007-07-21 17:10:01 +020017{
Glauber de Oliveira Costa8f12dea2008-01-30 13:31:06 +010018 unsigned int p;
Andi Kleen2aae9502007-07-21 17:10:01 +020019
Marcelo Tosatti51c19b42012-11-27 23:28:57 -020020 p = __getcpu();
21
Andi Kleen2aae9502007-07-21 17:10:01 +020022 if (cpu)
Marcelo Tosatti51c19b42012-11-27 23:28:57 -020023 *cpu = p & VGETCPU_CPU_MASK;
Andi Kleen2aae9502007-07-21 17:10:01 +020024 if (node)
25 *node = p >> 12;
26 return 0;
27}
28
29long getcpu(unsigned *cpu, unsigned *node, struct getcpu_cache *tcache)
30 __attribute__((weak, alias("__vdso_getcpu")));