aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRusty Russell <rusty@rustcorp.com.au>2009-02-20 02:29:08 -0500
committerTejun Heo <tj@kernel.org>2009-02-20 02:29:08 -0500
commitb36128c830a8f5bd7d4981f5b0b69950f5928ee6 (patch)
treec1cec2c2b374b53372ab2e0592321aae9f5ba245
parent6b588c18f8dacfa6d7957c33c5ff832096e752d3 (diff)
alloc_percpu: change percpu_ptr to per_cpu_ptr
Impact: cleanup There are two allocated per-cpu accessor macros with almost identical spelling. The original and far more popular is per_cpu_ptr (44 files), so change over the other 4 files. tj: kill percpu_ptr() and update UP too Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> Cc: mingo@redhat.com Cc: lenb@kernel.org Cc: cpufreq@vger.kernel.org Signed-off-by: Tejun Heo <tj@kernel.org>
-rw-r--r--arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c2
-rw-r--r--drivers/acpi/processor_perflib.c4
-rw-r--r--include/linux/percpu.h23
-rw-r--r--kernel/sched.c6
-rw-r--r--kernel/stop_machine.c2
5 files changed, 18 insertions, 19 deletions
diff --git a/arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c b/arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c
index 4b1c319d30c3..22590cf688ae 100644
--- a/arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c
+++ b/arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c
@@ -601,7 +601,7 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
601 if (!data) 601 if (!data)
602 return -ENOMEM; 602 return -ENOMEM;
603 603
604 data->acpi_data = percpu_ptr(acpi_perf_data, cpu); 604 data->acpi_data = per_cpu_ptr(acpi_perf_data, cpu);
605 per_cpu(drv_data, cpu) = data; 605 per_cpu(drv_data, cpu) = data;
606 606
607 if (cpu_has(c, X86_FEATURE_CONSTANT_TSC)) 607 if (cpu_has(c, X86_FEATURE_CONSTANT_TSC))
diff --git a/drivers/acpi/processor_perflib.c b/drivers/acpi/processor_perflib.c
index 9cc769b587ff..68fd3d292799 100644
--- a/drivers/acpi/processor_perflib.c
+++ b/drivers/acpi/processor_perflib.c
@@ -516,12 +516,12 @@ int acpi_processor_preregister_performance(
516 continue; 516 continue;
517 } 517 }
518 518
519 if (!performance || !percpu_ptr(performance, i)) { 519 if (!performance || !per_cpu_ptr(performance, i)) {
520 retval = -EINVAL; 520 retval = -EINVAL;
521 continue; 521 continue;
522 } 522 }
523 523
524 pr->performance = percpu_ptr(performance, i); 524 pr->performance = per_cpu_ptr(performance, i);
525 cpumask_set_cpu(i, pr->performance->shared_cpu_map); 525 cpumask_set_cpu(i, pr->performance->shared_cpu_map);
526 if (acpi_processor_get_psd(pr)) { 526 if (acpi_processor_get_psd(pr)) {
527 retval = -EINVAL; 527 retval = -EINVAL;
diff --git a/include/linux/percpu.h b/include/linux/percpu.h
index 3577ffd90d45..c80cfe1260ec 100644
--- a/include/linux/percpu.h
+++ b/include/linux/percpu.h
@@ -81,23 +81,13 @@ struct percpu_data {
81}; 81};
82 82
83#define __percpu_disguise(pdata) (struct percpu_data *)~(unsigned long)(pdata) 83#define __percpu_disguise(pdata) (struct percpu_data *)~(unsigned long)(pdata)
84/*
85 * Use this to get to a cpu's version of the per-cpu object dynamically
86 * allocated. Non-atomic access to the current CPU's version should
87 * probably be combined with get_cpu()/put_cpu().
88 */
89#define percpu_ptr(ptr, cpu) \
90({ \
91 struct percpu_data *__p = __percpu_disguise(ptr); \
92 (__typeof__(ptr))__p->ptrs[(cpu)]; \
93})
94 84
95extern void *__percpu_alloc_mask(size_t size, gfp_t gfp, cpumask_t *mask); 85extern void *__percpu_alloc_mask(size_t size, gfp_t gfp, cpumask_t *mask);
96extern void percpu_free(void *__pdata); 86extern void percpu_free(void *__pdata);
97 87
98#else /* CONFIG_SMP */ 88#else /* CONFIG_SMP */
99 89
100#define percpu_ptr(ptr, cpu) ({ (void)(cpu); (ptr); }) 90#define per_cpu_ptr(ptr, cpu) ({ (void)(cpu); (ptr); })
101 91
102static __always_inline void *__percpu_alloc_mask(size_t size, gfp_t gfp, cpumask_t *mask) 92static __always_inline void *__percpu_alloc_mask(size_t size, gfp_t gfp, cpumask_t *mask)
103{ 93{
@@ -122,6 +112,15 @@ static inline void percpu_free(void *__pdata)
122 cpu_possible_map) 112 cpu_possible_map)
123#define alloc_percpu(type) (type *)__alloc_percpu(sizeof(type)) 113#define alloc_percpu(type) (type *)__alloc_percpu(sizeof(type))
124#define free_percpu(ptr) percpu_free((ptr)) 114#define free_percpu(ptr) percpu_free((ptr))
125#define per_cpu_ptr(ptr, cpu) percpu_ptr((ptr), (cpu)) 115/*
116 * Use this to get to a cpu's version of the per-cpu object dynamically
117 * allocated. Non-atomic access to the current CPU's version should
118 * probably be combined with get_cpu()/put_cpu().
119 */
120#define per_cpu_ptr(ptr, cpu) \
121({ \
122 struct percpu_data *__p = __percpu_disguise(ptr); \
123 (__typeof__(ptr))__p->ptrs[(cpu)]; \
124})
126 125
127#endif /* __LINUX_PERCPU_H */ 126#endif /* __LINUX_PERCPU_H */
diff --git a/kernel/sched.c b/kernel/sched.c
index fc17fd91ab57..9d30ac956328 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -9472,7 +9472,7 @@ cpuacct_destroy(struct cgroup_subsys *ss, struct cgroup *cgrp)
9472 9472
9473static u64 cpuacct_cpuusage_read(struct cpuacct *ca, int cpu) 9473static u64 cpuacct_cpuusage_read(struct cpuacct *ca, int cpu)
9474{ 9474{
9475 u64 *cpuusage = percpu_ptr(ca->cpuusage, cpu); 9475 u64 *cpuusage = per_cpu_ptr(ca->cpuusage, cpu);
9476 u64 data; 9476 u64 data;
9477 9477
9478#ifndef CONFIG_64BIT 9478#ifndef CONFIG_64BIT
@@ -9491,7 +9491,7 @@ static u64 cpuacct_cpuusage_read(struct cpuacct *ca, int cpu)
9491 9491
9492static void cpuacct_cpuusage_write(struct cpuacct *ca, int cpu, u64 val) 9492static void cpuacct_cpuusage_write(struct cpuacct *ca, int cpu, u64 val)
9493{ 9493{
9494 u64 *cpuusage = percpu_ptr(ca->cpuusage, cpu); 9494 u64 *cpuusage = per_cpu_ptr(ca->cpuusage, cpu);
9495 9495
9496#ifndef CONFIG_64BIT 9496#ifndef CONFIG_64BIT
9497 /* 9497 /*
@@ -9587,7 +9587,7 @@ static void cpuacct_charge(struct task_struct *tsk, u64 cputime)
9587 ca = task_ca(tsk); 9587 ca = task_ca(tsk);
9588 9588
9589 for (; ca; ca = ca->parent) { 9589 for (; ca; ca = ca->parent) {
9590 u64 *cpuusage = percpu_ptr(ca->cpuusage, cpu); 9590 u64 *cpuusage = per_cpu_ptr(ca->cpuusage, cpu);
9591 *cpuusage += cputime; 9591 *cpuusage += cputime;
9592 } 9592 }
9593} 9593}
diff --git a/kernel/stop_machine.c b/kernel/stop_machine.c
index 0cd415ee62a2..74541ca49536 100644
--- a/kernel/stop_machine.c
+++ b/kernel/stop_machine.c
@@ -170,7 +170,7 @@ int __stop_machine(int (*fn)(void *), void *data, const struct cpumask *cpus)
170 * doesn't hit this CPU until we're ready. */ 170 * doesn't hit this CPU until we're ready. */
171 get_cpu(); 171 get_cpu();
172 for_each_online_cpu(i) { 172 for_each_online_cpu(i) {
173 sm_work = percpu_ptr(stop_machine_work, i); 173 sm_work = per_cpu_ptr(stop_machine_work, i);
174 INIT_WORK(sm_work, stop_cpu); 174 INIT_WORK(sm_work, stop_cpu);
175 queue_work_on(i, stop_machine_wq, sm_work); 175 queue_work_on(i, stop_machine_wq, sm_work);
176 } 176 }