~ubuntu-branches/ubuntu/precise/linux-lowlatency/precise

« back to all changes in this revision

Viewing changes to arch/x86/vdso/vgetcpu.c

  • Committer: Package Import Robot
  • Author(s): Alessio Igor Bogani
  • Date: 2011-10-26 11:13:05 UTC
  • Revision ID: package-import@ubuntu.com-20111026111305-tz023xykf0i6eosh
Tags: upstream-3.2.0
ImportĀ upstreamĀ versionĀ 3.2.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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>
 
14
 
 
15
notrace long
 
16
__vdso_getcpu(unsigned *cpu, unsigned *node, struct getcpu_cache *unused)
 
17
{
 
18
        unsigned int p;
 
19
 
 
20
        if (VVAR(vgetcpu_mode) == VGETCPU_RDTSCP) {
 
21
                /* Load per CPU data from RDTSCP */
 
22
                native_read_tscp(&p);
 
23
        } else {
 
24
                /* Load per CPU data from GDT */
 
25
                asm("lsl %1,%0" : "=r" (p) : "r" (__PER_CPU_SEG));
 
26
        }
 
27
        if (cpu)
 
28
                *cpu = p & 0xfff;
 
29
        if (node)
 
30
                *node = p >> 12;
 
31
        return 0;
 
32
}
 
33
 
 
34
long getcpu(unsigned *cpu, unsigned *node, struct getcpu_cache *tcache)
 
35
        __attribute__((weak, alias("__vdso_getcpu")));