linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 35/51] acpi-cpufreq: Fix CPU hotplug callback registration
       [not found] <20140205220251.19080.92336.stgit@srivatsabhat.in.ibm.com>
@ 2014-02-05 22:10 ` Srivatsa S. Bhat
  2014-02-06 12:43   ` Rafael J. Wysocki
  2014-02-07  4:09   ` Viresh Kumar
  2014-02-05 22:11 ` [PATCH 38/51] intel-idle: " Srivatsa S. Bhat
  2014-02-05 22:11 ` [PATCH 41/51] thermal, x86-pkg-temp: " Srivatsa S. Bhat
  2 siblings, 2 replies; 8+ messages in thread
From: Srivatsa S. Bhat @ 2014-02-05 22:10 UTC (permalink / raw)
  To: paulus, oleg, rusty, peterz, tglx, akpm
  Cc: mingo, paulmck, tj, walken, ego, linux, linux-kernel,
	srivatsa.bhat, Rafael J. Wysocki, Viresh Kumar, cpufreq, linux-pm

Subsystems that want to register CPU hotplug callbacks, as well as perform
initialization for the CPUs that are already online, often do it as shown
below:

	get_online_cpus();

	for_each_online_cpu(cpu)
		init_cpu(cpu);

	register_cpu_notifier(&foobar_cpu_notifier);

	put_online_cpus();

This is wrong, since it is prone to ABBA deadlocks involving the
cpu_add_remove_lock and the cpu_hotplug.lock (when running concurrently
with CPU hotplug operations).

Instead, the correct and race-free way of performing the callback
registration is:

	cpu_maps_update_begin();

	for_each_online_cpu(cpu)
		init_cpu(cpu);

	/* Note the use of the double underscored version of the API */
	__register_cpu_notifier(&foobar_cpu_notifier);

	cpu_maps_update_done();


Fix the acpi-cpufreq code by using this latter form of callback registration.

Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Viresh Kumar <viresh.kumar@linaro.org>
Cc: cpufreq@vger.kernel.org
Cc: linux-pm@vger.kernel.org
Signed-off-by: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
---

 drivers/cpufreq/acpi-cpufreq.c |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
index 18448a7..e2eb471 100644
--- a/drivers/cpufreq/acpi-cpufreq.c
+++ b/drivers/cpufreq/acpi-cpufreq.c
@@ -907,15 +907,16 @@ static void __init acpi_cpufreq_boost_init(void)
 
 		acpi_cpufreq_driver.boost_supported = true;
 		acpi_cpufreq_driver.boost_enabled = boost_state(0);
-		get_online_cpus();
+
+		cpu_maps_update_begin();
 
 		/* Force all MSRs to the same value */
 		boost_set_msrs(acpi_cpufreq_driver.boost_enabled,
 			       cpu_online_mask);
 
-		register_cpu_notifier(&boost_nb);
+		__register_cpu_notifier(&boost_nb);
 
-		put_online_cpus();
+		cpu_maps_update_done();
 	}
 }
 

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 38/51] intel-idle: Fix CPU hotplug callback registration
       [not found] <20140205220251.19080.92336.stgit@srivatsabhat.in.ibm.com>
  2014-02-05 22:10 ` [PATCH 35/51] acpi-cpufreq: Fix CPU hotplug callback registration Srivatsa S. Bhat
