zfs icon indicating copy to clipboard operation
zfs copied to clipboard

Offload SHA256 to FreeBSD's OCF.

Open gldisater opened this issue 3 years ago • 1 comments

Motivation and Context

Improve the performance of SHA256 checksum usage by ZFS.

Description

Check if OCF has hardware acceleration available. If so, use it instead of the software implementation that's built into OpenZFS. Allan Jude did a review of this patch and wanted the crypto_os.h files and cleaned up style issues.

FreeBSD 13 will need https://cgit.freebsd.org/src/commit/?id=c71f2370c5d480cf70f12ee276e044681c57aefc to be backported to it before this patch will work on 13

How Has This Been Tested?

On Intel without SHA256 acceleration and on Ryzen and Apple M1, created a zpool and dataset using SHA256, dd 100GB of /dev/random into the dataset and scrub the pool. Apply the patch, recompile the FreeBSD kernel and reboot. Scrub the pool.

On Apple M1 the pre-patch scrub is 1000MB/s and 80% cpu usage, after the patch and loading ossl.ko to provide the SHA256 acceleration results in 1.7GB/s and 30% cpu usage.

On my Ryzen 1700 I don't have fast enough SSDs to saturate my cpu, about 25-30% cpu usage before at 500MB/s. After is 5-8%

Types of changes

  • [ ] Bug fix (non-breaking change which fixes an issue)
  • [ ] New feature (non-breaking change which adds functionality)
  • [x] Performance enhancement (non-breaking change which improves efficiency)
  • [ ] Code cleanup (non-breaking change which makes code smaller or more readable)
  • [ ] Breaking change (fix or feature that would cause existing functionality to change)
  • [ ] Library ABI change (libzfs, libzfs_core, libnvpair, libuutil and libzfsbootenv)
  • [ ] Documentation (a change to man pages or other documentation)

Checklist:

  • [x] My code follows the OpenZFS code style requirements.
  • [ ] I have updated the documentation accordingly.
  • [x] I have read the contributing document.
  • [ ] I have added tests to cover my changes.
  • [ ] I have run the ZFS Test Suite with this change applied.
  • [x] All commit messages are properly formatted and contain Signed-off-by.

gldisater avatar Jul 13 '22 01:07 gldisater

Hello,

the Intel QAT stuff is also hacked into OpenZFS this way... I think we should have it switchable at running time.

There are two methods for this right now:

  1. the current default way with module parameter and also the on the fly switch via echo
  2. the Z.I.A. way ... which may get into ZFS some day

mcmilk avatar Jul 13 '22 16:07 mcmilk