summaryrefslogtreecommitdiffstats
path: root/lib/closure.c
Commit message (Collapse)AuthorAgeFilesLines
* closures: Fix race in closure_sync()Kent Overstreet2023-10-301-0/+3
| | | | | | | | | | | | As pointed out by Linus, closure_sync() was racy; we could skip blocking immediately after a get() and a put(), but then that would skip any barrier corresponding to the other thread's put() barrier. To fix this, always do the full __closure_sync() sequence whenever any get() has happened and the closure might have been used by other threads. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
* closures: Better memory barriersKent Overstreet2023-10-301-2/+4
| | | | | | | | | | | | | atomic_(dec|sub)_return_release() are a thing now - use them. Also, delete the useless barrier in set_closure_fn(): it's redundant with the memory barrier in closure_put(0. Since closure_put() would now otherwise just have a release barrier, we also need a new barrier when the ref hits 0 - smp_acquire__after_ctrl_dep(). Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
* closures: Add a missing includeKent Overstreet2023-10-191-0/+1
| | | | | | Fixes building in userspace. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
* bcache: move closures to lib/Kent Overstreet2023-10-191-0/+204
Prep work for bcachefs - being a fork of bcache it also uses closures Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev> Acked-by: Coly Li <colyli@suse.de> Reviewed-by: Randy Dunlap <rdunlap@infradead.org>