@ 2014-02-05 22:11 ` Srivatsa S. Bhat
  2014-02-06 12:43   ` Rafael J. Wysocki
  2014-02-05 22:11 ` [PATCH 41/51] thermal, x86-pkg-temp: " Srivatsa S. Bhat
  2 siblings, 1 reply; 8+ messages in thread
From: Srivatsa S. Bhat @ 2014-02-05 22:11 UTC (permalink / raw)
  To: paulus, oleg, rusty, peterz, tglx, akpm
  Cc: mingo, paulmck, tj, walken, ego, linux, linux-kernel,
	srivatsa.bhat, Len Brown, Rafael J. Wysocki, linux-pm

Subsystems that want to register CPU hotplug callbacks, as well as perform
initialization for the CPUs that are already online, often do it as shown
below:

	get_online_cpus();

	for_each_online_cpu(cpu)
		init_cpu(cpu);

	register_cpu_notifier(&foobar_cpu_notifier);

	put_online_cpus();

This is wrong, since it is prone to ABBA deadlocks involving the
cpu_add_remove_lock and the cpu_hotplug.lock (when running concurrently
with CPU hotplug operations).

Instead, the correct and race-free way of performing the callback
registration is:

	cpu_maps_update_begin();

	for_each_online_cpu(cpu)
		init_cpu(cpu);

	/* Note the use of the double underscored version of the API */
	__register_cpu_notifier(&foobar_cpu_notifier);

	cpu_maps_update_done();


Fix the intel-idle code by using this latter form of callback registration.

Cc: Len Brown <lenb@kernel.org>
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: linux-pm@vger.kernel.org
Signed-off-by: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
---

 drivers/idle/intel_idle.c |   12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/idle/intel_idle.c b/drivers/idle/intel_idle.c
index 8e1939f..716ee5a 100644
--- a/drivers/idle/intel_idle.c
+++ b/drivers/idle/intel_idle.c
@@ -681,14 +681,19 @@ static int __init intel_idle_init(void)
 	if (intel_idle_cpuidle_devices == NULL)
 		return -ENOMEM;
 
+	cpu_maps_update_begin();
+
 	for_each_online_cpu(i) {
 		retval = intel_idle_cpu_init(i);
 		if (retval) {
+			cpu_maps_update_done();
 			cpuidle_unregister_driver(&intel_idle_driver);
 			return retval;
 		}
 	}
-	register_cpu_notifier(&cpu_hotplug_notifier);
+	__register_cpu_notifier(&cpu_hotplug_notifier);
+
+	cpu_maps_update_done();
 
 	return 0;
 }
@@ -698,10 +703,13 @@ static void __exit intel_idle_exit(void)
 	intel_idle_cpuidle_devices_uninit();
 	cpuidle_unregister_driver(&intel_idle_driver);
 
+	cpu_maps_update_begin();
 
 	if (lapic_timer_reliable_states != LAPIC_TIMER_ALWAYS_RELIABLE)
 		on_each_cpu(__setup_broadcast_timer, (void *)false, 1);
-	unregister_cpu_notifier(&cpu_hotplug_notifier);
+	__unregister_cpu_notifier(&cpu_hotplug_notifier);
+
+	cpu_maps_update_done();
 
 	return;
 }

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 41/51] thermal, x86-pkg-temp: Fix CPU hotplug callback registration
       [not found] <20140205220251.19080.92336.stgit@srivatsabhat.in.ibm.com>
  2014-02-05 22:10 ` [PATCH 35/51] acpi-cpufreq: Fix CPU hotplug callback registration Srivatsa S. Bhat
  2014-02-05 22:11 ` [PATCH 38/51] intel-idle: " Srivatsa S. Bhat
@ 2014-02-05 22:11 ` Srivatsa S. Bhat
  2 siblings, 0 replies; 8+ messages in thread
From: Srivatsa S. Bhat @ 2014-02-05 22:11 UTC (permalink / raw)
  To: paulus, oleg, rusty, peterz, tglx, akpm
  Cc: mingo, paulmck, tj, walken, ego, linux, linux-kernel,
	srivatsa.bhat, Zhang Rui, Eduardo Valentin, linux-pm

Subsystems that want to register CPU hotplug callbacks, as well as perform
initialization for the CPUs that are already online, often do it as shown
below:

	get_online_cpus();

	for_each_online_cpu(cpu)
		init_cpu(cpu);

	register_cpu_notifier(&foobar_cpu_notifier);

	put_online_cpus();

