|SMR_CALL(9)||Kernel Developer's Manual||SMR_CALL(9)|
safe memory reclamation
smr_entry *smr, void
(*fn)(void *), void
The safe memory reclamation API provides a mechanism for reclaiming shared objects that readers can access without locking. Objects that are reclaimed through SMR are called SMR-protected. The mechanism guarantees that SMR-protected objects are not destroyed while readers are using them. However, it does not control how these objects are modified.
Readers access SMR-protected objects inside an
SMR read-side critical section using
SMR_PTR_GET(9). The section is
and exited with
These routines never block. Sleeping is not allowed within SMR read-side
initializes the entry smr for use with
schedules a callback to be invoked after the entry smr
cannot be referenced by a reader in SMR read-side critical section. On
invocation, the system calls function fn with argument
arg in process context without any locks held. The
implementation may delay the call in order to reduce overall system overhead
sleeps until any SMR read-side critical sections that are active on other
CPUs at the time of invocation have ended. Like with
smr_call(), the processing of the request may be
smr_barrier() but the system is forced to
process the request as soon as possible. The use of this function is
discouraged because of the heavy impact on system performance.
The SMR implementation does not limit the number
of deferred calls. It is important to prevent arbitrary call rate of
Otherwise, it might be possible to exhaust system resources if the system is
not able to invoke callbacks quickly enough.
smr_init() can be called during autoconf, from
process context, or from interrupt context.
smr_flush() can be called from process context.
The SMR API first appeared in OpenBSD 6.5.
|February 25, 2020||OpenBSD-current|