freebsd-skq/sys/cddl
Alexander Motin c10aea724f Reduce number of atomic_add() calls in aggsum.
Previous code used 4 atomics to do aggsum_flush_bucket() and 2 more to
re-borrow after the flush.  But since asc_borrowed and asc_delta are
accessed only while holding asc_lock, it makes no any sense to modify
as_lower_bound and as_upper_bound in multiple steps.  Instead of that
the new code uses only 2 atomics in all the cases, one per as_*_bound
variable.  I think even that is overkill, simple atomic store and
load could be used here, since all modifications are done under the
as_lock, but there are no such primitives in ZFS code now.

While there, make borrow code consider previous borrow value, so that
on mixed request patterns reduce chance of needing to borrow again if
much larger request follows tiny one that needed borrow.

Also reduce as_numbuckets from uint64_t to u_int.  It makes no sense
to use so large division operation on every aggsum_add().

Reviewed by:	Brian Behlendorf, Paul Dagnelie
MFC after:	2 weeks
Sponsored by:	iXsystems, Inc.
2020-02-06 20:32:53 +00:00
..
boot/zfs loader: rewrite zfs reader zap code to use malloc 2020-02-04 07:37:55 +00:00
compat/opensolaris Add sys/systm.h to several places that use vm headers. 2020-02-04 18:56:26 +00:00
contrib/opensolaris Reduce number of atomic_add() calls in aggsum. 2020-02-06 20:32:53 +00:00
dev dtrace: add missing CLTFLAG_MPSAFE annotations 2020-01-12 04:53:22 +00:00