This is wrong, since it is prone to ABBA deadlocks involving the
cpu_add_remove_lock and the cpu_hotplug.lock (when running concurrently
with CPU hotplug operations).

Instead, the correct and race-free way of performing the callback
registration is:

	cpu_maps_update_begin();

	for_each_online_cpu(cpu)
		init_cpu(cpu);

	/* Note the use of the double underscored version of the API */
	__register_cpu_notifier(&foobar_cpu_notifier);

	cpu_maps_update_done();


Fix the thermal x86-pkg-temp code by using this latter form of callback
registration.

Cc: Zhang Rui <rui.zhang@intel.com>
Cc: Eduardo Valentin <eduardo.valentin@ti.com>
Cc: linux-pm@vger.kernel.org
Signed-off-by: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
---

 drivers/thermal/x86_pkg_temp_thermal.c |   14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/thermal/x86_pkg_temp_thermal.c b/drivers/thermal/x86_pkg_temp_thermal.c
index 972e1c7..55f9eac 100644
--- a/drivers/thermal/x86_pkg_temp_thermal.c
+++ b/drivers/thermal/x86_pkg_temp_thermal.c
@@ -589,12 +589,12 @@ static int __init pkg_temp_thermal_init(void)
 	platform_thermal_package_rate_control =
 			pkg_temp_thermal_platform_thermal_rate_control;
 
-	get_online_cpus();
+	cpu_maps_update_begin();
 	for_each_online_cpu(i)
 		if (get_core_online(i))
 			goto err_ret;
-	register_hotcpu_notifier(&pkg_temp_thermal_notifier);
-	put_online_cpus();
+	__register_hotcpu_notifier(&pkg_temp_thermal_notifier);
+	cpu_maps_update_done();
 
 	pkg_temp_debugfs_init(); /* Don't care if fails */
 
@@ -603,7 +603,7 @@ static int __init pkg_temp_thermal_init(void)
 err_ret:
 	for_each_online_cpu(i)
 		put_core_offline(i);
-	put_online_cpus();
+	cpu_maps_update_done();
 	kfree(pkg_work_scheduled);
 	platform_thermal_package_notify = NULL;
 	platform_thermal_package_rate_control = NULL;
@@ -616,8 +616,8 @@ static void __exit pkg_temp_thermal_exit(void)
 	struct phy_dev_entry *phdev, *n;
 	int i;
 
