lkml.org 
[lkml]   [2013]   [Oct]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Date
    From
    Subject[PATCH 01/16] sched/wait: Make the signal_pending() checks consistent
    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>
    ---
    include/linux/tty.h | 13 ++++++-------
    include/linux/wait.h | 35 ++++++++++++++++-------------------
    2 files changed, 22 insertions(+), 26 deletions(-)

    --- a/include/linux/tty.h
    +++ b/include/linux/tty.h
    @@ -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)
    --- a/include/linux/wait.h
    +++ b/include/linux/wait.h
    @@ -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)




    \
     
     \ /
      Last update: 2013-10-02 12:21    [W:2.762 / U:0.648 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site