Skip to content

Commit 1871e52

Browse files
committed
percpu: make percpu symbols under kernel/ and mm/ unique
This patch updates percpu related symbols under kernel/ and mm/ such that percpu symbols are unique and don't clash with local symbols. This serves two purposes of decreasing the possibility of global percpu symbol collision and allowing dropping per_cpu__ prefix from percpu symbols. * kernel/lockdep.c: s/lock_stats/cpu_lock_stats/ * kernel/sched.c: s/init_rq_rt/init_rt_rq_var/ (any better idea?) s/sched_group_cpus/sched_groups/ * kernel/softirq.c: s/ksoftirqd/run_ksoftirqd/a * kernel/softlockup.c: s/(*)_timestamp/softlockup_\1_ts/ s/watchdog_task/softlockup_watchdog/ s/timestamp/ts/ for local variables * kernel/time/timer_stats: s/lookup_lock/tstats_lookup_lock/ * mm/slab.c: s/reap_work/slab_reap_work/ s/reap_node/slab_reap_node/ * mm/vmstat.c: local variable changed to avoid collision with vmstat_work Partly based on Rusty Russell's "alloc_percpu: rename percpu vars which cause name clashes" patch. Signed-off-by: Tejun Heo <tj@kernel.org> Acked-by: (slab/vmstat) Christoph Lameter <cl@linux-foundation.org> Reviewed-by: Christoph Lameter <cl@linux-foundation.org> Cc: Rusty Russell <rusty@rustcorp.com.au> Cc: Ingo Molnar <mingo@redhat.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Nick Piggin <npiggin@suse.de>
1 parent 0f5e481 commit 1871e52

7 files changed

Lines changed: 57 additions & 56 deletions

File tree

‎kernel/lockdep.c‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,8 @@ static inline struct lock_class *hlock_class(struct held_lock *hlock)
140140
}
141141

142142
#ifdef CONFIG_LOCK_STAT
143-
static DEFINE_PER_CPU(struct lock_class_stats[MAX_LOCKDEP_KEYS], lock_stats);
143+
static DEFINE_PER_CPU(struct lock_class_stats[MAX_LOCKDEP_KEYS],
144+
cpu_lock_stats);
144145

