1 #ifndef __LINUX_CACHE_H
2 #define __LINUX_CACHE_H
4 #include <uapi/linux/kernel.h>
8 #define L1_CACHE_ALIGN(x) __ALIGN_KERNEL(x, L1_CACHE_BYTES)
11 #ifndef SMP_CACHE_BYTES
12 #define SMP_CACHE_BYTES L1_CACHE_BYTES
16 * __read_mostly is used to keep rarely changing variables out of frequently
17 * updated cachelines. If an architecture doesn't support it, ignore the
25 * __ro_after_init is used to mark things that are read-only after init (i.e.
26 * after mark_rodata_ro() has been called). These are effectively read-only,
27 * but may get written to during init, so can't live in .rodata (via "const").
29 #ifndef __ro_after_init
30 #define __ro_after_init __attribute__((__section__(".data..ro_after_init")))
33 #ifndef ____cacheline_aligned
34 #define ____cacheline_aligned __attribute__((__aligned__(SMP_CACHE_BYTES)))
37 #ifndef ____cacheline_aligned_in_smp
39 #define ____cacheline_aligned_in_smp ____cacheline_aligned
41 #define ____cacheline_aligned_in_smp
42 #endif /* CONFIG_SMP */
45 #ifndef __cacheline_aligned
46 #define __cacheline_aligned \
47 __attribute__((__aligned__(SMP_CACHE_BYTES), \
48 __section__(".data..cacheline_aligned")))
49 #endif /* __cacheline_aligned */
51 #ifndef __cacheline_aligned_in_smp
53 #define __cacheline_aligned_in_smp __cacheline_aligned
55 #define __cacheline_aligned_in_smp
56 #endif /* CONFIG_SMP */
60 * The maximum alignment needed for some critical structures
61 * These could be inter-node cacheline sizes/L3 cacheline
62 * size etc. Define this in asm/cache.h for your arch
64 #ifndef INTERNODE_CACHE_SHIFT
65 #define INTERNODE_CACHE_SHIFT L1_CACHE_SHIFT
68 #if !defined(____cacheline_internodealigned_in_smp)
69 #if defined(CONFIG_SMP)
70 #define ____cacheline_internodealigned_in_smp \
71 __attribute__((__aligned__(1 << (INTERNODE_CACHE_SHIFT))))
73 #define ____cacheline_internodealigned_in_smp
77 #ifndef CONFIG_ARCH_HAS_CACHE_LINE_SIZE
78 #define cache_line_size() L1_CACHE_BYTES
81 #endif /* __LINUX_CACHE_H */