diff --git a/module/zfs/sha256.c b/module/zfs/sha256.c index 23a97aa3de17..723d68a5bed3 100644 --- a/module/zfs/sha256.c +++ b/module/zfs/sha256.c @@ -31,6 +31,17 @@ #include #include + +#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) { @@ -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); diff --git a/module/zfs/spa.c b/module/zfs/spa.c index c519e933b117..3c402b777483 100644 --- a/module/zfs/spa.c +++ b/module/zfs/spa.c @@ -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 */ @@ -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 percentage of cpu */ + if (!zfs_hash_mb_disable) + value = zio_taskq_batch_pct * 8; + else +#endif value = MIN(zio_taskq_batch_pct, 100); break;