• Prateek Sood's avatar
    cgroup: Fix deadlock in cpu hotplug path · e289e195
    Prateek Sood authored
    commit 116d2f74 upstream.
    
    Deadlock during cgroup migration from cpu hotplug path when a task T is
    being moved from source to destination cgroup.
    
    kworker/0:0
    cpuset_hotplug_workfn()
       cpuset_hotplug_update_tasks()
          hotplug_update_tasks_legacy()
            remove_tasks_in_empty_cpuset()
              cgroup_transfer_tasks() // stuck in iterator loop
                cgroup_migrate()
                  cgroup_migrate_add_task()
    
    In cgroup_migrate_add_task() it checks for PF_EXITING flag of task T.
    Task T will not migrate to destination cgroup. css_task_iter_start()
    will keep pointing to task T in loop waiting for task T cg_list node
    to be removed.
    
    Task T
    do_exit()
      exit_signals() // sets PF_EXITING
      exit_task_namespaces()
        switch_task_namespaces()
          free_nsproxy()
            put_mnt_ns()
              drop_collected_mounts()
                namespace_unlock()
                  synchronize_rcu()
                    _synchronize_rcu_expedited()
               ...
    e289e195
cgroup.c 148 KB