aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2010-02-02 00:38:57 -0500
committerTejun Heo <tj@kernel.org>2010-02-16 21:17:38 -0500
commit43cf38eb5cea91245502df3fcee4dbfc1c74dd1c (patch)
treea58ea87af1f07b8aed4941db074f44103f321f6e
parentab386128f20c44c458a90039ab1bdc265ac474c9 (diff)
percpu: add __percpu sparse annotations to core kernel subsystems
Add __percpu sparse annotations to core subsystems. These annotations are to make sparse consider percpu variables to be in a different address space and warn if accessed without going through percpu accessors. This patch doesn't affect normal builds. Signed-off-by: Tejun Heo <tj@kernel.org> Reviewed-by: Christoph Lameter <cl@linux-foundation.org> Acked-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com> Cc: Jens Axboe <axboe@kernel.dk> Cc: linux-mm@kvack.org Cc: Rusty Russell <rusty@rustcorp.com.au> Cc: Dipankar Sarma <dipankar@in.ibm.com> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Eric Biederman <ebiederm@xmission.com>
-rw-r--r--include/linux/blktrace_api.h4
-rw-r--r--include/linux/genhd.h2
-rw-r--r--include/linux/kexec.h2
-rw-r--r--include/linux/mmzone.h2
-rw-r--r--include/linux/module.h2
-rw-r--r--include/linux/percpu_counter.h2
-rw-r--r--include/linux/srcu.h2
-rw-r--r--kernel/kexec.c2
-rw-r--r--kernel/sched.c4
-rw-r--r--kernel/stop_machine.c2
-rw-r--r--mm/percpu.c18
11 files changed, 22 insertions, 20 deletions
diff --git a/include/linux/blktrace_api.h b/include/linux/blktrace_api.h
index 3b73b9992b26..416bf62d6d46 100644
--- a/include/linux/blktrace_api.h
+++ b/include/linux/blktrace_api.h
@@ -150,8 +150,8 @@ struct blk_user_trace_setup {
150struct blk_trace { 150struct 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/genhd.h b/include/linux/genhd.h
index 9717081c75ad..56b50514ab25 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 c356b6914ffd..03e8e8dbc577 100644
--- a/include/linux/kexec.h
+++ b/include/linux/kexec.h
@@ -199,7 +199,7 @@ extern struct kimage *kexec_crash_image;
199 */ 199 */
200extern struct resource crashk_res; 200extern struct resource crashk_res;
201typedef u32 note_buf_t[KEXEC_NOTE_BYTES/4]; 201typedef u32 note_buf_t[KEXEC_NOTE_BYTES/4];
202extern note_buf_t *crash_notes; 202extern note_buf_t __percpu *crash_notes;
203extern u32 vmcoreinfo_note[VMCOREINFO_NOTE_SIZE/4]; 203extern u32 vmcoreinfo_note[VMCOREINFO_NOTE_SIZE/4];
204extern size_t vmcoreinfo_size; 204extern size_t vmcoreinfo_size;
205extern size_t vmcoreinfo_max_size; 205extern size_t vmcoreinfo_max_size;
diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
index 7874201a3556..41acd4bf7664 100644
--- a/include/linux/mmzone.h
+++ b/include/linux/mmzone.h
@@ -301,7 +301,7 @@ struct zone {
301 unsigned long min_unmapped_pages; 301 unsigned long min_unmapped_pages;
302 unsigned long min_slab_pages; 302 unsigned long min_slab_pages;
303#endif 303#endif
304 struct per_cpu_pageset *pageset; 304 struct per_cpu_pageset __percpu *pageset;
305 /* 305 /*
306 * free areas of different sizes 306 * free areas of different sizes
307 */ 307 */
diff --git a/include/linux/module.h b/include/linux/module.h
index 7e74ae0051cc..dd618eb026aa 100644
--- a/include/linux/module.h
+++ b/include/linux/module.h
@@ -365,7 +365,7 @@ struct module
365 365
366 struct module_ref { 366 struct module_ref {
367 int count; 367 int count;
368 } *refptr; 368 } __percpu *refptr;
369#endif 369#endif
370 370
371#ifdef CONFIG_CONSTRUCTORS 371#ifdef CONFIG_CONSTRUCTORS
diff --git a/include/linux/percpu_counter.h b/include/linux/percpu_counter.h
index a7684a513994..9bd103c844ee 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
27extern int percpu_counter_batch; 27extern int percpu_counter_batch;
diff --git a/include/linux/srcu.h b/include/linux/srcu.h
index 4765d97dcafb..41eedccc962c 100644
--- a/include/linux/srcu.h
+++ b/include/linux/srcu.h
@@ -33,7 +33,7 @@ struct srcu_struct_array {
33 33
34struct srcu_struct { 34struct 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}; 38};
39 39
diff --git a/kernel/kexec.c b/kernel/kexec.c
index ef077fb73155..87ebe8adc474 100644
--- a/kernel/kexec.c
+++ b/kernel/kexec.c
@@ -41,7 +41,7 @@
41#include <asm/sections.h> 41#include <asm/sections.h>
42 42
43/* Per cpu memory for storing cpu states in case of system crash. */ 43/* Per cpu memory for storing cpu states in case of system crash. */
44note_buf_t* crash_notes; 44note_buf_t __percpu *crash_notes;
45 45
46/* vmcoreinfo stuff */ 46/* vmcoreinfo stuff */
47static unsigned char vmcoreinfo_data[VMCOREINFO_BYTES]; 47static unsigned char vmcoreinfo_data[VMCOREINFO_BYTES];
diff --git a/kernel/sched.c b/kernel/sched.c
index 3a8fb30a91b1..978edfd35a96 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -1566,7 +1566,7 @@ static unsigned long cpu_avg_load_per_task(int cpu)
1566 1566
1567#ifdef CONFIG_FAIR_GROUP_SCHED 1567#ifdef CONFIG_FAIR_GROUP_SCHED
1568 1568
1569static __read_mostly unsigned long *update_shares_data; 1569static __read_mostly unsigned long __percpu *update_shares_data;
1570 1570
1571static void __set_se_shares(struct sched_entity *se, unsigned long shares); 1571static void __set_se_shares(struct sched_entity *se, unsigned long shares);
1572 1572
@@ -10683,7 +10683,7 @@ struct cgroup_subsys cpu_cgroup_subsys = {
10683struct cpuacct { 10683struct cpuacct {
10684 struct cgroup_subsys_state css; 10684 struct cgroup_subsys_state css;
10685 /* cpuusage holds pointer to a u64-type object on every cpu */ 10685 /* cpuusage holds pointer to a u64-type object on every cpu */
10686 u64 *cpuusage; 10686 u64 __percpu *cpuusage;
10687 struct percpu_counter cpustat[CPUACCT_STAT_NSTATS]; 10687 struct percpu_counter cpustat[CPUACCT_STAT_NSTATS];
10688 struct cpuacct *parent; 10688 struct cpuacct *parent;
10689}; 10689};
diff --git a/kernel/stop_machine.c b/kernel/stop_machine.c
index 912823e2a11b..9bb9fb1bd79c 100644
--- a/kernel/stop_machine.c
+++ b/kernel/stop_machine.c
@@ -45,7 +45,7 @@ static int refcount;
45static struct workqueue_struct *stop_machine_wq; 45static struct workqueue_struct *stop_machine_wq;
46static struct stop_machine_data active, idle; 46static struct stop_machine_data active, idle;
47static const struct cpumask *active_cpus; 47static const struct cpumask *active_cpus;
48static void *stop_machine_work; 48static void __percpu *stop_machine_work;
49 49
50static void set_state(enum stopmachine_state newstate) 50static void set_state(enum stopmachine_state newstate)
51{ 51{
diff --git a/mm/percpu.c b/mm/percpu.c
index b336638d20e7..768419d44ad7 100644
--- a/mm/percpu.c
+++ b/mm/percpu.c
@@ -80,13 +80,15 @@
80/* default addr <-> pcpu_ptr mapping, override in asm/percpu.h if necessary */ 80/* default addr <-> pcpu_ptr mapping, override in asm/percpu.h if necessary */
81#ifndef __addr_to_pcpu_ptr 81#ifndef __addr_to_pcpu_ptr
82#define __addr_to_pcpu_ptr(addr) \ 82#define __addr_to_pcpu_ptr(addr) \
83 (void *)((unsigned long)(addr) - (unsigned long)pcpu_base_addr \ 83 (void __percpu *)((unsigned long)(addr) - \
84 + (unsigned long)__per_cpu_start) 84 (unsigned long)pcpu_base_addr + \
85 (unsigned long)__per_cpu_start)
85#endif 86#endif
86#ifndef __pcpu_ptr_to_addr 87#ifndef __pcpu_ptr_to_addr
87#define __pcpu_ptr_to_addr(ptr) \ 88#define __pcpu_ptr_to_addr(ptr) \
88 (void *)((unsigned long)(ptr) + (unsigned long)pcpu_base_addr \ 89 (void __force *)((unsigned long)(ptr) + \
89 - (unsigned long)__per_cpu_start) 90 (unsigned long)pcpu_base_addr - \
91 (unsigned long)__per_cpu_start)
90#endif 92#endif
91 93
92struct pcpu_chunk { 94struct pcpu_chunk {
@@ -1065,7 +1067,7 @@ static struct pcpu_chunk *alloc_pcpu_chunk(void)
1065 * RETURNS: 1067 * RETURNS:
1066 * Percpu pointer to the allocated area on success, NULL on failure. 1068 * Percpu pointer to the allocated area on success, NULL on failure.
1067 */ 1069 */
1068static void *pcpu_alloc(size_t size, size_t align, bool reserved) 1070static void __percpu *pcpu_alloc(size_t size, size_t align, bool reserved)
1069{ 1071{
1070 static int warn_limit = 10; 1072 static int warn_limit = 10;
1071 struct pcpu_chunk *chunk; 1073 struct pcpu_chunk *chunk;
@@ -1194,7 +1196,7 @@ fail_unlock_mutex:
1194 * RETURNS: 1196 * RETURNS:
1195 * Percpu pointer to the allocated area on success, NULL on failure. 1197 * Percpu pointer to the allocated area on success, NULL on failure.
1196 */ 1198 */
1197void *__alloc_percpu(size_t size, size_t align) 1199void __percpu *__alloc_percpu(size_t size, size_t align)
1198{ 1200{
1199 return pcpu_alloc(size, align, false); 1201 return pcpu_alloc(size, align, false);
1200} 1202}
@@ -1215,7 +1217,7 @@ EXPORT_SYMBOL_GPL(__alloc_percpu);
1215 * RETURNS: 1217 * RETURNS:
1216 * Percpu pointer to the allocated area on success, NULL on failure. 1218 * Percpu pointer to the allocated area on success, NULL on failure.
1217 */ 1219 */
1218void *__alloc_reserved_percpu(size_t size, size_t align) 1220void __percpu *__alloc_reserved_percpu(size_t size, size_t align)
1219{ 1221{
1220 return pcpu_alloc(size, align, true); 1222 return pcpu_alloc(size, align, true);
1221} 1223}
@@ -1267,7 +1269,7 @@ static void pcpu_reclaim(struct work_struct *work)
1267 * CONTEXT: 1269 * CONTEXT:
1268 * Can be called from atomic context. 1270 * Can be called from atomic context.
1269 */ 1271 */
1270void free_percpu(void *ptr) 1272void free_percpu(void __percpu *ptr)
1271{ 1273{
1272 void *addr; 1274 void *addr;
1273 struct pcpu_chunk *chunk; 1275 struct pcpu_chunk *chunk;