This adds a wait bit to refcount with an atomic sleep. Consumers that use this facility need to be aware that specific count values can not be examined directly.
When a counter is saturated this will block forever.
Differential D21254
Add support for blocking waits to refcounts. jeff on Aug 13 2019, 8:02 PM. Authored by Tags None Referenced Files
Details This adds a wait bit to refcount with an atomic sleep. Consumers that use this facility need to be aware that specific count values can not be examined directly. When a counter is saturated this will block forever.
Diff Detail
Event TimelineComment Actions I'm not really crazy about this to be honest. refcount_release() gets inlined hundreds if not thousands of times into various functions. Now all of those callers are polluted with extra dead branch to call wakeup(). The fences in refcount_release() also don't make sense when refcount_wait() is used since a refcount of 0 doesn't mean that the protected object is unreachable, the way you'd normally expect a refcount to work. I would argue that this use-case would be better served by a new KPI or something open-coded. That said, I don't see any technical issues aside from the nits I pointed out.
Comment Actions Address some of Markj's feedback. Move the last ref drop into a dedicated function to lessen text bloat.
|