lkml.org 
[lkml]   [2011]   [May]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 9/9] ptrace: make TRAPPING wait interruptible
    Date
    With JOBCTL_TRAPPING waits moved to wait_task_stopped() and
    ptrace_check_attach(), and both using full syscall retries after wait,
    TRAPPING wait can switch to interruptible sleeps.

    As all transitions are interlocked and all cancellation events
    (supposedly) clear TRAPPING, this doesn't change the actual behavior
    but it makes the TRAPPING wait mechanism much more forgiving when
    something goes wrong and allows using TRAPPING waits across freezing
    points.

    Signed-off-by: Tejun Heo <tj@kernel.org>
    ---
    kernel/ptrace.c | 10 +++++++---
    1 files changed, 7 insertions(+), 3 deletions(-)
    diff --git a/kernel/ptrace.c b/kernel/ptrace.c
    index 03349b5..6e79eab 100644
    --- a/kernel/ptrace.c
    +++ b/kernel/ptrace.c
    @@ -27,7 +27,7 @@
    static int ptrace_trapping_sleep_fn(void *flags)
    {
    schedule();
    - return 0;
    + return signal_pending(current);
    }

    /**
    @@ -44,7 +44,11 @@ static int ptrace_trapping_sleep_fn(void *flags)
    * to make sure no transition is in progress before proceeding.
    *
    * This function checks whether @child is TRAPPING and, if so, waits for
    - * the transition to complete.
    + * the transition to complete. Interruptible sleep is used for waiting and
    + * %true will be returned regardless of why it is woken up. On %true
    + * return, callers should ensure that the whole operation is restarted
    + * using the syscall restart mechanism so that operations like freezing or
    + * killing don't get blocked by TRAPPING waits.
    *
    * CONTEXT:
    * read_lock(&tasklist_lock) and spin_lock_irq(&child->sighand->siglock).
    @@ -66,7 +70,7 @@ bool ptrace_wait_trapping(struct task_struct *child)
    get_task_struct(child);
    read_unlock(&tasklist_lock);
    wait_on_bit(&child->jobctl, ilog2(JOBCTL_TRAPPING),
    - ptrace_trapping_sleep_fn, TASK_UNINTERRUPTIBLE);
    + ptrace_trapping_sleep_fn, TASK_INTERRUPTIBLE);
    put_task_struct(child);
    return true;
    }
    --
    1.7.1


    \
     
     \ /
      Last update: 2011-05-13 17:49    [W:0.140 / U:0.164 seconds]
    ©2003-2014 Jasper Spaans. Advertise on this site