Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

powerpc: Replace __get_cpu_var uses

This still has not been merged and now powerpc is the only arch that does
not have this change. Sorry about missing linuxppc-dev before.

V2->V2
- Fix up to work against 3.18-rc1

__get_cpu_var() is used for multiple purposes in the kernel source. One of
them is address calculation via the form &__get_cpu_var(x). This calculates
the address for the instance of the percpu variable of the current processor
based on an offset.

Other use cases are for storing and retrieving data from the current
processors percpu area. __get_cpu_var() can be used as an lvalue when
writing data or on the right side of an assignment.

__get_cpu_var() is defined as :

__get_cpu_var() always only does an address determination. However, store
and retrieve operations could use a segment prefix (or global register on
other platforms) to avoid the address calculation.

this_cpu_write() and this_cpu_read() can directly take an offset into a
percpu area and use optimized assembly code to read and write per cpu
variables.

This patch converts __get_cpu_var into either an explicit address
calculation using this_cpu_ptr() or into a use of this_cpu operations that
use the offset. Thereby address calculations are avoided and less registers
are used when code is generated.

At the end of the patch set all uses of __get_cpu_var have been removed so
the macro is removed too.

The patch set includes passes over all arches as well. Once these operations
are used throughout then specialized macros can be defined in non -x86
arches as well in order to optimize per cpu access by f.e. using a global
register that may be set to the per cpu base.

Transformations done to __get_cpu_var()

1. Determine the address of the percpu instance of the current processor.

DEFINE_PER_CPU(int, y);
int *x = &__get_cpu_var(y);

Converts to

int *x = this_cpu_ptr(&y);

2. Same as #1 but this time an array structure is involved.

DEFINE_PER_CPU(int, y[20]);
int *x = __get_cpu_var(y);

Converts to

int *x = this_cpu_ptr(y);

3. Retrieve the content of the current processors instance of a per cpu
variable.

DEFINE_PER_CPU(int, y);
int x = __get_cpu_var(y)

Converts to

int x = __this_cpu_read(y);

4. Retrieve the content of a percpu struct

DEFINE_PER_CPU(struct mystruct, y);
struct mystruct x = __get_cpu_var(y);

Converts to

memcpy(&x, this_cpu_ptr(&y), sizeof(x));

5. Assignment to a per cpu variable

DEFINE_PER_CPU(int, y)
__get_cpu_var(y) = x;

Converts to

__this_cpu_write(y, x);

6. Increment/Decrement etc of a per cpu variable

DEFINE_PER_CPU(int, y);
__get_cpu_var(y)++

Converts to

__this_cpu_inc(y)

Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
CC: Paul Mackerras <paulus@samba.org>
Signed-off-by: Christoph Lameter <cl@linux.com>
[mpe: Fix build errors caused by set/or_softirq_pending(), and rework
assignment in __set_breakpoint() to use memcpy().]
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>

authored by

Christoph Lameter and committed by
Michael Ellerman
69111bac 0df1f248

