linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] __cpuhp_setup_state() returns positive value for dynamic state
@ 2016-12-15 15:00 Boris Ostrovsky
  2016-12-15 15:00 ` [PATCH 1/2] cpu/hotplug: Clarify description of __cpuhp_setup_state() return value Boris Ostrovsky
  2016-12-15 15:00 ` [PATCH 2/2] cpufreq: Remove cpu hotplug callbacks only if they were initialized Boris Ostrovsky
  0 siblings, 2 replies; 4+ messages in thread
From: Boris Ostrovsky @ 2016-12-15 15:00 UTC (permalink / raw)
  To: tglx, bigeasy, rjw, viresh.kumar
  Cc: linux-pm, linux-kernel, xen-devel, Boris Ostrovsky

The first patch corrects description of __cpuhp_setup_state()'s possible
return values and the second fixes a bug (which causes Xen guests to crash).

As a follow-up question for the first patch --- should we allow calling
__cpuhp_setup_state() with state in [CPUHP_AP_ONLINE_DYN + 1 .. CPUHP_AP_ONLINE_DYN_END]
range?

Boris Ostrovsky (2):
  cpu/hotplug: Clarify description of __cpuhp_setup_state() return
    value
  cpufreq: Remove cpu hotplug callbacks only if they were initialized

 drivers/cpufreq/acpi-cpufreq.c |    2 +-
 kernel/cpu.c                   |    6 +++++-
 2 files changed, 6 insertions(+), 2 deletions(-)

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

* [PATCH 1/2] cpu/hotplug: Clarify description of __cpuhp_setup_state() return value
  2016-12-15 15:00 [PATCH 0/2] __cpuhp_setup_state() returns positive value for dynamic state Boris Ostrovsky
@ 2016-12-15 15:00 ` Boris Ostrovsky
  2016-12-15 15:00 ` [PATCH 2/2] cpufreq: Remove cpu hotplug callbacks only if they were initialized Boris Ostrovsky
  1 sibling, 0 replies; 4+ messages in thread
From: Boris Ostrovsky @ 2016-12-15 15:00 UTC (permalink / raw)
  To: tglx, bigeasy, rjw, viresh.kumar
  Cc: linux-pm, linux-kernel, xen-devel, Boris Ostrovsky

When ivoked with CPUHP_AP_ONLINE_DYN state __cpuhp_setup_state()
is expected to return positive value which is the hotplug state that
the routine assigns.

Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
---

 kernel/cpu.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/kernel/cpu.c b/kernel/cpu.c
index 217fd2e..5339aca 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -1586,7 +1586,11 @@ int __cpuhp_state_add_instance(enum cpuhp_state state, struct hlist_node *node,
  * @startup:	startup callback function
  * @teardown:	teardown callback function
  *
- * Returns 0 if successful, otherwise a proper error code
+ * Returns:
+ *   On success:
+ *      Positive state number if @state is CPUHP_AP_ONLINE_DYN
+ *      0 for all other states
+ *   On failure: proper (negative) error code
  */
 int __cpuhp_setup_state(enum cpuhp_state state,
 			const char *name, bool invoke,
-- 
1.7.1

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

* [PATCH 2/2] cpufreq: Remove cpu hotplug callbacks only if they were initialized
  2016-12-15 15:00 [PATCH 0/2] __cpuhp_setup_state() returns positive value for dynamic state Boris Ostrovsky
  2016-12-15 15:00 ` [PATCH 1/2] cpu/hotplug: Clarify description of __cpuhp_setup_state() return value Boris Ostrovsky
@ 2016-12-15 15:00 ` Boris Ostrovsky
  2016-12-15 16:47   ` Thomas Gleixner
  1 sibling, 1 reply; 4+ messages in thread
From: Boris Ostrovsky @ 2016-12-15 15:00 UTC (permalink / raw)
  To: tglx, bigeasy, rjw, viresh.kumar
  Cc: linux-pm, linux-kernel, xen-devel, Boris Ostrovsky

Since cpu hotplug callbacks are requested for CPUHP_AP_ONLINE_DYN state,
successful callback initialization will result in cpuhp_setup_state()
returning a positive value. Therefore acpi_cpufreq_online being zero
indicates that callbacks have not been installed.

This means that acpi_cpufreq_boost_exit() should only remove them if
acpi_cpufreq_online is positive. Trying to call
cpuhp_remove_state_nocalls(0) will cause a BUG().

Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
---
 drivers/cpufreq/acpi-cpufreq.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
index 3a98702..3a2ca0f 100644
--- a/drivers/cpufreq/acpi-cpufreq.c
+++ b/drivers/cpufreq/acpi-cpufreq.c
@@ -930,7 +930,7 @@ static void __init acpi_cpufreq_boost_init(void)
 
 static void acpi_cpufreq_boost_exit(void)
 {
-	if (acpi_cpufreq_online >= 0)
+	if (acpi_cpufreq_online > 0)
 		cpuhp_remove_state_nocalls(acpi_cpufreq_online);
 }
 
-- 
1.7.1


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

* Re: [PATCH 2/2] cpufreq: Remove cpu hotplug callbacks only if they were initialized
  2016-12-15 15:00 ` [PATCH 2/2] cpufreq: Remove cpu hotplug callbacks only if they were initialized Boris Ostrovsky
@ 2016-12-15 16:47   ` Thomas Gleixner
  0 siblings, 0 replies; 4+ messages in thread
From: Thomas Gleixner @ 2016-12-15 16:47 UTC (permalink / raw)
  To: Boris Ostrovsky
  Cc: bigeasy, rjw, viresh.kumar, linux-pm, linux-kernel, xen-devel

On Thu, 15 Dec 2016, Boris Ostrovsky wrote:

> Since cpu hotplug callbacks are requested for CPUHP_AP_ONLINE_DYN state,
> successful callback initialization will result in cpuhp_setup_state()
> returning a positive value. Therefore acpi_cpufreq_online being zero
> indicates that callbacks have not been installed.
> 
> This means that acpi_cpufreq_boost_exit() should only remove them if
> acpi_cpufreq_online is positive. Trying to call
> cpuhp_remove_state_nocalls(0) will cause a BUG().
> 
> Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>

Reviewed-by: Thomas Gleixner <tglx@linutronix.de>

> ---
>  drivers/cpufreq/acpi-cpufreq.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
> index 3a98702..3a2ca0f 100644
> --- a/drivers/cpufreq/acpi-cpufreq.c
> +++ b/drivers/cpufreq/acpi-cpufreq.c
> @@ -930,7 +930,7 @@ static void __init acpi_cpufreq_boost_init(void)
>  
>  static void acpi_cpufreq_boost_exit(void)
>  {
> -	if (acpi_cpufreq_online >= 0)
> +	if (acpi_cpufreq_online > 0)
>  		cpuhp_remove_state_nocalls(acpi_cpufreq_online);
>  }
>  
> -- 
> 1.7.1
> 
> 

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

end of thread, other threads:[~2016-12-15 16:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-12-15 15:00 [PATCH 0/2] __cpuhp_setup_state() returns positive value for dynamic state Boris Ostrovsky
2016-12-15 15:00 ` [PATCH 1/2] cpu/hotplug: Clarify description of __cpuhp_setup_state() return value Boris Ostrovsky
2016-12-15 15:00 ` [PATCH 2/2] cpufreq: Remove cpu hotplug callbacks only if they were initialized Boris Ostrovsky
2016-12-15 16:47   ` Thomas Gleixner

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).