alistair23-linux/arch/ia64/kernel
Christoph Lameter 6065a244a0 ia64: Replace __get_cpu_var uses
__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 :

#define __get_cpu_var(var) (*this_cpu_ptr(&(var)))

__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: Tony Luck <tony.luck@intel.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: linux-ia64@vger.kernel.org
Signed-off-by: Christoph Lameter <cl@linux.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
2014-08-26 13:45:52 -04:00
..
.gitignore
acpi-ext.c
acpi.c ACPI / ia64: introduce variable acpi_lapic into ia64 2014-05-16 16:01:16 +02:00
asm-offsets.c ia64/xen: Remove Xen support for ia64 2013-12-10 16:11:07 -08:00
audit.c
brl_emu.c
crash.c ia64: convert use of typedef ctl_table to struct ctl_table 2014-06-06 16:08:15 -07:00
crash_dump.c
cyclone.c
dma-mapping.c
efi.c ia64/efi: Implement efi_enabled() 2014-03-04 16:17:20 +00:00
efi_stub.S
elfcore.c switch elf_core_write_extra_data() to dump_emit() 2013-11-09 00:16:23 -05:00
entry.h
entry.S [IA64] Wire up getrandom() system call 2014-08-06 14:37:12 -07:00
err_inject.c ia64, err-inject: Fix CPU hotplug callback registration 2014-03-20 13:43:41 +01:00
esi.c
esi_stub.S
fsys.S Fix broken fsys_getppid() 2013-03-19 16:14:52 -07:00
fsyscall_gtod_data.h
ftrace.c ftrace: Do not pass data to ftrace_dyn_arch_init 2014-03-07 10:06:14 -05:00
gate-data.S
gate.lds.S
gate.S
head.S [IA64] Change default PSR.ac from '1' to '0' (Fix erratum #237) 2014-04-16 10:20:34 -07:00
ia64_ksyms.c
init_task.c
iosapic.c ia64: Use irq_init_desc 2014-05-16 14:05:22 +02:00
irq.c ia64: Replace __get_cpu_var uses 2014-08-26 13:45:52 -04:00
irq_ia64.c ia64: Replace __get_cpu_var uses 2014-08-26 13:45:52 -04:00
irq_lsapic.c
ivt.S [IA64] Change default PSR.ac from '1' to '0' (Fix erratum #237) 2014-04-16 10:20:34 -07:00
jprobes.S
kprobes.c ia64: Replace __get_cpu_var uses 2014-08-26 13:45:52 -04:00
machine_kexec.c [IA64] kexec: Move the dereference below the NULL test 2012-09-10 14:31:23 -07:00
machvec.c
Makefile cpufreq: ia64: move cpufreq driver to drivers/cpufreq 2013-04-10 13:19:25 +02:00
Makefile.gate
mca.c ia64: Replace __get_cpu_var uses 2014-08-26 13:45:52 -04:00
mca_asm.S
mca_drv.c Remove cast for kmalloc return value 2013-03-19 16:14:53 -07:00
mca_drv.h
mca_drv_asm.S
minstate.h cputime: Generic on-demand virtual cputime accounting 2013-01-27 19:23:27 +01:00
module.c
msi_ia64.c ia64: Validate online cpus in irq_set_affinity() callbacks 2014-03-12 13:07:40 +01:00
nr-irqs.c ia64/xen: Remove Xen support for ia64 2013-12-10 16:11:07 -08:00
numa.c [IA64] Delete __cpuinit usage from all ia64 users 2013-06-24 15:44:27 -07:00
pal.S
palinfo.c ia64, palinfo: Fix CPU hotplug callback registration 2014-03-20 13:43:40 +01:00
paravirt.c
paravirt_inst.h ia64/xen: Remove Xen support for ia64 2013-12-10 16:11:07 -08:00
paravirt_patch.c
paravirt_patchlist.c
paravirt_patchlist.h ia64/xen: Remove Xen support for ia64 2013-12-10 16:11:07 -08:00
paravirtentry.S
patch.c
pci-dma.c [IA64] pci: Remove unused fallback_dev 2013-06-03 16:04:31 -07:00
pci-swiotlb.c
perfmon.c ia64: convert use of typedef ctl_table to struct ctl_table 2014-06-06 16:08:15 -07:00
perfmon_default_smpl.c
perfmon_generic.h
perfmon_itanium.h
perfmon_mckinley.h
perfmon_montecito.h
process.c ia64: Replace __get_cpu_var uses 2014-08-26 13:45:52 -04:00
ptrace.c ia64: kill thread_matches(), unexport ptrace_check_attach() 2013-01-20 12:26:05 -08:00
relocate_kernel.S
sal.c
salinfo.c ia64, salinfo: Fix hotplug callback registration 2014-03-20 13:43:40 +01:00
setup.c DMI: Parse memory device (type 17) in SMBIOS 2013-10-23 10:10:12 -07:00
sigframe.h
signal.c ia64: Use get_signal() signal_setup_done() 2014-08-06 13:02:14 +02:00
smp.c
smpboot.c [IA64] Delete __cpuinit usage from all ia64 users 2013-06-24 15:44:27 -07:00
stacktrace.c
sys_ia64.c mm: use vm_unmapped_area() on ia64 architecture 2013-02-22 13:46:59 -08:00
time.c rtc: ia64: allow other architectures to use EFI RTC 2014-08-08 15:57:19 -07:00
topology.c ia64, topology: Fix CPU hotplug callback registration 2014-03-20 13:43:40 +01:00
traps.c ia64: Replace __get_cpu_var uses 2014-08-26 13:45:52 -04:00
unaligned.c
uncached.c mm: fix GFP_THISNODE callers and clarify 2014-03-10 17:26:19 -07:00
unwind.c
unwind_decoder.c
unwind_i.h
vmlinux.lds.S ia64/xen: Remove Xen support for ia64 2013-12-10 16:11:07 -08:00