Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #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 | |
Kyle McMartin | 804f159 | 2006-03-23 03:00:16 -0800 | [diff] [blame] | 16 | #ifndef __read_mostly |
Christoph Lameter | 6c03652 | 2005-07-07 17:56:59 -0700 | [diff] [blame] | 17 | #define __read_mostly |
| 18 | #endif |
| 19 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 20 | #ifndef ____cacheline_aligned |
| 21 | #define ____cacheline_aligned __attribute__((__aligned__(SMP_CACHE_BYTES))) |
| 22 | #endif |
| 23 | |
| 24 | #ifndef ____cacheline_aligned_in_smp |
| 25 | #ifdef CONFIG_SMP |
| 26 | #define ____cacheline_aligned_in_smp ____cacheline_aligned |
| 27 | #else |
| 28 | #define ____cacheline_aligned_in_smp |
| 29 | #endif /* CONFIG_SMP */ |
| 30 | #endif |
| 31 | |
| 32 | #ifndef __cacheline_aligned |
| 33 | #define __cacheline_aligned \ |
| 34 | __attribute__((__aligned__(SMP_CACHE_BYTES), \ |
| 35 | __section__(".data.cacheline_aligned"))) |
| 36 | #endif /* __cacheline_aligned */ |
| 37 | |
| 38 | #ifndef __cacheline_aligned_in_smp |
| 39 | #ifdef CONFIG_SMP |
| 40 | #define __cacheline_aligned_in_smp __cacheline_aligned |
| 41 | #else |
| 42 | #define __cacheline_aligned_in_smp |
| 43 | #endif /* CONFIG_SMP */ |
| 44 | #endif |
| 45 | |
Ravikiran G Thirumalai | 22fc6ec | 2006-01-08 01:01:27 -0800 | [diff] [blame] | 46 | /* |
| 47 | * The maximum alignment needed for some critical structures |
| 48 | * These could be inter-node cacheline sizes/L3 cacheline |
| 49 | * size etc. Define this in asm/cache.h for your arch |
| 50 | */ |
| 51 | #ifndef INTERNODE_CACHE_SHIFT |
| 52 | #define INTERNODE_CACHE_SHIFT L1_CACHE_SHIFT |
| 53 | #endif |
| 54 | |
| 55 | #if !defined(____cacheline_internodealigned_in_smp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 56 | #if defined(CONFIG_SMP) |
Ravikiran G Thirumalai | 22fc6ec | 2006-01-08 01:01:27 -0800 | [diff] [blame] | 57 | #define ____cacheline_internodealigned_in_smp \ |
| 58 | __attribute__((__aligned__(1 << (INTERNODE_CACHE_SHIFT)))) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 | #else |
Ravikiran G Thirumalai | 22fc6ec | 2006-01-08 01:01:27 -0800 | [diff] [blame] | 60 | #define ____cacheline_internodealigned_in_smp |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 61 | #endif |
| 62 | #endif |
| 63 | |
| 64 | #endif /* __LINUX_CACHE_H */ |