mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-25 11:47:43 +03:00
Introduce zfs_refcount_(add|remove)_few().
There are two places where we need to add/remove several references with semantics of zfs_refcount_(add|remove). But when debug/tracing is disabled, it is a crime to run multiple atomic_inc() in a loop, especially under congested pool-wide allocator lock. Introduced new functions implement the same semantics as the loop, but without overhead in production builds. Reviewed-by: Rich Ercolani <rincebrain@gmail.com> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Alexander Motin <mav@FreeBSD.org> Sponsored by: iXsystems, Inc. Closes #14934
This commit is contained in:
@@ -151,6 +151,15 @@ zfs_refcount_add(zfs_refcount_t *rc, const void *holder)
|
||||
return (zfs_refcount_add_many(rc, 1, holder));
|
||||
}
|
||||
|
||||
void
|
||||
zfs_refcount_add_few(zfs_refcount_t *rc, uint64_t number, const void *holder)
|
||||
{
|
||||
if (!rc->rc_tracked)
|
||||
(void) zfs_refcount_add_many(rc, number, holder);
|
||||
else for (; number > 0; number--)
|
||||
(void) zfs_refcount_add(rc, holder);
|
||||
}
|
||||
|
||||
int64_t
|
||||
zfs_refcount_remove_many(zfs_refcount_t *rc, uint64_t number,
|
||||
const void *holder)
|
||||
@@ -204,6 +213,15 @@ zfs_refcount_remove(zfs_refcount_t *rc, const void *holder)
|
||||
return (zfs_refcount_remove_many(rc, 1, holder));
|
||||
}
|
||||
|
||||
void
|
||||
zfs_refcount_remove_few(zfs_refcount_t *rc, uint64_t number, const void *holder)
|
||||
{
|
||||
if (!rc->rc_tracked)
|
||||
(void) zfs_refcount_remove_many(rc, number, holder);
|
||||
else for (; number > 0; number--)
|
||||
(void) zfs_refcount_remove(rc, holder);
|
||||
}
|
||||
|
||||
void
|
||||
zfs_refcount_transfer(zfs_refcount_t *dst, zfs_refcount_t *src)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user