+108 -103
+6 -1
arch/powerpc/include/asm/hardirq.h
··· 21 21 22 22 #define __ARCH_IRQ_STAT 23 23 24 - #define local_softirq_pending() __get_cpu_var(irq_stat).__softirq_pending 24 + #define local_softirq_pending() __this_cpu_read(irq_stat.__softirq_pending) 25 + 26 + #define __ARCH_SET_SOFTIRQ_PENDING 27 + 28 + #define set_softirq_pending(x) __this_cpu_write(irq_stat.__softirq_pending, (x)) 29 + #define or_softirq_pending(x) __this_cpu_or(irq_stat.__softirq_pending, (x)) 25 30 26 31 static inline void ack_bad_irq(unsigned int irq) 27 32 {
+2 -2
arch/powerpc/include/asm/tlbflush.h
··· 107 107 108 108 static inline void arch_enter_lazy_mmu_mode(void) 109 109 { 110 - struct ppc64_tlb_batch *batch = &__get_cpu_var(ppc64_tlb_batch); 110 + struct ppc64_tlb_batch *batch = this_cpu_ptr(&ppc64_tlb_batch); 111 111 112 112 batch->active = 1; 113 113 } 114 114 115 115 static inline void arch_leave_lazy_mmu_mode(void) 116 116 { 117 - struct ppc64_tlb_batch *batch = &__get_cpu_var(ppc64_tlb_batch); 117 + struct ppc64_tlb_batch *batch = this_cpu_ptr(&ppc64_tlb_batch); 118 118 119 119 if (batch->index) 120 120 __flush_tlb_pending(batch);
+4 -4
arch/powerpc/include/asm/xics.h
··· 98 98 99 99 static inline void xics_push_cppr(unsigned int vec) 100 100 { 101 - struct xics_cppr *os_cppr = &__get_cpu_var(xics_cppr); 101 + struct xics_cppr *os_cppr = this_cpu_ptr(&xics_cppr); 102 102 103 103 if (WARN_ON(os_cppr->index >= MAX_NUM_PRIORITIES - 1)) 104 104 return; ··· 111 111 112 112 static inline unsigned char xics_pop_cppr(void) 113 113 { 114 - struct xics_cppr *os_cppr = &__get_cpu_var(xics_cppr); 114 + struct xics_cppr *os_cppr = this_cpu_ptr(&xics_cppr); 115 115 116 116 if (WARN_ON(os_cppr->index < 1)) 117 117 return LOWEST_PRIORITY; ··· 121 121 122 122 static inline void xics_set_base_cppr(unsigned char cppr) 123 123 { 124 - struct xics_cppr *os_cppr = &__get_cpu_var(xics_cppr); 124 + struct xics_cppr *os_cppr = this_cpu_ptr(&xics_cppr); 125 125 126 126 /* we only really want to set the priority when there's 127 127 * just one cppr value on the stack ··· 133 133 134 134 static inline unsigned char xics_cppr_top(void) 135 135 { 136 - struct xics_cppr *os_cppr = &__get_cpu_var(xics_cppr); 136 + struct xics_cppr *os_cppr = this_cpu_ptr(&xics_cppr); 137 137 138 138 return os_cppr->stack[os_cppr->index]; 139 139 }
+1 -1
arch/powerpc/kernel/dbell.c
··· 41 41 42 42 may_hard_irq_enable(); 43 43 44 - __get_cpu_var(irq_stat).doorbell_irqs++; 44 + __this_cpu_inc(irq_stat.doorbell_irqs); 45 45 46 46 smp_ipi_demux(); 47 47
+3 -3
arch/powerpc/kernel/hw_breakpoint.c
··· 63 63 int arch_install_hw_breakpoint(struct perf_event *bp) 64 64 { 65 65 struct arch_hw_breakpoint *info = counter_arch_bp(bp); 66 - struct perf_event **slot = &__get_cpu_var(bp_per_reg); 66 + struct perf_event **slot = this_cpu_ptr(&bp_per_reg); 67 67 68 68 *slot = bp; 69 69 ··· 88 88 */ 89 89 void arch_uninstall_hw_breakpoint(struct perf_event *bp) 90 90 { 91 - struct perf_event **slot = &__get_cpu_var(bp_per_reg); 91 + struct perf_event **slot = this_cpu_ptr(&bp_per_reg); 92 92 93 93 if (*slot != bp) { 94 94 WARN_ONCE(1, "Can't find the breakpoint"); ··· 226 226 */ 227 227 rcu_read_lock(); 228 228 229 - bp = __get_cpu_var(bp_per_reg); 229 + bp = __this_cpu_read(bp_per_reg); 230 230 if (!bp) 231 231 goto out; 232 232 info = counter_arch_bp(bp);
+1 -1
arch/powerpc/kernel/iommu.c
··· 208 208 * We don't need to disable preemption here because any CPU can 209 209 * safely use any IOMMU pool. 210 210 */ 211 - pool_nr = __raw_get_cpu_var(iommu_pool_hash) & (tbl->nr_pools - 1); 211 + pool_nr = __this_cpu_read(iommu_pool_hash) & (tbl->nr_pools - 1); 212 212 213 213 if (largealloc) 214 214 pool = &(tbl->large_pool);
+2 -2
arch/powerpc/kernel/irq.c
··· 114 114 static inline notrace int decrementer_check_overflow(void) 115 115 { 116 116 u64 now = get_tb_or_rtc(); 117 - u64 *next_tb = &__get_cpu_var(decrementers_next_tb); 117 + u64 *next_tb = this_cpu_ptr(&decrementers_next_tb); 118 118 119 119 return now >= *next_tb; 120 120 } ··· 499 499 500 500 /* And finally process it */ 501 501 if (unlikely(irq == NO_IRQ)) 502 - __get_cpu_var(irq_stat).spurious_irqs++; 502 + __this_cpu_inc(irq_stat.spurious_irqs); 503 503 else 504 504 generic_handle_irq(irq); 505 505
+1 -1
arch/powerpc/kernel/kgdb.c
··· 155 155 { 156 156 struct thread_info *thread_info, *exception_thread_info; 157 157 struct thread_info *backup_current_thread_info = 158 - &__get_cpu_var(kgdb_thread_info); 158 + this_cpu_ptr(&kgdb_thread_info); 159 159 160 160 if (user_mode(regs)) 161 161 return 0;
+3 -3
arch/powerpc/kernel/kprobes.c
··· 119 119 120 120 static void __kprobes restore_previous_kprobe(struct kprobe_ctlblk *kcb) 121 121 { 122 - __get_cpu_var(current_kprobe) = kcb->prev_kprobe.kp; 122 + __this_cpu_write(current_kprobe, kcb->prev_kprobe.kp); 123 123 kcb->kprobe_status = kcb->prev_kprobe.status; 124 124 kcb->kprobe_saved_msr = kcb->prev_kprobe.saved_msr; 125 125 } ··· 127 127 static void __kprobes set_current_kprobe(struct kprobe *p, struct pt_regs *regs, 128 128 struct kprobe_ctlblk *kcb) 129 129 { 130 - __get_cpu_var(current_kprobe) = p; 130 + __this_cpu_write(current_kprobe, p); 131 131 kcb->kprobe_saved_msr = regs->msr; 132 132 } 133 133 ··· 192 192 ret = 1; 193 193 goto no_kprobe; 194 194 } 195 - p = __get_cpu_var(current_kprobe); 195 + p = __this_cpu_read(current_kprobe); 196 196 if (p->break_handler && p->break_handler(p, regs)) { 197 197 goto ss_probe; 198 198 }
+12 -12
arch/powerpc/kernel/mce.c
··· 73 73 uint64_t nip, uint64_t addr) 74 74 { 75 75 uint64_t srr1; 76 - int index = __get_cpu_var(mce_nest_count)++; 77 - struct machine_check_event *mce = &__get_cpu_var(mce_event[index]); 76 + int index = __this_cpu_inc_return(mce_nest_count); 77 + struct machine_check_event *mce = this_cpu_ptr(&mce_event[index]); 78 78 79 79 /* 80 80 * Return if we don't have enough space to log mce event. ··· 143 143 */ 144 144 int get_mce_event(struct machine_check_event *mce, bool release) 145 145 { 146 - int index = __get_cpu_var(mce_nest_count) - 1; 146 + int index = __this_cpu_read(mce_nest_count) - 1; 147 147 struct machine_check_event *mc_evt; 148 148 int ret = 0; 149 149 ··· 153 153 154 154 /* Check if we have MCE info to process. */ 155 155 if (index < MAX_MC_EVT) { 156 - mc_evt = &__get_cpu_var(mce_event[index]); 156 + mc_evt = this_cpu_ptr(&mce_event[index]); 157 157 /* Copy the event structure and release the original */ 158 158 if (mce) 159 159 *mce = *mc_evt; ··· 163 163 } 164 164 /* Decrement the count to free the slot. */ 165 165 if (release) 166 - __get_cpu_var(mce_nest_count)--; 166 + __this_cpu_dec(mce_nest_count); 167 167 168 168 return ret; 169 169 } ··· 184 184 if (!get_mce_event(&evt, MCE_EVENT_RELEASE)) 185 185 return; 186 186 187 - index = __get_cpu_var(mce_queue_count)++; 187 + index = __this_cpu_inc_return(mce_queue_count); 188 188 /* If queue is full, just return for now. */ 189 189 if (index >= MAX_MC_EVT) { 190 - __get_cpu_var(mce_queue_count)--; 190 + __this_cpu_dec(mce_queue_count); 191 191 return; 192 192 } 193 - __get_cpu_var(mce_event_queue[index]) = evt; 193 + memcpy(this_cpu_ptr(&mce_event_queue[index]), &evt, sizeof(evt)); 194 194 195 195 /* Queue irq work to process this event later. */ 196 196 irq_work_queue(&mce_event_process_work); ··· 208 208 * For now just print it to console. 209 209 * TODO: log this error event to FSP or nvram. 210 210 */ 211 - while (__get_cpu_var(mce_queue_count) > 0) { 212 - index = __get_cpu_var(mce_queue_count) - 1; 211 + while (__this_cpu_read(mce_queue_count) > 0) { 212 + index = __this_cpu_read(mce_queue_count) - 1; 213 213 machine_check_print_event_info( 214 - &__get_cpu_var(mce_event_queue[index])); 215 - __get_cpu_var(mce_queue_count)--; 214 + this_cpu_ptr(&mce_event_queue[index])); 215 + __this_cpu_dec(mce_queue_count); 216 216 } 217 217 } 218 218
+5 -5
arch/powerpc/kernel/process.c
··· 499 499 500 500 void __set_breakpoint(struct arch_hw_breakpoint *brk) 501 501 { 502 - __get_cpu_var(current_brk) = *brk; 502 + memcpy(this_cpu_ptr(&current_brk), brk, sizeof(*brk)); 503 503 504 504 if (cpu_has_feature(CPU_FTR_DAWR)) 505 505 set_dawr(brk); ··· 842 842 * schedule DABR 843 843 */ 844 844 #ifndef CONFIG_HAVE_HW_BREAKPOINT 845 - if (unlikely(!hw_brk_match(&__get_cpu_var(current_brk), &new->thread.hw_brk))) 845 + if (unlikely(!hw_brk_match(this_cpu_ptr(&current_brk), &new->thread.hw_brk))) 846 846 __set_breakpoint(&new->thread.hw_brk); 847 847 #endif /* CONFIG_HAVE_HW_BREAKPOINT */ 848 848 #endif ··· 856 856 * Collect processor utilization data per process 857 857 */ 858 858 if (firmware_has_feature(FW_FEATURE_SPLPAR)) { 859 - struct cpu_usage *cu = &__get_cpu_var(cpu_usage_array); 859 + struct cpu_usage *cu = this_cpu_ptr(&cpu_usage_array); 860 860 long unsigned start_tb, current_tb; 861 861 start_tb = old_thread->start_tb; 862 862 cu->current_tb = current_tb = mfspr(SPRN_PURR); ··· 866 866 #endif /* CONFIG_PPC64 */ 867 867 868 868 #ifdef CONFIG_PPC_BOOK3S_64 869 - batch = &__get_cpu_var(ppc64_tlb_batch); 869 + batch = this_cpu_ptr(&ppc64_tlb_batch); 870 870 if (batch->active) { 871 871 current_thread_info()->local_flags |= _TLF_LAZY_MMU; 872 872 if (batch->index) ··· 889 889 #ifdef CONFIG_PPC_BOOK3S_64 890 890 if (current_thread_info()->local_flags & _TLF_LAZY_MMU) { 891 891 current_thread_info()->local_flags &= ~_TLF_LAZY_MMU; 892 - batch = &__get_cpu_var(ppc64_tlb_batch); 892 + batch = this_cpu_ptr(&ppc64_tlb_batch); 893 893 batch->active = 1; 894 894 } 895 895 #endif /* CONFIG_PPC_BOOK3S_64 */
+3 -3
arch/powerpc/kernel/smp.c
··· 243 243 244 244 irqreturn_t smp_ipi_demux(void) 245 245 { 246 - struct cpu_messages *info = &__get_cpu_var(ipi_message); 246 + struct cpu_messages *info = this_cpu_ptr(&ipi_message); 247 247 unsigned int all; 248 248 249 249 mb(); /* order any irq clear */ ··· 442 442 idle_task_exit(); 443 443 cpu = smp_processor_id(); 444 444 printk(KERN_DEBUG "CPU%d offline\n", cpu); 445 - __get_cpu_var(cpu_state) = CPU_DEAD; 445 + __this_cpu_write(cpu_state, CPU_DEAD); 446 446 smp_wmb(); 447 - while (__get_cpu_var(cpu_state) != CPU_UP_PREPARE) 447 + while (__this_cpu_read(cpu_state) != CPU_UP_PREPARE) 448 448 cpu_relax(); 449 449 } 450 450
+2 -2
arch/powerpc/kernel/sysfs.c
··· 394 394 ppc_set_pmu_inuse(1); 395 395 396 396 /* Only need to enable them once */ 397 - if (__get_cpu_var(pmcs_enabled)) 397 + if (__this_cpu_read(pmcs_enabled)) 398 398 return; 399 399 400 - __get_cpu_var(pmcs_enabled) = 1; 400 + __this_cpu_write(pmcs_enabled, 1); 401 401 402 402 if (ppc_md.enable_pmcs) 403 403 ppc_md.enable_pmcs();
+11 -11
arch/powerpc/kernel/time.c
··· 458 458 459 459 DEFINE_PER_CPU(u8, irq_work_pending); 460 460 461 - #define set_irq_work_pending_flag() __get_cpu_var(irq_work_pending) = 1 462 - #define test_irq_work_pending() __get_cpu_var(irq_work_pending) 463 - #define clear_irq_work_pending() __get_cpu_var(irq_work_pending) = 0 461 + #define set_irq_work_pending_flag() __this_cpu_write(irq_work_pending, 1) 462 + #define test_irq_work_pending() __this_cpu_read(irq_work_pending) 463 + #define clear_irq_work_pending() __this_cpu_write(irq_work_pending, 0) 464 464 465 465 #endif /* 32 vs 64 bit */ 466 466 ··· 482 482 static void __timer_interrupt(void) 483 483 { 484 484 struct pt_regs *regs = get_irq_regs(); 485 - u64 *next_tb = &__get_cpu_var(decrementers_next_tb); 486 - struct clock_event_device *evt = &__get_cpu_var(decrementers); 485 + u64 *next_tb = this_cpu_ptr(&decrementers_next_tb); 486 + struct clock_event_device *evt = this_cpu_ptr(&decrementers); 487 487 u64 now; 488 488 489 489 trace_timer_interrupt_entry(regs); ··· 498 498 *next_tb = ~(u64)0; 499 499 if (evt->event_handler) 500 500 evt->event_handler(evt); 501 - __get_cpu_var(irq_stat).timer_irqs_event++; 501 + __this_cpu_inc(irq_stat.timer_irqs_event); 502 502 } else { 503 503 now = *next_tb - now; 504 504 if (now <= DECREMENTER_MAX) ··· 506 506 /* We may have raced with new irq work */ 507 507 if (test_irq_work_pending()) 508 508 set_dec(1); 509 - __get_cpu_var(irq_stat).timer_irqs_others++; 509 + __this_cpu_inc(irq_stat.timer_irqs_others); 510 510 } 511 511 512 512 #ifdef CONFIG_PPC64 513 513 /* collect purr register values often, for accurate calculations */ 514 514 if (firmware_has_feature(FW_FEATURE_SPLPAR)) { 515 - struct cpu_usage *cu = &__get_cpu_var(cpu_usage_array); 515 + struct cpu_usage *cu = this_cpu_ptr(&cpu_usage_array); 516 516 cu->current_tb = mfspr(SPRN_PURR); 517 517 } 518 518 #endif ··· 527 527 void timer_interrupt(struct pt_regs * regs) 528 528 { 529 529 struct pt_regs *old_regs; 530 - u64 *next_tb = &__get_cpu_var(decrementers_next_tb); 530 + u64 *next_tb = this_cpu_ptr(&decrementers_next_tb); 531 531 532 532 /* Ensure a positive value is written to the decrementer, or else 533 533 * some CPUs will continue to take decrementer exceptions. ··· 813 813 static int decrementer_set_next_event(unsigned long evt, 814 814 struct clock_event_device *dev) 815 815 { 816 - __get_cpu_var(decrementers_next_tb) = get_tb_or_rtc() + evt; 816 + __this_cpu_write(decrementers_next_tb, get_tb_or_rtc() + evt); 817 817 set_dec(evt); 818 818 819 819 /* We may have raced with new irq work */ ··· 833 833 /* Interrupt handler for the timer broadcast IPI */ 834 834 void tick_broadcast_ipi_handler(void) 835 835 { 836 - u64 *next_tb = &__get_cpu_var(decrementers_next_tb); 836 + u64 *next_tb = this_cpu_ptr(&decrementers_next_tb); 837 837 838 838 *next_tb = get_tb_or_rtc(); 839 839 __timer_interrupt();
+4 -4
arch/powerpc/kernel/traps.c
··· 295 295 { 296 296 long handled = 0; 297 297 298 - __get_cpu_var(irq_stat).mce_exceptions++; 298 + __this_cpu_inc(irq_stat.mce_exceptions); 299 299 300 300 if (cur_cpu_spec && cur_cpu_spec->machine_check_early) 301 301 handled = cur_cpu_spec->machine_check_early(regs); ··· 304 304 305 305 long hmi_exception_realmode(struct pt_regs *regs) 306 306 { 307 - __get_cpu_var(irq_stat).hmi_exceptions++; 307 + __this_cpu_inc(irq_stat.hmi_exceptions); 308 308 309 309 if (ppc_md.hmi_exception_early) 310 310 ppc_md.hmi_exception_early(regs); ··· 700 700 enum ctx_state prev_state = exception_enter(); 701 701 int recover = 0; 702 702 703 - __get_cpu_var(irq_stat).mce_exceptions++; 703 + __this_cpu_inc(irq_stat.mce_exceptions); 704 704 705 705 /* See if any machine dependent calls. In theory, we would want 706 706 * to call the CPU first, and call the ppc_md. one if the CPU ··· 1519 1519 1520 1520 void performance_monitor_exception(struct pt_regs *regs) 1521 1521 { 1522 - __get_cpu_var(irq_stat).pmu_irqs++; 1522 + __this_cpu_inc(irq_stat.pmu_irqs); 1523 1523 1524 1524 perf_irq(regs); 1525 1525 }
+7 -7
arch/powerpc/kvm/e500.c
··· 76 76 unsigned long sid; 77 77 int ret = -1; 78 78 79 - sid = ++(__get_cpu_var(pcpu_last_used_sid)); 79 + sid = __this_cpu_inc_return(pcpu_last_used_sid); 80 80 if (sid < NUM_TIDS) { 81 - __get_cpu_var(pcpu_sids).entry[sid] = entry; 81 + __this_cpu_write(pcpu_sids)entry[sid], entry); 82 82 entry->val = sid; 83 - entry->pentry = &__get_cpu_var(pcpu_sids).entry[sid]; 83 + entry->pentry = this_cpu_ptr(&pcpu_sids.entry[sid]); 84 84 ret = sid; 85 85 } 86 86 ··· 108 108 static inline int local_sid_lookup(struct id *entry) 109 109 { 110 110 if (entry && entry->val != 0 && 111 - __get_cpu_var(pcpu_sids).entry[entry->val] == entry && 112 - entry->pentry == &__get_cpu_var(pcpu_sids).entry[entry->val]) 111 + __this_cpu_read(pcpu_sids.entry[entry->val]) == entry && 112 + entry->pentry == this_cpu_ptr(&pcpu_sids.entry[entry->val])) 113 113 return entry->val; 114 114 return -1; 115 115 } ··· 117 117 /* Invalidate all id mappings on local core -- call with preempt disabled */ 118 118 static inline void local_sid_destroy_all(void) 119 119 { 120 - __get_cpu_var(pcpu_last_used_sid) = 0; 121 - memset(&__get_cpu_var(pcpu_sids), 0, sizeof(__get_cpu_var(pcpu_sids))); 120 + __this_cpu_write(pcpu_last_used_sid, 0); 121 + memset(this_cpu_ptr(&pcpu_sids), 0, sizeof(pcpu_sids)); 122 122 } 123 123 124 124 static void *kvmppc_e500_id_table_alloc(struct kvmppc_vcpu_e500 *vcpu_e500)
+2 -2
arch/powerpc/kvm/e500mc.c
··· 144 144 mtspr(SPRN_GESR, vcpu->arch.shared->esr); 145 145 146 146 if (vcpu->arch.oldpir != mfspr(SPRN_PIR) || 147 - __get_cpu_var(last_vcpu_of_lpid)[get_lpid(vcpu)] != vcpu) { 147 + __this_cpu_read(last_vcpu_of_lpid[get_lpid(vcpu)]) != vcpu) { 148 148 kvmppc_e500_tlbil_all(vcpu_e500); 149 - __get_cpu_var(last_vcpu_of_lpid)[get_lpid(vcpu)] = vcpu; 149 + __this_cpu_write(last_vcpu_of_lpid[get_lpid(vcpu)], vcpu); 150 150 } 151 151 } 152 152
+1 -1
arch/powerpc/mm/hash_native_64.c
··· 629 629 unsigned long want_v; 630 630 unsigned long flags; 631 631 real_pte_t pte; 632 - struct ppc64_tlb_batch *batch = &__get_cpu_var(ppc64_tlb_batch); 632 + struct ppc64_tlb_batch *batch = this_cpu_ptr(&ppc64_tlb_batch); 633 633 unsigned long psize = batch->psize; 634 634 int ssize = batch->ssize; 635 635 int i;
+1 -1
arch/powerpc/mm/hash_utils_64.c
··· 1322 1322 else { 1323 1323 int i; 1324 1324 struct ppc64_tlb_batch *batch = 1325 - &__get_cpu_var(ppc64_tlb_batch); 1325 + this_cpu_ptr(&ppc64_tlb_batch); 1326 1326 1327 1327 for (i = 0; i < number; i++) 1328 1328 flush_hash_page(batch->vpn[i], batch->pte[i],
+3 -3
arch/powerpc/mm/hugetlbpage-book3e.c
··· 33 33 34 34 ncams = mfspr(SPRN_TLB1CFG) & TLBnCFG_N_ENTRY; 35 35 36 - index = __get_cpu_var(next_tlbcam_idx); 36 + index = this_cpu_read(next_tlbcam_idx); 37 37 38 38 /* Just round-robin the entries and wrap when we hit the end */ 39 39 if (unlikely(index == ncams - 1)) 40 - __get_cpu_var(next_tlbcam_idx) = tlbcam_index; 40 + __this_cpu_write(next_tlbcam_idx, tlbcam_index); 41 41 else 42 - __get_cpu_var(next_tlbcam_idx)++; 42 + __this_cpu_inc(next_tlbcam_idx); 43 43 44 44 return index; 45 45 }
+1 -1
arch/powerpc/mm/hugetlbpage.c
··· 462 462 { 463 463 struct hugepd_freelist **batchp; 464 464 465 - batchp = &get_cpu_var(hugepd_freelist_cur); 465 + batchp = this_cpu_ptr(&hugepd_freelist_cur); 466 466 467 467 if (atomic_read(&tlb->mm->mm_users) < 2 || 468 468 cpumask_equal(mm_cpumask(tlb->mm),
+11 -11
arch/powerpc/perf/core-book3s.c
··· 339 339 340 340 static void power_pmu_bhrb_enable(struct perf_event *event) 341 341 { 342 - struct cpu_hw_events *cpuhw = &__get_cpu_var(cpu_hw_events); 342 + struct cpu_hw_events *cpuhw = this_cpu_ptr(&cpu_hw_events); 343 343 344 344 if (!ppmu->bhrb_nr) 345 345 return; ··· 354 354 355 355 static void power_pmu_bhrb_disable(struct perf_event *event) 356 356 { 357 - struct cpu_hw_events *cpuhw = &__get_cpu_var(cpu_hw_events); 357 + struct cpu_hw_events *cpuhw = this_cpu_ptr(&cpu_hw_events); 358 358 359 359 if (!ppmu->bhrb_nr) 360 360 return; ··· 1144 1144 if (!ppmu) 1145 1145 return; 1146 1146 local_irq_save(flags); 1147 - cpuhw = &__get_cpu_var(cpu_hw_events); 1147 + cpuhw = this_cpu_ptr(&cpu_hw_events); 1148 1148 1149 1149 if (!cpuhw->disabled) { 1150 1150 /* ··· 1211 1211 return; 1212 1212 local_irq_save(flags); 1213 1213 1214 - cpuhw = &__get_cpu_var(cpu_hw_events); 1214 + cpuhw = this_cpu_ptr(&cpu_hw_events); 1215 1215 if (!cpuhw->disabled) 1216 1216 goto out; 1217 1217 ··· 1403 1403 * Add the event to the list (if there is room) 1404 1404 * and check whether the total set is still feasible. 1405 1405 */ 1406 - cpuhw = &__get_cpu_var(cpu_hw_events); 1406 + cpuhw = this_cpu_ptr(&cpu_hw_events); 1407 1407 n0 = cpuhw->n_events; 1408 1408 if (n0 >= ppmu->n_counter) 1409 1409 goto out; ··· 1469 1469 1470 1470 power_pmu_read(event); 1471 1471 1472 - cpuhw = &__get_cpu_var(cpu_hw_events); 1472 + cpuhw = this_cpu_ptr(&cpu_hw_events); 1473 1473 for (i = 0; i < cpuhw->n_events; ++i) { 1474 1474 if (event == cpuhw->event[i]) { 1475 1475 while (++i < cpuhw->n_events) { ··· 1575 1575 */ 1576 1576 static void power_pmu_start_txn(struct pmu *pmu) 1577 1577 { 1578 - struct cpu_hw_events *cpuhw = &__get_cpu_var(cpu_hw_events); 1578 + struct cpu_hw_events *cpuhw = this_cpu_ptr(&cpu_hw_events); 1579 1579 1580 1580 perf_pmu_disable(pmu); 1581 1581 cpuhw->group_flag |= PERF_EVENT_TXN; ··· 1589 1589 */ 1590 1590 static void power_pmu_cancel_txn(struct pmu *pmu) 1591 1591 { 1592 - struct cpu_hw_events *cpuhw = &__get_cpu_var(cpu_hw_events); 1592 + struct cpu_hw_events *cpuhw = this_cpu_ptr(&cpu_hw_events); 1593 1593 1594 1594 cpuhw->group_flag &= ~PERF_EVENT_TXN; 1595 1595 perf_pmu_enable(pmu); ··· 1607 1607 1608 1608 if (!ppmu) 1609 1609 return -EAGAIN; 1610 - cpuhw = &__get_cpu_var(cpu_hw_events); 1610 + cpuhw = this_cpu_ptr(&cpu_hw_events); 1611 1611 n = cpuhw->n_events; 1612 1612 if (check_excludes(cpuhw->event, cpuhw->flags, 0, n)) 1613 1613 return -EAGAIN; ··· 1964 1964 1965 1965 if (event->attr.sample_type & PERF_SAMPLE_BRANCH_STACK) { 1966 1966 struct cpu_hw_events *cpuhw; 1967 - cpuhw = &__get_cpu_var(cpu_hw_events); 1967 + cpuhw = this_cpu_ptr(&cpu_hw_events); 1968 1968 power_pmu_bhrb_read(cpuhw); 1969 1969 data.br_stack = &cpuhw->bhrb_stack; 1970 1970 } ··· 2037 2037 static void perf_event_interrupt(struct pt_regs *regs) 2038 2038 { 2039 2039 int i, j; 2040 - struct cpu_hw_events *cpuhw = &__get_cpu_var(cpu_hw_events); 2040 + struct cpu_hw_events *cpuhw = this_cpu_ptr(&cpu_hw_events); 2041 2041 struct perf_event *event; 2042 2042 unsigned long val[8]; 2043 2043 int found, active;
+3 -3
arch/powerpc/perf/core-fsl-emb.c
··· 210 210 unsigned long flags; 211 211 212 212 local_irq_save(flags); 213 - cpuhw = &__get_cpu_var(cpu_hw_events); 213 + cpuhw = this_cpu_ptr(&cpu_hw_events); 214 214 215 215 if (!cpuhw->disabled) { 216 216 cpuhw->disabled = 1; ··· 249 249 unsigned long flags; 250 250 251 251 local_irq_save(flags); 252 - cpuhw = &__get_cpu_var(cpu_hw_events); 252 + cpuhw = this_cpu_ptr(&cpu_hw_events); 253 253 if (!cpuhw->disabled) 254 254 goto out; 255 255 ··· 653 653 static void perf_event_interrupt(struct pt_regs *regs) 654 654 { 655 655 int i; 656 - struct cpu_hw_events *cpuhw = &__get_cpu_var(cpu_hw_events); 656 + struct cpu_hw_events *cpuhw = this_cpu_ptr(&cpu_hw_events); 657 657 struct perf_event *event; 658 658 unsigned long val; 659 659 int found = 0;
+3 -3
arch/powerpc/platforms/cell/interrupt.c
··· 82 82 83 83 static void iic_eoi(struct irq_data *d) 84 84 { 85 - struct iic *iic = &__get_cpu_var(cpu_iic); 85 + struct iic *iic = this_cpu_ptr(&cpu_iic); 86 86 out_be64(&iic->regs->prio, iic->eoi_stack[--iic->eoi_ptr]); 87 87 BUG_ON(iic->eoi_ptr < 0); 88 88 } ··· 148 148 struct iic *iic; 149 149 unsigned int virq; 150 150 151 - iic = &__get_cpu_var(cpu_iic); 151 + iic = this_cpu_ptr(&cpu_iic); 152 152 *(unsigned long *) &pending = 153 153 in_be64((u64 __iomem *) &iic->regs->pending_destr); 154 154 if (!(pending.flags & CBE_IIC_IRQ_VALID)) ··· 163 163 164 164 void iic_setup_cpu(void) 165 165 { 166 - out_be64(&__get_cpu_var(cpu_iic).regs->prio, 0xff); 166 + out_be64(this_cpu_ptr(&cpu_iic.regs->prio), 0xff); 167 167 } 168 168 169 169 u8 iic_get_target_id(int cpu)
+2 -2
arch/powerpc/platforms/powernv/opal-tracepoints.c
··· 48 48 49 49 local_irq_save(flags); 50 50 51 - depth = &__get_cpu_var(opal_trace_depth); 51 + depth = this_cpu_ptr(&opal_trace_depth); 52 52 53 53 if (*depth) 54 54 goto out; ··· 69 69 70 70 local_irq_save(flags); 71 71 72 - depth = &__get_cpu_var(opal_trace_depth); 72 + depth = this_cpu_ptr(&opal_trace_depth); 73 73 74 74 if (*depth) 75 75 goto out;
+1 -1
arch/powerpc/platforms/ps3/interrupt.c
··· 711 711 712 712 static unsigned int ps3_get_irq(void) 713 713 { 714 - struct ps3_private *pd = &__get_cpu_var(ps3_private); 714 + struct ps3_private *pd = this_cpu_ptr(&ps3_private); 715 715 u64 x = (pd->bmp.status & pd->bmp.mask); 716 716 unsigned int plug; 717 717
+1 -1
arch/powerpc/platforms/pseries/dtl.c
··· 75 75 */ 76 76 static void consume_dtle(struct dtl_entry *dtle, u64 index) 77 77 { 78 - struct dtl_ring *dtlr = &__get_cpu_var(dtl_rings); 78 + struct dtl_ring *dtlr = this_cpu_ptr(&dtl_rings); 79 79 struct dtl_entry *wp = dtlr->write_ptr; 80 80 struct lppaca *vpa = local_paca->lppaca_ptr; 81 81
+2 -2
arch/powerpc/platforms/pseries/hvCall_inst.c
··· 110 110 if (opcode > MAX_HCALL_OPCODE) 111 111 return; 112 112 113 - h = &__get_cpu_var(hcall_stats)[opcode / 4]; 113 + h = this_cpu_ptr(&hcall_stats[opcode / 4]); 114 114 h->tb_start = mftb(); 115 115 h->purr_start = mfspr(SPRN_PURR); 116 116 } ··· 123 123 if (opcode > MAX_HCALL_OPCODE) 124 124 return; 125 125 126 - h = &__get_cpu_var(hcall_stats)[opcode / 4]; 126 + h = this_cpu_ptr(&hcall_stats[opcode / 4]); 127 127 h->num_calls++; 128 128 h->tb_total += mftb() - h->tb_start; 129 129 h->purr_total += mfspr(SPRN_PURR) - h->purr_start;
+4 -4
arch/powerpc/platforms/pseries/iommu.c
··· 199 199 200 200 local_irq_save(flags); /* to protect tcep and the page behind it */ 201 201 202 - tcep = __get_cpu_var(tce_page); 202 + tcep = __this_cpu_read(tce_page); 203 203 204 204 /* This is safe to do since interrupts are off when we're called 205 205 * from iommu_alloc{,_sg}() ··· 212 212 return tce_build_pSeriesLP(tbl, tcenum, npages, uaddr, 213 213 direction, attrs); 214 214 } 215 - __get_cpu_var(tce_page) = tcep; 215 + __this_cpu_write(tce_page, tcep); 216 216 } 217 217 218 218 rpn = __pa(uaddr) >> TCE_SHIFT; ··· 398 398 long l, limit; 399 399 400 400 local_irq_disable(); /* to protect tcep and the page behind it */ 401 - tcep = __get_cpu_var(tce_page); 401 + tcep = __this_cpu_read(tce_page); 402 402 403 403 if (!tcep) { 404 404 tcep = (__be64 *)__get_free_page(GFP_ATOMIC); ··· 406 406 local_irq_enable(); 407 407 return -ENOMEM; 408 408 } 409 - __get_cpu_var(tce_page) = tcep; 409 + __this_cpu_write(tce_page, tcep); 410 410 } 411 411 412 412 proto_tce = TCE_PCI_READ | TCE_PCI_WRITE;
+3 -3
arch/powerpc/platforms/pseries/lpar.c
··· 505 505 unsigned long vpn; 506 506 unsigned long i, pix, rc; 507 507 unsigned long flags = 0; 508 - struct ppc64_tlb_batch *batch = &__get_cpu_var(ppc64_tlb_batch); 508 + struct ppc64_tlb_batch *batch = this_cpu_ptr(&ppc64_tlb_batch); 509 509 int lock_tlbie = !mmu_has_feature(MMU_FTR_LOCKLESS_TLBIE); 510 510 unsigned long param[9]; 511 511 unsigned long hash, index, shift, hidx, slot; ··· 695 695 696 696 local_irq_save(flags); 697 697 698 - depth = &__get_cpu_var(hcall_trace_depth); 698 + depth = this_cpu_ptr(&hcall_trace_depth); 699 699 700 700 if (*depth) 701 701 goto out; ··· 720 720 721 721 local_irq_save(flags); 722 722 723 - depth = &__get_cpu_var(hcall_trace_depth); 723 + depth = this_cpu_ptr(&hcall_trace_depth); 724 724 725 725 if (*depth) 726 726 goto out;
+2 -2
arch/powerpc/platforms/pseries/ras.c
··· 302 302 /* If it isn't an extended log we can use the per cpu 64bit buffer */ 303 303 h = (struct rtas_error_log *)&savep[1]; 304 304 if (!rtas_error_extended(h)) { 305 - memcpy(&__get_cpu_var(mce_data_buf), h, sizeof(__u64)); 306 - errhdr = (struct rtas_error_log *)&__get_cpu_var(mce_data_buf); 305 + memcpy(this_cpu_ptr(&mce_data_buf), h, sizeof(__u64)); 306 + errhdr = (struct rtas_error_log *)this_cpu_ptr(&mce_data_buf); 307 307 } else { 308 308 int len, error_log_length; 309 309
+1 -1
arch/powerpc/sysdev/xics/xics-common.c
··· 155 155 156 156 void xics_teardown_cpu(void) 157 157 { 158 - struct xics_cppr *os_cppr = &__get_cpu_var(xics_cppr); 158 + struct xics_cppr *os_cppr = this_cpu_ptr(&xics_cppr); 159 159 160 160 /* 161 161 * we have to reset the cppr index to 0 because we're