HomeFreeBSD

Fix assertions in crypto reference helpers

Description

Fix assertions in crypto reference helpers

The assertions are racy and the use of membar_exit() did nothing to
fix that.

The helpers use atomic functions, so we cleverly get values from the
atomics that we can use to ensure that the assertions operate on the
correct values.

We also use membar_producer() prior to decrementing reference counts
so that operations that happened prior to a decrement to 0 will be
guaranteed to happen before the decrement on architectures that reorder
atomics.

This also slightly improves performance by eliminating unnecessary
reads, although I doubt it would be measurable in any benchmark.

Reviewed-by: Mateusz Guzik <mjguzik@gmail.com>
Signed-off-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Closes #13880

Details

Provenance
Richard Yao <richard.yao@alumni.stonybrook.edu>Authored on Sep 15 2022, 8:24 PM
GitHub <noreply@github.com>Committed on Sep 15 2022, 8:24 PM
Parents
rGdc2fe24ca223: ZTS: parameter expansion in zfs_unshare_006_pos
Branches
Unknown
Tags
Unknown

Event Timeline

GitHub <noreply@github.com> committed rGe949d36040e5: Fix assertions in crypto reference helpers (authored by Richard Yao <richard.yao@alumni.stonybrook.edu>).Sep 15 2022, 8:24 PM