[lkml]   [2008]   [May]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
    Patch in this message
    Subject[PATCH 02 of 11] get_task_mm
    # HG changeset patch
    # User Andrea Arcangeli <>
    # Date 1209740185 -7200
    # Node ID c85c85c4be165eb6de16136bb97cf1fa7fd5c88f
    # Parent 1489529e7b53d3f2dab8431372aa4850ec821caa

    get_task_mm should not succeed if mmput() is running and has reduced
    the mm_users count to zero. This can occur if a processor follows
    a tasks pointer to an mm struct because that pointer is only cleared
    after the mmput().

    If get_task_mm() succeeds after mmput() reduced the mm_users to zero then
    we have the lovely situation that one portion of the kernel is doing
    all the teardown work for an mm while another portion is happily using

    Signed-off-by: Christoph Lameter <>
    Signed-off-by: Andrea Arcangeli <>

    diff --git a/kernel/fork.c b/kernel/fork.c
    --- a/kernel/fork.c
    +++ b/kernel/fork.c
    @@ -465,7 +465,8 @@ struct mm_struct *get_task_mm(struct tas
    if (task->flags & PF_BORROWED_MM)
    mm = NULL;
    - atomic_inc(&mm->mm_users);
    + if (!atomic_inc_not_zero(&mm->mm_users))
    + mm = NULL;
    return mm;

     \ /
      Last update: 2008-05-02 17:17    [W:0.018 / U:32.356 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site