diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2010-03-03 10:34:18 -0500 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-03-03 10:34:18 -0500 |
| commit | 0a135ba14d71fb84c691a5386aff5049691fe6d7 (patch) | |
| tree | adb1de887dd6839d69d2fc16ffa2a10ff63298fa /include/linux | |
| parent | 4850f524b2c4c8a4e9f8ef4dd9c7c4afde2f2b2c (diff) | |
| parent | a29d8b8e2d811a24bbe49215a0f0c536b72ebc18 (diff) | |
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/percpu
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/percpu:
percpu: add __percpu sparse annotations to what's left
percpu: add __percpu sparse annotations to fs
percpu: add __percpu sparse annotations to core kernel subsystems
local_t: Remove leftover local.h
this_cpu: Remove pageset_notifier
this_cpu: Page allocator conversion
percpu, x86: Generic inc / dec percpu instructions
local_t: Move local.h include to ringbuffer.c and ring_buffer_benchmark.c
module: Use this_cpu_xx to dynamically allocate counters
local_t: Remove cpu_local_xx macros
percpu: refactor the code in pcpu_[de]populate_chunk()
percpu: remove compile warnings caused by __verify_pcpu_ptr()
percpu: make accessors check for percpu pointer in sparse
percpu: add __percpu for sparse.
percpu: make access macros universal
percpu: remove per_cpu__ prefix.
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/blktrace_api.h | 4 | ||||
| -rw-r--r-- | include/linux/compiler.h | 2 | ||||
| -rw-r--r-- | include/linux/dmaengine.h | 2 | ||||
| -rw-r--r-- | include/linux/genhd.h | 2 | ||||
| -rw-r--r-- | include/linux/kexec.h | 2 | ||||
| -rw-r--r-- | include/linux/mm.h | 4 | ||||
| -rw-r--r-- | include/linux/mmzone.h | 12 | ||||
| -rw-r--r-- | include/linux/module.h | 37 | ||||
| -rw-r--r-- | include/linux/mount.h | 2 | ||||
| -rw-r--r-- | include/linux/nfs_fs_sb.h | 2 | ||||
| -rw-r--r-- | include/linux/percpu-defs.h | 40 | ||||
| -rw-r--r-- | include/linux/percpu.h | 44 | ||||
| -rw-r--r-- | include/linux/percpu_counter.h | 2 | ||||
| -rw-r--r-- | include/linux/srcu.h | 2 | ||||
| -rw-r--r-- | include/linux/vmstat.h | 8 |
15 files changed, 82 insertions, 83 deletions
diff --git a/include/linux/blktrace_api.h b/include/linux/blktrace_api.h index 3b73b9992b2..416bf62d6d4 100644 --- a/include/linux/blktrace_api.h +++ b/include/linux/blktrace_api.h | |||
| @@ -150,8 +150,8 @@ struct blk_user_trace_setup { | |||
| 150 | struct blk_trace { | 150 | struct blk_trace { |
| 151 | int trace_state; | 151 | int trace_state; |
| 152 | struct rchan *rchan; | 152 | struct rchan *rchan; |
| 153 | unsigned long *sequence; | 153 | unsigned long __percpu *sequence; |
| 154 | unsigned char *msg_data; | 154 | unsigned char __percpu *msg_data; |
| 155 | u16 act_mask; | 155 | u16 act_mask; |
| 156 | u64 start_lba; | 156 | u64 start_lba; |
| 157 | u64 end_lba; | 157 | u64 end_lba; |
diff --git a/include/linux/compiler.h b/include/linux/compiler.h index 188fcae10a9..a5a472b1074 100644 --- a/include/linux/compiler.h +++ b/include/linux/compiler.h | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | 5 | ||
| 6 | #ifdef __CHECKER__ | 6 | #ifdef __CHECKER__ |
| 7 | # define __user __attribute__((noderef, address_space(1))) | 7 | # define __user __attribute__((noderef, address_space(1))) |
| 8 | # define __kernel /* default address space */ | 8 | # define __kernel __attribute__((address_space(0))) |
| 9 | # define __safe __attribute__((safe)) | 9 | # define __safe __attribute__((safe)) |
| 10 | # define __force __attribute__((force)) | 10 | # define __force __attribute__((force)) |
| 11 | # define __nocast __attribute__((nocast)) | 11 | # define __nocast __attribute__((nocast)) |
diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h index 78784982b33..21fd9b7c6a4 100644 --- a/include/linux/dmaengine.h +++ b/include/linux/dmaengine.h | |||
| @@ -162,7 +162,7 @@ struct dma_chan { | |||
| 162 | struct dma_chan_dev *dev; | 162 | struct dma_chan_dev *dev; |
| 163 | 163 | ||
| 164 | struct list_head device_node; | 164 | struct list_head device_node; |
| 165 | struct dma_chan_percpu *local; | 165 | struct dma_chan_percpu __percpu *local; |
| 166 | int client_count; | 166 | int client_count; |
| 167 | int table_count; | 167 | int table_count; |
| 168 | void *private; | 168 | void *private; |
diff --git a/include/linux/genhd.h b/include/linux/genhd.h index 9717081c75a..56b50514ab2 100644 --- a/include/linux/genhd.h +++ b/include/linux/genhd.h | |||
| @@ -101,7 +101,7 @@ struct hd_struct { | |||
| 101 | unsigned long stamp; | 101 | unsigned long stamp; |
| 102 | int in_flight[2]; | 102 | int in_flight[2]; |
| 103 | #ifdef CONFIG_SMP | 103 | #ifdef CONFIG_SMP |
| 104 | struct disk_stats *dkstats; | 104 | struct disk_stats __percpu *dkstats; |
| 105 | #else | 105 | #else |
| 106 | struct disk_stats dkstats; | 106 | struct disk_stats dkstats; |
| 107 | #endif | 107 | #endif |
diff --git a/include/linux/kexec.h b/include/linux/kexec.h index c356b6914ff..03e8e8dbc57 100644 --- a/include/linux/kexec.h +++ b/include/linux/kexec.h | |||
| @@ -199,7 +199,7 @@ extern struct kimage *kexec_crash_image; | |||
| 199 | */ | 199 | */ |
| 200 | extern struct resource crashk_res; | 200 | extern struct resource crashk_res; |
| 201 | typedef u32 note_buf_t[KEXEC_NOTE_BYTES/4]; | 201 | typedef u32 note_buf_t[KEXEC_NOTE_BYTES/4]; |
| 202 | extern note_buf_t *crash_notes; | 202 | extern note_buf_t __percpu *crash_notes; |
| 203 | extern u32 vmcoreinfo_note[VMCOREINFO_NOTE_SIZE/4]; | 203 | extern u32 vmcoreinfo_note[VMCOREINFO_NOTE_SIZE/4]; |
| 204 | extern size_t vmcoreinfo_size; | 204 | extern size_t vmcoreinfo_size; |
| 205 | extern size_t vmcoreinfo_max_size; | 205 | extern size_t vmcoreinfo_max_size; |
diff --git a/include/linux/mm.h b/include/linux/mm.h index 8b2fa8593c6..2e724c877ec 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h | |||
| @@ -1081,11 +1081,7 @@ extern void si_meminfo(struct sysinfo * val); | |||
| 1081 | extern void si_meminfo_node(struct sysinfo *val, int nid); | 1081 | extern void si_meminfo_node(struct sysinfo *val, int nid); |
| 1082 | extern int after_bootmem; | 1082 | extern int after_bootmem; |
| 1083 | 1083 | ||
| 1084 | #ifdef CONFIG_NUMA | ||
| 1085 | extern void setup_per_cpu_pageset(void); | 1084 | extern void setup_per_cpu_pageset(void); |
| 1086 | #else | ||
| 1087 | static inline void setup_per_cpu_pageset(void) {} | ||
| 1088 | #endif | ||
| 1089 | 1085 | ||
| 1090 | extern void zone_pcp_update(struct zone *zone); | 1086 | extern void zone_pcp_update(struct zone *zone); |
| 1091 | 1087 | ||
diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index 30fe668c254..41acd4bf766 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h | |||
| @@ -184,13 +184,7 @@ struct per_cpu_pageset { | |||
| 184 | s8 stat_threshold; | 184 | s8 stat_threshold; |
| 185 | s8 vm_stat_diff[NR_VM_ZONE_STAT_ITEMS]; | 185 | s8 vm_stat_diff[NR_VM_ZONE_STAT_ITEMS]; |
| 186 | #endif | 186 | #endif |
| 187 | } ____cacheline_aligned_in_smp; | 187 | }; |
| 188 | |||
| 189 | #ifdef CONFIG_NUMA | ||
| 190 | #define zone_pcp(__z, __cpu) ((__z)->pageset[(__cpu)]) | ||
| 191 | #else | ||
| 192 | #define zone_pcp(__z, __cpu) (&(__z)->pageset[(__cpu)]) | ||
| 193 | #endif | ||
| 194 | 188 | ||
| 195 | #endif /* !__GENERATING_BOUNDS.H */ | 189 | #endif /* !__GENERATING_BOUNDS.H */ |
| 196 | 190 | ||
| @@ -306,10 +300,8 @@ struct zone { | |||
| 306 | */ | 300 | */ |
| 307 | unsigned long min_unmapped_pages; | 301 | unsigned long min_unmapped_pages; |
| 308 | unsigned long min_slab_pages; | 302 | unsigned long min_slab_pages; |
| 309 | struct per_cpu_pageset *pageset[NR_CPUS]; | ||
| 310 | #else | ||
| 311 | struct per_cpu_pageset pageset[NR_CPUS]; | ||
| 312 | #endif | 303 | #endif |
| 304 | struct per_cpu_pageset __percpu *pageset; | ||
| 313 | /* | 305 | /* |
| 314 | * free areas of different sizes | 306 | * free areas of different sizes |
| 315 | */ | 307 | */ |
diff --git a/include/linux/module.h b/include/linux/module.h index 6cb1a3cab5d..dd618eb026a 100644 --- a/include/linux/module.h +++ b/include/linux/module.h | |||
| @@ -17,7 +17,7 @@ | |||
| 17 | #include <linux/moduleparam.h> | 17 | #include <linux/moduleparam.h> |
| 18 | #include <linux/tracepoint.h> | 18 | #include <linux/tracepoint.h> |
| 19 | 19 | ||
| 20 | #include <asm/local.h> | 20 | #include <linux/percpu.h> |
| 21 | #include <asm/module.h> | 21 | #include <asm/module.h> |
| 22 | 22 | ||
| 23 | #include <trace/events/module.h> | 23 | #include <trace/events/module.h> |
| @@ -363,11 +363,9 @@ struct module | |||
| 363 | /* Destruction function. */ | 363 | /* Destruction function. */ |
| 364 | void (*exit)(void); | 364 | void (*exit)(void); |
| 365 | 365 | ||
| 366 | #ifdef CONFIG_SMP | 366 | struct module_ref { |
| 367 | char *refptr; | 367 | int count; |
| 368 | #else | 368 | } __percpu *refptr; |
| 369 | local_t ref; | ||
| 370 | #endif | ||
| 371 | #endif | 369 | #endif |
| 372 | 370 | ||
| 373 | #ifdef CONFIG_CONSTRUCTORS | 371 | #ifdef CONFIG_CONSTRUCTORS |
| @@ -454,25 +452,16 @@ void __symbol_put(const char *symbol); | |||
| 454 | #define symbol_put(x) __symbol_put(MODULE_SYMBOL_PREFIX #x) | 452 | #define symbol_put(x) __symbol_put(MODULE_SYMBOL_PREFIX #x) |
| 455 | void symbol_put_addr(void *addr); | 453 | void symbol_put_addr(void *addr); |
| 456 | 454 | ||
| 457 | static inline local_t *__module_ref_addr(struct module *mod, int cpu) | ||
| 458 | { | ||
| 459 | #ifdef CONFIG_SMP | ||
| 460 | return (local_t *) (mod->refptr + per_cpu_offset(cpu)); | ||
| 461 | #else | ||
| 462 | return &mod->ref; | ||
| 463 | #endif | ||
| 464 | } | ||
| 465 | |||
| 466 | /* Sometimes we know we already have a refcount, and it's easier not | 455 | /* Sometimes we know we already have a refcount, and it's easier not |
| 467 | to handle the error case (which only happens with rmmod --wait). */ | 456 | to handle the error case (which only happens with rmmod --wait). */ |
| 468 | static inline void __module_get(struct module *module) | 457 | static inline void __module_get(struct module *module) |
| 469 | { | 458 | { |
| 470 | if (module) { | 459 | if (module) { |
| 471 | unsigned int cpu = get_cpu(); | 460 | preempt_disable(); |
| 472 | local_inc(__module_ref_addr(module, cpu)); | 461 | __this_cpu_inc(module->refptr->count); |
| 473 | trace_module_get(module, _THIS_IP_, | 462 | trace_module_get(module, _THIS_IP_, |
| 474 | local_read(__module_ref_addr(module, cpu))); | 463 | __this_cpu_read(module->refptr->count)); |
| 475 | put_cpu(); | 464 | preempt_enable(); |
| 476 | } | 465 | } |
| 477 | } | 466 | } |
| 478 | 467 | ||
| @@ -481,15 +470,17 @@ static inline int try_module_get(struct module *module) | |||
| 481 | int ret = 1; | 470 | int ret = 1; |
| 482 | 471 | ||
| 483 | if (module) { | 472 | if (module) { |
| 484 | unsigned int cpu = get_cpu(); | 473 | preempt_disable(); |
| 474 | |||
| 485 | if (likely(module_is_live(module))) { | 475 | if (likely(module_is_live(module))) { |
| 486 | local_inc(__module_ref_addr(module, cpu)); | 476 | __this_cpu_inc(module->refptr->count); |
| 487 | trace_module_get(module, _THIS_IP_, | 477 | trace_module_get(module, _THIS_IP_, |
| 488 | local_read(__module_ref_addr(module, cpu))); | 478 | __this_cpu_read(module->refptr->count)); |
| 489 | } | 479 | } |
| 490 | else | 480 | else |
| 491 | ret = 0; | 481 | ret = 0; |
| 492 | put_cpu(); | 482 | |
| 483 | preempt_enable(); | ||
| 493 | } | 484 | } |
| 494 | return ret; | 485 | return ret; |
| 495 | } | 486 | } |
diff --git a/include/linux/mount.h b/include/linux/mount.h index 5d527536486..b5f43a34ef8 100644 --- a/include/linux/mount.h +++ b/include/linux/mount.h | |||
| @@ -66,7 +66,7 @@ struct vfsmount { | |||
| 66 | int mnt_pinned; | 66 | int mnt_pinned; |
| 67 | int mnt_ghosts; | 67 | int mnt_ghosts; |
| 68 | #ifdef CONFIG_SMP | 68 | #ifdef CONFIG_SMP |
| 69 | int *mnt_writers; | 69 | int __percpu *mnt_writers; |
| 70 | #else | 70 | #else |
| 71 | int mnt_writers; | 71 | int mnt_writers; |
| 72 | #endif | 72 | #endif |
diff --git a/include/linux/nfs_fs_sb.h b/include/linux/nfs_fs_sb.h index 34fc6be5bfc..6a2e44fd75e 100644 --- a/include/linux/nfs_fs_sb.h +++ b/include/linux/nfs_fs_sb.h | |||
| @@ -105,7 +105,7 @@ struct nfs_server { | |||
| 105 | struct rpc_clnt * client; /* RPC client handle */ | 105 | struct rpc_clnt * client; /* RPC client handle */ |
| 106 | struct rpc_clnt * client_acl; /* ACL RPC client handle */ | 106 | struct rpc_clnt * client_acl; /* ACL RPC client handle */ |
| 107 | struct nlm_host *nlm_host; /* NLM client handle */ | 107 | struct nlm_host *nlm_host; /* NLM client handle */ |
| 108 | struct nfs_iostats * io_stats; /* I/O statistics */ | 108 | struct nfs_iostats __percpu *io_stats; /* I/O statistics */ |
| 109 | struct backing_dev_info backing_dev_info; | 109 | struct backing_dev_info backing_dev_info; |
| 110 | atomic_long_t writeback; /* number of writeback pages */ | 110 | atomic_long_t writeback; /* number of writeback pages */ |
| 111 | int flags; /* various flags */ | 111 | int flags; /* various flags */ |
diff --git a/include/linux/percpu-defs.h b/include/linux/percpu-defs.h index 5a5d6ce4bd5..68567c0b3a5 100644 --- a/include/linux/percpu-defs.h +++ b/include/linux/percpu-defs.h | |||
| @@ -2,12 +2,6 @@ | |||
| 2 | #define _LINUX_PERCPU_DEFS_H | 2 | #define _LINUX_PERCPU_DEFS_H |
| 3 | 3 | ||
| 4 | /* | 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 | 5 | * 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 | 6 | * the section in which the variable is to be placed is provided by the |
| 13 | * 'sec' argument. This may be used to affect the parameters governing the | 7 | * 'sec' argument. This may be used to affect the parameters governing the |
| @@ -18,13 +12,23 @@ | |||
| 18 | * that section. | 12 | * that section. |
| 19 | */ | 13 | */ |
| 20 | #define __PCPU_ATTRS(sec) \ | 14 | #define __PCPU_ATTRS(sec) \ |
| 21 | __attribute__((section(PER_CPU_BASE_SECTION sec))) \ | 15 | __percpu __attribute__((section(PER_CPU_BASE_SECTION sec))) \ |
| 22 | PER_CPU_ATTRIBUTES | 16 | PER_CPU_ATTRIBUTES |
| 23 | 17 | ||
| 24 | #define __PCPU_DUMMY_ATTRS \ | 18 | #define __PCPU_DUMMY_ATTRS \ |
| 25 | __attribute__((section(".discard"), unused)) | 19 | __attribute__((section(".discard"), unused)) |
| 26 | 20 | ||
| 27 | /* | 21 | /* |
| 22 | * Macro which verifies @ptr is a percpu pointer without evaluating | ||
| 23 | * @ptr. This is to be used in percpu accessors to verify that the | ||
| 24 | * input parameter is a percpu pointer. | ||
| 25 | */ | ||
| 26 | #define __verify_pcpu_ptr(ptr) do { \ | ||
| 27 | const void __percpu *__vpp_verify = (typeof(ptr))NULL; \ | ||
| 28 | (void)__vpp_verify; \ | ||
| 29 | } while (0) | ||
| 30 | |||
| 31 | /* | ||
| 28 | * s390 and alpha modules require percpu variables to be defined as | 32 | * s390 and alpha modules require percpu variables to be defined as |
| 29 | * weak to force the compiler to generate GOT based external | 33 | * weak to force the compiler to generate GOT based external |
| 30 | * references for them. This is necessary because percpu sections | 34 | * references for them. This is necessary because percpu sections |
| @@ -56,24 +60,24 @@ | |||
| 56 | */ | 60 | */ |
| 57 | #define DECLARE_PER_CPU_SECTION(type, name, sec) \ | 61 | #define DECLARE_PER_CPU_SECTION(type, name, sec) \ |
| 58 | extern __PCPU_DUMMY_ATTRS char __pcpu_scope_##name; \ | 62 | extern __PCPU_DUMMY_ATTRS char __pcpu_scope_##name; \ |
| 59 | extern __PCPU_ATTRS(sec) __typeof__(type) per_cpu__##name | 63 | extern __PCPU_ATTRS(sec) __typeof__(type) name |
| 60 | 64 | ||
| 61 | #define DEFINE_PER_CPU_SECTION(type, name, sec) \ | 65 | #define DEFINE_PER_CPU_SECTION(type, name, sec) \ |
| 62 | __PCPU_DUMMY_ATTRS char __pcpu_scope_##name; \ | 66 | __PCPU_DUMMY_ATTRS char __pcpu_scope_##name; \ |
| 63 | extern __PCPU_DUMMY_ATTRS char __pcpu_unique_##name; \ | 67 | extern __PCPU_DUMMY_ATTRS char __pcpu_unique_##name; \ |
| 64 | __PCPU_DUMMY_ATTRS char __pcpu_unique_##name; \ | 68 | __PCPU_DUMMY_ATTRS char __pcpu_unique_##name; \ |
| 65 | __PCPU_ATTRS(sec) PER_CPU_DEF_ATTRIBUTES __weak \ | 69 | __PCPU_ATTRS(sec) PER_CPU_DEF_ATTRIBUTES __weak \ |
| 66 | __typeof__(type) per_cpu__##name | 70 | __typeof__(type) name |
| 67 | #else | 71 | #else |
| 68 | /* | 72 | /* |
| 69 | * Normal declaration and definition macros. | 73 | * Normal declaration and definition macros. |
| 70 | */ | 74 | */ |
| 71 | #define DECLARE_PER_CPU_SECTION(type, name, sec) \ | 75 | #define DECLARE_PER_CPU_SECTION(type, name, sec) \ |
| 72 | extern __PCPU_ATTRS(sec) __typeof__(type) per_cpu__##name | 76 | extern __PCPU_ATTRS(sec) __typeof__(type) name |
| 73 | 77 | ||
| 74 | #define DEFINE_PER_CPU_SECTION(type, name, sec) \ | 78 | #define DEFINE_PER_CPU_SECTION(type, name, sec) \ |
| 75 | __PCPU_ATTRS(sec) PER_CPU_DEF_ATTRIBUTES \ | 79 | __PCPU_ATTRS(sec) PER_CPU_DEF_ATTRIBUTES \ |
| 76 | __typeof__(type) per_cpu__##name | 80 | __typeof__(type) name |
| 77 | #endif | 81 | #endif |
| 78 | 82 | ||
| 79 | /* | 83 | /* |
| @@ -135,10 +139,16 @@ | |||
| 135 | __aligned(PAGE_SIZE) | 139 | __aligned(PAGE_SIZE) |
| 136 | 140 | ||
| 137 | /* | 141 | /* |
| 138 | * Intermodule exports for per-CPU variables. | 142 | * Intermodule exports for per-CPU variables. sparse forgets about |
| 143 | * address space across EXPORT_SYMBOL(), change EXPORT_SYMBOL() to | ||
| 144 | * noop if __CHECKER__. | ||
| 139 | */ | 145 | */ |
| 140 | #define EXPORT_PER_CPU_SYMBOL(var) EXPORT_SYMBOL(per_cpu__##var) | 146 | #ifndef __CHECKER__ |
| 141 | #define EXPORT_PER_CPU_SYMBOL_GPL(var) EXPORT_SYMBOL_GPL(per_cpu__##var) | 147 | #define EXPORT_PER_CPU_SYMBOL(var) EXPORT_SYMBOL(var) |
| 142 | 148 | #define EXPORT_PER_CPU_SYMBOL_GPL(var) EXPORT_SYMBOL_GPL(var) | |
| 149 | #else | ||
| 150 | #define EXPORT_PER_CPU_SYMBOL(var) | ||
| 151 | #define EXPORT_PER_CPU_SYMBOL_GPL(var) | ||
| 152 | #endif | ||
| 143 | 153 | ||
| 144 | #endif /* _LINUX_PERCPU_DEFS_H */ | 154 | #endif /* _LINUX_PERCPU_DEFS_H */ |
diff --git a/include/linux/percpu.h b/include/linux/percpu.h index cf5efbcf716..a93e5bfdccb 100644 --- a/include/linux/percpu.h +++ b/include/linux/percpu.h | |||
| @@ -27,10 +27,17 @@ | |||
| 27 | * we force a syntax error here if it isn't. | 27 | * we force a syntax error here if it isn't. |
| 28 | */ | 28 | */ |
| 29 | #define get_cpu_var(var) (*({ \ | 29 | #define get_cpu_var(var) (*({ \ |
| 30 | extern int simple_identifier_##var(void); \ | ||
| 31 | preempt_disable(); \ | 30 | preempt_disable(); \ |
| 32 | &__get_cpu_var(var); })) | 31 | &__get_cpu_var(var); })) |
| 33 | #define put_cpu_var(var) preempt_enable() | 32 | |
| 33 | /* | ||
| 34 | * The weird & is necessary because sparse considers (void)(var) to be | ||
| 35 | * a direct dereference of percpu variable (var). | ||
| 36 | */ | ||
| 37 | #define put_cpu_var(var) do { \ | ||
| 38 | (void)&(var); \ | ||
| 39 | preempt_enable(); \ | ||
| 40 | } while (0) | ||
| 34 | 41 | ||
| 35 | #ifdef CONFIG_SMP | 42 | #ifdef CONFIG_SMP |
| 36 | 43 | ||
| @@ -127,9 +134,9 @@ extern int __init pcpu_page_first_chunk(size_t reserved_size, | |||
| 127 | */ | 134 | */ |
| 128 | #define per_cpu_ptr(ptr, cpu) SHIFT_PERCPU_PTR((ptr), per_cpu_offset((cpu))) | 135 | #define per_cpu_ptr(ptr, cpu) SHIFT_PERCPU_PTR((ptr), per_cpu_offset((cpu))) |
| 129 | 136 | ||
| 130 | extern void *__alloc_reserved_percpu(size_t size, size_t align); | 137 | extern void __percpu *__alloc_reserved_percpu(size_t size, size_t align); |
| 131 | extern void *__alloc_percpu(size_t size, size_t align); | 138 | extern void __percpu *__alloc_percpu(size_t size, size_t align); |
| 132 | extern void free_percpu(void *__pdata); | 139 | extern void free_percpu(void __percpu *__pdata); |
| 133 | extern phys_addr_t per_cpu_ptr_to_phys(void *addr); | 140 | extern phys_addr_t per_cpu_ptr_to_phys(void *addr); |
| 134 | 141 | ||
| 135 | #ifndef CONFIG_HAVE_SETUP_PER_CPU_AREA | 142 | #ifndef CONFIG_HAVE_SETUP_PER_CPU_AREA |
| @@ -140,7 +147,7 @@ extern void __init setup_per_cpu_areas(void); | |||
| 140 | 147 | ||
| 141 | #define per_cpu_ptr(ptr, cpu) ({ (void)(cpu); (ptr); }) | 148 | #define per_cpu_ptr(ptr, cpu) ({ (void)(cpu); (ptr); }) |
| 142 | 149 | ||
| 143 | static inline void *__alloc_percpu(size_t size, size_t align) | 150 | static inline void __percpu *__alloc_percpu(size_t size, size_t align) |
| 144 | { | 151 | { |
| 145 | /* | 152 | /* |
| 146 | * Can't easily make larger alignment work with kmalloc. WARN | 153 | * Can't easily make larger alignment work with kmalloc. WARN |
| @@ -151,7 +158,7 @@ static inline void *__alloc_percpu(size_t size, size_t align) | |||
| 151 | return kzalloc(size, GFP_KERNEL); | 158 | return kzalloc(size, GFP_KERNEL); |
| 152 | } | 159 | } |
| 153 | 160 | ||
| 154 | static inline void free_percpu(void *p) | 161 | static inline void free_percpu(void __percpu *p) |
| 155 | { | 162 | { |
| 156 | kfree(p); | 163 | kfree(p); |
| 157 | } | 164 | } |
| @@ -171,7 +178,7 @@ static inline void *pcpu_lpage_remapped(void *kaddr) | |||
| 171 | #endif /* CONFIG_SMP */ | 178 | #endif /* CONFIG_SMP */ |
| 172 | 179 | ||
| 173 | #define alloc_percpu(type) \ | 180 | #define alloc_percpu(type) \ |
| 174 | (typeof(type) *)__alloc_percpu(sizeof(type), __alignof__(type)) | 181 | (typeof(type) __percpu *)__alloc_percpu(sizeof(type), __alignof__(type)) |
| 175 | 182 | ||
| 176 | /* | 183 | /* |
| 177 | * Optional methods for optimized non-lvalue per-cpu variable access. | 184 | * Optional methods for optimized non-lvalue per-cpu variable access. |
| @@ -188,17 +195,19 @@ static inline void *pcpu_lpage_remapped(void *kaddr) | |||
| 188 | #ifndef percpu_read | 195 | #ifndef percpu_read |
| 189 | # define percpu_read(var) \ | 196 | # define percpu_read(var) \ |
| 190 | ({ \ | 197 | ({ \ |
| 191 | typeof(per_cpu_var(var)) __tmp_var__; \ | 198 | typeof(var) *pr_ptr__ = &(var); \ |
| 192 | __tmp_var__ = get_cpu_var(var); \ | 199 | typeof(var) pr_ret__; \ |
| 193 | put_cpu_var(var); \ | 200 | pr_ret__ = get_cpu_var(*pr_ptr__); \ |
| 194 | __tmp_var__; \ | 201 | put_cpu_var(*pr_ptr__); \ |
| 202 | pr_ret__; \ | ||
| 195 | }) | 203 | }) |
| 196 | #endif | 204 | #endif |
| 197 | 205 | ||
| 198 | #define __percpu_generic_to_op(var, val, op) \ | 206 | #define __percpu_generic_to_op(var, val, op) \ |
| 199 | do { \ | 207 | do { \ |
| 200 | get_cpu_var(var) op val; \ | 208 | typeof(var) *pgto_ptr__ = &(var); \ |
| 201 | put_cpu_var(var); \ | 209 | get_cpu_var(*pgto_ptr__) op val; \ |
| 210 | put_cpu_var(*pgto_ptr__); \ | ||
| 202 | } while (0) | 211 | } while (0) |
| 203 | 212 | ||
| 204 | #ifndef percpu_write | 213 | #ifndef percpu_write |
| @@ -234,6 +243,7 @@ extern void __bad_size_call_parameter(void); | |||
| 234 | 243 | ||
| 235 | #define __pcpu_size_call_return(stem, variable) \ | 244 | #define __pcpu_size_call_return(stem, variable) \ |
| 236 | ({ typeof(variable) pscr_ret__; \ | 245 | ({ typeof(variable) pscr_ret__; \ |
| 246 | __verify_pcpu_ptr(&(variable)); \ | ||
| 237 | switch(sizeof(variable)) { \ | 247 | switch(sizeof(variable)) { \ |
| 238 | case 1: pscr_ret__ = stem##1(variable);break; \ | 248 | case 1: pscr_ret__ = stem##1(variable);break; \ |
| 239 | case 2: pscr_ret__ = stem##2(variable);break; \ | 249 | case 2: pscr_ret__ = stem##2(variable);break; \ |
| @@ -247,6 +257,7 @@ extern void __bad_size_call_parameter(void); | |||
| 247 | 257 | ||
| 248 | #define __pcpu_size_call(stem, variable, ...) \ | 258 | #define __pcpu_size_call(stem, variable, ...) \ |
| 249 | do { \ | 259 | do { \ |
| 260 | __verify_pcpu_ptr(&(variable)); \ | ||
| 250 | switch(sizeof(variable)) { \ | 261 | switch(sizeof(variable)) { \ |
| 251 | case 1: stem##1(variable, __VA_ARGS__);break; \ | 262 | case 1: stem##1(variable, __VA_ARGS__);break; \ |
| 252 | case 2: stem##2(variable, __VA_ARGS__);break; \ | 263 | case 2: stem##2(variable, __VA_ARGS__);break; \ |
| @@ -259,8 +270,7 @@ do { \ | |||
| 259 | 270 | ||
| 260 | /* | 271 | /* |
| 261 | * Optimized manipulation for memory allocated through the per cpu | 272 | * Optimized manipulation for memory allocated through the per cpu |
| 262 | * allocator or for addresses of per cpu variables (can be determined | 273 | * allocator or for addresses of per cpu variables. |
| 263 | * using per_cpu_var(xx). | ||
| 264 | * | 274 | * |
| 265 | * These operation guarantee exclusivity of access for other operations | 275 | * These operation guarantee exclusivity of access for other operations |
| 266 | * on the *same* processor. The assumption is that per cpu data is only | 276 | * on the *same* processor. The assumption is that per cpu data is only |
| @@ -311,7 +321,7 @@ do { \ | |||
| 311 | #define _this_cpu_generic_to_op(pcp, val, op) \ | 321 | #define _this_cpu_generic_to_op(pcp, val, op) \ |
| 312 | do { \ | 322 | do { \ |
| 313 | preempt_disable(); \ | 323 | preempt_disable(); \ |
| 314 | *__this_cpu_ptr(&pcp) op val; \ | 324 | *__this_cpu_ptr(&(pcp)) op val; \ |
| 315 | preempt_enable(); \ | 325 | preempt_enable(); \ |
| 316 | } while (0) | 326 | } while (0) |
| 317 | 327 | ||
diff --git a/include/linux/percpu_counter.h b/include/linux/percpu_counter.h index 794662b2be5..c88d67b5939 100644 --- a/include/linux/percpu_counter.h +++ b/include/linux/percpu_counter.h | |||
| @@ -21,7 +21,7 @@ struct percpu_counter { | |||
| 21 | #ifdef CONFIG_HOTPLUG_CPU | 21 | #ifdef CONFIG_HOTPLUG_CPU |
| 22 | struct list_head list; /* All percpu_counters are on a list */ | 22 | struct list_head list; /* All percpu_counters are on a list */ |
| 23 | #endif | 23 | #endif |
| 24 | s32 *counters; | 24 | s32 __percpu *counters; |
| 25 | }; | 25 | }; |
| 26 | 26 | ||
| 27 | extern int percpu_counter_batch; | 27 | extern int percpu_counter_batch; |
diff --git a/include/linux/srcu.h b/include/linux/srcu.h index 3084f80909c..4d5ecb222af 100644 --- a/include/linux/srcu.h +++ b/include/linux/srcu.h | |||
| @@ -33,7 +33,7 @@ struct srcu_struct_array { | |||
| 33 | 33 | ||
| 34 | struct srcu_struct { | 34 | struct srcu_struct { |
| 35 | int completed; | 35 | int completed; |
| 36 | struct srcu_struct_array *per_cpu_ref; | 36 | struct srcu_struct_array __percpu *per_cpu_ref; |
| 37 | struct mutex mutex; | 37 | struct mutex mutex; |
| 38 | #ifdef CONFIG_DEBUG_LOCK_ALLOC | 38 | #ifdef CONFIG_DEBUG_LOCK_ALLOC |
| 39 | struct lockdep_map dep_map; | 39 | struct lockdep_map dep_map; |
diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h index ee03bba9c5d..117f0dd8ad0 100644 --- a/include/linux/vmstat.h +++ b/include/linux/vmstat.h | |||
| @@ -78,22 +78,22 @@ DECLARE_PER_CPU(struct vm_event_state, vm_event_states); | |||
| 78 | 78 | ||
| 79 | static inline void __count_vm_event(enum vm_event_item item) | 79 | static inline void __count_vm_event(enum vm_event_item item) |
| 80 | { | 80 | { |
| 81 | __this_cpu_inc(per_cpu_var(vm_event_states).event[item]); | 81 | __this_cpu_inc(vm_event_states.event[item]); |
| 82 | } | 82 | } |
| 83 | 83 | ||
| 84 | static inline void count_vm_event(enum vm_event_item item) | 84 | static inline void count_vm_event(enum vm_event_item item) |
| 85 | { | 85 | { |
| 86 | this_cpu_inc(per_cpu_var(vm_event_states).event[item]); | 86 | this_cpu_inc(vm_event_states.event[item]); |
| 87 | } | 87 | } |
| 88 | 88 | ||
| 89 | static inline void __count_vm_events(enum vm_event_item item, long delta) | 89 | static inline void __count_vm_events(enum vm_event_item item, long delta) |
| 90 | { | 90 | { |
| 91 | __this_cpu_add(per_cpu_var(vm_event_states).event[item], delta); | 91 | __this_cpu_add(vm_event_states.event[item], delta); |
| 92 | } | 92 | } |
| 93 | 93 | ||
| 94 | static inline void count_vm_events(enum vm_event_item item, long delta) | 94 | static inline void count_vm_events(enum vm_event_item item, long delta) |
| 95 | { | 95 | { |
| 96 | this_cpu_add(per_cpu_var(vm_event_states).event[item], delta); | 96 | this_cpu_add(vm_event_states.event[item], delta); |
| 97 | } | 97 | } |
| 98 | 98 | ||
| 99 | extern void all_vm_events(unsigned long *); | 99 | extern void all_vm_events(unsigned long *); |
