percpu.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #ifndef _ASM_IA64_PERCPU_H
  2. #define _ASM_IA64_PERCPU_H
  3. /*
  4. * Copyright (C) 2002-2003 Hewlett-Packard Co
  5. * David Mosberger-Tang <davidm@hpl.hp.com>
  6. */
  7. #define PERCPU_ENOUGH_ROOM PERCPU_PAGE_SIZE
  8. #ifdef __ASSEMBLY__
  9. # define THIS_CPU(var) (per_cpu__##var) /* use this to mark accesses to per-CPU variables... */
  10. #else /* !__ASSEMBLY__ */
  11. #include <linux/config.h>
  12. #include <linux/threads.h>
  13. #ifdef HAVE_MODEL_SMALL_ATTRIBUTE
  14. # define __SMALL_ADDR_AREA __attribute__((__model__ (__small__)))
  15. #else
  16. # define __SMALL_ADDR_AREA
  17. #endif
  18. #define DECLARE_PER_CPU(type, name) \
  19. extern __SMALL_ADDR_AREA __typeof__(type) per_cpu__##name
  20. /* Separate out the type, so (int[3], foo) works. */
  21. #define DEFINE_PER_CPU(type, name) \
  22. __attribute__((__section__(".data.percpu"))) \
  23. __SMALL_ADDR_AREA __typeof__(type) per_cpu__##name
  24. /*
  25. * Pretty much a literal copy of asm-generic/percpu.h, except that percpu_modcopy() is an
  26. * external routine, to avoid include-hell.
  27. */
  28. #ifdef CONFIG_SMP
  29. extern unsigned long __per_cpu_offset[NR_CPUS];
  30. /* Equal to __per_cpu_offset[smp_processor_id()], but faster to access: */
  31. DECLARE_PER_CPU(unsigned long, local_per_cpu_offset);
  32. #define per_cpu(var, cpu) (*RELOC_HIDE(&per_cpu__##var, __per_cpu_offset[cpu]))
  33. #define __get_cpu_var(var) (*RELOC_HIDE(&per_cpu__##var, __ia64_per_cpu_var(local_per_cpu_offset)))
  34. extern void percpu_modcopy(void *pcpudst, const void *src, unsigned long size);
  35. extern void setup_per_cpu_areas (void);
  36. extern void *per_cpu_init(void);
  37. #else /* ! SMP */
  38. #define per_cpu(var, cpu) (*((void)(cpu), &per_cpu__##var))
  39. #define __get_cpu_var(var) per_cpu__##var
  40. #define per_cpu_init() (__phys_per_cpu_start)
  41. #endif /* SMP */
  42. #define EXPORT_PER_CPU_SYMBOL(var) EXPORT_SYMBOL(per_cpu__##var)
  43. #define EXPORT_PER_CPU_SYMBOL_GPL(var) EXPORT_SYMBOL_GPL(per_cpu__##var)
  44. /*
  45. * Be extremely careful when taking the address of this variable! Due to virtual
  46. * remapping, it is different from the canonical address returned by __get_cpu_var(var)!
  47. * On the positive side, using __ia64_per_cpu_var() instead of __get_cpu_var() is slightly
  48. * more efficient.
  49. */
  50. #define __ia64_per_cpu_var(var) (per_cpu__##var)
  51. #endif /* !__ASSEMBLY__ */
  52. #endif /* _ASM_IA64_PERCPU_H */