vgetcpu.c 572 B

1234567891011121314151617181920212223242526272829
  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. #include <linux/kernel.h>
  8. #include <linux/getcpu.h>
  9. #include <linux/time.h>
  10. #include <asm/vgtod.h>
  11. notrace long
  12. __vdso_getcpu(unsigned *cpu, unsigned *node, struct getcpu_cache *unused)
  13. {
  14. unsigned int p;
  15. p = __getcpu();
  16. if (cpu)
  17. *cpu = p & VGETCPU_CPU_MASK;
  18. if (node)
  19. *node = p >> 12;
  20. return 0;
  21. }
  22. long getcpu(unsigned *cpu, unsigned *node, struct getcpu_cache *tcache)
  23. __attribute__((weak, alias("__vdso_getcpu")));