Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Multi-buffer sha256 support from SPL #6546

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions module/zfs/sha256.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,17 @@
#include <sys/sha2.h>
#include <sys/abd.h>


#if defined(__x86_64) && defined(_KERNEL) && defined(HAVE_HASH_MB)

extern int mulbuf_sha256(void *buffer, size_t size, unsigned char *digest);

int zfs_hash_mb_disable = B_FALSE;
module_param(zfs_hash_mb_disable, int, 0644);
MODULE_PARM_DESC(zfs_hash_mb_disable, "Disable multi-buffer sha256");

#endif

static int
sha_incremental(void *buf, size_t size, void *arg)
{
Expand All @@ -47,6 +58,19 @@ abd_checksum_SHA256(abd_t *abd, uint64_t size,
SHA2_CTX ctx;
zio_cksum_t tmp;

#if defined(__x86_64) && defined(_KERNEL) && defined(HAVE_HASH_MB)

void *buffer;

if (abd_is_linear(abd) && size > 8 * 1024 && !zfs_hash_mb_disable) {
buffer = abd->abd_u.abd_linear.abd_buf;
mulbuf_sha256(buffer, size, (unsigned char *)zcp);

return;
}

#endif /* _KERNEL && __x86_64 && HAVE_HASH_MB */

SHA2Init(SHA256, &ctx);
(void) abd_iterate_func(abd, 0, size, sha_incremental, &ctx);
SHA2Final(&tmp, &ctx);
Expand Down
8 changes: 8 additions & 0 deletions module/zfs/spa.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ static inline int spa_load_impl(spa_t *spa, uint64_t, nvlist_t *config,
char **ereport);
static void spa_vdev_resilver_done(spa_t *spa);

extern int zfs_hash_mb_disable;
uint_t zio_taskq_batch_pct = 75; /* 1 thread per cpu in pset */
id_t zio_taskq_psrset_bind = PS_NONE;
boolean_t zio_taskq_sysdc = B_TRUE; /* use SDC scheduling class */
Expand Down Expand Up @@ -899,6 +900,13 @@ spa_taskqs_init(spa_t *spa, zio_type_t t, zio_taskq_type_t q)
case ZTI_MODE_BATCH:
batch = B_TRUE;
flags |= TASKQ_THREADS_CPU_PCT;

#if defined(__x86_64) && defined(_KERNEL) && defined(HAVE_HASH_MB)
/* Eightfold threads cpu percentage */
if (!zfs_hash_mb_disable)
value = zio_taskq_batch_pct * 8;
else
#endif
value = MIN(zio_taskq_batch_pct, 100);
break;

Expand Down