Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7668a372 authored by Rohit Gupta's avatar Rohit Gupta Committed by Kyle Yan
Browse files

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: default avatarRohit Gupta <rohgup@codeaurora.org>
parent 8b2d1771
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment