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

arm64: lib: patch in prfm for copy_page if requested

On ThunderX T88 pass 1 and pass 2, there is no hardware prefetching so
we need to patch in explicit software prefetching instructions

Prefetching improves this code by 60% over the original code and 2x
over the code without prefetching for the affected hardware using the
benchmark code at https://github.com/apinski-cavium/copy_page_benchmark

Signed-off-by: Andrew Pinski <apinski@cavium.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
Tested-by: Andrew Pinski <apinski@cavium.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>

authored by

Andrew Pinski and committed by
Catalin Marinas
60e0a09d 223e23e8

+17
+17
arch/arm64/lib/copy_page.S
··· 18 18 #include <linux/const.h> 19 19 #include <asm/assembler.h> 20 20 #include <asm/page.h> 21 + #include <asm/cpufeature.h> 22 + #include <asm/alternative.h> 21 23 22 24 /* 23 25 * Copy a page from src to dest (both are page aligned) ··· 29 27 * x1 - src 30 28 */ 31 29 ENTRY(copy_page) 30 + alternative_if_not ARM64_HAS_NO_HW_PREFETCH 31 + nop 32 + nop 33 + alternative_else 34 + # Prefetch two cache lines ahead. 35 + prfm pldl1strm, [x1, #128] 36 + prfm pldl1strm, [x1, #256] 37 + alternative_endif 38 + 32 39 ldp x2, x3, [x1] 33 40 ldp x4, x5, [x1, #16] 34 41 ldp x6, x7, [x1, #32] ··· 51 40 add x1, x1, #128 52 41 1: 53 42 subs x18, x18, #128 43 + 44 + alternative_if_not ARM64_HAS_NO_HW_PREFETCH 45 + nop 46 + alternative_else 47 + prfm pldl1strm, [x1, #384] 48 + alternative_endif 54 49 55 50 stnp x2, x3, [x0] 56 51 ldp x2, x3, [x1]