-	get_online_cpus();
-	unregister_hotcpu_notifier(&pkg_temp_thermal_notifier);
+	cpu_maps_update_begin();
+	__unregister_hotcpu_notifier(&pkg_temp_thermal_notifier);
 	mutex_lock(&phy_dev_list_mutex);
 	list_for_each_entry_safe(phdev, n, &phy_dev_list, list) {
 		/* Retore old MSR value for package thermal interrupt */
@@ -635,7 +635,7 @@ static void __exit pkg_temp_thermal_exit(void)
 	for_each_online_cpu(i)
 		cancel_delayed_work_sync(
 			&per_cpu(pkg_temp_thermal_threshold_work, i));
-	put_online_cpus();
+	cpu_maps_update_done();
 
 	kfree(pkg_work_scheduled);
 


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH 38/51] intel-idle: Fix CPU hotplug callback registration
  2014-02-05 22:11 ` [PATCH 38/51] intel-idle: " Srivatsa S. Bhat
@ 2014-02-06 12:43   ` Rafael J. Wysocki
  2014-02-06 16:04     ` Srivatsa S. Bhat
  0 siblings, 1 reply; 8+ messages in thread
From: Rafael J. Wysocki @ 2014-02-06 12:43 UTC (permalink / raw)
  To: Srivatsa S. Bhat, Len Brown
  Cc: paulus, oleg, rusty, peterz, tglx, akpm, mingo, paulmck, tj,
	walken, ego, linux, linux-kernel, linux-pm

On Thursday, February 06, 2014 03:41:23 AM Srivatsa S. Bhat wrote:
> Subsystems that want to register CPU hotplug callbacks, as well as perform
> initialization for the CPUs that are already online, often do it as shown
> below:
> 
> 	get_online_cpus();
> 
> 	for_each_online_cpu(cpu)
> 		init_cpu(cpu);
> 
> 	register_cpu_notifier(&foobar_cpu_notifier);
> 
> 	put_online_cpus();
> 
> This is wrong, since it is prone to ABBA deadlocks involving the
> cpu_add_remove_lock and the cpu_hotplug.lock (when running concurrently
> with CPU hotplug operations).
> 
> Instead, the correct and race-free way of performing the callback
> registration is:
> 
> 	cpu_maps_update_begin();
> 
> 	for_each_online_cpu(cpu)
> 		init_cpu(cpu);
> 
> 	/* Note the use of the double underscored version of the API */
> 	__register_cpu_notifier(&foobar_cpu_notifier);
> 
> 	cpu_maps_update_done();
> 
> 
> Fix the intel-idle code by using this latter form of callback registration.
> 
> Cc: Len Brown <lenb@kernel.org>
> Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
> Cc: linux-pm@vger.kernel.org
> Signed-off-by: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>

This looks good to me.  Len, what do you think?

Srivatsa, how does it depend on the rest of your series?

> ---
> 
>  drivers/idle/intel_idle.c |   12 ++++++++++--
>  1 file changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/idle/intel_idle.c b/drivers/idle/intel_idle.c
> index 8e1939f..716ee5a 100644
> --- a/drivers/idle/intel_idle.c
> +++ b/drivers/idle/intel_idle.c
> @@ -681,14 +681,19 @@ static int __init intel_idle_init(void)
>  	if (intel_idle_cpuidle_devices == NULL)
>  		return -ENOMEM;
>  
> +	cpu_maps_update_begin();
> +
>  	for_each_online_cpu(i) {
>  		retval = intel_idle_cpu_init(i);
>  		if (retval) {
> +			cpu_maps_update_done();
>  			cpuidle_unregister_driver(&intel_idle_driver);
>  			return retval;
>  		}
>  	}
> -	register_cpu_notifier(&cpu_hotplug_notifier);
> +	__register_cpu_notifier(&cpu_hotplug_notifier);
> +
> +	cpu_maps_update_done();
>  
>  	return 0;
>  }
> @@ -698,10 +703,13 @@ static void __exit intel_idle_exit(void)
>  	intel_idle_cpuidle_devices_uninit();
>  	cpuidle_unregister_driver(&intel_idle_driver);
>  
> +	cpu_maps_update_begin();
>  
>  	if (lapic_timer_reliable_states != LAPIC_TIMER_ALWAYS_RELIABLE)
>  		on_each_cpu(__setup_broadcast_timer, (void *)false, 1);
> -	unregister_cpu_notifier(&cpu_hotplug_notifier);
> +	__unregister_cpu_notifier(&cpu_hotplug_notifier);
> +
> +	cpu_maps_update_done();
>  
>  	return;
>  }
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-pm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 35/51] acpi-cpufreq: Fix CPU hotplug callback registration
  2014-02-05 22:10 ` [PATCH 35/51] acpi-cpufreq: Fix CPU hotplug callback registration Srivatsa S. Bhat
