]> git.proxmox.com Git - mirror_ubuntu-disco-kernel.git/commitdiff
sched/wait: Make the signal_pending() checks consistent
authorPeter Zijlstra <peterz@infradead.org>
Wed, 2 Oct 2013 09:22:18 +0000 (11:22 +0200)
committerIngo Molnar <mingo@kernel.org>
Fri, 4 Oct 2013 08:14:44 +0000 (10:14 +0200)
There's two patterns to check signals in the __wait_event*() macros:

  if (!signal_pending(current)) {
schedule();
continue;
  }
  ret = -ERESTARTSYS;
  break;

And the more natural:

  if (signal_pending(current)) {
ret = -ERESTARTSYS;
break;
  }
  schedule();

Change them all into the latter form.

Reviewed-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20131002092527.956416254@infradead.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
include/linux/tty.h
include/linux/wait.h

index 64f864651d8696aa5cf8a93b931c78c06a23bfdc..050372979076c7217af4928efcda1853d64a6436 100644 (file)
@@ -686,14 +686,13 @@ do {                                                                      \
                prepare_to_wait(&wq, &__wait, TASK_INTERRUPTIBLE);      \
                if (condition)                                          \
                        break;                                          \
-               if (!signal_pending(current)) {                         \
-                       tty_unlock(tty);                                        \
-                       schedule();                                     \
-                       tty_lock(tty);                                  \
-                       continue;                                       \
+               if (signal_pending(current)) {                          \
+                       ret = -ERESTARTSYS;                             \
+                       break;                                          \
                }                                                       \
-               ret = -ERESTARTSYS;                                     \
-               break;                                                  \
+               tty_unlock(tty);                                        \
+               schedule();                                             \
+               tty_lock(tty);                                          \
        }                                                               \
        finish_wait(&wq, &__wait);                                      \
 } while (0)
index a67fc1635592fd34717ef559049924b1add707ca..ccf0c529fd375a590b26047fa0b805a38421dd30 100644 (file)
@@ -261,12 +261,11 @@ do {                                                                      \
                prepare_to_wait(&wq, &__wait, TASK_INTERRUPTIBLE);      \
                if (condition)                                          \
                        break;                                          \
-               if (!signal_pending(current)) {                         \
-                       schedule();                                     \
-                       continue;                                       \
+               if (signal_pending(current)) {                          \
+                       ret = -ERESTARTSYS;                             \
+                       break;                                          \
                }                                                       \
-               ret = -ERESTARTSYS;                                     \
-               break;                                                  \
+               schedule();                                             \
        }                                                               \
        finish_wait(&wq, &__wait);                                      \
 } while (0)
@@ -302,14 +301,13 @@ do {                                                                      \
                prepare_to_wait(&wq, &__wait, TASK_INTERRUPTIBLE);      \
                if (condition)                                          \
                        break;                                          \
-               if (!signal_pending(current)) {                         \
-                       ret = schedule_timeout(ret);                    \
-                       if (!ret)                                       \
-                               break;                                  \
-                       continue;                                       \
+               if (signal_pending(current)) {                          \
+                       ret = -ERESTARTSYS;                             \
+                       break;                                          \
                }                                                       \
-               ret = -ERESTARTSYS;                                     \
-               break;                                                  \
+               ret = schedule_timeout(ret);                            \
+               if (!ret)                                               \
+                       break;                                          \
        }                                                               \
        if (!ret && (condition))                                        \
                ret = 1;                                                \
@@ -439,14 +437,13 @@ do {                                                                      \
                        finish_wait(&wq, &__wait);                      \
                        break;                                          \
                }                                                       \
-               if (!signal_pending(current)) {                         \
-                       schedule();                                     \
-                       continue;                                       \
-               }                                                       \
-               ret = -ERESTARTSYS;                                     \
-               abort_exclusive_wait(&wq, &__wait,                      \
+               if (signal_pending(current)) {                          \
+                       ret = -ERESTARTSYS;                             \
+                       abort_exclusive_wait(&wq, &__wait,              \
                                TASK_INTERRUPTIBLE, NULL);              \
-               break;                                                  \
+                       break;                                          \
+               }                                                       \
+               schedule();                                             \
        }                                                               \
 } while (0)