Skip to content

Commit 4a36c3f

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 4a36c3f

File tree

5 files changed

+7
-6
lines changed

5 files changed

+7
-6
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/icp/algs/sha2/sha256_impl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ sha256_param(ZFS_MODULE_PARAM_ARGS)
260260
int err;
261261

262262
generic_impl_init();
263-
if ((void *)req->newptr == NULL) {
263+
if ((const void *)req->newptr == NULL) {
264264
const uint32_t impl = IMPL_READ(generic_impl_chosen);
265265
const int init_buflen = 64;
266266
const char *fmt;

module/icp/algs/sha2/sha512_impl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ sha512_param(ZFS_MODULE_PARAM_ARGS)
235235
int err;
236236

237237
generic_impl_init();
238-
if ((void *)req->newptr == NULL) {
238+
if ((const void *)req->newptr == NULL) {
239239
const uint32_t impl = IMPL_READ(generic_impl_chosen);
240240
const int init_buflen = 64;
241241
const char *fmt;

module/zcommon/zfs_fletcher.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -949,7 +949,7 @@ fletcher_4_param(ZFS_MODULE_PARAM_ARGS)
949949
{
950950
int err = 0;
951951

952-
if ((void *)req->newptr == NULL) {
952+
if ((const void *)req->newptr == NULL) {
953953
const uint32_t impl = IMPL_READ(fletcher_4_impl_chosen);
954954
const int init_buflen = 64;
955955
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)