Skip to content

Commit abcf9d3

Browse files
committed
Fix blake3 on macOS/arm64
BLAKE3_CTX *ctx = blake3_per_cpu_ctx[CPU_SEQID_UNSTABLE]; We have macOS arm64 to call kmem_alloc() as the cpu_number() changes quite frequently, and would reuse an already active ctx. If in future we want to avoid kmem_alloc, we can use the blake3_per_cpu_ctx[CPU_SEQID_UNSTABLE] but check if it is busy, and move to the next free slot. Easily implemented with CAS. Signed-off-by: Jorgen Lundman <[email protected]>
1 parent 802749c commit abcf9d3

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

module/icp/algs/blake3/blake3_impl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ blake3_param(ZFS_MODULE_PARAM_ARGS)
364364
int err;
365365

366366
generic_impl_init();
367-
if ((void *)req->newptr == NULL) {
367+
if ((const void *)req->newptr == NULL) {
368368
const uint32_t impl = IMPL_READ(generic_impl_chosen);
369369
const int init_buflen = 64;
370370
const char *fmt;

module/zfs/blake3_zfs.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ abd_checksum_blake3_native(abd_t *abd, uint64_t size, const void *ctx_template,
4949
{
5050
ASSERT(ctx_template != NULL);
5151

52-
#if defined(_KERNEL)
52+
#if defined(_KERNEL) && !(defined(__APPLE__) && defined(__aarch64__))
5353
kpreempt_disable();
5454
BLAKE3_CTX *ctx = blake3_per_cpu_ctx[CPU_SEQID];
5555
#else
@@ -60,7 +60,8 @@ abd_checksum_blake3_native(abd_t *abd, uint64_t size, const void *ctx_template,
6060
(void) abd_iterate_func(abd, 0, size, blake3_incremental, ctx);
6161
Blake3_Final(ctx, (uint8_t *)zcp);
6262

63-
#if defined(_KERNEL)
63+
#if defined(_KERNEL) && !(defined(__APPLE__) && defined(__aarch64__))
64+
/* To keep conditionals the same */
6465
kpreempt_enable();
6566
#else
6667
memset(ctx, 0, sizeof (*ctx));

0 commit comments

Comments
 (0)