mirror_zfs/include/os/freebsd/spl
Mark Johnston fdcb79b52e
spl: Don't check FreeBSD rwlocks for double initialization (#13019)
This checking breaks KMSAN since it effectively loads from uninitialized
memory to see if the lock is already initialized.  This happens in
dnode_cons() for example.  This checking is not very useful, partly due
to UMA's memory trashing, and is already disabled for mutexes.  Make
mutexes and rwlocks consistent: remove double-initialization checking
for rwlocks, and pass SX_NEW to disable the same checking in
lock_init().

No functional change intended, this affects only debug builds.

As a side note, kmem cache constructors/destructors are implemented
suboptimally on FreeBSD.  FreeBSD's slab allocator, UMA, supports two
pairs of constructors/destructors: ctor/dtor and init/fini.  The former
are called upon every allocation and free of an item, while the latter
are called when an item is imported or released from a zone,
respectively.  That is, when a slab is allocated to a particular cache,
it is subdivided into items, and init is called on each.  fini is called
when the slab is being prepared to be freed back to the system.  The
intent is for them to initialize static fields such as locks, which
do not need to be initialized upon each allocation of an item.

In illumos, kmem_cache constructors/destructors correspond to UMA's
init/fini callbacks.  However, in the SPL they are implemented as UMA
ctor/dtors, meaning that they get called far more often than necessary.
This may be difficult to fix, since new code may assume the kmem cache
ctor/dtors are in fact called upon each allocation/free, and there
doesn't seem to be a clear way to implement the intended semantics on
Linux.

Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Signed-off-by: Mark Johnston <markj@FreeBSD.org>
Closes #13019
2022-01-31 10:58:45 -08:00
..
acl Avoid installing kernel headers on FreeBSD 2020-06-27 17:40:14 -07:00
rpc FreeBSD: make adjustments for the standalone environment 2020-10-13 21:05:49 -07:00
sys spl: Don't check FreeBSD rwlocks for double initialization (#13019) 2022-01-31 10:58:45 -08:00
Makefile.am Add FreeBSD support to OpenZFS 2020-04-14 11:36:28 -07:00