Skip to content

Commit

Permalink
Fix blake3 on macOS/arm64
Browse files Browse the repository at this point in the history
    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]>
  • Loading branch information
lundman committed Aug 12, 2023
1 parent 9b8d05b commit a96cfb7
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions module/zfs/blake3_zfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ abd_checksum_blake3_native(abd_t *abd, uint64_t size, const void *ctx_template,
{
ASSERT(ctx_template != NULL);

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

#if defined(_KERNEL)
#if defined(_KERNEL) && !(defined(__APPLE__) && defined(__aarch64__))
/* To keep conditionals the same */
kpreempt_enable();
#else
memset(ctx, 0, sizeof (*ctx));
Expand Down

0 comments on commit a96cfb7

Please sign in to comment.