Skip to content

powerpc/64: memcmp() optimization

[email protected] linuxppc-dev 8 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v8 Latest5 patches 1 replyIn review
  2. v75 patches 5 repliesSuperseded
  3. v64 patches 12 repliesSuperseded
Earlier versions · 5
VersionPostedPatchesRepliesStatus
v54 patches2 repliesSuperseded
v44 patches2 repliesSuperseded
v33 patches2 repliesSuperseded
v23 patches14 repliesSuperseded
v13 patches6 repliesSuperseded

Changes in v8 from the cover letter

- define memcmp with _GLOBAL_TOC() instead of _GLOBAL() to fix TOC issue. add _GLOBAL_TOC() definition into selftest so that it can be compiled.
- use mfocrf/mtocrf instead of mcrf to save/restore CR0

Patches in v8 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/5powerpc/64: Align bytes before fall back to .Lshort in powerpc64 memcmp()arch/powerpc/lib/memcmp_64.S+133 -71 reply
2/5powerpc: add vcmpequd/vcmpequb ppc instruction macroarch/powerpc/include/asm/ppc-opcode.h+11 -00 replies
3/5powerpc/64: enhance memcmp() with VMX instruction for long bytes comparisionarch/powerpc/include/asm/asm-prototypes.h arch/powerpc/lib/copypage_power7.S arch/powerpc/lib/memcmp_64.S +2 more+248 -110 replies
4/5powerpc/64: add 32 bytes prechecking before using VMX optimization on memcmp()arch/powerpc/lib/memcmp_64.S+46 -110 replies
5/5powerpc:selftest update memcmp_64 selftest for VMX implementationtools/testing/selftests/powerpc/copyloops/asm/ppc_asm.h tools/testing/selftests/powerpc/stringloops/asm/ppc-opcode.h tools/testing/selftests/powerpc/stringloops/asm/ppc_asm.h +1 more+142 -240 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v8 yet.

Read the v8 thread

Cover letter [PATCH v8 0/5] powerpc/64: memcmp() optimization

From: Simon Guo <[email protected]>

There is some room to optimize memcmp() in powerpc 64 bits version for following 2 cases:
(1) Even src/dst addresses are not aligned with 8 bytes at the beginning, memcmp() can align them and go with .Llong comparision mode without fallback to .Lshort comparision mode do compare buffer byte by byte.
(2) VMX instructions can be used to speed up for large size comparision, currently the threshold is set for 4K bytes. Notes the VMX instructions will lead to VMX regs save/load penalty. This patch set includes a patch to add a 32 bytes pre-checking to minimize the penalty.

It did the similar with glibc commit dec4a7105e (powerpc: Improve memcmp performance for POWER8). Thanks Cyril Bur's information. This patch set also updates memcmp selftest case to make it compiled and incorporate large size comparison case.

v7 -> v8:
- define memcmp with _GLOBAL_TOC() instead of _GLOBAL() to fix TOC issue. add _GLOBAL_TOC() definition into selftest so that it can be compiled.
- use mfocrf/mtocrf instead of mcrf to save/restore CR0

v6 -> v7:
- add vcmpequd/vcmpequdb .long macro
- add CPU_FTR pair so that Power7 won't invoke Altivec instrs.
- rework some instructions for higher performance or more readable.

v5 -> v6:
- correct some comments/commit messsage.
- rename VMX_OPS_THRES to VMX_THRESH

v4 -> v5:
- Expand 32 bytes prechk to src/dst different offset case, and remove KSM specific label/comment.

v3 -> v4:
- Add 32 bytes pre-checking before using VMX instructions.

v2 -> v3:
- add optimization for src/dst with different offset against 8 bytes boundary.
- renamed some label names.
- reworked some comments from Cyril Bur, such as fill the pipeline, and use VMX when size == 4K.
- fix a bug of enter/exit_vmx_ops pairness issue. And revised test case to test whether enter/exit_vmx_ops are paired.

v1 -> v2:
- update 8bytes unaligned bytes comparison method.
- fix a VMX comparision bug.
- enhanced the original memcmp() selftest.
- add powerpc/64 to subject/commit message.

Simon Guo (5):
powerpc/64: Align bytes before fall back to .Lshort in powerpc64
memcmp()
powerpc: add vcmpequd/vcmpequb ppc instruction macro powerpc/64: enhance memcmp() with VMX instruction for long bytes
comparision
powerpc/64: add 32 bytes prechecking before using VMX optimization on
memcmp()
powerpc:selftest update memcmp_64 selftest for VMX implementation

 arch/powerpc/include/asm/asm-prototypes.h          |   4 +-
 arch/powerpc/include/asm/ppc-opcode.h              |  11 +
 arch/powerpc/lib/copypage_power7.S                 |   4 +-
 arch/powerpc/lib/memcmp_64.S                       | 414 ++++++++++++++++++++-
 arch/powerpc/lib/memcpy_power7.S                   |   6 +-
 arch/powerpc/lib/vmx-helper.c                      |   4 +-
 .../selftests/powerpc/copyloops/asm/ppc_asm.h      |   4 +-
 .../selftests/powerpc/stringloops/asm/ppc-opcode.h |  39 ++
 .../selftests/powerpc/stringloops/asm/ppc_asm.h    |  25 ++
 .../testing/selftests/powerpc/stringloops/memcmp.c |  98 +++--
 10 files changed, 568 insertions(+), 41 deletions(-)
 create mode 100644 tools/testing/selftests/powerpc/stringloops/asm/ppc-opcode.h
Signature · 1 line
1.8.3.1