diff options
| -rw-r--r-- | include/asm-generic/percpu.h | 26 | ||||
| -rw-r--r-- | include/linux/percpu-defs.h | 84 | ||||
| -rw-r--r-- | include/linux/percpu.h | 20 |
3 files changed, 86 insertions, 44 deletions
diff --git a/include/asm-generic/percpu.h b/include/asm-generic/percpu.h index af47b9e10064..d7d50d7ee51e 100644 --- a/include/asm-generic/percpu.h +++ b/include/asm-generic/percpu.h | |||
| @@ -1,13 +1,9 @@ | |||
| 1 | #ifndef _ASM_GENERIC_PERCPU_H_ | 1 | #ifndef _ASM_GENERIC_PERCPU_H_ |
| 2 | #define _ASM_GENERIC_PERCPU_H_ | 2 | #define _ASM_GENERIC_PERCPU_H_ |
| 3 | |||
| 3 | #include <linux/compiler.h> | 4 | #include <linux/compiler.h> |
| 4 | #include <linux/threads.h> | 5 | #include <linux/threads.h> |
| 5 | 6 | #include <linux/percpu-defs.h> | |
| 6 | /* | ||
| 7 | * Determine the real variable name from the name visible in the | ||
| 8 | * kernel sources. | ||
| 9 | */ | ||
| 10 | #define per_cpu_var(var) per_cpu__##var | ||
| 11 | 7 | ||
| 12 | #ifdef CONFIG_SMP | 8 | #ifdef CONFIG_SMP |
| 13 | 9 | ||
| @@ -101,22 +97,4 @@ extern void setup_per_cpu_areas(void); | |||
| 101 | #define PER_CPU_ATTRIBUTES | 97 | #define PER_CPU_ATTRIBUTES |
| 102 | #endif | 98 | #endif |
| 103 | 99 | ||
| 104 | #define DECLARE_PER_CPU_SECTION(type, name, section) \ | ||
| 105 | extern \ | ||
| 106 | __attribute__((__section__(PER_CPU_BASE_SECTION section))) \ | ||
| 107 | PER_CPU_ATTRIBUTES __typeof__(type) per_cpu__##name | ||
| 108 | |||
| 109 | #define DECLARE_PER_CPU(type, name) \ | ||
| 110 | DECLARE_PER_CPU_SECTION(type, name, "") | ||
| 111 | |||
| 112 | #define DECLARE_PER_CPU_SHARED_ALIGNED(type, name) \ | ||
| 113 | DECLARE_PER_CPU_SECTION(type, name, PER_CPU_SHARED_ALIGNED_SECTION) \ | ||
| 114 | ____cacheline_aligned_in_smp | ||
| 115 | |||
| 116 | #define DECLARE_PER_CPU_PAGE_ALIGNED(type, name) \ | ||
| 117 | DECLARE_PER_CPU_SECTION(type, name, ".page_aligned") | ||
| 118 | |||
| 119 | #define DECLARE_PER_CPU_FIRST(type, name) \ | ||
| 120 | DECLARE_PER_CPU_SECTION(type, name, PER_CPU_FIRST_SECTION) | ||
| 121 | |||
| 122 | #endif /* _ASM_GENERIC_PERCPU_H_ */ | 100 | #endif /* _ASM_GENERIC_PERCPU_H_ */ |
diff --git a/include/linux/percpu-defs.h b/include/linux/percpu-defs.h new file mode 100644 index 000000000000..8f921d74f49f --- /dev/null +++ b/include/linux/percpu-defs.h | |||
| @@ -0,0 +1,84 @@ | |||
| 1 | #ifndef _LINUX_PERCPU_DEFS_H | ||
| 2 | #define _LINUX_PERCPU_DEFS_H | ||
| 3 | |||
| 4 | /* | ||
| 5 | * Determine the real variable name from the name visible in the | ||
| 6 | * kernel sources. | ||
| 7 | */ | ||
| 8 | #define per_cpu_var(var) per_cpu__##var | ||
| 9 | |||
| 10 | /* | ||
| 11 | * Base implementations of per-CPU variable declarations and definitions, where | ||
| 12 | * the section in which the variable is to be placed is provided by the | ||
| 13 | * 'section' argument. This may be used to affect the parameters governing the | ||
| 14 | * variable's storage. | ||
| 15 | * | ||
| 16 | * NOTE! The sections for the DECLARE and for the DEFINE must match, lest | ||
| 17 | * linkage errors occur due the compiler generating the wrong code to access | ||
| 18 | * that section. | ||
| 19 | */ | ||
| 20 | #define DECLARE_PER_CPU_SECTION(type, name, section) \ | ||
| 21 | extern \ | ||
| 22 | __attribute__((__section__(PER_CPU_BASE_SECTION section))) \ | ||
| 23 | PER_CPU_ATTRIBUTES __typeof__(type) per_cpu__##name | ||
| 24 | |||
| 25 | #define DEFINE_PER_CPU_SECTION(type, name, section) \ | ||
| 26 | __attribute__((__section__(PER_CPU_BASE_SECTION section))) \ | ||
| 27 | PER_CPU_ATTRIBUTES __typeof__(type) per_cpu__##name | ||
| 28 | |||
| 29 | /* | ||
| 30 | * Variant on the per-CPU variable declaration/definition theme used for | ||
| 31 | * ordinary per-CPU variables. | ||
| 32 | */ | ||
| 33 | #define DECLARE_PER_CPU(type, name) \ | ||
| 34 | DECLARE_PER_CPU_SECTION(type, name, "") | ||
| 35 | |||
| 36 | #define DEFINE_PER_CPU(type, name) \ | ||
| 37 | DEFINE_PER_CPU_SECTION(type, name, "") | ||
| 38 | |||
| 39 | /* | ||
| 40 | * Declaration/definition used for per-CPU variables that must come first in | ||
| 41 | * the set of variables. | ||
| 42 | */ | ||
| 43 | #define DECLARE_PER_CPU_FIRST(type, name) \ | ||
| 44 | DECLARE_PER_CPU_SECTION(type, name, PER_CPU_FIRST_SECTION) | ||
| 45 | |||
| 46 | #define DEFINE_PER_CPU_FIRST(type, name) \ | ||
| 47 | DEFINE_PER_CPU_SECTION(type, name, PER_CPU_FIRST_SECTION) | ||
| 48 | |||
| 49 | /* | ||
| 50 | * Declaration/definition used for per-CPU variables that must be cacheline | ||
| 51 | * aligned under SMP conditions so that, whilst a particular instance of the | ||
| 52 | * data corresponds to a particular CPU, inefficiencies due to direct access by | ||
| 53 | * other CPUs are reduced by preventing the data from unnecessarily spanning | ||
| 54 | * cachelines. | ||
| 55 | * | ||
| 56 | * An example of this would be statistical data, where each CPU's set of data | ||
| 57 | * is updated by that CPU alone, but the data from across all CPUs is collated | ||
| 58 | * by a CPU processing a read from a proc file. | ||
| 59 | */ | ||
| 60 | #define DECLARE_PER_CPU_SHARED_ALIGNED(type, name) \ | ||
| 61 | DECLARE_PER_CPU_SECTION(type, name, PER_CPU_SHARED_ALIGNED_SECTION) \ | ||
| 62 | ____cacheline_aligned_in_smp | ||
| 63 | |||
| 64 | #define DEFINE_PER_CPU_SHARED_ALIGNED(type, name) \ | ||
| 65 | DEFINE_PER_CPU_SECTION(type, name, PER_CPU_SHARED_ALIGNED_SECTION) \ | ||
| 66 | ____cacheline_aligned_in_smp | ||
| 67 | |||
| 68 | /* | ||
| 69 | * Declaration/definition used for per-CPU variables that must be page aligned. | ||
| 70 | */ | ||
| 71 | #define DECLARE_PER_CPU_PAGE_ALIGNED(type, name) \ | ||
| 72 | DECLARE_PER_CPU_SECTION(type, name, ".page_aligned") | ||
| 73 | |||
| 74 | #define DEFINE_PER_CPU_PAGE_ALIGNED(type, name) \ | ||
| 75 | DEFINE_PER_CPU_SECTION(type, name, ".page_aligned") | ||
| 76 | |||
| 77 | /* | ||
| 78 | * Intermodule exports for per-CPU variables. | ||
| 79 | */ | ||
| 80 | #define EXPORT_PER_CPU_SYMBOL(var) EXPORT_SYMBOL(per_cpu__##var) | ||
| 81 | #define EXPORT_PER_CPU_SYMBOL_GPL(var) EXPORT_SYMBOL_GPL(per_cpu__##var) | ||
| 82 | |||
| 83 | |||
| 84 | #endif /* _LINUX_PERCPU_DEFS_H */ | ||
diff --git a/include/linux/percpu.h b/include/linux/percpu.h index f052d8184993..1581ff235c7e 100644 --- a/include/linux/percpu.h +++ b/include/linux/percpu.h | |||
| @@ -9,26 +9,6 @@ | |||
| 9 | 9 | ||
| 10 | #include <asm/percpu.h> | 10 | #include <asm/percpu.h> |
| 11 | 11 | ||
| 12 | #define DEFINE_PER_CPU_SECTION(type, name, section) \ | ||
| 13 | __attribute__((__section__(PER_CPU_BASE_SECTION section))) \ | ||
| 14 | PER_CPU_ATTRIBUTES __typeof__(type) per_cpu__##name | ||
| 15 | |||
| 16 | #define DEFINE_PER_CPU(type, name) \ | ||
| 17 | DEFINE_PER_CPU_SECTION(type, name, "") | ||
| 18 | |||
| 19 | #define DEFINE_PER_CPU_SHARED_ALIGNED(type, name) \ | ||
| 20 | DEFINE_PER_CPU_SECTION(type, name, PER_CPU_SHARED_ALIGNED_SECTION) \ | ||
| 21 | ____cacheline_aligned_in_smp | ||
| 22 | |||
| 23 | #define DEFINE_PER_CPU_PAGE_ALIGNED(type, name) \ | ||
| 24 | DEFINE_PER_CPU_SECTION(type, name, ".page_aligned") | ||
| 25 | |||
| 26 | #define DEFINE_PER_CPU_FIRST(type, name) \ | ||
| 27 | DEFINE_PER_CPU_SECTION(type, name, PER_CPU_FIRST_SECTION) | ||
| 28 | |||
| 29 | #define EXPORT_PER_CPU_SYMBOL(var) EXPORT_SYMBOL(per_cpu__##var) | ||
| 30 | #define EXPORT_PER_CPU_SYMBOL_GPL(var) EXPORT_SYMBOL_GPL(per_cpu__##var) | ||
| 31 | |||
| 32 | /* enough to cover all DEFINE_PER_CPUs in modules */ | 12 | /* enough to cover all DEFINE_PER_CPUs in modules */ |
| 33 | #ifdef CONFIG_MODULES | 13 | #ifdef CONFIG_MODULES |
| 34 | #define PERCPU_MODULE_RESERVE (8 << 10) | 14 | #define PERCPU_MODULE_RESERVE (8 << 10) |
