cache.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #ifndef __LINUX_CACHE_H
  2. #define __LINUX_CACHE_H
  3. #include <uapi/linux/kernel.h>
  4. #include <asm/cache.h>
  5. #ifndef L1_CACHE_ALIGN
  6. #define L1_CACHE_ALIGN(x) __ALIGN_KERNEL(x, L1_CACHE_BYTES)
  7. #endif
  8. #ifndef SMP_CACHE_BYTES
  9. #define SMP_CACHE_BYTES L1_CACHE_BYTES
  10. #endif
  11. #ifndef __read_mostly
  12. #define __read_mostly
  13. #endif
  14. #ifndef ____cacheline_aligned
  15. #define ____cacheline_aligned __attribute__((__aligned__(SMP_CACHE_BYTES)))
  16. #endif
  17. #ifndef ____cacheline_aligned_in_smp
  18. #ifdef CONFIG_SMP
  19. #define ____cacheline_aligned_in_smp ____cacheline_aligned
  20. #else
  21. #define ____cacheline_aligned_in_smp
  22. #endif /* CONFIG_SMP */
  23. #endif
  24. #ifndef __cacheline_aligned
  25. #define __cacheline_aligned \
  26. __attribute__((__aligned__(SMP_CACHE_BYTES), \
  27. __section__(".data..cacheline_aligned")))
  28. #endif /* __cacheline_aligned */
  29. #ifndef __cacheline_aligned_in_smp
  30. #ifdef CONFIG_SMP
  31. #define __cacheline_aligned_in_smp __cacheline_aligned
  32. #else
  33. #define __cacheline_aligned_in_smp
  34. #endif /* CONFIG_SMP */
  35. #endif
  36. /*
  37. * The maximum alignment needed for some critical structures
  38. * These could be inter-node cacheline sizes/L3 cacheline
  39. * size etc. Define this in asm/cache.h for your arch
  40. */
  41. #ifndef INTERNODE_CACHE_SHIFT
  42. #define INTERNODE_CACHE_SHIFT L1_CACHE_SHIFT
  43. #endif
  44. #if !defined(____cacheline_internodealigned_in_smp)
  45. #if defined(CONFIG_SMP)
  46. #define ____cacheline_internodealigned_in_smp \
  47. __attribute__((__aligned__(1 << (INTERNODE_CACHE_SHIFT))))
  48. #else
  49. #define ____cacheline_internodealigned_in_smp
  50. #endif
  51. #endif
  52. #ifndef CONFIG_ARCH_HAS_CACHE_LINE_SIZE
  53. #define cache_line_size() L1_CACHE_BYTES
  54. #endif
  55. #endif /* __LINUX_CACHE_H */