diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-24 20:46:58 +0200 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-31 02:48:22 +0100 |
commit | 2bce6368c46b835a133f7f4946eea9c4513828dd (patch) | |
tree | 9ddb4e9e192a1cb25c27d9b29641d2650be8f718 /lib/closure.c | |
parent | Merge tag 'objtool-core-2023-10-28' of git://git.kernel.org/pub/scm/linux/ker... (diff) | |
download | linux-2bce6368c46b835a133f7f4946eea9c4513828dd.tar.xz linux-2bce6368c46b835a133f7f4946eea9c4513828dd.zip |
closures: Better memory barriers
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>
Diffstat (limited to '')
-rw-r--r-- | lib/closure.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/closure.c b/lib/closure.c index 0855e698ced1..501dfa277b59 100644 --- a/lib/closure.c +++ b/lib/closure.c @@ -21,6 +21,8 @@ static inline void closure_put_after_sub(struct closure *cl, int flags) BUG_ON(!r && (flags & ~CLOSURE_DESTRUCTOR)); if (!r) { + smp_acquire__after_ctrl_dep(); + if (cl->fn && !(flags & CLOSURE_DESTRUCTOR)) { atomic_set(&cl->remaining, CLOSURE_REMAINING_INITIALIZER); @@ -43,7 +45,7 @@ static inline void closure_put_after_sub(struct closure *cl, int flags) /* For clearing flags with the same atomic op as a put */ void closure_sub(struct closure *cl, int v) { - closure_put_after_sub(cl, atomic_sub_return(v, &cl->remaining)); + closure_put_after_sub(cl, atomic_sub_return_release(v, &cl->remaining)); } EXPORT_SYMBOL(closure_sub); @@ -52,7 +54,7 @@ EXPORT_SYMBOL(closure_sub); */ void closure_put(struct closure *cl) { - closure_put_after_sub(cl, atomic_dec_return(&cl->remaining)); + closure_put_after_sub(cl, atomic_dec_return_release(&cl->remaining)); } EXPORT_SYMBOL(closure_put); |