145146
static int lock_point(unsigned long points[], unsigned long ip)
146147
{
@@ -186,7 +187,7 @@ struct lock_class_stats lock_stats(struct lock_class *class)
186187
memset(&stats, 0, sizeof(struct lock_class_stats));
187188
for_each_possible_cpu(cpu) {
188189
struct lock_class_stats *pcs =
189-
&per_cpu(lock_stats, cpu)[class - lock_classes];
190+
&per_cpu(cpu_lock_stats, cpu)[class - lock_classes];
190191

191192
for (i = 0; i < ARRAY_SIZE(stats.contention_point); i++)
192193
stats.contention_point[i] += pcs->contention_point[i];
@@ -213,7 +214,7 @@ void clear_lock_stats(struct lock_class *class)
213214

214215
for_each_possible_cpu(cpu) {
215216
struct lock_class_stats *cpu_stats =
216-
&per_cpu(lock_stats, cpu)[class - lock_classes];
217+
&per_cpu(cpu_lock_stats, cpu)[class - lock_classes];
217218

218219
memset(cpu_stats, 0, sizeof(struct lock_class_stats));
219220
}
@@ -223,12 +224,12 @@ void clear_lock_stats(struct lock_class *class)
223224

224225
static struct lock_class_stats *get_lock_stats(struct lock_class *class)
225226
{
226-
return &get_cpu_var(lock_stats)[class - lock_classes];
227+
return &get_cpu_var(cpu_lock_stats)[class - lock_classes];
227228
}
228229

229230
static void put_lock_stats(struct lock_class_stats *stats)
230231
{
231-
put_cpu_var(lock_stats);
232+
put_cpu_var(cpu_lock_stats);
232233
}
233234

234235
static void lock_release_holdtime(struct held_lock *hlock)

‎kernel/sched.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ static DEFINE_PER_CPU_SHARED_ALIGNED(struct cfs_rq, init_tg_cfs_rq);
298298

299299
#ifdef CONFIG_RT_GROUP_SCHED
300300
static DEFINE_PER_CPU(struct sched_rt_entity, init_sched_rt_entity);
301-
static DEFINE_PER_CPU_SHARED_ALIGNED(struct rt_rq, init_rt_rq);
301+
static DEFINE_PER_CPU_SHARED_ALIGNED(struct rt_rq, init_rt_rq_var);
302302
#endif /* CONFIG_RT_GROUP_SCHED */
303303
#else /* !CONFIG_USER_SCHED */
304304
#define root_task_group init_task_group
@@ -8199,14 +8199,14 @@ enum s_alloc {
81998199
*/
82008200
#ifdef CONFIG_SCHED_SMT
82018201
static DEFINE_PER_CPU(struct static_sched_domain, cpu_domains);
8202-
static DEFINE_PER_CPU(struct static_sched_group, sched_group_cpus);
8202+
static DEFINE_PER_CPU(struct static_sched_group, sched_groups);
82038203

82048204
static int
82058205
cpu_to_cpu_group(int cpu, const struct cpumask *cpu_map,
82068206
struct sched_group **sg, struct cpumask *unused)
82078207
{
82088208
if (sg)
8209-
*sg = &per_cpu(sched_group_cpus, cpu).sg;
8209+
*sg = &per_cpu(sched_groups, cpu).sg;
82108210
return cpu;
82118211
}
82128212
#endif /* CONFIG_SCHED_SMT */
@@ -9470,7 +9470,7 @@ void __init sched_init(void)
94709470
#elif defined CONFIG_USER_SCHED
94719471
init_tg_rt_entry(&root_task_group, &rq->rt, NULL, i, 0, NULL);
94729472
init_tg_rt_entry(&init_task_group,
9473-
&per_cpu(init_rt_rq, i),
9473+
&per_cpu(init_rt_rq_var, i),
94749474
&per_cpu(init_sched_rt_entity, i), i, 1,
94759475
root_task_group.rt_se[i]);
94769476
#endif

‎kernel/softirq.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,7 @@ void __init softirq_init(void)
697697
open_softirq(HI_SOFTIRQ, tasklet_hi_action);
698698
}
699699

700-
static int ksoftirqd(void * __bind_cpu)
700+
static int run_ksoftirqd(void * __bind_cpu)
701701
{
702702
set_current_state(TASK_INTERRUPTIBLE);
703703

@@ -810,7 +810,7 @@ static int __cpuinit cpu_callback(struct notifier_block *nfb,
810810
switch (action) {
811811
case CPU_UP_PREPARE:
812812
case CPU_UP_PREPARE_FROZEN:
813-
p = kthread_create(ksoftirqd, hcpu, "ksoftirqd/%d", hotcpu);
813+
p = kthread_create(run_ksoftirqd, hcpu, "ksoftirqd/%d", hotcpu);
814814
if (IS_ERR(p)) {
815815
printk("ksoftirqd for %i failed\n", hotcpu);
816816
return NOTIFY_BAD;

‎kernel/softlockup.c‎

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222

2323
static DEFINE_SPINLOCK(print_lock);
2424

25-
static DEFINE_PER_CPU(unsigned long, touch_timestamp);
26-
static DEFINE_PER_CPU(unsigned long, print_timestamp);
27-
static DEFINE_PER_CPU(struct task_struct *, watchdog_task);
25+
static DEFINE_PER_CPU(unsigned long, softlockup_touch_ts); /* touch timestamp */
26+
static DEFINE_PER_CPU(unsigned long, softlockup_print_ts); /* print timestamp */
27+
static DEFINE_PER_CPU(struct task_struct *, softlockup_watchdog);
2828

2929
static int __read_mostly did_panic;
3030
int __read_mostly softlockup_thresh = 60;
@@ -70,12 +70,12 @@ static void __touch_softlockup_watchdog(void)
7070
{
7171
int this_cpu = raw_smp_processor_id();
7272

73-
__raw_get_cpu_var(touch_timestamp) = get_timestamp(this_cpu);
73+
__raw_get_cpu_var(softlockup_touch_ts) = get_timestamp(this_cpu);
7474
}
7575

7676
void touch_softlockup_watchdog(void)
7777
{
78-
__raw_get_cpu_var(touch_timestamp) = 0;
78+
__raw_get_cpu_var(softlockup_touch_ts) = 0;
7979
}
8080
EXPORT_SYMBOL(touch_softlockup_watchdog);
8181

@@ -85,7 +85,7 @@ void touch_all_softlockup_watchdogs(void)
8585

8686
/* Cause each CPU to re-update its timestamp rather than complain */
8787
for_each_online_cpu(cpu)
88-
per_cpu(touch_timestamp, cpu) = 0;
88+
per_cpu(softlockup_touch_ts, cpu) = 0;
8989
}
9090
EXPORT_SYMBOL(touch_all_softlockup_watchdogs);
9191

@@ -104,28 +104,28 @@ int proc_dosoftlockup_thresh(struct ctl_table *table, int write,
104104
void softlockup_tick(void)
105105
{
106106
int this_cpu = smp_processor_id();
107-
unsigned long touch_timestamp = per_cpu(touch_timestamp, this_cpu);
108-
unsigned long print_timestamp;
107+
unsigned long touch_ts = per_cpu(softlockup_touch_ts, this_cpu);
108+
unsigned long print_ts;
109109
struct pt_regs *regs = get_irq_regs();
110110
unsigned long now;
111111

112112
/* Is detection switched off? */
113-
if (!per_cpu(watchdog_task, this_cpu) || softlockup_thresh <= 0) {
113+
if (!per_cpu(softlockup_watchdog, this_cpu) || softlockup_thresh <= 0) {
114114
/* Be sure we don't false trigger if switched back on */
115-
if (touch_timestamp)
116-
per_cpu(touch_timestamp, this_cpu) = 0;
115+
if (touch_ts)
116+
per_cpu(softlockup_touch_ts, this_cpu) = 0;
117117
return;
118118
}
119119

120-
if (touch_timestamp == 0) {
120+
if (touch_ts == 0) {
121121
__touch_softlockup_watchdog();
122122
return;
123123
}
124124

125-
print_timestamp = per_cpu(print_timestamp, this_cpu);
125+
print_ts = per_cpu(softlockup_print_ts, this_cpu);
126126

127127
/* report at most once a second */
128-
if (print_timestamp == touch_timestamp || did_panic)
128+
if (print_ts == touch_ts || did_panic)
129129
return;
130130

131131
/* do not print during early bootup: */
@@ -140,18 +140,18 @@ void softlockup_tick(void)
140140
* Wake up the high-prio watchdog task twice per
141141
* threshold timespan.
142142
*/
143-
if (now > touch_timestamp + softlockup_thresh/2)
144-
wake_up_process(per_cpu(watchdog_task, this_cpu));
143+
if (now > touch_ts + softlockup_thresh/2)
144+
wake_up_process(per_cpu(softlockup_watchdog, this_cpu));
145145

146146
/* Warn about unreasonable delays: */
147-
if (now <= (touch_timestamp + softlockup_thresh))
147+
if (now <= (touch_ts + softlockup_thresh))
148148
return;
149149

150-
per_cpu(print_timestamp, this_cpu) = touch_timestamp;
150+
per_cpu(softlockup_print_ts, this_cpu) = touch_ts;
151151

152152
spin_lock(&print_lock);
153153
printk(KERN_ERR "BUG: soft lockup - CPU#%d stuck for %lus! [%s:%d]\n",
154-
this_cpu, now - touch_timestamp,
154+
this_cpu, now - touch_ts,
155155
current->comm, task_pid_nr(current));
156156
print_modules();
157157
print_irqtrace_events(current);
@@ -209,32 +209,32 @@ cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
209209
switch (action) {
210210
case CPU_UP_PREPARE:
211211
case CPU_UP_PREPARE_FROZEN:
212-
BUG_ON(per_cpu(watchdog_task, hotcpu));
212+
BUG_ON(per_cpu(softlockup_watchdog, hotcpu));
213213
p = kthread_create(watchdog, hcpu, "watchdog/%d", hotcpu);
214214
if (IS_ERR(p)) {
215215
printk(KERN_ERR "watchdog for %i failed\n", hotcpu);
216216
return NOTIFY_BAD;
217217
}
218-
per_cpu(touch_timestamp, hotcpu) = 0;
219-
per_cpu(watchdog_task, hotcpu) = p;
218+
per_cpu(softlockup_touch_ts, hotcpu) = 0;
219+
per_cpu(softlockup_watchdog, hotcpu) = p;
220220
kthread_bind(p, hotcpu);
221221
break;
222222
case CPU_ONLINE:
223223
case CPU_ONLINE_FROZEN:
224-
wake_up_process(per_cpu(watchdog_task, hotcpu));
224+
wake_up_process(per_cpu(softlockup_watchdog, hotcpu));
225225
break;
226226
#ifdef CONFIG_HOTPLUG_CPU
227227
case CPU_UP_CANCELED:
228228
case CPU_UP_CANCELED_FROZEN:
229-
if (!per_cpu(watchdog_task, hotcpu))
229+
if (!per_cpu(softlockup_watchdog, hotcpu))
230230
break;
231231
/* Unbind so it can run. Fall thru. */
232-
kthread_bind(per_cpu(watchdog_task, hotcpu),
232+
kthread_bind(per_cpu(softlockup_watchdog, hotcpu),
233233
cpumask_any(cpu_online_mask));
234234
case CPU_DEAD:
235235
case CPU_DEAD_FROZEN:
236-
p = per_cpu(watchdog_task, hotcpu);
237-
per_cpu(watchdog_task, hotcpu) = NULL;
236+
p = per_cpu(softlockup_watchdog, hotcpu);
237+
per_cpu(softlockup_watchdog, hotcpu) = NULL;
238238
kthread_stop(p);
239239
break;
240240
#endif /* CONFIG_HOTPLUG_CPU */

‎kernel/time/timer_stats.c‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ static DEFINE_SPINLOCK(table_lock);
8686
/*
8787
* Per-CPU lookup locks for fast hash lookup:
8888
*/
89-
static DEFINE_PER_CPU(spinlock_t, lookup_lock);
89+
static DEFINE_PER_CPU(spinlock_t, tstats_lookup_lock);
9090

9191
/*
9292
* Mutex to serialize state changes with show-stats activities:
@@ -245,7 +245,7 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
245245
if (likely(!timer_stats_active))
246246
return;
247247

248-
lock = &per_cpu(lookup_lock, raw_smp_processor_id());
248+
lock = &per_cpu(tstats_lookup_lock, raw_smp_processor_id());
249249

250250
input.timer = timer;
251251
input.start_func = startf;
@@ -348,9 +348,10 @@ static void sync_access(void)
348348
int cpu;
349349

350350
for_each_online_cpu(cpu) {
351-
spin_lock_irqsave(&per_cpu(lookup_lock, cpu), flags);
351+
spinlock_t *lock = &per_cpu(tstats_lookup_lock, cpu);
352+
spin_lock_irqsave(lock, flags);
352353
/* nothing */
353-
spin_unlock_irqrestore(&per_cpu(lookup_lock, cpu), flags);
354+
spin_unlock_irqrestore(lock, flags);
354355
}
355356
}
356357

@@ -408,7 +409,7 @@ void __init init_timer_stats(void)
408409
int cpu;
409410

410411
for_each_possible_cpu(cpu)
411-
spin_lock_init(&per_cpu(lookup_lock, cpu));
412+
spin_lock_init(&per_cpu(tstats_lookup_lock, cpu));
412413
}
413414

414415
static int __init init_tstats_procfs(void)

‎mm/slab.c‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,7 @@ int slab_is_available(void)
685685
return g_cpucache_up >= EARLY;
686686
}
687687

688-
static DEFINE_PER_CPU(struct delayed_work, reap_work);
688+
static DEFINE_PER_CPU(struct delayed_work, slab_reap_work);
689689

690690
static inline struct array_cache *cpu_cache_get(struct kmem_cache *cachep)
691691
{
@@ -826,7 +826,7 @@ __setup("noaliencache", noaliencache_setup);
826826
* objects freed on different nodes from which they were allocated) and the
827827
* flushing of remote pcps by calling drain_node_pages.
828828
*/
829-
static DEFINE_PER_CPU(unsigned long, reap_node);
829+
static DEFINE_PER_CPU(unsigned long, slab_reap_node);
830830

831831
static void init_reap_node(int cpu)
832832
{
@@ -836,17 +836,17 @@ static void init_reap_node(int cpu)
836836
if (node == MAX_NUMNODES)
837837
node = first_node(node_online_map);
838838

839-
per_cpu(reap_node, cpu) = node;
839+
per_cpu(slab_reap_node, cpu) = node;
840840
}
841841

842842
static void next_reap_node(void)
843843
{
844-
int node = __get_cpu_var(reap_node);
844+
int node = __get_cpu_var(slab_reap_node);
845845

846846
node = next_node(node, node_online_map);
847847
if (unlikely(node >= MAX_NUMNODES))
848848
node = first_node(node_online_map);
849-
__get_cpu_var(reap_node) = node;
849+
__get_cpu_var(slab_reap_node) = node;
850850
}
851851

852852
#else
@@ -863,7 +863,7 @@ static void next_reap_node(void)
863863
*/
864864
static void __cpuinit start_cpu_timer(int cpu)
865865
{
866-
struct delayed_work *reap_work = &per_cpu(reap_work, cpu);
866+
struct delayed_work *reap_work = &per_cpu(slab_reap_work, cpu);
867867

868868
/*
869869
* When this gets called from do_initcalls via cpucache_init(),
@@ -1027,7 +1027,7 @@ static void __drain_alien_cache(struct kmem_cache *cachep,
10271027
*/
10281028
static void reap_alien(struct kmem_cache *cachep, struct kmem_list3 *l3)
10291029
{
1030-
int node = __get_cpu_var(reap_node);
1030+
int node = __get_cpu_var(slab_reap_node);
10311031

10321032
if (l3->alien) {
10331033
struct array_cache *ac = l3->alien[node];
@@ -1286,9 +1286,9 @@ static int __cpuinit cpuup_callback(struct notifier_block *nfb,
12861286
* anything expensive but will only modify reap_work
12871287
* and reschedule the timer.
12881288
*/
1289-
cancel_rearming_delayed_work(&per_cpu(reap_work, cpu));
1289+
cancel_rearming_delayed_work(&per_cpu(slab_reap_work, cpu));
12901290
/* Now the cache_reaper is guaranteed to be not running. */
1291-
per_cpu(reap_work, cpu).work.func = NULL;
1291+
per_cpu(slab_reap_work, cpu).work.func = NULL;
12921292
break;
12931293
case CPU_DOWN_FAILED:
12941294
case CPU_DOWN_FAILED_FROZEN:

‎mm/vmstat.c‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -883,11 +883,10 @@ static void vmstat_update(struct work_struct *w)
883883

884884
static void __cpuinit start_cpu_timer(int cpu)
885885
{
886-
struct delayed_work *vmstat_work = &per_cpu(vmstat_work, cpu);
886+
struct delayed_work *work = &per_cpu(vmstat_work, cpu);
887887

888-
INIT_DELAYED_WORK_DEFERRABLE(vmstat_work, vmstat_update);
889-
schedule_delayed_work_on(cpu, vmstat_work,
890-
__round_jiffies_relative(HZ, cpu));
888+
INIT_DELAYED_WORK_DEFERRABLE(work, vmstat_update);
889+
schedule_delayed_work_on(cpu, work, __round_jiffies_relative(HZ, cpu));
891890
}
892891

893892
/*

0 commit comments

Comments
 (0)