[PATCH 4/5] rcuwait: Introduce rcuwait_active()

From: Davidlohr Bueso
Date: Fri Apr 24 2020 - 01:52:38 EST


This call is lockless and thus should not be trustedblindly,
ie: for wakeup purposes, which is already provided correctly
by rcuwait_wakeup().

Signed-off-by: Davidlohr Bueso <dbueso@xxxxxxx>
---
include/linux/rcuwait.h | 9 +++++++++
1 file changed, 9 insertions(+)

diff --git a/include/linux/rcuwait.h b/include/linux/rcuwait.h
index 45bc6604e9b1..c1414ce44abc 100644
--- a/include/linux/rcuwait.h
+++ b/include/linux/rcuwait.h
@@ -25,6 +25,15 @@ static inline void rcuwait_init(struct rcuwait *w)
w->task = NULL;
}

+/*
+ * Note: this provides no serialization and, just as with waitqueues,
+ * requires care to estimate as to whether or not the wait is active.
+ */
+static inline int rcuwait_active(struct rcuwait *w)
+{
+ return !!rcu_dereference(w->task);
+}
+
extern int rcuwait_wake_up(struct rcuwait *w);

/*
--
2.16.4