• Rusty Russell's avatar
    [PATCH] Hotplug CPU vs TASK_ZOMBIEs: The Sequel to Hotplug CPU vs TASK_DEAD · e271fc85
    Rusty Russell authored
    release_task can sleep.  Sleeping allows a CPU to go down underneath you.
    release_task removes you from the tasklist, so you don't get migrated off the
    CPU: BUG() in sched.c.
    
    In last week's episode, our dashing hero (Ingo Molnar) solved this for
    self-reaping tasks by grabbing the hotplug cpu lock to prevent this. 
    However, in an unexpected twist, the problem remains for tasks whose
    parents call release_task on them: the zombies are off the task list, and
    lurk on the dead CPU.
    
    Fortunately, the comedic sidekick (Rusty Russell) has an answer: let's make
    the hotplug callback walk the runqueue of the dead CPU as well, taking care
    of the zombies.
    
    1) Restore exit.c to its former form.  The comment is incorrect: sched.c
       checks PF_DEAD, not the state, to decide to do the final
       put_task_struct(), and it does it for all tasks, self-reaping or no.
    
    2) Implement migrate_dead_tasks() in the sched.c hotplug CPU callback.
    
    3) Rename migrate_all_tasks() to migrate_live_tasks().
    Signed-off-by: default avatarRusty Russell <rusty@rustcorp.com.au>
    Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
    e271fc85
sched.c 119 KB