]> asedeno.scripts.mit.edu Git - linux.git/blobdiff - include/linux/swait.h
Merge tag 'for-linus-20191129' of git://git.kernel.dk/linux-block
[linux.git] / include / linux / swait.h
index bf8cb0dee23c01ed150f081ffd95861b8d416803..73e06e9986d4b4a57807a16224eaed0ea6a0f396 100644 (file)
@@ -16,7 +16,7 @@
  * wait-queues, but the semantics are actually completely different, and
  * every single user we have ever had has been buggy (or pointless).
  *
- * A "swake_up()" only wakes up _one_ waiter, which is not at all what
+ * A "swake_up_one()" only wakes up _one_ waiter, which is not at all what
  * "wake_up()" does, and has led to problems. In other cases, it has
  * been fine, because there's only ever one waiter (kvm), but in that
  * case gthe whole "simple" wait-queue is just pointless to begin with,
@@ -38,8 +38,8 @@
  *    all wakeups are TASK_NORMAL in order to avoid O(n) lookups for the right
  *    sleeper state.
  *
- *  - the exclusive mode; because this requires preserving the list order
- *    and this is hard.
+ *  - the !exclusive mode; because that leads to O(n) wakeups, everything is
+ *    exclusive.
  *
  *  - custom wake callback functions; because you cannot give any guarantees
  *    about random code. This also allows swait to be used in RT, such that
@@ -115,7 +115,7 @@ extern void __init_swait_queue_head(struct swait_queue_head *q, const char *name
  *      CPU0 - waker                    CPU1 - waiter
  *
  *                                      for (;;) {
- *      @cond = true;                     prepare_to_swait(&wq_head, &wait, state);
+ *      @cond = true;                     prepare_to_swait_exclusive(&wq_head, &wait, state);
  *      smp_mb();                         // smp_mb() from set_current_state()
  *      if (swait_active(wq_head))        if (@cond)
  *        wake_up(wq_head);                      break;
@@ -157,20 +157,20 @@ static inline bool swq_has_sleeper(struct swait_queue_head *wq)
        return swait_active(wq);
 }
 
-extern void swake_up(struct swait_queue_head *q);
+extern void swake_up_one(struct swait_queue_head *q);
 extern void swake_up_all(struct swait_queue_head *q);
 extern void swake_up_locked(struct swait_queue_head *q);
 
-extern void __prepare_to_swait(struct swait_queue_head *q, struct swait_queue *wait);
-extern void prepare_to_swait(struct swait_queue_head *q, struct swait_queue *wait, int state);
+extern void prepare_to_swait_exclusive(struct swait_queue_head *q, struct swait_queue *wait, int state);
 extern long prepare_to_swait_event(struct swait_queue_head *q, struct swait_queue *wait, int state);
 
 extern void __finish_swait(struct swait_queue_head *q, struct swait_queue *wait);
 extern void finish_swait(struct swait_queue_head *q, struct swait_queue *wait);
 
-/* as per ___wait_event() but for swait, therefore "exclusive == 0" */
+/* as per ___wait_event() but for swait, therefore "exclusive == 1" */
 #define ___swait_event(wq, condition, state, ret, cmd)                 \
 ({                                                                     \
+       __label__ __out;                                                \
        struct swait_queue __wait;                                      \
        long __ret = ret;                                               \
                                                                        \
@@ -183,20 +183,20 @@ extern void finish_swait(struct swait_queue_head *q, struct swait_queue *wait);
                                                                        \
                if (___wait_is_interruptible(state) && __int) {         \
                        __ret = __int;                                  \
-                       break;                                          \
+                       goto __out;                                     \
                }                                                       \
                                                                        \
                cmd;                                                    \
        }                                                               \
        finish_swait(&wq, &__wait);                                     \
-       __ret;                                                          \
+__out: __ret;                                                          \
 })
 
 #define __swait_event(wq, condition)                                   \
        (void)___swait_event(wq, condition, TASK_UNINTERRUPTIBLE, 0,    \
                            schedule())
 
-#define swait_event(wq, condition)                                     \
+#define swait_event_exclusive(wq, condition)                           \
 do {                                                                   \
        if (condition)                                                  \
                break;                                                  \
@@ -208,7 +208,7 @@ do {                                                                        \
                      TASK_UNINTERRUPTIBLE, timeout,                    \
                      __ret = schedule_timeout(__ret))
 
-#define swait_event_timeout(wq, condition, timeout)                    \
+#define swait_event_timeout_exclusive(wq, condition, timeout)          \
 ({                                                                     \
        long __ret = timeout;                                           \
        if (!___wait_cond_timeout(condition))                           \
@@ -220,7 +220,7 @@ do {                                                                        \
        ___swait_event(wq, condition, TASK_INTERRUPTIBLE, 0,            \
                      schedule())
 
-#define swait_event_interruptible(wq, condition)                       \
+#define swait_event_interruptible_exclusive(wq, condition)             \
 ({                                                                     \
        int __ret = 0;                                                  \
        if (!(condition))                                               \
@@ -233,7 +233,7 @@ do {                                                                        \
                      TASK_INTERRUPTIBLE, timeout,                      \
                      __ret = schedule_timeout(__ret))
 
-#define swait_event_interruptible_timeout(wq, condition, timeout)      \
+#define swait_event_interruptible_timeout_exclusive(wq, condition, timeout)\
 ({                                                                     \
        long __ret = timeout;                                           \
        if (!___wait_cond_timeout(condition))                           \
@@ -246,7 +246,7 @@ do {                                                                        \
        (void)___swait_event(wq, condition, TASK_IDLE, 0, schedule())
 
 /**
- * swait_event_idle - wait without system load contribution
+ * swait_event_idle_exclusive - wait without system load contribution
  * @wq: the waitqueue to wait on
  * @condition: a C expression for the event to wait for
  *
@@ -257,7 +257,7 @@ do {                                                                        \
  * condition and doesn't want to contribute to system load. Signals are
  * ignored.
  */
-#define swait_event_idle(wq, condition)                                        \
+#define swait_event_idle_exclusive(wq, condition)                      \
 do {                                                                   \
        if (condition)                                                  \
                break;                                                  \
@@ -270,7 +270,7 @@ do {                                                                        \
                       __ret = schedule_timeout(__ret))
 
 /**
- * swait_event_idle_timeout - wait up to timeout without load contribution
+ * swait_event_idle_timeout_exclusive - wait up to timeout without load contribution
  * @wq: the waitqueue to wait on
  * @condition: a C expression for the event to wait for
  * @timeout: timeout at which we'll give up in jiffies
@@ -288,7 +288,7 @@ do {                                                                        \
  * or the remaining jiffies (at least 1) if the @condition evaluated
  * to %true before the @timeout elapsed.
  */
-#define swait_event_idle_timeout(wq, condition, timeout)               \
+#define swait_event_idle_timeout_exclusive(wq, condition, timeout)     \
 ({                                                                     \
        long __ret = timeout;                                           \
        if (!___wait_cond_timeout(condition))                           \