WSL2-Linux-Kernel/arch/powerpc
Mark Nelson 25d6e2d7c5 powerpc: Update 64bit memcpy() using CPU_FTR_UNALIGNED_LD_STD
Update memcpy() to add two new feature sections: one for aligning the
destination before copying and one for copying using aligned load
and store doubles.

These new feature sections will only affect Power6 and Cell because
the CPU feature bit was only added to these two processors.

Power6 gets its best performance in memcpy() when aligning neither the
source nor the destination, while Cell gets its best performance when
just the destination is aligned. But in order to save on CPU feature
bits we can use the previously added CPU_FTR_CP_USE_DCBTZ feature bit
to differentiate between Power6 and Cell (because CPU_FTR_CP_USE_DCBTZ
was added to Cell but not Power6).

The first feature section acts to nop out the branch that takes us to
the code that aligns us to an eight byte boundary for the destination.
We only want to nop out this branch on Power6.

So the ALT_FTR_SECTION_END() for this feature section creates a test
mask of the two feature bits ORed together and provides an expected
result of just CPU_FTR_UNALIGNED_LD_STD, thus we nop out the branch
if we're on a CPU that has CPU_FTR_UNALIGNED_LD_STD set and
CPU_FTR_CP_USE_DCBTZ unset.

For the second feature section added, if we're on a CPU that has the
CPU_FTR_UNALIGNED_LD_STD bit set then we don't want to do the copy
with aligned loads and stores (and the appropriate shifting left and
right instructions), so we want to nop out the branch to
.Lsrc_unaligned.

The andi. used for this branch is moved to just above the branch
because this allows us to nop out both instructions with just one
feature section which gives us better performance and doesn't hurt
readability which two separate feature sections did.

Moving the andi. to just above the branch doesn't have any noticeable
negative effect on the remaining 64bit processors (the ones that
didn't have this feature bit added).

On Cell this simple modification results in an improvement to measured
memcpy() bandwidth of up to 50% in the hot cache case and up to 15% in
the cold cache case.

On Power6 we get memory bandwidth results that are up to three times
faster in the hot cache case and up to 50% faster in the cold cache
case.

Commit 2a9294369b ("powerpc: Add new CPU
feature: CPU_FTR_CP_USE_DCBTZ") was where CPU_FTR_CP_USE_DCBTZ was
added.

To say that Cell gets its best performance in memcpy() with just the
destination aligned is true but only for the reason that the indirect
shift and rotate instructions, sld and srd, are microcoded on Cell.
This means that either the destination or the source can be aligned,
but not both, and seeing as we get better performance with the
destination aligned we choose this option.

While we're at it make a one line change from cmpldi r1,... to
cmpldi cr1,... for consistency.

Signed-off-by: Mark Nelson <markn@au1.ibm.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>
2008-11-05 22:08:29 +11:00
..
boot powerpc: Remove device_type = "rtc" properties in .dts files 2008-11-05 22:08:28 +11:00
configs Merge branch 'merge' of master.kernel.org:/pub/scm/linux/kernel/git/jwboyer/powerpc-4xx into merge 2008-10-31 16:08:14 +11:00
include/asm powerpc: Add new CPU feature: CPU_FTR_UNALIGNED_LD_STD 2008-11-05 22:08:28 +11:00
kernel powerpc: Update page-in counter for CMM 2008-11-05 22:08:28 +11:00
kvm KVM: switch to get_user_pages_fast 2008-10-15 14:25:06 +02:00
lib powerpc: Update 64bit memcpy() using CPU_FTR_UNALIGNED_LD_STD 2008-11-05 22:08:29 +11:00
math-emu powerpc/math-emu: Use kernel generic math-emu code 2008-10-01 08:40:07 -05:00
mm powerpc: Update page-in counter for CMM 2008-11-05 22:08:28 +11:00
oprofile powerpc/cell/OProfile: Fix on-stack array size in activate spu profiling function 2008-10-31 16:13:51 +11:00
platforms powerpc/pseries: Fix getting the server number size 2008-11-05 22:08:28 +11:00
sysdev Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6 2008-11-02 10:15:52 -08:00
xmon powerpc: Fix compile errors with CONFIG_BUG=n 2008-10-31 21:34:09 +11:00
Kconfig Merge commit 'v2.6.28-rc2' into tracing/urgent 2008-10-27 10:50:54 +01:00
Kconfig.debug powerpc: Split-out common MSI bitmap logic into msi_bitmap.c 2008-08-20 16:34:57 +10:00
Makefile ftrace: rename FTRACE to FUNCTION_TRACER 2008-10-20 18:27:03 +02:00