devfreq: govener_memlat: fix cpu_hotplug_lock recursive lock warning

Possible unsafe locking scenario:

      CPU0
      ----
 lock(cpu_hotplug_lock.rw_sem);
 lock(cpu_hotplug_lock.rw_sem);

*** DEADLOCK ***

Below code under start_hwmon may cause this recursive locking.

	get_online_cpus();
	for_each_cpu(cpu, cpu_possible_mask) {
		if (!cpumask_test_cpu(cpu, cpu_online_mask))
			per_cpu(cpu_is_hp, cpu) = true;
	}
	ret = memlat_event_cpu_hp_init();
	put_online_cpus();

get_online_cpus() acquires cpu_hotplug_lock.rw_sem lock.
Then memlat_event_cpu_hp_init() -> __cpuhp_setup_state() tries
to acquire the same lock again.
Use cpuslocked version of __cpuhp_setup_state() to avoid this warning.

Change-Id: Ied9fe53d02c74816f38c1efe954cea91f9831cc7
Signed-off-by: Abhishek Shah <abhshah@codeaurora.org>
This commit is contained in:
Abhishek Shah 2021-08-16 17:18:33 +05:30 • committed by Alexander Winkowski
commit d8ea382c8a
No known key found for this signature in database
GPG key ID: 72762A66704CDE44

View file

@ -519,11 +519,15 @@ static int memlat_event_hotplug_going_down(unsigned int cpu)
return ret;
}
/*
* Note: We must be holding cpus_read_lock() before calling this function
* since we are using cpuslocked version of function inside it
*/
static int memlat_event_cpu_hp_init(void)
{
int ret = 0;
ret = cpuhp_setup_state_nocalls(CPUHP_AP_ONLINE_DYN,
ret = cpuhp_setup_state_nocalls_cpuslocked(CPUHP_AP_ONLINE_DYN,
"MEMLAT_EVENT",
memlat_event_hotplug_coming_up,
memlat_event_hotplug_going_down);