aboutsummaryrefslogtreecommitdiff
path: root/sys/modules/itwd
diff options
context:
space:
mode:
authorGleb Smirnoff <glebius@FreeBSD.org>2024-10-24 16:58:05 +0000
committerGleb Smirnoff <glebius@FreeBSD.org>2024-10-24 17:14:03 +0000
commitefcb2ec8cb81ea44c58e41082c6d965f9493099f (patch)
tree8160d512ffd58ed46024c0a47d27da294221c465 /sys/modules/itwd
parent656991b0c629038beddf1847a6c20318d3ac4181 (diff)
callout: provide CALLOUT_TRYLOCK flag
If a callout was initialized with the flag, then the callout(9) system will not drop the callwheel lock in softclock_call_cc() to obtain the callout lock. Instead it will use try-lock semantic to obtain the callout's lock. In case of a failure the callout will be rescheduled to the 50% of the precision value. The main benefit of such behavior is not the avoidance of the lock contention in the callout thread, but the fact that callout with such flag can be actually stopped in a safe manner, because the race window in the beginning of softclock_call_cc() is closed. Call of callout_stop() on such a callout would guarantee that nothing will be executed after callout_stop() returns, neither callout lock will be dereferenced. A callout marked as CALLOUT_TRYLOCK | CALLOUT_RETURNUNLOCKED can call callout_stop() from the callout function itself (0, a failure to stop, will be returned), then unlock the lock and then free the memory containing the callout structure. Caveat: when calling callout_stop() from outside the callout function, the return value from callout_stop() is still inconsistent. A race window at the end of softclock_call_cc() still exists, so callout_stop() may report failure to stop, which would not be true. Reviewed by: jtl, kib Differential Revision: https://reviews.freebsd.org/D45746
Diffstat (limited to 'sys/modules/itwd')
0 files changed, 0 insertions, 0 deletions