Skip to content

Commit eb68e3c

Browse files
amotinbehlendorf
authored andcommitted
Micro-optimize zrl_remove()
atomic_dec_32() should be a bit lighter than atomic_dec_32_nv(). Reviewed-by: Tino Reichardt <[email protected]> Reviewed-by: Richard Yao <[email protected]> Signed-off-by: Ryan Moeller <[email protected]> Signed-off-by: Alexander Motin <[email protected]> Closes #14200
1 parent 2098a00 commit eb68e3c

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

module/zfs/zrlock.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,16 +106,16 @@ zrl_add_impl(zrlock_t *zrl, const char *zc)
106106
void
107107
zrl_remove(zrlock_t *zrl)
108108
{
109-
uint32_t n;
110-
111109
#ifdef ZFS_DEBUG
112110
if (zrl->zr_owner == curthread) {
113111
zrl->zr_owner = NULL;
114112
zrl->zr_caller = NULL;
115113
}
114+
int32_t n = atomic_dec_32_nv((uint32_t *)&zrl->zr_refcount);
115+
ASSERT3S(n, >=, 0);
116+
#else
117+
atomic_dec_32((uint32_t *)&zrl->zr_refcount);
116118
#endif
117-
n = atomic_dec_32_nv((uint32_t *)&zrl->zr_refcount);
118-
ASSERT3S((int32_t)n, >=, 0);
119119
}
120120

121121
int

0 commit comments

Comments
 (0)