blob: d22e632f41fb54e096da4822d64cc27749d7dad7 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef __LINUX_CACHE_H
2#define __LINUX_CACHE_H
3
4#include <linux/kernel.h>
5#include <linux/config.h>
6#include <asm/cache.h>
7
8#ifndef L1_CACHE_ALIGN
9#define L1_CACHE_ALIGN(x) ALIGN(x, L1_CACHE_BYTES)
10#endif
11
12#ifndef SMP_CACHE_BYTES
13#define SMP_CACHE_BYTES L1_CACHE_BYTES
14#endif
15
Helge Deller8039de12006-01-10 20:35:03 -050016#if defined(CONFIG_X86) || defined(CONFIG_SPARC64) || defined(CONFIG_IA64) || defined(CONFIG_PARISC)
Christoph Lameter6c036522005-07-07 17:56:59 -070017#define __read_mostly __attribute__((__section__(".data.read_mostly")))
18#else
19#define __read_mostly
20#endif
21
Linus Torvalds1da177e2005-04-16 15:20:36 -070022#ifndef ____cacheline_aligned
23#define ____cacheline_aligned __attribute__((__aligned__(SMP_CACHE_BYTES)))
24#endif
25
26#ifndef ____cacheline_aligned_in_smp
27#ifdef CONFIG_SMP
28#define ____cacheline_aligned_in_smp ____cacheline_aligned
29#else
30#define ____cacheline_aligned_in_smp
31#endif /* CONFIG_SMP */
32#endif
33
34#ifndef __cacheline_aligned
35#define __cacheline_aligned \
36 __attribute__((__aligned__(SMP_CACHE_BYTES), \
37 __section__(".data.cacheline_aligned")))
38#endif /* __cacheline_aligned */
39
40#ifndef __cacheline_aligned_in_smp
41#ifdef CONFIG_SMP
42#define __cacheline_aligned_in_smp __cacheline_aligned
43#else
44#define __cacheline_aligned_in_smp
45#endif /* CONFIG_SMP */
46#endif
47
Ravikiran G Thirumalai22fc6ec2006-01-08 01:01:27 -080048/*
49 * The maximum alignment needed for some critical structures
50 * These could be inter-node cacheline sizes/L3 cacheline
51 * size etc. Define this in asm/cache.h for your arch
52 */
53#ifndef INTERNODE_CACHE_SHIFT
54#define INTERNODE_CACHE_SHIFT L1_CACHE_SHIFT
55#endif
56
57#if !defined(____cacheline_internodealigned_in_smp)
Linus Torvalds1da177e2005-04-16 15:20:36 -070058#if defined(CONFIG_SMP)
Ravikiran G Thirumalai22fc6ec2006-01-08 01:01:27 -080059#define ____cacheline_internodealigned_in_smp \
60 __attribute__((__aligned__(1 << (INTERNODE_CACHE_SHIFT))))
Linus Torvalds1da177e2005-04-16 15:20:36 -070061#else
Ravikiran G Thirumalai22fc6ec2006-01-08 01:01:27 -080062#define ____cacheline_internodealigned_in_smp
Linus Torvalds1da177e2005-04-16 15:20:36 -070063#endif
64#endif
65
66#endif /* __LINUX_CACHE_H */