OSDN Git Service

PM / devfreq: memlat: Prevent deadlock with hotplug in start_hwmon
authorRohit Gupta <rohgup@codeaurora.org>
Fri, 20 May 2016 00:42:04 +0000 (17:42 -0700)
committerKyle Yan <kyan@codeaurora.org>
Wed, 1 Jun 2016 22:27:34 +0000 (15:27 -0700)
commit7668a3726f0551a59865f7cb3704527fa4080c95
tree14513fc2890fc7abe835ff792f6754298507b7c3
parent8b2d1771d2a712a4718a5141bedd4fb031b0b91e
PM / devfreq: memlat: Prevent deadlock with hotplug in start_hwmon

When start_hwmon() runs with another thread trying to hotplug a
CPU the two threads can enter a deadlock situation as follows:

Thread A (start_hwmon()) Thread B (CPU down)
get_online_cpus()
|
atomic_inc(&cpu_hotplug.refcount)
     CPU down
|
     mutex_lock(&cpu_add_remove_lock)
|
     cpu_hotplug_begin() waits on
     cpu_hotplug.refcount to reset
register_cpu_notifier()
|
mutex_lock(&cpu_add_remove_lock)

With this change the notifers are registered and unregistered per
device rather than having a common notifier block for all the memlat
devices and unregistration only happens on stop_hwmon. This makes it
possible to move the registration outside the hotplug lock without
any race between multiple memlat devices.

Change-Id: I6ad561fe4967042e45190aea2c9b7fcfe05bafdd
Signed-off-by: Rohit Gupta <rohgup@codeaurora.org>
drivers/devfreq/arm-memlat-mon.c