@ 2014-02-06 12:43   ` Rafael J. Wysocki
  2014-02-06 16:05     ` Srivatsa S. Bhat
  2014-02-07  4:09   ` Viresh Kumar
  1 sibling, 1 reply; 8+ messages in thread
From: Rafael J. Wysocki @ 2014-02-06 12:43 UTC (permalink / raw)
  To: Srivatsa S. Bhat
  Cc: paulus, oleg, rusty, peterz, tglx, akpm, mingo, paulmck, tj,
	walken, ego, linux, linux-kernel, Viresh Kumar, cpufreq, linux-pm

On Thursday, February 06, 2014 03:40:53 AM Srivatsa S. Bhat wrote:
> Subsystems that want to register CPU hotplug callbacks, as well as perform
> initialization for the CPUs that are already online, often do it as shown
> below:
> 
> 	get_online_cpus();
> 
> 	for_each_online_cpu(cpu)
> 		init_cpu(cpu);
> 
> 	register_cpu_notifier(&foobar_cpu_notifier);
> 
> 	put_online_cpus();
> 
> This is wrong, since it is prone to ABBA deadlocks involving the
> cpu_add_remove_lock and the cpu_hotplug.lock (when running concurrently
> with CPU hotplug operations).
> 
> Instead, the correct and race-free way of performing the callback
> registration is:
> 
> 	cpu_maps_update_begin();
> 
> 	for_each_online_cpu(cpu)
> 		init_cpu(cpu);
> 
> 	/* Note the use of the double underscored version of the API */
> 	__register_cpu_notifier(&foobar_cpu_notifier);
> 
> 	cpu_maps_update_done();
> 
> 
> Fix the acpi-cpufreq code by using this latter form of callback registration.
> 
> Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
> Cc: Viresh Kumar <viresh.kumar@linaro.org>
> Cc: cpufreq@vger.kernel.org
> Cc: linux-pm@vger.kernel.org
> Signed-off-by: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>

Looks OK to me.  How does it depend on the rest of your series?

> ---
> 
>  drivers/cpufreq/acpi-cpufreq.c |    7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
> index 18448a7..e2eb471 100644
> --- a/drivers/cpufreq/acpi-cpufreq.c
> +++ b/drivers/cpufreq/acpi-cpufreq.c
> @@ -907,15 +907,16 @@ static void __init acpi_cpufreq_boost_init(void)
>  
>  		acpi_cpufreq_driver.boost_supported = true;
>  		acpi_cpufreq_driver.boost_enabled = boost_state(0);
> -		get_online_cpus();
> +
> +		cpu_maps_update_begin();
>  
>  		/* Force all MSRs to the same value */
>  		boost_set_msrs(acpi_cpufreq_driver.boost_enabled,
>  			       cpu_online_mask);
>  
> -		register_cpu_notifier(&boost_nb);
> +		__register_cpu_notifier(&boost_nb);
>  
> -		put_online_cpus();
> +		cpu_maps_update_done();
>  	}
>  }
>  
> 
> --
> To unsubscribe from this list: send the line "unsubscribe cpufreq" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 38/51] intel-idle: Fix CPU hotplug callback registration
  2014-02-06 12:43   ` Rafael J. Wysocki
