diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2023-03-04 02:39:39 -0500 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-07-11 21:03:01 -0400 |
commit | 0e771da4b24889de2d461c17dcd21a9ae24ea8d8 (patch) | |
tree | e84bb5f557239e40f98b52add990e0b143fe7a97 | |
parent | f35ba17a28f45ee0c51c2534201d0efb80b9c572 (diff) |
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.h | 7 |
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); } |