From eb68e3cd5655f3c8b22efce511fc5a056aa1f1a7 Mon Sep 17 00:00:00 2001 From: Alexander Motin Date: Tue, 29 Nov 2022 12:26:03 -0500 Subject: [PATCH] Micro-optimize zrl_remove() atomic_dec_32() should be a bit lighter than atomic_dec_32_nv(). Reviewed-by: Tino Reichardt Reviewed-by: Richard Yao Signed-off-by: Ryan Moeller Signed-off-by: Alexander Motin Closes #14200 --- module/zfs/zrlock.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/module/zfs/zrlock.c b/module/zfs/zrlock.c index a4def60536..8b6755bc93 100644 --- a/module/zfs/zrlock.c +++ b/module/zfs/zrlock.c @@ -106,16 +106,16 @@ zrl_add_impl(zrlock_t *zrl, const char *zc) void zrl_remove(zrlock_t *zrl) { - uint32_t n; - #ifdef ZFS_DEBUG if (zrl->zr_owner == curthread) { zrl->zr_owner = NULL; zrl->zr_caller = NULL; } + int32_t n = atomic_dec_32_nv((uint32_t *)&zrl->zr_refcount); + ASSERT3S(n, >=, 0); +#else + atomic_dec_32((uint32_t *)&zrl->zr_refcount); #endif - n = atomic_dec_32_nv((uint32_t *)&zrl->zr_refcount); - ASSERT3S((int32_t)n, >=, 0); } int