Thread (63 messages) 63 messages, 6 authors, 2014-03-18

Re: [PATCH v3 00/52] CPU hotplug: Fix issues with callback registration

From: Andrew Morton <akpm@linux-foundation.org>
Date: 2014-03-11 22:07:48
Also in: linux-arch, linux-pm, lkml

On Tue, 11 Mar 2014 02:03:52 +0530 "Srivatsa S. Bhat" [off-list ref] wrote:
Hi,

Many subsystems and drivers have the need to register CPU hotplug callbacks
from their init routines and also perform initialization for the CPUs that are
already online. But unfortunately there is no race-free way to achieve this
today.

For example, consider this piece of code:

	get_online_cpus();

	for_each_online_cpu(cpu)
		init_cpu(cpu);

	register_cpu_notifier(&foobar_cpu_notifier);

	put_online_cpus();

This is not safe because there is a possibility of an ABBA deadlock involving
the cpu_add_remove_lock and the cpu_hotplug.lock.

          CPU 0                                         CPU 1
          -----                                         -----

   Acquire cpu_hotplug.lock
   [via get_online_cpus()]

                                              CPU online/offline operation
                                              takes cpu_add_remove_lock
                                              [via cpu_maps_update_begin()]

   Try to acquire
   cpu_add_remove_lock
   [via register_cpu_notifier()]

                                              CPU online/offline operation
                                              tries to acquire cpu_hotplug.lock
                                              [via cpu_hotplug_begin()]
Can't we fix this by using a different (ie: new) lock to protect
cpu_chain?
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help