@ 2014-02-06 16:04     ` Srivatsa S. Bhat
  0 siblings, 0 replies; 8+ messages in thread
From: Srivatsa S. Bhat @ 2014-02-06 16:04 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Len Brown, paulus, oleg, rusty, peterz, tglx, akpm, mingo,
	paulmck, tj, walken, ego, linux, linux-kernel, linux-pm

On 02/06/2014 06:13 PM, Rafael J. Wysocki wrote:
> On Thursday, February 06, 2014 03:41:23 AM Srivatsa S. Bhat wrote:
>> Subsystems that want to register CPU hotplug callbacks, as well as perform
>> initialization for the CPUs that are already online, often do it as shown
>> below:
>>
>> 	get_online_cpus();
>>
>> 	for_each_online_cpu(cpu)
>> 		init_cpu(cpu);
>>
>> 	register_cpu_notifier(&foobar_cpu_notifier);
>>
>> 	put_online_cpus();
>>
>> This is wrong, since it is prone to ABBA deadlocks involving the
>> cpu_add_remove_lock and the cpu_hotplug.lock (when running concurrently
>> with CPU hotplug operations).
>>
>> Instead, the correct and race-free way of performing the callback
>> registration is:
>>
>> 	cpu_maps_update_begin();
>>
>> 	for_each_online_cpu(cpu)
>> 		init_cpu(cpu);
>>
>> 	/* Note the use of the double underscored version of the API */
>> 	__register_cpu_notifier(&foobar_cpu_notifier);
>>
>> 	cpu_maps_update_done();
>>
>>
>> Fix the intel-idle code by using this latter form of callback registration.
>>
>> Cc: Len Brown <lenb@kernel.org>
>> Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
>> Cc: linux-pm@vger.kernel.org
>> Signed-off-by: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
> 
> This looks good to me.  Len, what do you think?
> 

Thanks a lot Rafael!

> Srivatsa, how does it depend on the rest of your series?
> 

It depends only on the first patch in the series:
http://article.gmane.org/gmane.linux.kernel/1641640

But don't take this patch yet, we are discussing a possible rename
of the function cpu_maps_update_begin()/done(). So I'll post a v2
after the name is finalized.

Thank you!

Regards,
Srivatsa S. Bhat






^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 35/51] acpi-cpufreq: Fix CPU hotplug callback registration
  2014-02-06 12:43   ` Rafael J. Wysocki
@ 2014-02-06 16:05     ` Srivatsa S. Bhat
  0 siblings, 0 replies; 8+ messages in thread
From: Srivatsa S. Bhat @ 2014-02-06 16:05 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: paulus, oleg, rusty, peterz, tglx, akpm, mingo, paulmck, tj,
	walken, ego, linux, linux-kernel, Viresh Kumar, cpufreq, linux-pm

On 02/06/2014 06:13 PM, Rafael J. Wysocki wrote:
> On Thursday, February 06, 2014 03:40:53 AM Srivatsa S. Bhat wrote:
>> Subsystems that want to register CPU hotplug callbacks, as well as perform
>> initialization for the CPUs that are already online, often do it as shown
>> below:
>>
>> 	get_online_cpus();
>>
>> 	for_each_online_cpu(cpu)
>> 		init_cpu(cpu);
>>
>> 	register_cpu_notifier(&foobar_cpu_notifier);
>>
>> 	put_online_cpus();
>>
>> This is wrong, since it is prone to ABBA deadlocks involving the
>> cpu_add_remove_lock and the cpu_hotplug.lock (when running concurrently
>> with CPU hotplug operations).
>>
>> Instead, the correct and race-free way of performing the callback
>> registration is:
>>
>> 	cpu_maps_update_begin();
>>
>> 	for_each_online_cpu(cpu)
>> 		init_cpu(cpu);
>>
>> 	/* Note the use of the double underscored version of the API */
>> 	__register_cpu_notifier(&foobar_cpu_notifier);
>>
>> 	cpu_maps_update_done();
>>
>>
>> Fix the acpi-cpufreq code by using this latter form of callback registration.
>>
>> Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
>> Cc: Viresh Kumar <viresh.kumar@linaro.org>
>> Cc: cpufreq@vger.kernel.org
>> Cc: linux-pm@vger.kernel.org
>> Signed-off-by: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
> 
> Looks OK to me.  How does it depend on the rest of your series?
> 

Thank you! Same here, every patch depends only on the first patch in
the series. (Except the raid5 and the xen/balloon patches which don't
have any dependency).

But I'll be posting a v2 of this patchset soon with a rename of the
API..

Regards,
Srivatsa S. Bhat

>> ---
>>
>>  drivers/cpufreq/acpi-cpufreq.c |    7 ++++---
>>  1 file changed, 4 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
>> index 18448a7..e2eb471 100644
>> --- a/drivers/cpufreq/acpi-cpufreq.c
>> +++ b/drivers/cpufreq/acpi-cpufreq.c
>> @@ -907,15 +907,16 @@ static void __init acpi_cpufreq_boost_init(void)
>>  
>>  		acpi_cpufreq_driver.boost_supported = true;
>>  		acpi_cpufreq_driver.boost_enabled = boost_state(0);
>> -		get_online_cpus();
>> +
>> +		cpu_maps_update_begin();
>>  
>>  		/* Force all MSRs to the same value */
>>  		boost_set_msrs(acpi_cpufreq_driver.boost_enabled,
>>  			       cpu_online_mask);
>>  
>> -		register_cpu_notifier(&boost_nb);
>> +		__register_cpu_notifier(&boost_nb);
>>  
>> -		put_online_cpus();
>> +		cpu_maps_update_done();
>>  	}
>>  }
>>  
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe cpufreq" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 


-- 
Regards,
Srivatsa S. Bhat


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 35/51] acpi-cpufreq: Fix CPU hotplug callback registration
  2014-02-05 22:10 ` [PATCH 35/51] acpi-cpufreq: Fix CPU hotplug callback registration Srivatsa S. Bhat
  2014-02-06 12:43   ` Rafael J. Wysocki
@ 2014-02-07  4:09   ` Viresh Kumar
  1 sibling, 0 replies; 8+ messages in thread
