Skip to content
  • Paul E. McKenney's avatar
    rcu: Grace-period initialization excludes only RCU notifier · a4fbe35a
    Paul E. McKenney authored
    Kirill noted the following deadlock cycle on shutdown involving padata:
    
    > With commit 755609a9
    
     I've got deadlock on
    > poweroff.
    >
    > It guess it happens because of race for cpu_hotplug.lock:
    >
    >       CPU A                                   CPU B
    > disable_nonboot_cpus()
    > _cpu_down()
    > cpu_hotplug_begin()
    >  mutex_lock(&cpu_hotplug.lock);
    > __cpu_notify()
    > padata_cpu_callback()
    > __padata_remove_cpu()
    > padata_replace()
    > synchronize_rcu()
    >                                       rcu_gp_kthread()
    >                                       get_online_cpus();
    >                                       mutex_lock(&cpu_hotplug.lock);
    
    It would of course be good to eliminate grace-period delays from
    CPU-hotplug notifiers, but that is a separate issue.  Deadlock is
    not an appropriate diagnostic for excessive CPU-hotplug latency.
    
    Fortunately, grace-period initialization does not actually need to
    exclude all of the CPU-hotplug operation, but rather only RCU's own
    CPU_UP_PREPARE and CPU_DEAD CPU-hotplug notifiers.  This commit therefore
    introduces a new per-rcu_state onoff_mutex that provides the required
    concurrency control in place of the get_online_cpus() that was previously
    in rcu_gp_init().
    
    Reported-by: default avatar"Kirill A. Shutemov" <kirill@shutemov.name>
    Signed-off-by: default avatarPaul E. McKenney <paulmck@linux.vnet.ibm.com>
    Tested-by: default avatarKirill A. Shutemov <kirill@shutemov.name>
    a4fbe35a