summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2023-03-04 10:39:39 +0300
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-19 21:47:33 +0300
commit48b7935722b8403fec0469ba3dafc5a0af08225d (patch)
tree421292130e73b374d757b26d4a6aa89c90710a56
parentced58fc7ab9f2d4b3d8aaeb859321a61aa884f66 (diff)
downloadlinux-48b7935722b8403fec0469ba3dafc5a0af08225d.tar.xz
closures: closure_nr_remaining()
Factor out a new helper, which returns the number of events outstanding. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
-rw-r--r--include/linux/closure.h7
1 files changed, 6 insertions, 1 deletions
diff --git a/include/linux/closure.h b/include/linux/closure.h
index 36b4a83f9b77..722a586bb224 100644
--- a/include/linux/closure.h
+++ b/include/linux/closure.h
@@ -172,6 +172,11 @@ void __closure_wake_up(struct closure_waitlist *list);
bool closure_wait(struct closure_waitlist *list, struct closure *cl);
void __closure_sync(struct closure *cl);
+static inline unsigned closure_nr_remaining(struct closure *cl)
+{
+ return atomic_read(&cl->remaining) & CLOSURE_REMAINING_MASK;
+}
+
/**
* closure_sync - sleep until a closure a closure has nothing left to wait on
*
@@ -180,7 +185,7 @@ void __closure_sync(struct closure *cl);
*/
static inline void closure_sync(struct closure *cl)
{
- if ((atomic_read(&cl->remaining) & CLOSURE_REMAINING_MASK) != 1)
+ if (closure_nr_remaining(cl) != 1)
__closure_sync(cl);
}