From: Viresh Kumar @ 2014-02-07  4:09 UTC (permalink / raw)
  To: Srivatsa S. Bhat
  Cc: Paul Mackerras, oleg, rusty, Peter Zijlstra, Thomas Gleixner,
	Andrew Morton, Ingo Molnar, Paul McKenney, Tejun Heo, walken, ego,
	Russell King - ARM Linux, Linux Kernel Mailing List,
	Rafael J. Wysocki, cpufreq@vger.kernel.org,
	linux-pm@vger.kernel.org

On 6 February 2014 03:40, Srivatsa S. Bhat
<srivatsa.bhat@linux.vnet.ibm.com> wrote:
> Subsystems that want to register CPU hotplug callbacks, as well as perform
> initialization for the CPUs that are already online, often do it as shown
> below:
>
>         get_online_cpus();
>
>         for_each_online_cpu(cpu)
>                 init_cpu(cpu);
>
>         register_cpu_notifier(&foobar_cpu_notifier);
>
>         put_online_cpus();
>
> This is wrong, since it is prone to ABBA deadlocks involving the
> cpu_add_remove_lock and the cpu_hotplug.lock (when running concurrently
> with CPU hotplug operations).
>
> Instead, the correct and race-free way of performing the callback
> registration is:
>
>         cpu_maps_update_begin();
>
>         for_each_online_cpu(cpu)
>                 init_cpu(cpu);
>
>         /* Note the use of the double underscored version of the API */
>         __register_cpu_notifier(&foobar_cpu_notifier);
>
>         cpu_maps_update_done();
>
>
> Fix the acpi-cpufreq code by using this latter form of callback registration.
>
> Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
> Cc: Viresh Kumar <viresh.kumar@linaro.org>
> Cc: cpufreq@vger.kernel.org
> Cc: linux-pm@vger.kernel.org
> Signed-off-by: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>

Acked-by: Viresh Kumar <viresh.kumar@linaro.org>

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2014-02-07  4:09 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20140205220251.19080.92336.stgit@srivatsabhat.in.ibm.com>
2014-02-05 22:10 ` [PATCH 35/51] acpi-cpufreq: Fix CPU hotplug callback registration Srivatsa S. Bhat
2014-02-06 12:43   ` Rafael J. Wysocki
2014-02-06 16:05     ` Srivatsa S. Bhat
2014-02-07  4:09   ` Viresh Kumar
2014-02-05 22:11 ` [PATCH 38/51] intel-idle: " Srivatsa S. Bhat
2014-02-06 12:43   ` Rafael J. Wysocki
2014-02-06 16:04     ` Srivatsa S. Bhat
2014-02-05 22:11 ` [PATCH 41/51] thermal, x86-pkg-temp: " Srivatsa S. Bhat

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).