Skip to content

Commit 43cf38e

Browse files
committed
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>
1 parent ab38612 commit 43cf38e

11 files changed

Lines changed: 22 additions & 20 deletions

File tree

‎include/linux/blktrace_api.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,8 @@ struct blk_user_trace_setup {
150150
struct blk_trace {
151151
int trace_state;
152152
struct rchan *rchan;
153-
unsigned long *sequence;
154-
unsigned char *msg_data;
153+
unsigned long __percpu *sequence;
154+
unsigned char __percpu *msg_data;
155155
u16 act_mask;
156156
u64 start_lba;
157157
u64 end_lba;

‎include/linux/genhd.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ struct hd_struct {
101101
unsigned long stamp;
102102
int in_flight[2];
103103
#ifdef CONFIG_SMP
104-
struct disk_stats *dkstats;
104+
struct disk_stats __percpu *dkstats;
105105
#else
106106
struct disk_stats dkstats;
107107
#endif

‎include/linux/kexec.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ extern struct kimage *kexec_crash_image;
199199
*/
200200
extern struct resource crashk_res;
201201
typedef u32 note_buf_t[KEXEC_NOTE_BYTES/4];
202-
extern note_buf_t *crash_notes;
202+
extern note_buf_t __percpu *crash_notes;
203203
extern u32 vmcoreinfo_note[VMCOREINFO_NOTE_SIZE/4];
204204
extern size_t vmcoreinfo_size;
205205
extern size_t vmcoreinfo_max_size;

‎include/linux/mmzone.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ struct zone {
301301
unsigned long min_unmapped_pages;
302302
unsigned long min_slab_pages;
303303
#endif
304-
struct per_cpu_pageset *pageset;
304+
struct per_cpu_pageset __percpu *pageset;
305305
/*
306306
* free areas of different sizes
307307
*/

‎include/linux/module.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ struct module
365365

366366
struct module_ref {
367367
int count;
368-
} *refptr;
368+
} __percpu *refptr;
369369
#endif
370370

371371
#ifdef CONFIG_CONSTRUCTORS

‎include/linux/percpu_counter.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ struct percpu_counter {
2121
#ifdef CONFIG_HOTPLUG_CPU
2222
struct list_head list; /* All percpu_counters are on a list */
2323
#endif
24-
s32 *counters;
24+
s32 __percpu *counters;
2525
};
2626

2727
extern int percpu_counter_batch;

‎include/linux/srcu.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ struct srcu_struct_array {
3333

3434
struct srcu_struct {
3535
int completed;
36-
struct srcu_struct_array *per_cpu_ref;
36+
struct srcu_struct_array __percpu *per_cpu_ref;
3737
struct mutex mutex;
3838
};
3939

‎kernel/kexec.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
#include <asm/sections.h>
4242

4343
/* Per cpu memory for storing cpu states in case of system crash. */
44-
note_buf_t* crash_notes;
44+
note_buf_t __percpu *crash_notes;
4545

4646
/* vmcoreinfo stuff */
4747
static unsigned char vmcoreinfo_data[VMCOREINFO_BYTES];

‎kernel/sched.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1566,7 +1566,7 @@ static unsigned long cpu_avg_load_per_task(int cpu)
15661566

15671567
#ifdef CONFIG_FAIR_GROUP_SCHED
15681568

1569-
static __read_mostly unsigned long *update_shares_data;
1569+
static __read_mostly unsigned long __percpu *update_shares_data;
15701570

15711571
static void __set_se_shares(struct sched_entity *se, unsigned long shares);
15721572

@@ -10683,7 +10683,7 @@ struct cgroup_subsys cpu_cgroup_subsys = {
1068310683
struct cpuacct {
1068410684
struct cgroup_subsys_state css;
1068510685
/* cpuusage holds pointer to a u64-type object on every cpu */
10686-
u64 *cpuusage;
10686+
u64 __percpu *cpuusage;
1068710687
struct percpu_counter cpustat[CPUACCT_STAT_NSTATS];
1068810688
struct cpuacct *parent;
1068910689
};

‎kernel/stop_machine.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ static int refcount;
4545
static struct workqueue_struct *stop_machine_wq;
4646
static struct stop_machine_data active, idle;
4747
static const struct cpumask *active_cpus;
48-
static void *stop_machine_work;
48+
static void __percpu *stop_machine_work;
4949

5050
static void set_state(enum stopmachine_state newstate)
5151
{

0 commit comments

Comments
 (0)