Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1295487 > unrolled thread
| Started by | Andrew Pinski <apinski@cavium.com> |
|---|---|
| First post | 2015-12-20 01:20 +0100 |
| Last post | 2015-12-21 14:50 +0100 |
| Articles | 3 — 3 participants |
Back to article view | Back to linux.kernel
[PATCH] ARM64: Improve copy_page for 128 cache line sizes. Andrew Pinski <apinski@cavium.com> - 2015-12-20 01:20 +0100
Re: [PATCH] ARM64: Improve copy_page for 128 cache line sizes. Will Deacon <will.deacon@arm.com> - 2015-12-21 13:50 +0100
Re: [PATCH] ARM64: Improve copy_page for 128 cache line sizes. Arnd Bergmann <arnd@arndb.de> - 2015-12-21 14:50 +0100
| From | Andrew Pinski <apinski@cavium.com> |
|---|---|
| Date | 2015-12-20 01:20 +0100 |
| Subject | [PATCH] ARM64: Improve copy_page for 128 cache line sizes. |
| Message-ID | <qHzTb-1Jy-3@gated-at.bofh.it> |
Adding a check for the cache line size is not much overhead. Special case 128 byte cache line size. This improves copy_page by 85% on ThunderX compared to the original implementation. For LMBench, it improves between 4-10%. Signed-off-by: Andrew Pinski <apinski@cavium.com> --- arch/arm64/lib/copy_page.S | 39 +++++++++++++++++++++++++++++++++++++++ 1 files changed, 39 insertions(+), 0 deletions(-) diff --git a/arch/arm64/lib/copy_page.S b/arch/arm64/lib/copy_page.S index 512b9a7..4c28789 100644 --- a/arch/arm64/lib/copy_page.S +++ b/arch/arm64/lib/copy_page.S @@ -18,6 +18,7 @@ #include <linux/const.h> #include <asm/assembler.h> #include <asm/page.h> +#include <asm/cachetype.h> /* * Copy a page from src to dest (both are page aligned) @@ -27,8 +28,17 @@ * x1 - src */ ENTRY(copy_page) + /* Special case 128 byte or more cache lines */ + mrs x2, ctr_el0 + lsr x2, x2, CTR_CWG_SHIFT + and w2, w2, CTR_CWG_MASK + cmp w2, 5 + b.ge 2f + /* Assume cache line size is 64 bytes. */ prfm pldl1strm, [x1, #64] + /* Align the loop is it fits in one cache line. */ + .balign 64 1: ldp x2, x3, [x1] ldp x4, x5, [x1, #16] ldp x6, x7, [x1, #32] @@ -43,4 +53,33 @@ ENTRY(copy_page) tst x1, #(PAGE_SIZE - 1) b.ne 1b ret + +2: + /* The cache line size is at least 128 bytes. */ + prfm pldl1strm, [x1, #128] + /* Align the loop so it fits in one cache line */ + .balign 128 +1: prfm pldl1strm, [x1, #256] + ldp x2, x3, [x1] + ldp x4, x5, [x1, #16] + ldp x6, x7, [x1, #32] + ldp x8, x9, [x1, #48] + stnp x2, x3, [x0] + stnp x4, x5, [x0, #16] + stnp x6, x7, [x0, #32] + stnp x8, x9, [x0, #48] + + ldp x2, x3, [x1, #64] + ldp x4, x5, [x1, #80] + ldp x6, x7, [x1, #96] + ldp x8, x9, [x1, #112] + add x1, x1, #128 + stnp x2, x3, [x0, #64] + stnp x4, x5, [x0, #80] + stnp x6, x7, [x0, #96] + stnp x8, x9, [x0, #112] + add x0, x0, #128 + tst x1, #(PAGE_SIZE - 1) + b.ne 1b + ret ENDPROC(copy_page) -- 1.7.2.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [next] | [standalone]
| From | Will Deacon <will.deacon@arm.com> |
|---|---|
| Date | 2015-12-21 13:50 +0100 |
| Message-ID | <qI84x-6zh-7@gated-at.bofh.it> |
| In reply to | #1295487 |
On Sat, Dec 19, 2015 at 04:11:18PM -0800, Andrew Pinski wrote: > Adding a check for the cache line size is not much overhead. > Special case 128 byte cache line size. > This improves copy_page by 85% on ThunderX compared to the > original implementation. So this patch seems to: - Align the loop - Increase the prefetch size - Unroll the loop once Do you know where your 85% boost comes from between these? I'd really like to avoid having multiple versions of copy_page, if possible, but maybe we could end up with something that works well enough regardless of cacheline size. Understanding what your bottleneck is would help to lead us in the right direction. Also, how are you measuring the improvement? If you can share your test somewhere, I can see how it affects the other systems I have access to. Will -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Arnd Bergmann <arnd@arndb.de> |
|---|---|
| Date | 2015-12-21 14:50 +0100 |
| Message-ID | <qI90C-77H-5@gated-at.bofh.it> |
| In reply to | #1295957 |
On Monday 21 December 2015, Will Deacon wrote: > On Sat, Dec 19, 2015 at 04:11:18PM -0800, Andrew Pinski wrote: > > Adding a check for the cache line size is not much overhead. > > Special case 128 byte cache line size. > > This improves copy_page by 85% on ThunderX compared to the > > original implementation. > > So this patch seems to: > > - Align the loop > - Increase the prefetch size > - Unroll the loop once > > Do you know where your 85% boost comes from between these? I'd really > like to avoid having multiple versions of copy_page, if possible, but > maybe we could end up with something that works well enough regardless > of cacheline size. Understanding what your bottleneck is would help to > lead us in the right direction. > > Also, how are you measuring the improvement? If you can share your > test somewhere, I can see how it affects the other systems I have access > to. A related question would be how other CPU cores are affected by the change. The test for the cache line size is going to take a few cycles, possibly a lot on certain implementations, e.g. if we ever get one where 'mrs' is microcoded or trapped by a hypervisor. Are there any possible downsides to using the ThunderX version on other microarchitectures too and skip the check? Arnd -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web