All of lore.kernel.org
 help / color / mirror / Atom feed
* cpu hotplug: convert more drivers (batch #3)
@ 2016-09-06 17:04 Sebastian Andrzej Siewior
  2016-09-06 17:04   ` Sebastian Andrzej Siewior
                   ` (21 more replies)
  0 siblings, 22 replies; 83+ messages in thread
From: Sebastian Andrzej Siewior @ 2016-09-06 17:04 UTC (permalink / raw)
  To: linux-kernel; +Cc: Peter Zijlstra, Ingo Molnar, rt, tglx

This series converts more drivers to the new CPU-hotplug state machine. It
depends on TIP's smp/hotplug branch.

Sebastian

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

* [PATCH 01/21] arm64: FP/SIMD: Convert to hotplug state machine
  2016-09-06 17:04 cpu hotplug: convert more drivers (batch #3) Sebastian Andrzej Siewior
@ 2016-09-06 17:04   ` Sebastian Andrzej Siewior
  2016-09-06 17:04   ` Sebastian Andrzej Siewior
                     ` (20 subsequent siblings)
  21 siblings, 0 replies; 83+ messages in thread
From: Sebastian Andrzej Siewior @ 2016-09-06 17:04 UTC (permalink / raw)
  To: linux-kernel
  Cc: Peter Zijlstra, Ingo Molnar, rt, tglx, Sebastian Andrzej Siewior,
	Catalin Marinas, Will Deacon, linux-arm-kernel

Install the callbacks via the state machine.

Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will.deacon@arm.com>
Cc: linux-arm-kernel@lists.infradead.org
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
 arch/arm64/kernel/fpsimd.c | 22 +++++-----------------
 include/linux/cpuhotplug.h |  1 +
 2 files changed, 6 insertions(+), 17 deletions(-)

diff --git a/arch/arm64/kernel/fpsimd.c b/arch/arm64/kernel/fpsimd.c
index 975b274ee7b5..394c61db5566 100644
--- a/arch/arm64/kernel/fpsimd.c
+++ b/arch/arm64/kernel/fpsimd.c
@@ -299,28 +299,16 @@ static inline void fpsimd_pm_init(void) { }
 #endif /* CONFIG_CPU_PM */
 
 #ifdef CONFIG_HOTPLUG_CPU
-static int fpsimd_cpu_hotplug_notifier(struct notifier_block *nfb,
-				       unsigned long action,
-				       void *hcpu)
+static int fpsimd_cpu_dead(unsigned int cpu)
 {
-	unsigned int cpu = (long)hcpu;
-
-	switch (action) {
-	case CPU_DEAD:
-	case CPU_DEAD_FROZEN:
-		per_cpu(fpsimd_last_state, cpu) = NULL;
-		break;
-	}
-	return NOTIFY_OK;
+	per_cpu(fpsimd_last_state, cpu) = NULL;
+	return 0;
 }
 
-static struct notifier_block fpsimd_cpu_hotplug_notifier_block = {
-	.notifier_call = fpsimd_cpu_hotplug_notifier,
-};
-
 static inline void fpsimd_hotplug_init(void)
 {
-	register_cpu_notifier(&fpsimd_cpu_hotplug_notifier_block);
+	cpuhp_setup_state_nocalls(CPUHP_ARM64_FPSIMD_DEAD, "arm64/fpsimd:dead",
+				  NULL, fpsimd_cpu_dead);
 }
 
 #else
diff --git a/include/linux/cpuhotplug.h b/include/linux/cpuhotplug.h
index afd59e2ca4b3..0da071ff36d2 100644
--- a/include/linux/cpuhotplug.h
+++ b/include/linux/cpuhotplug.h
@@ -20,6 +20,7 @@ enum cpuhp_state {
 	CPUHP_SOFTIRQ_DEAD,
 	CPUHP_NET_MVNETA_DEAD,
 	CPUHP_CPUIDLE_DEAD,
+	CPUHP_ARM64_FPSIMD_DEAD,
 	CPUHP_WORKQUEUE_PREP,
 	CPUHP_POWER_NUMA_PREPARE,
 	CPUHP_HRTIMERS_PREPARE,
-- 
2.9.3

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

* [PATCH 01/21] arm64: FP/SIMD: Convert to hotplug state machine
@ 2016-09-06 17:04   ` Sebastian Andrzej Siewior
  0 siblings, 0 replies; 83+ messages in thread
From: Sebastian Andrzej Siewior @ 2016-09-06 17:04 UTC (permalink / raw)
  To: linux-arm-kernel

Install the callbacks via the state machine.

Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will.deacon@arm.com>
Cc: linux-arm-kernel at lists.infradead.org
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
 arch/arm64/kernel/fpsimd.c | 22 +++++-----------------
 include/linux/cpuhotplug.h |  1 +
 2 files changed, 6 insertions(+), 17 deletions(-)

diff --git a/arch/arm64/kernel/fpsimd.c b/arch/arm64/kernel/fpsimd.c
index 975b274ee7b5..394c61db5566 100644
--- a/arch/arm64/kernel/fpsimd.c
+++ b/arch/arm64/kernel/fpsimd.c
@@ -299,28 +299,16 @@ static inline void fpsimd_pm_init(void) { }
 #endif /* CONFIG_CPU_PM */
 
 #ifdef CONFIG_HOTPLUG_CPU
-static int fpsimd_cpu_hotplug_notifier(struct notifier_block *nfb,
-				       unsigned long action,
-				       void *hcpu)
+static int fpsimd_cpu_dead(unsigned int cpu)
 {
-	unsigned int cpu = (long)hcpu;
-
-	switch (action) {
-	case CPU_DEAD:
-	case CPU_DEAD_FROZEN:
-		per_cpu(fpsimd_last_state, cpu) = NULL;
-		break;
-	}
-	return NOTIFY_OK;
+	per_cpu(fpsimd_last_state, cpu) = NULL;
+	return 0;
 }
 
-static struct notifier_block fpsimd_cpu_hotplug_notifier_block = {
-	.notifier_call = fpsimd_cpu_hotplug_notifier,
-};
-
 static inline void fpsimd_hotplug_init(void)
 {
-	register_cpu_notifier(&fpsimd_cpu_hotplug_notifier_block);
+	cpuhp_setup_state_nocalls(CPUHP_ARM64_FPSIMD_DEAD, "arm64/fpsimd:dead",
+				  NULL, fpsimd_cpu_dead);
 }
 
 #else
diff --git a/include/linux/cpuhotplug.h b/include/linux/cpuhotplug.h
index afd59e2ca4b3..0da071ff36d2 100644
--- a/include/linux/cpuhotplug.h
+++ b/include/linux/cpuhotplug.h
@@ -20,6 +20,7 @@ enum cpuhp_state {
 	CPUHP_SOFTIRQ_DEAD,
 	CPUHP_NET_MVNETA_DEAD,
 	CPUHP_CPUIDLE_DEAD,
+	CPUHP_ARM64_FPSIMD_DEAD,
 	CPUHP_WORKQUEUE_PREP,
 	CPUHP_POWER_NUMA_PREPARE,
 	CPUHP_HRTIMERS_PREPARE,
-- 
2.9.3

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

* [PATCH 02/21] ARM: shmobile: Convert to hotplug state machine
  2016-09-06 17:04 cpu hotplug: convert more drivers (batch #3) Sebastian Andrzej Siewior
  2016-09-06 17:04   ` Sebastian Andrzej Siewior
@ 2016-09-06 17:04   ` Sebastian Andrzej Siewior
  2016-09-06 17:04   ` Sebastian Andrzej Siewior
                     ` (19 subsequent siblings)
  21 siblings, 0 replies; 83+ messages in thread
From: Sebastian Andrzej Siewior @ 2016-09-06 17:04 UTC (permalink / raw)
  To: linux-arm-kernel

Install the callbacks via the state machine.

Cc: Simon Horman <horms@verge.net.au>
Cc: Magnus Damm <magnus.damm@gmail.com>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-sh@vger.kernel.org
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
 arch/arm/mach-shmobile/platsmp-scu.c | 26 ++++++++------------------
 include/linux/cpuhotplug.h           |  1 +
 2 files changed, 9 insertions(+), 18 deletions(-)

diff --git a/arch/arm/mach-shmobile/platsmp-scu.c b/arch/arm/mach-shmobile/platsmp-scu.c
index 8d478f1da265..d1ecaf37d142 100644
--- a/arch/arm/mach-shmobile/platsmp-scu.c
+++ b/arch/arm/mach-shmobile/platsmp-scu.c
@@ -21,26 +21,14 @@
 static phys_addr_t shmobile_scu_base_phys;
 static void __iomem *shmobile_scu_base;
 
-static int shmobile_smp_scu_notifier_call(struct notifier_block *nfb,
-					  unsigned long action, void *hcpu)
+static int shmobile_scu_cpu_prepare(unsigned int cpu)
 {
-	unsigned int cpu = (long)hcpu;
-
-	switch (action) {
-	case CPU_UP_PREPARE:
-		/* For this particular CPU register SCU SMP boot vector */
-		shmobile_smp_hook(cpu, virt_to_phys(shmobile_boot_scu),
-				  shmobile_scu_base_phys);
-		break;
-	};
-
-	return NOTIFY_OK;
+	/* For this particular CPU register SCU SMP boot vector */
+	shmobile_smp_hook(cpu, virt_to_phys(shmobile_boot_scu),
+			  shmobile_scu_base_phys);
+	return 0;
 }
 
-static struct notifier_block shmobile_smp_scu_notifier = {
-	.notifier_call = shmobile_smp_scu_notifier_call,
-};
-
 void __init shmobile_smp_scu_prepare_cpus(phys_addr_t scu_base_phys,
 					  unsigned int max_cpus)
 {
@@ -54,7 +42,9 @@ void __init shmobile_smp_scu_prepare_cpus(phys_addr_t scu_base_phys,
 	scu_power_mode(shmobile_scu_base, SCU_PM_NORMAL);
 
 	/* Use CPU notifier for reset vector control */
-	register_cpu_notifier(&shmobile_smp_scu_notifier);
+	cpuhp_setup_state_nocalls(CPUHP_ARM_SHMOBILE_SCU_PREPARE,
+				  "arm/shmobile-scu:prepare",
+				  shmobile_scu_cpu_prepare, NULL);
 }
 
 #ifdef CONFIG_HOTPLUG_CPU
diff --git a/include/linux/cpuhotplug.h b/include/linux/cpuhotplug.h
index 0da071ff36d2..008eed0c0787 100644
--- a/include/linux/cpuhotplug.h
+++ b/include/linux/cpuhotplug.h
@@ -35,6 +35,7 @@ enum cpuhp_state {
 	CPUHP_POWERPC_PMAC_PREPARE,
 	CPUHP_POWERPC_MMU_CTX_PREPARE,
 	CPUHP_NOTIFY_PREPARE,
+	CPUHP_ARM_SHMOBILE_SCU_PREPARE,
 	CPUHP_TIMERS_DEAD,
 	CPUHP_BRINGUP_CPU,
 	CPUHP_AP_IDLE_DEAD,
-- 
2.9.3


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

* [PATCH 02/21] ARM: shmobile: Convert to hotplug state machine
@ 2016-09-06 17:04   ` Sebastian Andrzej Siewior
  0 siblings, 0 replies; 83+ messages in thread
From: Sebastian Andrzej Siewior @ 2016-09-06 17:04 UTC (permalink / raw)
  To: linux-kernel
  Cc: Peter Zijlstra, Ingo Molnar, rt, tglx, Sebastian Andrzej Siewior,
	Simon Horman, Magnus Damm, linux-arm-kernel, linux-sh

Install the callbacks via the state machine.

Cc: Simon Horman <horms@verge.net.au>
Cc: Magnus Damm <magnus.damm@gmail.com>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-sh@vger.kernel.org
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
 arch/arm/mach-shmobile/platsmp-scu.c | 26 ++++++++------------------
 include/linux/cpuhotplug.h           |  1 +
 2 files changed, 9 insertions(+), 18 deletions(-)

diff --git a/arch/arm/mach-shmobile/platsmp-scu.c b/arch/arm/mach-shmobile/platsmp-scu.c
index 8d478f1da265..d1ecaf37d142 100644
--- a/arch/arm/mach-shmobile/platsmp-scu.c
+++ b/arch/arm/mach-shmobile/platsmp-scu.c
@@ -21,26 +21,14 @@
 static phys_addr_t shmobile_scu_base_phys;
 static void __iomem *shmobile_scu_base;
 
-static int shmobile_smp_scu_notifier_call(struct notifier_block *nfb,
-					  unsigned long action, void *hcpu)
+static int shmobile_scu_cpu_prepare(unsigned int cpu)
 {
-	unsigned int cpu = (long)hcpu;
-
-	switch (action) {
-	case CPU_UP_PREPARE:
-		/* For this particular CPU register SCU SMP boot vector */
-		shmobile_smp_hook(cpu, virt_to_phys(shmobile_boot_scu),
-				  shmobile_scu_base_phys);
-		break;
-	};
-
-	return NOTIFY_OK;
+	/* For this particular CPU register SCU SMP boot vector */
+	shmobile_smp_hook(cpu, virt_to_phys(shmobile_boot_scu),
+			  shmobile_scu_base_phys);
+	return 0;
 }
 
-static struct notifier_block shmobile_smp_scu_notifier = {
-	.notifier_call = shmobile_smp_scu_notifier_call,
-};
-
 void __init shmobile_smp_scu_prepare_cpus(phys_addr_t scu_base_phys,
 					  unsigned int max_cpus)
 {
@@ -54,7 +42,9 @@ void __init shmobile_smp_scu_prepare_cpus(phys_addr_t scu_base_phys,
 	scu_power_mode(shmobile_scu_base, SCU_PM_NORMAL);
 
 	/* Use CPU notifier for reset vector control */
-	register_cpu_notifier(&shmobile_smp_scu_notifier);
+	cpuhp_setup_state_nocalls(CPUHP_ARM_SHMOBILE_SCU_PREPARE,
+				  "arm/shmobile-scu:prepare",
+				  shmobile_scu_cpu_prepare, NULL);
 }
 
 #ifdef CONFIG_HOTPLUG_CPU
diff --git a/include/linux/cpuhotplug.h b/include/linux/cpuhotplug.h
index 0da071ff36d2..008eed0c0787 100644
--- a/include/linux/cpuhotplug.h
+++ b/include/linux/cpuhotplug.h
@@ -35,6 +35,7 @@ enum cpuhp_state {
 	CPUHP_POWERPC_PMAC_PREPARE,
 	CPUHP_POWERPC_MMU_CTX_PREPARE,
 	CPUHP_NOTIFY_PREPARE,
+	CPUHP_ARM_SHMOBILE_SCU_PREPARE,
 	CPUHP_TIMERS_DEAD,
 	CPUHP_BRINGUP_CPU,
 	CPUHP_AP_IDLE_DEAD,
-- 
2.9.3

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

* [PATCH 02/21] ARM: shmobile: Convert to hotplug state machine
@ 2016-09-06 17:04   ` Sebastian Andrzej Siewior
  0 siblings, 0 replies; 83+ messages in thread
From: Sebastian Andrzej Siewior @ 2016-09-06 17:04 UTC (permalink / raw)
  To: linux-arm-kernel

Install the callbacks via the state machine.

Cc: Simon Horman <horms@verge.net.au>
Cc: Magnus Damm <magnus.damm@gmail.com>
Cc: linux-arm-kernel at lists.infradead.org
Cc: linux-sh at vger.kernel.org
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
 arch/arm/mach-shmobile/platsmp-scu.c | 26 ++++++++------------------
 include/linux/cpuhotplug.h           |  1 +
 2 files changed, 9 insertions(+), 18 deletions(-)

diff --git a/arch/arm/mach-shmobile/platsmp-scu.c b/arch/arm/mach-shmobile/platsmp-scu.c
index 8d478f1da265..d1ecaf37d142 100644
--- a/arch/arm/mach-shmobile/platsmp-scu.c
+++ b/arch/arm/mach-shmobile/platsmp-scu.c
@@ -21,26 +21,14 @@
 static phys_addr_t shmobile_scu_base_phys;
 static void __iomem *shmobile_scu_base;
 
-static int shmobile_smp_scu_notifier_call(struct notifier_block *nfb,
-					  unsigned long action, void *hcpu)
+static int shmobile_scu_cpu_prepare(unsigned int cpu)
 {
-	unsigned int cpu = (long)hcpu;
-
-	switch (action) {
-	case CPU_UP_PREPARE:
-		/* For this particular CPU register SCU SMP boot vector */
-		shmobile_smp_hook(cpu, virt_to_phys(shmobile_boot_scu),
-				  shmobile_scu_base_phys);
-		break;
-	};
-
-	return NOTIFY_OK;
+	/* For this particular CPU register SCU SMP boot vector */
+	shmobile_smp_hook(cpu, virt_to_phys(shmobile_boot_scu),
+			  shmobile_scu_base_phys);
+	return 0;
 }
 
-static struct notifier_block shmobile_smp_scu_notifier = {
-	.notifier_call = shmobile_smp_scu_notifier_call,
-};
-
 void __init shmobile_smp_scu_prepare_cpus(phys_addr_t scu_base_phys,
 					  unsigned int max_cpus)
 {
@@ -54,7 +42,9 @@ void __init shmobile_smp_scu_prepare_cpus(phys_addr_t scu_base_phys,
 	scu_power_mode(shmobile_scu_base, SCU_PM_NORMAL);
 
 	/* Use CPU notifier for reset vector control */
-	register_cpu_notifier(&shmobile_smp_scu_notifier);
+	cpuhp_setup_state_nocalls(CPUHP_ARM_SHMOBILE_SCU_PREPARE,
+				  "arm/shmobile-scu:prepare",
+				  shmobile_scu_cpu_prepare, NULL);
 }
 
 #ifdef CONFIG_HOTPLUG_CPU
diff --git a/include/linux/cpuhotplug.h b/include/linux/cpuhotplug.h
index 0da071ff36d2..008eed0c0787 100644
--- a/include/linux/cpuhotplug.h
+++ b/include/linux/cpuhotplug.h
@@ -35,6 +35,7 @@ enum cpuhp_state {
 	CPUHP_POWERPC_PMAC_PREPARE,
 	CPUHP_POWERPC_MMU_CTX_PREPARE,
 	CPUHP_NOTIFY_PREPARE,
+	CPUHP_ARM_SHMOBILE_SCU_PREPARE,
 	CPUHP_TIMERS_DEAD,
 	CPUHP_BRINGUP_CPU,
 	CPUHP_AP_IDLE_DEAD,
-- 
2.9.3

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

* [PATCH 03/21] ARM: OMAP: wakeupgen: Convert to hotplug state machine
  2016-09-06 17:04 cpu hotplug: convert more drivers (batch #3) Sebastian Andrzej Siewior
@ 2016-09-06 17:04   ` Sebastian Andrzej Siewior
  2016-09-06 17:04   ` Sebastian Andrzej Siewior
                     ` (20 subsequent siblings)
  21 siblings, 0 replies; 83+ messages in thread
From: Sebastian Andrzej Siewior @ 2016-09-06 17:04 UTC (permalink / raw)
  To: linux-kernel
  Cc: Peter Zijlstra, Ingo Molnar, rt, tglx, Sebastian Andrzej Siewior,
	Tony Lindgren, linux-omap, linux-arm-kernel

Install the callbacks via the state machine.

Cc: Tony Lindgren <tony@atomide.com>
Cc: linux-omap@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
 arch/arm/mach-omap2/omap-wakeupgen.c | 35 +++++++++++++----------------------
 include/linux/cpuhotplug.h           |  1 +
 2 files changed, 14 insertions(+), 22 deletions(-)

diff --git a/arch/arm/mach-omap2/omap-wakeupgen.c b/arch/arm/mach-omap2/omap-wakeupgen.c
index 0c4754386532..369f95a703ac 100644
--- a/arch/arm/mach-omap2/omap-wakeupgen.c
+++ b/arch/arm/mach-omap2/omap-wakeupgen.c
@@ -322,34 +322,25 @@ static void irq_save_secure_context(void)
 #endif
 
 #ifdef CONFIG_HOTPLUG_CPU
-static int irq_cpu_hotplug_notify(struct notifier_block *self,
-				  unsigned long action, void *hcpu)
+static int omap_wakeupgen_cpu_online(unsigned int cpu)
 {
-	unsigned int cpu = (unsigned int)hcpu;
-
-	/*
-	 * Corresponding FROZEN transitions do not have to be handled,
-	 * they are handled by at a higher level
-	 * (drivers/cpuidle/coupled.c).
-	 */
-	switch (action) {
-	case CPU_ONLINE:
-		wakeupgen_irqmask_all(cpu, 0);
-		break;
-	case CPU_DEAD:
-		wakeupgen_irqmask_all(cpu, 1);
-		break;
-	}
-	return NOTIFY_OK;
+	wakeupgen_irqmask_all(cpu, 0);
+	return 0;
 }
 
-static struct notifier_block irq_hotplug_notifier = {
-	.notifier_call = irq_cpu_hotplug_notify,
-};
+static int omap_wakeupgen_cpu_dead(unsigned int cpu)
+{
+	wakeupgen_irqmask_all(cpu, 1);
+	return 0;
+}
 
 static void __init irq_hotplug_init(void)
 {
-	register_hotcpu_notifier(&irq_hotplug_notifier);
+	cpuhp_setup_state_nocalls(CPUHP_AP_ONLINE_DYN, "arm/omap-wake:online",
+				  omap_wakeupgen_cpu_online, NULL);
+	cpuhp_setup_state_nocalls(CPUHP_ARM_OMAP_WAKE_DEAD,
+				  "arm/omap-wake:dead", NULL,
+				  omap_wakeupgen_cpu_dead);
 }
 #else
 static void __init irq_hotplug_init(void)
diff --git a/include/linux/cpuhotplug.h b/include/linux/cpuhotplug.h
index 008eed0c0787..35859aafbbfc 100644
--- a/include/linux/cpuhotplug.h
+++ b/include/linux/cpuhotplug.h
@@ -21,6 +21,7 @@ enum cpuhp_state {
 	CPUHP_NET_MVNETA_DEAD,
 	CPUHP_CPUIDLE_DEAD,
 	CPUHP_ARM64_FPSIMD_DEAD,
+	CPUHP_ARM_OMAP_WAKE_DEAD,
 	CPUHP_WORKQUEUE_PREP,
 	CPUHP_POWER_NUMA_PREPARE,
 	CPUHP_HRTIMERS_PREPARE,
-- 
2.9.3

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

* [PATCH 03/21] ARM: OMAP: wakeupgen: Convert to hotplug state machine
@ 2016-09-06 17:04   ` Sebastian Andrzej Siewior
  0 siblings, 0 replies; 83+ messages in thread
From: Sebastian Andrzej Siewior @ 2016-09-06 17:04 UTC (permalink / raw)
  To: linux-arm-kernel

Install the callbacks via the state machine.

Cc: Tony Lindgren <tony@atomide.com>
Cc: linux-omap at vger.kernel.org
Cc: linux-arm-kernel at lists.infradead.org
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
 arch/arm/mach-omap2/omap-wakeupgen.c | 35 +++++++++++++----------------------
 include/linux/cpuhotplug.h           |  1 +
 2 files changed, 14 insertions(+), 22 deletions(-)

diff --git a/arch/arm/mach-omap2/omap-wakeupgen.c b/arch/arm/mach-omap2/omap-wakeupgen.c
index 0c4754386532..369f95a703ac 100644
--- a/arch/arm/mach-omap2/omap-wakeupgen.c
+++ b/arch/arm/mach-omap2/omap-wakeupgen.c
@@ -322,34 +322,25 @@ static void irq_save_secure_context(void)
 #endif
 
 #ifdef CONFIG_HOTPLUG_CPU
-static int irq_cpu_hotplug_notify(struct notifier_block *self,
-				  unsigned long action, void *hcpu)
+static int omap_wakeupgen_cpu_online(unsigned int cpu)
 {
-	unsigned int cpu = (unsigned int)hcpu;
-
-	/*
-	 * Corresponding FROZEN transitions do not have to be handled,
-	 * they are handled by at a higher level
-	 * (drivers/cpuidle/coupled.c).
-	 */
-	switch (action) {
-	case CPU_ONLINE:
-		wakeupgen_irqmask_all(cpu, 0);
-		break;
-	case CPU_DEAD:
-		wakeupgen_irqmask_all(cpu, 1);
-		break;
-	}
-	return NOTIFY_OK;
+	wakeupgen_irqmask_all(cpu, 0);
+	return 0;
 }
 
-static struct notifier_block irq_hotplug_notifier = {
-	.notifier_call = irq_cpu_hotplug_notify,
-};
+static int omap_wakeupgen_cpu_dead(unsigned int cpu)
+{
+	wakeupgen_irqmask_all(cpu, 1);
+	return 0;
+}
 
 static void __init irq_hotplug_init(void)
 {
-	register_hotcpu_notifier(&irq_hotplug_notifier);
+	cpuhp_setup_state_nocalls(CPUHP_AP_ONLINE_DYN, "arm/omap-wake:online",
+				  omap_wakeupgen_cpu_online, NULL);
+	cpuhp_setup_state_nocalls(CPUHP_ARM_OMAP_WAKE_DEAD,
+				  "arm/omap-wake:dead", NULL,
+				  omap_wakeupgen_cpu_dead);
 }
 #else
 static void __init irq_hotplug_init(void)
diff --git a/include/linux/cpuhotplug.h b/include/linux/cpuhotplug.h
index 008eed0c0787..35859aafbbfc 100644
--- a/include/linux/cpuhotplug.h
+++ b/include/linux/cpuhotplug.h
@@ -21,6 +21,7 @@ enum cpuhp_state {
 	CPUHP_NET_MVNETA_DEAD,
 	CPUHP_CPUIDLE_DEAD,
 	CPUHP_ARM64_FPSIMD_DEAD,
+	CPUHP_ARM_OMAP_WAKE_DEAD,
 	CPUHP_WORKQUEUE_PREP,
 	CPUHP_POWER_NUMA_PREPARE,
 	CPUHP_HRTIMERS_PREPARE,
-- 
2.9.3

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

* [PATCH 04/21] ia64: mca: Convert to hotplug state machine
  2016-09-06 17:04 cpu hotplug: convert more drivers (batch #3) Sebastian Andrzej Siewior
@ 2016-09-06 17:04   ` Sebastian Andrzej Siewior
  2016-09-06 17:04   ` Sebastian Andrzej Siewior
                     ` (20 subsequent siblings)
  21 siblings, 0 replies; 83+ messages in thread
From: Sebastian Andrzej Siewior @ 2016-09-06 17:04 UTC (permalink / raw)
  To: linux-kernel
  Cc: Peter Zijlstra, Ingo Molnar, rt, tglx, Sebastian Andrzej Siewior,
	Tony Luck, Fenghua Yu, linux-ia64

Install the callbacks via the state machine and let the core invoke
the callbacks on the already online CPUs.

Cc: Tony Luck <tony.luck@intel.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: linux-ia64@vger.kernel.org
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
 arch/ia64/kernel/mca.c | 26 ++++----------------------
 1 file changed, 4 insertions(+), 22 deletions(-)

diff --git a/arch/ia64/kernel/mca.c b/arch/ia64/kernel/mca.c
index eb9220cde76c..c2858865b146 100644
--- a/arch/ia64/kernel/mca.c
+++ b/arch/ia64/kernel/mca.c
@@ -1890,7 +1890,7 @@ ia64_mca_cpu_init(void *cpu_data)
 							      PAGE_KERNEL)));
 }
 
-static void ia64_mca_cmc_vector_adjust(void *dummy)
+static int ia64_mca_cpu_online(unsigned int cpu)
 {
 	unsigned long flags;
 
@@ -1898,25 +1898,9 @@ static void ia64_mca_cmc_vector_adjust(void *dummy)
 	if (!cmc_polling_enabled)
 		ia64_mca_cmc_vector_enable(NULL);
 	local_irq_restore(flags);
+	return 0;
 }
 
-static int mca_cpu_callback(struct notifier_block *nfb,
-				      unsigned long action,
-				      void *hcpu)
-{
-	switch (action) {
-	case CPU_ONLINE:
-	case CPU_ONLINE_FROZEN:
-		ia64_mca_cmc_vector_adjust(NULL);
-		break;
-	}
-	return NOTIFY_OK;
-}
-
-static struct notifier_block mca_cpu_notifier = {
-	.notifier_call = mca_cpu_callback
-};
-
 /*
  * ia64_mca_init
  *
@@ -2111,15 +2095,13 @@ ia64_mca_late_init(void)
 	if (!mca_init)
 		return 0;
 
-	register_hotcpu_notifier(&mca_cpu_notifier);
-
 	/* Setup the CMCI/P vector and handler */
 	setup_timer(&cmc_poll_timer, ia64_mca_cmc_poll, 0UL);
 
 	/* Unmask/enable the vector */
 	cmc_polling_enabled = 0;
-	schedule_work(&cmc_enable_work);
-
+	cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "ia64/mca:online",
+			  ia64_mca_cpu_online, NULL);
 	IA64_MCA_DEBUG("%s: CMCI/P setup and enabled.\n", __func__);
 
 #ifdef CONFIG_ACPI
-- 
2.9.3

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

* [PATCH 04/21] ia64: mca: Convert to hotplug state machine
@ 2016-09-06 17:04   ` Sebastian Andrzej Siewior
  0 siblings, 0 replies; 83+ messages in thread
From: Sebastian Andrzej Siewior @ 2016-09-06 17:04 UTC (permalink / raw)
  To: linux-kernel
  Cc: Peter Zijlstra, Ingo Molnar, rt, tglx, Sebastian Andrzej Siewior,
	Tony Luck, Fenghua Yu, linux-ia64

Install the callbacks via the state machine and let the core invoke
the callbacks on the already online CPUs.

Cc: Tony Luck <tony.luck@intel.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: linux-ia64@vger.kernel.org
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
 arch/ia64/kernel/mca.c | 26 ++++----------------------
 1 file changed, 4 insertions(+), 22 deletions(-)

diff --git a/arch/ia64/kernel/mca.c b/arch/ia64/kernel/mca.c
index eb9220cde76c..c2858865b146 100644
--- a/arch/ia64/kernel/mca.c
+++ b/arch/ia64/kernel/mca.c
@@ -1890,7 +1890,7 @@ ia64_mca_cpu_init(void *cpu_data)
 							      PAGE_KERNEL)));
 }
 
-static void ia64_mca_cmc_vector_adjust(void *dummy)
+static int ia64_mca_cpu_online(unsigned int cpu)
 {
 	unsigned long flags;
 
@@ -1898,25 +1898,9 @@ static void ia64_mca_cmc_vector_adjust(void *dummy)
 	if (!cmc_polling_enabled)
 		ia64_mca_cmc_vector_enable(NULL);
 	local_irq_restore(flags);
+	return 0;
 }
 
-static int mca_cpu_callback(struct notifier_block *nfb,
-				      unsigned long action,
-				      void *hcpu)
-{
-	switch (action) {
-	case CPU_ONLINE:
-	case CPU_ONLINE_FROZEN:
-		ia64_mca_cmc_vector_adjust(NULL);
-		break;
-	}
-	return NOTIFY_OK;
-}
-
-static struct notifier_block mca_cpu_notifier = {
-	.notifier_call = mca_cpu_callback
-};
-
 /*
  * ia64_mca_init
  *
@@ -2111,15 +2095,13 @@ ia64_mca_late_init(void)
 	if (!mca_init)
 		return 0;
 
-	register_hotcpu_notifier(&mca_cpu_notifier);
-
 	/* Setup the CMCI/P vector and handler */
 	setup_timer(&cmc_poll_timer, ia64_mca_cmc_poll, 0UL);
 
 	/* Unmask/enable the vector */
 	cmc_polling_enabled = 0;
-	schedule_work(&cmc_enable_work);
-
+	cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "ia64/mca:online",
+			  ia64_mca_cpu_online, NULL);
 	IA64_MCA_DEBUG("%s: CMCI/P setup and enabled.\n", __func__);
 
 #ifdef CONFIG_ACPI
-- 
2.9.3


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

* [PATCH 05/21] sh: SH-X3 SMP: Convert to hotplug state machine
  2016-09-06 17:04 cpu hotplug: convert more drivers (batch #3) Sebastian Andrzej Siewior
@ 2016-09-06 17:04   ` Sebastian Andrzej Siewior
  2016-09-06 17:04   ` Sebastian Andrzej Siewior
                     ` (20 subsequent siblings)
  21 siblings, 0 replies; 83+ messages in thread
From: Sebastian Andrzej Siewior @ 2016-09-06 17:04 UTC (permalink / raw)
  To: linux-kernel
  Cc: Peter Zijlstra, Ingo Molnar, rt, tglx, Sebastian Andrzej Siewior,
	linux-sh

Install the callbacks via the state machine.

Cc: linux-sh@vger.kernel.org
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
 arch/sh/kernel/cpu/sh4a/smp-shx3.c | 26 +++++---------------------
 include/linux/cpuhotplug.h         |  1 +
 2 files changed, 6 insertions(+), 21 deletions(-)

diff --git a/arch/sh/kernel/cpu/sh4a/smp-shx3.c b/arch/sh/kernel/cpu/sh4a/smp-shx3.c
index 839612c8a0a0..0d3637c494bf 100644
--- a/arch/sh/kernel/cpu/sh4a/smp-shx3.c
+++ b/arch/sh/kernel/cpu/sh4a/smp-shx3.c
@@ -122,32 +122,16 @@ static void shx3_update_boot_vector(unsigned int cpu)
 	__raw_writel(STBCR_RESET, STBCR_REG(cpu));
 }
 
-static int
-shx3_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
+static int shx3_cpu_prepare(unsigned int cpu)
 {
-	unsigned int cpu = (unsigned int)hcpu;
-
-	switch (action) {
-	case CPU_UP_PREPARE:
-		shx3_update_boot_vector(cpu);
-		break;
-	case CPU_ONLINE:
-		pr_info("CPU %u is now online\n", cpu);
-		break;
-	case CPU_DEAD:
-		break;
-	}
-
-	return NOTIFY_OK;
+	shx3_update_boot_vector(cpu);
+	return 0;
 }
 
-static struct notifier_block shx3_cpu_notifier = {
-	.notifier_call		= shx3_cpu_callback,
-};
-
 static int register_shx3_cpu_notifier(void)
 {
-	register_hotcpu_notifier(&shx3_cpu_notifier);
+	cpuhp_setup_state_nocalls(CPUHP_SH_SH3X_PREPARE, "sh/shx3:prepare",
+				  shx3_cpu_prepare, NULL);
 	return 0;
 }
 late_initcall(register_shx3_cpu_notifier);
diff --git a/include/linux/cpuhotplug.h b/include/linux/cpuhotplug.h
index 35859aafbbfc..8dec2a236af3 100644
--- a/include/linux/cpuhotplug.h
+++ b/include/linux/cpuhotplug.h
@@ -37,6 +37,7 @@ enum cpuhp_state {
 	CPUHP_POWERPC_MMU_CTX_PREPARE,
 	CPUHP_NOTIFY_PREPARE,
 	CPUHP_ARM_SHMOBILE_SCU_PREPARE,
+	CPUHP_SH_SH3X_PREPARE,
 	CPUHP_TIMERS_DEAD,
 	CPUHP_BRINGUP_CPU,
 	CPUHP_AP_IDLE_DEAD,
-- 
2.9.3


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

* [PATCH 05/21] sh: SH-X3 SMP: Convert to hotplug state machine
@ 2016-09-06 17:04   ` Sebastian Andrzej Siewior
  0 siblings, 0 replies; 83+ messages in thread
From: Sebastian Andrzej Siewior @ 2016-09-06 17:04 UTC (permalink / raw)
  To: linux-kernel
  Cc: Peter Zijlstra, Ingo Molnar, rt, tglx, Sebastian Andrzej Siewior,
	linux-sh

Install the callbacks via the state machine.

Cc: linux-sh@vger.kernel.org
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
 arch/sh/kernel/cpu/sh4a/smp-shx3.c | 26 +++++---------------------
 include/linux/cpuhotplug.h         |  1 +
 2 files changed, 6 insertions(+), 21 deletions(-)

diff --git a/arch/sh/kernel/cpu/sh4a/smp-shx3.c b/arch/sh/kernel/cpu/sh4a/smp-shx3.c
index 839612c8a0a0..0d3637c494bf 100644
--- a/arch/sh/kernel/cpu/sh4a/smp-shx3.c
+++ b/arch/sh/kernel/cpu/sh4a/smp-shx3.c
@@ -122,32 +122,16 @@ static void shx3_update_boot_vector(unsigned int cpu)
 	__raw_writel(STBCR_RESET, STBCR_REG(cpu));
 }
 
-static int
-shx3_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
+static int shx3_cpu_prepare(unsigned int cpu)
 {
-	unsigned int cpu = (unsigned int)hcpu;
-
-	switch (action) {
-	case CPU_UP_PREPARE:
-		shx3_update_boot_vector(cpu);
-		break;
-	case CPU_ONLINE:
-		pr_info("CPU %u is now online\n", cpu);
-		break;
-	case CPU_DEAD:
-		break;
-	}
-
-	return NOTIFY_OK;
+	shx3_update_boot_vector(cpu);
+	return 0;
 }
 
-static struct notifier_block shx3_cpu_notifier = {
-	.notifier_call		= shx3_cpu_callback,
-};
-
 static int register_shx3_cpu_notifier(void)
 {
-	register_hotcpu_notifier(&shx3_cpu_notifier);
+	cpuhp_setup_state_nocalls(CPUHP_SH_SH3X_PREPARE, "sh/shx3:prepare",
+				  shx3_cpu_prepare, NULL);
 	return 0;
 }
 late_initcall(register_shx3_cpu_notifier);
diff --git a/include/linux/cpuhotplug.h b/include/linux/cpuhotplug.h
index 35859aafbbfc..8dec2a236af3 100644
--- a/include/linux/cpuhotplug.h
+++ b/include/linux/cpuhotplug.h
@@ -37,6 +37,7 @@ enum cpuhp_state {
 	CPUHP_POWERPC_MMU_CTX_PREPARE,
 	CPUHP_NOTIFY_PREPARE,
 	CPUHP_ARM_SHMOBILE_SCU_PREPARE,
+	CPUHP_SH_SH3X_PREPARE,
 	CPUHP_TIMERS_DEAD,
 	CPUHP_BRINGUP_CPU,
 	CPUHP_AP_IDLE_DEAD,
-- 
2.9.3

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

* [PATCH 06/21] x86: microcode: Convert to hotplug state machine
  2016-09-06 17:04 cpu hotplug: convert more drivers (batch #3) Sebastian Andrzej Siewior
                   ` (4 preceding siblings ...)
  2016-09-06 17:04   ` Sebastian Andrzej Siewior
@ 2016-09-06 17:04 ` Sebastian Andrzej Siewior
  2016-09-07 11:36   ` Borislav Petkov
  2016-09-06 17:04 ` [PATCH 07/21] lib: irq_poll: " Sebastian Andrzej Siewior
                   ` (15 subsequent siblings)
  21 siblings, 1 reply; 83+ messages in thread
From: Sebastian Andrzej Siewior @ 2016-09-06 17:04 UTC (permalink / raw)
  To: linux-kernel
  Cc: Peter Zijlstra, Ingo Molnar, rt, tglx, Sebastian Andrzej Siewior,
	Borislav Petkov

Install the callbacks via the state machine. There is little hackery with
mc_cpu_dead() which should only be called if CPU_UP failed durin resume.
This change may not fully represent the current behaviour. The current code
also behaves different if the CPU does not come up in the _cpu_up() state vs
one of the CPU_ONLINE notifier returned an error. Not sure what kind of a
problem is solved here.

Cc: Borislav Petkov <bp@alien8.de>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
 arch/x86/kernel/cpu/microcode/core.c | 71 +++++++++++++++---------------------
 include/linux/cpuhotplug.h           |  1 +
 2 files changed, 30 insertions(+), 42 deletions(-)

diff --git a/arch/x86/kernel/cpu/microcode/core.c b/arch/x86/kernel/cpu/microcode/core.c
index df04b2d033f6..4fc67b51e22e 100644
--- a/arch/x86/kernel/cpu/microcode/core.c
+++ b/arch/x86/kernel/cpu/microcode/core.c
@@ -558,54 +558,38 @@ static struct syscore_ops mc_syscore_ops = {
 	.resume			= mc_bp_resume,
 };
 
-static int
-mc_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu)
+static int mc_cpu_online(unsigned int cpu)
 {
-	unsigned int cpu = (unsigned long)hcpu;
 	struct device *dev;
 
 	dev = get_cpu_device(cpu);
+	microcode_update_cpu(cpu);
+	pr_debug("CPU%d added\n", cpu);
 
-	switch (action & ~CPU_TASKS_FROZEN) {
-	case CPU_ONLINE:
-		microcode_update_cpu(cpu);
-		pr_debug("CPU%d added\n", cpu);
-		/*
-		 * "break" is missing on purpose here because we want to fall
-		 * through in order to create the sysfs group.
-		 */
-
-	case CPU_DOWN_FAILED:
-		if (sysfs_create_group(&dev->kobj, &mc_attr_group))
-			pr_err("Failed to create group for CPU%d\n", cpu);
-		break;
-
-	case CPU_DOWN_PREPARE:
-		/* Suspend is in progress, only remove the interface */
-		sysfs_remove_group(&dev->kobj, &mc_attr_group);
-		pr_debug("CPU%d removed\n", cpu);
-		break;
-
-	/*
-	 * case CPU_DEAD:
-	 *
-	 * When a CPU goes offline, don't free up or invalidate the copy of
-	 * the microcode in kernel memory, so that we can reuse it when the
-	 * CPU comes back online without unnecessarily requesting the userspace
-	 * for it again.
-	 */
-	}
-
-	/* The CPU refused to come up during a system resume */
-	if (action == CPU_UP_CANCELED_FROZEN)
-		microcode_fini_cpu(cpu);
-
-	return NOTIFY_OK;
+	if (sysfs_create_group(&dev->kobj, &mc_attr_group))
+		pr_err("Failed to create group for CPU%d\n", cpu);
+	return 0;
 }
 
-static struct notifier_block mc_cpu_notifier = {
-	.notifier_call	= mc_cpu_callback,
-};
+static int mc_cpu_down_prep(unsigned int cpu)
+{
+	struct device *dev;
+
+	dev = get_cpu_device(cpu);
+	/* Suspend is in progress, only remove the interface */
+	sysfs_remove_group(&dev->kobj, &mc_attr_group);
+	pr_debug("CPU%d removed\n", cpu);
+	return 0;
+}
+
+static int mc_cpu_dead(unsigned int cpu)
+{
+#ifdef CONFIG_SMP
+	if (cpuhp_tasks_frozen)
+		microcode_fini_cpu(cpu);
+#endif
+	return 0;
+}
 
 static struct attribute *cpu_root_microcode_attrs[] = {
 	&dev_attr_reload.attr,
@@ -665,7 +649,10 @@ int __init microcode_init(void)
 		goto out_ucode_group;
 
 	register_syscore_ops(&mc_syscore_ops);
-	register_hotcpu_notifier(&mc_cpu_notifier);
+	cpuhp_setup_state_nocalls(CPUHP_AP_ONLINE_DYN, "x86/microcode:online",
+				  mc_cpu_online, mc_cpu_down_prep);
+	cpuhp_setup_state_nocalls(CPUHP_X86_MICRCODE_PREPARE,
+				  "x86/microcode:prepare", NULL, mc_cpu_dead);
 
 	pr_info("Microcode Update Driver: v" MICROCODE_VERSION
 		" <tigran@aivazian.fsnet.co.uk>, Peter Oruba\n");
diff --git a/include/linux/cpuhotplug.h b/include/linux/cpuhotplug.h
index 8dec2a236af3..4ca7551b902f 100644
--- a/include/linux/cpuhotplug.h
+++ b/include/linux/cpuhotplug.h
@@ -38,6 +38,7 @@ enum cpuhp_state {
 	CPUHP_NOTIFY_PREPARE,
 	CPUHP_ARM_SHMOBILE_SCU_PREPARE,
 	CPUHP_SH_SH3X_PREPARE,
+	CPUHP_X86_MICRCODE_PREPARE,
 	CPUHP_TIMERS_DEAD,
 	CPUHP_BRINGUP_CPU,
 	CPUHP_AP_IDLE_DEAD,
-- 
2.9.3

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

* [PATCH 07/21] lib: irq_poll: Convert to hotplug state machine
  2016-09-06 17:04 cpu hotplug: convert more drivers (batch #3) Sebastian Andrzej Siewior
                   ` (5 preceding siblings ...)
  2016-09-06 17:04 ` [PATCH 06/21] x86: microcode: " Sebastian Andrzej Siewior
@ 2016-09-06 17:04 ` Sebastian Andrzej Siewior
  2016-09-19 19:54   ` [tip:smp/hotplug] lib/irq_poll: " tip-bot for Sebastian Andrzej Siewior
  2016-09-06 17:04 ` [PATCH 08/21] block: softirq: " Sebastian Andrzej Siewior
                   ` (14 subsequent siblings)
  21 siblings, 1 reply; 83+ messages in thread
From: Sebastian Andrzej Siewior @ 2016-09-06 17:04 UTC (permalink / raw)
  To: linux-kernel
  Cc: Peter Zijlstra, Ingo Molnar, rt, tglx, Sebastian Andrzej Siewior,
	Jens Axboe

Install the callbacks via the state machine.

Cc: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
 include/linux/cpuhotplug.h |  1 +
 lib/irq_poll.c             | 26 +++++++++-----------------
 2 files changed, 10 insertions(+), 17 deletions(-)

diff --git a/include/linux/cpuhotplug.h b/include/linux/cpuhotplug.h
index 4ca7551b902f..be6c01b7efbe 100644
--- a/include/linux/cpuhotplug.h
+++ b/include/linux/cpuhotplug.h
@@ -22,6 +22,7 @@ enum cpuhp_state {
 	CPUHP_CPUIDLE_DEAD,
 	CPUHP_ARM64_FPSIMD_DEAD,
 	CPUHP_ARM_OMAP_WAKE_DEAD,
+	CPUHP_IRQ_POLL_DEAD,
 	CPUHP_WORKQUEUE_PREP,
 	CPUHP_POWER_NUMA_PREPARE,
 	CPUHP_HRTIMERS_PREPARE,
diff --git a/lib/irq_poll.c b/lib/irq_poll.c
index 836f7db4e548..2be55692aa43 100644
--- a/lib/irq_poll.c
+++ b/lib/irq_poll.c
@@ -184,30 +184,21 @@ void irq_poll_init(struct irq_poll *iop, int weight, irq_poll_fn *poll_fn)
 }
 EXPORT_SYMBOL(irq_poll_init);
 
-static int irq_poll_cpu_notify(struct notifier_block *self,
-				 unsigned long action, void *hcpu)
+static int irq_poll_cpu_dead(unsigned int cpu)
 {
 	/*
 	 * If a CPU goes away, splice its entries to the current CPU
 	 * and trigger a run of the softirq
 	 */
-	if (action == CPU_DEAD || action == CPU_DEAD_FROZEN) {
-		int cpu = (unsigned long) hcpu;
+	local_irq_disable();
+	list_splice_init(&per_cpu(blk_cpu_iopoll, cpu),
+			 this_cpu_ptr(&blk_cpu_iopoll));
+	__raise_softirq_irqoff(IRQ_POLL_SOFTIRQ);
+	local_irq_enable();
 
-		local_irq_disable();
-		list_splice_init(&per_cpu(blk_cpu_iopoll, cpu),
-				 this_cpu_ptr(&blk_cpu_iopoll));
-		__raise_softirq_irqoff(IRQ_POLL_SOFTIRQ);
-		local_irq_enable();
-	}
-
-	return NOTIFY_OK;
+	return 0;
 }
 
-static struct notifier_block irq_poll_cpu_notifier = {
-	.notifier_call	= irq_poll_cpu_notify,
-};
-
 static __init int irq_poll_setup(void)
 {
 	int i;
@@ -216,7 +207,8 @@ static __init int irq_poll_setup(void)
 		INIT_LIST_HEAD(&per_cpu(blk_cpu_iopoll, i));
 
 	open_softirq(IRQ_POLL_SOFTIRQ, irq_poll_softirq);
-	register_hotcpu_notifier(&irq_poll_cpu_notifier);
+	cpuhp_setup_state_nocalls(CPUHP_IRQ_POLL_DEAD, "irq_poll:dead", NULL,
+				  irq_poll_cpu_dead);
 	return 0;
 }
 subsys_initcall(irq_poll_setup);
-- 
2.9.3

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

* [PATCH 08/21] block: softirq: Convert to hotplug state machine
  2016-09-06 17:04 cpu hotplug: convert more drivers (batch #3) Sebastian Andrzej Siewior
                   ` (6 preceding siblings ...)
  2016-09-06 17:04 ` [PATCH 07/21] lib: irq_poll: " Sebastian Andrzej Siewior
@ 2016-09-06 17:04 ` Sebastian Andrzej Siewior
  2016-09-19 19:55   ` [tip:smp/hotplug] block/softirq: " tip-bot for Sebastian Andrzej Siewior
  2016-09-06 17:04 ` [PATCH 09/21] oprofile: timer: " Sebastian Andrzej Siewior
                   ` (13 subsequent siblings)
  21 siblings, 1 reply; 83+ messages in thread
From: Sebastian Andrzej Siewior @ 2016-09-06 17:04 UTC (permalink / raw)
  To: linux-kernel
  Cc: Peter Zijlstra, Ingo Molnar, rt, tglx, Sebastian Andrzej Siewior,
	Jens Axboe

Install the callbacks via the state machine.

Cc: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
 block/blk-softirq.c        | 27 ++++++++++-----------------
 include/linux/cpuhotplug.h |  1 +
 2 files changed, 11 insertions(+), 17 deletions(-)

diff --git a/block/blk-softirq.c b/block/blk-softirq.c
index 53b1737e978d..96631e6a22b9 100644
--- a/block/blk-softirq.c
+++ b/block/blk-softirq.c
@@ -78,30 +78,21 @@ static int raise_blk_irq(int cpu, struct request *rq)
 }
 #endif
 
-static int blk_cpu_notify(struct notifier_block *self, unsigned long action,
-			  void *hcpu)
+static int blk_softirq_cpu_dead(unsigned int cpu)
 {
 	/*
 	 * If a CPU goes away, splice its entries to the current CPU
 	 * and trigger a run of the softirq
 	 */
-	if (action == CPU_DEAD || action == CPU_DEAD_FROZEN) {
-		int cpu = (unsigned long) hcpu;
+	local_irq_disable();
+	list_splice_init(&per_cpu(blk_cpu_done, cpu),
+			 this_cpu_ptr(&blk_cpu_done));
+	raise_softirq_irqoff(BLOCK_SOFTIRQ);
+	local_irq_enable();
 
-		local_irq_disable();
-		list_splice_init(&per_cpu(blk_cpu_done, cpu),
-				 this_cpu_ptr(&blk_cpu_done));
-		raise_softirq_irqoff(BLOCK_SOFTIRQ);
-		local_irq_enable();
-	}
-
-	return NOTIFY_OK;
+	return 0;
 }
 
-static struct notifier_block blk_cpu_notifier = {
-	.notifier_call	= blk_cpu_notify,
-};
-
 void __blk_complete_request(struct request *req)
 {
 	int ccpu, cpu;
@@ -180,7 +171,9 @@ static __init int blk_softirq_init(void)
 		INIT_LIST_HEAD(&per_cpu(blk_cpu_done, i));
 
 	open_softirq(BLOCK_SOFTIRQ, blk_done_softirq);
-	register_hotcpu_notifier(&blk_cpu_notifier);
+	cpuhp_setup_state_nocalls(CPUHP_BLOCK_SOFTIRQ_DEAD,
+				  "block/softirq:dead", NULL,
+				  blk_softirq_cpu_dead);
 	return 0;
 }
 subsys_initcall(blk_softirq_init);
diff --git a/include/linux/cpuhotplug.h b/include/linux/cpuhotplug.h
index be6c01b7efbe..a12044828e03 100644
--- a/include/linux/cpuhotplug.h
+++ b/include/linux/cpuhotplug.h
@@ -23,6 +23,7 @@ enum cpuhp_state {
 	CPUHP_ARM64_FPSIMD_DEAD,
 	CPUHP_ARM_OMAP_WAKE_DEAD,
 	CPUHP_IRQ_POLL_DEAD,
+	CPUHP_BLOCK_SOFTIRQ_DEAD,
 	CPUHP_WORKQUEUE_PREP,
 	CPUHP_POWER_NUMA_PREPARE,
 	CPUHP_HRTIMERS_PREPARE,
-- 
2.9.3

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

* [PATCH 09/21] oprofile: timer: Convert to hotplug state machine
  2016-09-06 17:04 cpu hotplug: convert more drivers (batch #3) Sebastian Andrzej Siewior
                   ` (7 preceding siblings ...)
  2016-09-06 17:04 ` [PATCH 08/21] block: softirq: " Sebastian Andrzej Siewior
@ 2016-09-06 17:04 ` Sebastian Andrzej Siewior
  2016-09-19 19:55   ` [tip:smp/hotplug] oprofile/timer: " tip-bot for Sebastian Andrzej Siewior
  2016-09-06 17:04 ` [PATCH 10/21] virtio scsi: " Sebastian Andrzej Siewior
                   ` (12 subsequent siblings)
  21 siblings, 1 reply; 83+ messages in thread
From: Sebastian Andrzej Siewior @ 2016-09-06 17:04 UTC (permalink / raw)
  To: linux-kernel
  Cc: Peter Zijlstra, Ingo Molnar, rt, tglx, Sebastian Andrzej Siewior,
	Robert Richter, oprofile-list

Install the callbacks via the state machine and let the core invoke
the callbacks on the already online CPUs.
Since the online target runs always on the target CPU we can drop
smp_call_function_single(). The functions is invoked with interrupts off to
keep the old calling convention. If the maintainer things that this function
can be called with interrupts enabled then it can be removed :)

Cc: Robert Richter <rric@kernel.org>
Cc: oprofile-list@lists.sf.net
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
 drivers/oprofile/timer_int.c | 44 +++++++++++++++++++++++---------------------
 1 file changed, 23 insertions(+), 21 deletions(-)

diff --git a/drivers/oprofile/timer_int.c b/drivers/oprofile/timer_int.c
index bdef916e5dda..2498a6cd7c24 100644
--- a/drivers/oprofile/timer_int.c
+++ b/drivers/oprofile/timer_int.c
@@ -74,37 +74,39 @@ static void oprofile_hrtimer_stop(void)
 	put_online_cpus();
 }
 
-static int oprofile_cpu_notify(struct notifier_block *self,
-			       unsigned long action, void *hcpu)
+static int oprofile_timer_online(unsigned int cpu)
 {
-	long cpu = (long) hcpu;
-
-	switch (action) {
-	case CPU_ONLINE:
-	case CPU_ONLINE_FROZEN:
-		smp_call_function_single(cpu, __oprofile_hrtimer_start,
-					 NULL, 1);
-		break;
-	case CPU_DEAD:
-	case CPU_DEAD_FROZEN:
-		__oprofile_hrtimer_stop(cpu);
-		break;
-	}
-	return NOTIFY_OK;
+	local_irq_disable();
+	__oprofile_hrtimer_start(NULL);
+	local_irq_enable();
+	return 0;
 }
 
-static struct notifier_block __refdata oprofile_cpu_notifier = {
-	.notifier_call = oprofile_cpu_notify,
-};
+static int oprofile_timer_prep_down(unsigned int cpu)
+{
+	__oprofile_hrtimer_stop(cpu);
+	return 0;
+}
+
+static enum cpuhp_state hp_online;
 
 static int oprofile_hrtimer_setup(void)
 {
-	return register_hotcpu_notifier(&oprofile_cpu_notifier);
+	int ret;
+
+	ret = cpuhp_setup_state_nocalls(CPUHP_AP_ONLINE_DYN,
+					"oprofile/timer:online",
+					oprofile_timer_online,
+					oprofile_timer_prep_down);
+	if (ret < 0)
+		return ret;
+	hp_online = ret;
+	return 0;
 }
 
 static void oprofile_hrtimer_shutdown(void)
 {
-	unregister_hotcpu_notifier(&oprofile_cpu_notifier);
+	cpuhp_remove_state_nocalls(hp_online);
 }
 
 int oprofile_timer_init(struct oprofile_operations *ops)
-- 
2.9.3

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

* [PATCH 10/21] virtio scsi: Convert to hotplug state machine
  2016-09-06 17:04 cpu hotplug: convert more drivers (batch #3) Sebastian Andrzej Siewior
                   ` (9 preceding siblings ...)
  2016-09-06 17:04 ` [PATCH 10/21] virtio scsi: " Sebastian Andrzej Siewior
@ 2016-09-06 17:04 ` Sebastian Andrzej Siewior
  2016-09-19 19:56   ` [tip:smp/hotplug] " tip-bot for Sebastian Andrzej Siewior
  2016-09-06 17:04 ` [PATCH 11/21] ACPI: processor: " Sebastian Andrzej Siewior
                   ` (10 subsequent siblings)
  21 siblings, 1 reply; 83+ messages in thread
From: Sebastian Andrzej Siewior @ 2016-09-06 17:04 UTC (permalink / raw)
  To: linux-kernel
  Cc: Peter Zijlstra, Ingo Molnar, rt, tglx, Sebastian Andrzej Siewior,
	James E.J. Bottomley, Martin K. Petersen, linux-scsi,
	Michael S. Tsirkin, virtualization

Install the callbacks via the state machine. It uses the multi instance
infrastructure of the hotplug code to handle each interface.

virtscsi_set_affinity() is removed from virtscsi_init() because
virtscsi_cpu_notif_add() (the function which registers the instance) is invoked
right after it and the cpuhp_state_add_instance() functions invokes the startup
callback on all online CPUs.

The same thing can not be applied virtscsi_cpu_notif_remove() because
virtscsi_remove_vqs() invokes virtscsi_set_affinity() with affinity = false as
argument but the old CPU_DEAD state invoked the function with affinity = true
(which does not match the DEAD callback).

Cc: "James E.J. Bottomley" <jejb@linux.vnet.ibm.com>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: linux-scsi@vger.kernel.org
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Cc: virtualization@lists.linux-foundation.org
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
 drivers/scsi/virtio_scsi.c | 76 ++++++++++++++++++++++++++++++----------------
 include/linux/cpuhotplug.h |  1 +
 2 files changed, 50 insertions(+), 27 deletions(-)

diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c
index 7dbbb29d24c6..deefab3a94d0 100644
--- a/drivers/scsi/virtio_scsi.c
+++ b/drivers/scsi/virtio_scsi.c
@@ -107,8 +107,8 @@ struct virtio_scsi {
 	/* If the affinity hint is set for virtqueues */
 	bool affinity_hint_set;
 
-	/* CPU hotplug notifier */
-	struct notifier_block nb;
+	struct hlist_node node;
+	struct hlist_node node_dead;
 
 	/* Protected by event_vq lock */
 	bool stop_events;
@@ -118,6 +118,7 @@ struct virtio_scsi {
 	struct virtio_scsi_vq req_vqs[];
 };
 
+static enum cpuhp_state virtioscsi_online;
 static struct kmem_cache *virtscsi_cmd_cache;
 static mempool_t *virtscsi_cmd_pool;
 
@@ -852,21 +853,33 @@ static void virtscsi_set_affinity(struct virtio_scsi *vscsi, bool affinity)
 	put_online_cpus();
 }
 
-static int virtscsi_cpu_callback(struct notifier_block *nfb,
-				 unsigned long action, void *hcpu)
+static int virtscsi_cpu_online(unsigned int cpu, struct hlist_node *node)
 {
-	struct virtio_scsi *vscsi = container_of(nfb, struct virtio_scsi, nb);
-	switch(action) {
-	case CPU_ONLINE:
-	case CPU_ONLINE_FROZEN:
-	case CPU_DEAD:
-	case CPU_DEAD_FROZEN:
-		__virtscsi_set_affinity(vscsi, true);
-		break;
-	default:
-		break;
-	}
-	return NOTIFY_OK;
+	struct virtio_scsi *vscsi = hlist_entry_safe(node, struct virtio_scsi,
+						     node);
+	__virtscsi_set_affinity(vscsi, true);
+	return 0;
+}
+
+static int virtscsi_cpu_notif_add(struct virtio_scsi *vi)
+{
+	int ret;
+
+	ret = cpuhp_state_add_instance(virtioscsi_online, &vi->node);
+	if (ret)
+		return ret;
+
+	ret = cpuhp_state_add_instance(CPUHP_VIRT_SCSI_DEAD, &vi->node_dead);
+	if (ret)
+		cpuhp_state_remove_instance(virtioscsi_online, &vi->node);
+	return ret;
+}
+
+static void virtscsi_cpu_notif_remove(struct virtio_scsi *vi)
+{
+	cpuhp_state_remove_instance_nocalls(virtioscsi_online, &vi->node);
+	cpuhp_state_remove_instance_nocalls(CPUHP_VIRT_SCSI_DEAD,
+					    &vi->node_dead);
 }
 
 static void virtscsi_init_vq(struct virtio_scsi_vq *virtscsi_vq,
@@ -929,8 +942,6 @@ static int virtscsi_init(struct virtio_device *vdev,
 		virtscsi_init_vq(&vscsi->req_vqs[i - VIRTIO_SCSI_VQ_BASE],
 				 vqs[i]);
 
-	virtscsi_set_affinity(vscsi, true);
-
 	virtscsi_config_set(vdev, cdb_size, VIRTIO_SCSI_CDB_SIZE);
 	virtscsi_config_set(vdev, sense_size, VIRTIO_SCSI_SENSE_SIZE);
 
@@ -987,12 +998,9 @@ static int virtscsi_probe(struct virtio_device *vdev)
 	if (err)
 		goto virtscsi_init_failed;
 
-	vscsi->nb.notifier_call = &virtscsi_cpu_callback;
-	err = register_hotcpu_notifier(&vscsi->nb);
-	if (err) {
-		pr_err("registering cpu notifier failed\n");
+	err = virtscsi_cpu_notif_add(vscsi);
+	if (err)
 		goto scsi_add_host_failed;
-	}
 
 	cmd_per_lun = virtscsi_config_get(vdev, cmd_per_lun) ?: 1;
 	shost->cmd_per_lun = min_t(u32, cmd_per_lun, shost->can_queue);
@@ -1049,7 +1057,7 @@ static void virtscsi_remove(struct virtio_device *vdev)
 
 	scsi_remove_host(shost);
 
-	unregister_hotcpu_notifier(&vscsi->nb);
+	virtscsi_cpu_notif_remove(vscsi);
 
 	virtscsi_remove_vqs(vdev);
 	scsi_host_put(shost);
@@ -1061,7 +1069,7 @@ static int virtscsi_freeze(struct virtio_device *vdev)
 	struct Scsi_Host *sh = virtio_scsi_host(vdev);
 	struct virtio_scsi *vscsi = shost_priv(sh);
 
-	unregister_hotcpu_notifier(&vscsi->nb);
+	virtscsi_cpu_notif_remove(vscsi);
 	virtscsi_remove_vqs(vdev);
 	return 0;
 }
@@ -1076,12 +1084,11 @@ static int virtscsi_restore(struct virtio_device *vdev)
 	if (err)
 		return err;
 
-	err = register_hotcpu_notifier(&vscsi->nb);
+	err = virtscsi_cpu_notif_add(vscsi);
 	if (err) {
 		vdev->config->del_vqs(vdev);
 		return err;
 	}
-
 	virtio_device_ready(vdev);
 
 	if (virtio_has_feature(vdev, VIRTIO_SCSI_F_HOTPLUG))
@@ -1136,6 +1143,16 @@ static int __init init(void)
 		pr_err("mempool_create() for virtscsi_cmd_pool failed\n");
 		goto error;
 	}
+	ret = cpuhp_setup_state_multi(CPUHP_AP_ONLINE_DYN,
+				      "scsi/virtio:online",
+				      virtscsi_cpu_online, NULL);
+	if (ret < 0)
+		goto error;
+	virtioscsi_online = ret;
+	ret = cpuhp_setup_state_multi(CPUHP_VIRT_SCSI_DEAD, "scsi/virtio:dead",
+				      NULL, virtscsi_cpu_online);
+	if (ret)
+		goto error;
 	ret = register_virtio_driver(&virtio_scsi_driver);
 	if (ret < 0)
 		goto error;
@@ -1151,12 +1168,17 @@ static int __init init(void)
 		kmem_cache_destroy(virtscsi_cmd_cache);
 		virtscsi_cmd_cache = NULL;
 	}
+	if (virtioscsi_online)
+		cpuhp_remove_multi_state(virtioscsi_online);
+	cpuhp_remove_multi_state(CPUHP_VIRT_SCSI_DEAD);
 	return ret;
 }
 
 static void __exit fini(void)
 {
 	unregister_virtio_driver(&virtio_scsi_driver);
+	cpuhp_remove_multi_state(virtioscsi_online);
+	cpuhp_remove_multi_state(CPUHP_VIRT_SCSI_DEAD);
 	mempool_destroy(virtscsi_cmd_pool);
 	kmem_cache_destroy(virtscsi_cmd_cache);
 }
diff --git a/include/linux/cpuhotplug.h b/include/linux/cpuhotplug.h
index a12044828e03..73a4daf08c04 100644
--- a/include/linux/cpuhotplug.h
+++ b/include/linux/cpuhotplug.h
@@ -24,6 +24,7 @@ enum cpuhp_state {
 	CPUHP_ARM_OMAP_WAKE_DEAD,
 	CPUHP_IRQ_POLL_DEAD,
 	CPUHP_BLOCK_SOFTIRQ_DEAD,
+	CPUHP_VIRT_SCSI_DEAD,
 	CPUHP_WORKQUEUE_PREP,
 	CPUHP_POWER_NUMA_PREPARE,
 	CPUHP_HRTIMERS_PREPARE,
-- 
2.9.3

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

* [PATCH 10/21] virtio scsi: Convert to hotplug state machine
  2016-09-06 17:04 cpu hotplug: convert more drivers (batch #3) Sebastian Andrzej Siewior
                   ` (8 preceding siblings ...)
  2016-09-06 17:04 ` [PATCH 09/21] oprofile: timer: " Sebastian Andrzej Siewior
@ 2016-09-06 17:04 ` Sebastian Andrzej Siewior
  2016-09-06 17:04 ` Sebastian Andrzej Siewior
                   ` (11 subsequent siblings)
  21 siblings, 0 replies; 83+ messages in thread
From: Sebastian Andrzej Siewior @ 2016-09-06 17:04 UTC (permalink / raw)
  To: linux-kernel
  Cc: James E.J. Bottomley, linux-scsi, Martin K. Petersen,
	Michael S. Tsirkin, Peter Zijlstra, Sebastian Andrzej Siewior,
	virtualization, Ingo Molnar, rt, tglx

Install the callbacks via the state machine. It uses the multi instance
infrastructure of the hotplug code to handle each interface.

virtscsi_set_affinity() is removed from virtscsi_init() because
virtscsi_cpu_notif_add() (the function which registers the instance) is invoked
right after it and the cpuhp_state_add_instance() functions invokes the startup
callback on all online CPUs.

The same thing can not be applied virtscsi_cpu_notif_remove() because
virtscsi_remove_vqs() invokes virtscsi_set_affinity() with affinity = false as
argument but the old CPU_DEAD state invoked the function with affinity = true
(which does not match the DEAD callback).

Cc: "James E.J. Bottomley" <jejb@linux.vnet.ibm.com>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: linux-scsi@vger.kernel.org
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Cc: virtualization@lists.linux-foundation.org
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
 drivers/scsi/virtio_scsi.c | 76 ++++++++++++++++++++++++++++++----------------
 include/linux/cpuhotplug.h |  1 +
 2 files changed, 50 insertions(+), 27 deletions(-)

diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c
index 7dbbb29d24c6..deefab3a94d0 100644
--- a/drivers/scsi/virtio_scsi.c
+++ b/drivers/scsi/virtio_scsi.c
@@ -107,8 +107,8 @@ struct virtio_scsi {
 	/* If the affinity hint is set for virtqueues */
 	bool affinity_hint_set;
 
-	/* CPU hotplug notifier */
-	struct notifier_block nb;
+	struct hlist_node node;
+	struct hlist_node node_dead;
 
 	/* Protected by event_vq lock */
 	bool stop_events;
@@ -118,6 +118,7 @@ struct virtio_scsi {
 	struct virtio_scsi_vq req_vqs[];
 };
 
+static enum cpuhp_state virtioscsi_online;
 static struct kmem_cache *virtscsi_cmd_cache;
 static mempool_t *virtscsi_cmd_pool;
 
@@ -852,21 +853,33 @@ static void virtscsi_set_affinity(struct virtio_scsi *vscsi, bool affinity)
 	put_online_cpus();
 }
 
-static int virtscsi_cpu_callback(struct notifier_block *nfb,
-				 unsigned long action, void *hcpu)
+static int virtscsi_cpu_online(unsigned int cpu, struct hlist_node *node)
 {
-	struct virtio_scsi *vscsi = container_of(nfb, struct virtio_scsi, nb);
-	switch(action) {
-	case CPU_ONLINE:
-	case CPU_ONLINE_FROZEN:
-	case CPU_DEAD:
-	case CPU_DEAD_FROZEN:
-		__virtscsi_set_affinity(vscsi, true);
-		break;
-	default:
-		break;
-	}
-	return NOTIFY_OK;
+	struct virtio_scsi *vscsi = hlist_entry_safe(node, struct virtio_scsi,
+						     node);
+	__virtscsi_set_affinity(vscsi, true);
+	return 0;
+}
+
+static int virtscsi_cpu_notif_add(struct virtio_scsi *vi)
+{
+	int ret;
+
+	ret = cpuhp_state_add_instance(virtioscsi_online, &vi->node);
+	if (ret)
+		return ret;
+
+	ret = cpuhp_state_add_instance(CPUHP_VIRT_SCSI_DEAD, &vi->node_dead);
+	if (ret)
+		cpuhp_state_remove_instance(virtioscsi_online, &vi->node);
+	return ret;
+}
+
+static void virtscsi_cpu_notif_remove(struct virtio_scsi *vi)
+{
+	cpuhp_state_remove_instance_nocalls(virtioscsi_online, &vi->node);
+	cpuhp_state_remove_instance_nocalls(CPUHP_VIRT_SCSI_DEAD,
+					    &vi->node_dead);
 }
 
 static void virtscsi_init_vq(struct virtio_scsi_vq *virtscsi_vq,
@@ -929,8 +942,6 @@ static int virtscsi_init(struct virtio_device *vdev,
 		virtscsi_init_vq(&vscsi->req_vqs[i - VIRTIO_SCSI_VQ_BASE],
 				 vqs[i]);
 
-	virtscsi_set_affinity(vscsi, true);
-
 	virtscsi_config_set(vdev, cdb_size, VIRTIO_SCSI_CDB_SIZE);
 	virtscsi_config_set(vdev, sense_size, VIRTIO_SCSI_SENSE_SIZE);
 
@@ -987,12 +998,9 @@ static int virtscsi_probe(struct virtio_device *vdev)
 	if (err)
 		goto virtscsi_init_failed;
 
-	vscsi->nb.notifier_call = &virtscsi_cpu_callback;
-	err = register_hotcpu_notifier(&vscsi->nb);
-	if (err) {
-		pr_err("registering cpu notifier failed\n");
+	err = virtscsi_cpu_notif_add(vscsi);
+	if (err)
 		goto scsi_add_host_failed;
-	}
 
 	cmd_per_lun = virtscsi_config_get(vdev, cmd_per_lun) ?: 1;
 	shost->cmd_per_lun = min_t(u32, cmd_per_lun, shost->can_queue);
@@ -1049,7 +1057,7 @@ static void virtscsi_remove(struct virtio_device *vdev)
 
 	scsi_remove_host(shost);
 
-	unregister_hotcpu_notifier(&vscsi->nb);
+	virtscsi_cpu_notif_remove(vscsi);
 
 	virtscsi_remove_vqs(vdev);
 	scsi_host_put(shost);
@@ -1061,7 +1069,7 @@ static int virtscsi_freeze(struct virtio_device *vdev)
 	struct Scsi_Host *sh = virtio_scsi_host(vdev);
 	struct virtio_scsi *vscsi = shost_priv(sh);
 
-	unregister_hotcpu_notifier(&vscsi->nb);
+	virtscsi_cpu_notif_remove(vscsi);
 	virtscsi_remove_vqs(vdev);
 	return 0;
 }
@@ -1076,12 +1084,11 @@ static int virtscsi_restore(struct virtio_device *vdev)
 	if (err)
 		return err;
 
-	err = register_hotcpu_notifier(&vscsi->nb);
+	err = virtscsi_cpu_notif_add(vscsi);
 	if (err) {
 		vdev->config->del_vqs(vdev);
 		return err;
 	}
-
 	virtio_device_ready(vdev);
 
 	if (virtio_has_feature(vdev, VIRTIO_SCSI_F_HOTPLUG))
@@ -1136,6 +1143,16 @@ static int __init init(void)
 		pr_err("mempool_create() for virtscsi_cmd_pool failed\n");
 		goto error;
 	}
+	ret = cpuhp_setup_state_multi(CPUHP_AP_ONLINE_DYN,
+				      "scsi/virtio:online",
+				      virtscsi_cpu_online, NULL);
+	if (ret < 0)
+		goto error;
+	virtioscsi_online = ret;
+	ret = cpuhp_setup_state_multi(CPUHP_VIRT_SCSI_DEAD, "scsi/virtio:dead",
+				      NULL, virtscsi_cpu_online);
+	if (ret)
+		goto error;
 	ret = register_virtio_driver(&virtio_scsi_driver);
 	if (ret < 0)
 		goto error;
@@ -1151,12 +1168,17 @@ static int __init init(void)
 		kmem_cache_destroy(virtscsi_cmd_cache);
 		virtscsi_cmd_cache = NULL;
 	}
+	if (virtioscsi_online)
+		cpuhp_remove_multi_state(virtioscsi_online);
+	cpuhp_remove_multi_state(CPUHP_VIRT_SCSI_DEAD);
 	return ret;
 }
 
 static void __exit fini(void)
 {
 	unregister_virtio_driver(&virtio_scsi_driver);
+	cpuhp_remove_multi_state(virtioscsi_online);
+	cpuhp_remove_multi_state(CPUHP_VIRT_SCSI_DEAD);
 	mempool_destroy(virtscsi_cmd_pool);
 	kmem_cache_destroy(virtscsi_cmd_cache);
 }
diff --git a/include/linux/cpuhotplug.h b/include/linux/cpuhotplug.h
index a12044828e03..73a4daf08c04 100644
--- a/include/linux/cpuhotplug.h
+++ b/include/linux/cpuhotplug.h
@@ -24,6 +24,7 @@ enum cpuhp_state {
 	CPUHP_ARM_OMAP_WAKE_DEAD,
 	CPUHP_IRQ_POLL_DEAD,
 	CPUHP_BLOCK_SOFTIRQ_DEAD,
+	CPUHP_VIRT_SCSI_DEAD,
 	CPUHP_WORKQUEUE_PREP,
 	CPUHP_POWER_NUMA_PREPARE,
 	CPUHP_HRTIMERS_PREPARE,
-- 
2.9.3

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

* [PATCH 11/21] ACPI: processor: Convert to hotplug state machine
  2016-09-06 17:04 cpu hotplug: convert more drivers (batch #3) Sebastian Andrzej Siewior
                   ` (10 preceding siblings ...)
  2016-09-06 17:04 ` Sebastian Andrzej Siewior
@ 2016-09-06 17:04 ` Sebastian Andrzej Siewior
  2016-09-06 21:08   ` Rafael J. Wysocki
  2016-09-19 19:56   ` [tip:smp/hotplug] ACPI/processor: " tip-bot for Sebastian Andrzej Siewior
  2016-09-06 17:04 ` [PATCH 12/21] cpufreq: " Sebastian Andrzej Siewior
                   ` (9 subsequent siblings)
  21 siblings, 2 replies; 83+ messages in thread
From: Sebastian Andrzej Siewior @ 2016-09-06 17:04 UTC (permalink / raw)
  To: linux-kernel
  Cc: Peter Zijlstra, Ingo Molnar, rt, tglx, Sebastian Andrzej Siewior,
	Rafael J. Wysocki, Len Brown, linux-acpi

Install the callbacks via the state machine.

Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Len Brown <lenb@kernel.org>
Cc: linux-acpi@vger.kernel.org
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
 drivers/acpi/processor_driver.c     | 89 +++++++++++++++++++------------------
 drivers/acpi/processor_throttling.c |  4 +-
 include/acpi/processor.h            |  4 +-
 include/linux/cpuhotplug.h          |  1 +
 4 files changed, 51 insertions(+), 47 deletions(-)

diff --git a/drivers/acpi/processor_driver.c b/drivers/acpi/processor_driver.c
index 0553aeebb228..13e5ac415abf 100644
--- a/drivers/acpi/processor_driver.c
+++ b/drivers/acpi/processor_driver.c
@@ -110,55 +110,46 @@ static void acpi_processor_notify(acpi_handle handle, u32 event, void *data)
 
 static int __acpi_processor_start(struct acpi_device *device);
 
-static int acpi_cpu_soft_notify(struct notifier_block *nfb,
-					  unsigned long action, void *hcpu)
+static int acpi_soft_cpu_online(unsigned int cpu)
 {
-	unsigned int cpu = (unsigned long)hcpu;
 	struct acpi_processor *pr = per_cpu(processors, cpu);
 	struct acpi_device *device;
-	action &= ~CPU_TASKS_FROZEN;
-
-	switch (action) {
-	case CPU_ONLINE:
-	case CPU_DEAD:
-		break;
-	default:
-		return NOTIFY_DONE;
-	}
 
 	if (!pr || acpi_bus_get_device(pr->handle, &device))
-		return NOTIFY_DONE;
+		return 0;
+	/*
+	 * CPU got physically hotplugged and onlined for the first time:
+	 * Initialize missing things.
+	 */
+	if (pr->flags.need_hotplug_init) {
+		int ret;
 
-	if (action == CPU_ONLINE) {
-		/*
-		 * CPU got physically hotplugged and onlined for the first time:
-		 * Initialize missing things.
-		 */
-		if (pr->flags.need_hotplug_init) {
-			int ret;
-
-			pr_info("Will online and init hotplugged CPU: %d\n",
-				pr->id);
-			pr->flags.need_hotplug_init = 0;
-			ret = __acpi_processor_start(device);
-			WARN(ret, "Failed to start CPU: %d\n", pr->id);
-		} else {
-			/* Normal CPU soft online event. */
-			acpi_processor_ppc_has_changed(pr, 0);
-			acpi_processor_hotplug(pr);
-			acpi_processor_reevaluate_tstate(pr, action);
-			acpi_processor_tstate_has_changed(pr);
-		}
-	} else if (action == CPU_DEAD) {
-		/* Invalidate flag.throttling after the CPU is offline. */
-		acpi_processor_reevaluate_tstate(pr, action);
+		pr_info("Will online and init hotplugged CPU: %d\n",
+			pr->id);
+		pr->flags.need_hotplug_init = 0;
+		ret = __acpi_processor_start(device);
+		WARN(ret, "Failed to start CPU: %d\n", pr->id);
+	} else {
+		/* Normal CPU soft online event. */
+		acpi_processor_ppc_has_changed(pr, 0);
+		acpi_processor_hotplug(pr);
+		acpi_processor_reevaluate_tstate(pr, false);
+		acpi_processor_tstate_has_changed(pr);
 	}
-	return NOTIFY_OK;
+	return 0;
 }
 
-static struct notifier_block acpi_cpu_notifier = {
-	    .notifier_call = acpi_cpu_soft_notify,
-};
+static int acpi_soft_cpu_dead(unsigned int cpu)
+{
+	struct acpi_processor *pr = per_cpu(processors, cpu);
+	struct acpi_device *device;
+
+	if (!pr || acpi_bus_get_device(pr->handle, &device))
+		return 0;
+
+	acpi_processor_reevaluate_tstate(pr, true);
+	return 0;
+}
 
 #ifdef CONFIG_ACPI_CPU_FREQ_PSS
 static int acpi_pss_perf_init(struct acpi_processor *pr,
@@ -303,7 +294,7 @@ static int acpi_processor_stop(struct device *dev)
  * This is needed for the powernow-k8 driver, that works even without
  * ACPI, but needs symbols from this driver
  */
-
+static enum cpuhp_state hp_online;
 static int __init acpi_processor_driver_init(void)
 {
 	int result = 0;
@@ -315,11 +306,22 @@ static int __init acpi_processor_driver_init(void)
 	if (result < 0)
 		return result;
 
-	register_hotcpu_notifier(&acpi_cpu_notifier);
+	result = cpuhp_setup_state_nocalls(CPUHP_AP_ONLINE_DYN,
+					   "acpi/cpu-drv:online",
+					   acpi_soft_cpu_online, NULL);
+	if (result < 0)
+		goto err;
+	hp_online = result;
+	cpuhp_setup_state_nocalls(CPUHP_ACPI_CPUDRV_DEAD, "acpi/cpu-drv:dead",
+				  NULL, acpi_soft_cpu_dead);
+
 	acpi_thermal_cpufreq_init();
 	acpi_processor_ppc_init();
 	acpi_processor_throttling_init();
 	return 0;
+err:
+	driver_unregister(&acpi_processor_driver);
+	return result;
 }
 
 static void __exit acpi_processor_driver_exit(void)
@@ -329,7 +331,8 @@ static void __exit acpi_processor_driver_exit(void)
 
 	acpi_processor_ppc_exit();
 	acpi_thermal_cpufreq_exit();
-	unregister_hotcpu_notifier(&acpi_cpu_notifier);
+	cpuhp_remove_state_nocalls(hp_online);
+	cpuhp_remove_state_nocalls(CPUHP_ACPI_CPUDRV_DEAD);
 	driver_unregister(&acpi_processor_driver);
 }
 
diff --git a/drivers/acpi/processor_throttling.c b/drivers/acpi/processor_throttling.c
index c72e64893d03..d51ca1c05619 100644
--- a/drivers/acpi/processor_throttling.c
+++ b/drivers/acpi/processor_throttling.c
@@ -375,11 +375,11 @@ int acpi_processor_tstate_has_changed(struct acpi_processor *pr)
  *	3. TSD domain
  */
 void acpi_processor_reevaluate_tstate(struct acpi_processor *pr,
-					unsigned long action)
+					bool is_dead)
 {
 	int result = 0;
 
-	if (action == CPU_DEAD) {
+	if (is_dead) {
 		/* When one CPU is offline, the T-state throttling
 		 * will be invalidated.
 		 */
diff --git a/include/acpi/processor.h b/include/acpi/processor.h
index bfe6b2e10f3a..f3db11c24654 100644
--- a/include/acpi/processor.h
+++ b/include/acpi/processor.h
@@ -359,7 +359,7 @@ extern int acpi_processor_set_throttling(struct acpi_processor *pr,
  * onlined/offlined. In such case the flags.throttling will be updated.
  */
 extern void acpi_processor_reevaluate_tstate(struct acpi_processor *pr,
-			unsigned long action);
+			bool is_dead);
 extern const struct file_operations acpi_processor_throttling_fops;
 extern void acpi_processor_throttling_init(void);
 #else
@@ -380,7 +380,7 @@ static inline int acpi_processor_set_throttling(struct acpi_processor *pr,
 }
 
 static inline void acpi_processor_reevaluate_tstate(struct acpi_processor *pr,
-			unsigned long action) {}
+			bool is_dead) {}
 
 static inline void acpi_processor_throttling_init(void) {}
 #endif	/* CONFIG_ACPI_CPU_FREQ_PSS */
diff --git a/include/linux/cpuhotplug.h b/include/linux/cpuhotplug.h
index 73a4daf08c04..0c33668d1626 100644
--- a/include/linux/cpuhotplug.h
+++ b/include/linux/cpuhotplug.h
@@ -25,6 +25,7 @@ enum cpuhp_state {
 	CPUHP_IRQ_POLL_DEAD,
 	CPUHP_BLOCK_SOFTIRQ_DEAD,
 	CPUHP_VIRT_SCSI_DEAD,
+	CPUHP_ACPI_CPUDRV_DEAD,
 	CPUHP_WORKQUEUE_PREP,
 	CPUHP_POWER_NUMA_PREPARE,
 	CPUHP_HRTIMERS_PREPARE,
-- 
2.9.3

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

* [PATCH 12/21] cpufreq: Convert to hotplug state machine
  2016-09-06 17:04 cpu hotplug: convert more drivers (batch #3) Sebastian Andrzej Siewior
                   ` (11 preceding siblings ...)
  2016-09-06 17:04 ` [PATCH 11/21] ACPI: processor: " Sebastian Andrzej Siewior
@ 2016-09-06 17:04 ` Sebastian Andrzej Siewior
  2016-09-06 21:27   ` Rafael J. Wysocki
  2016-09-19 19:56   ` [tip:smp/hotplug] " tip-bot for Sebastian Andrzej Siewior
  2016-09-06 17:04 ` [PATCH 13/21] padata: Convert " Sebastian Andrzej Siewior
                   ` (8 subsequent siblings)
  21 siblings, 2 replies; 83+ messages in thread
From: Sebastian Andrzej Siewior @ 2016-09-06 17:04 UTC (permalink / raw)
  To: linux-kernel
  Cc: Peter Zijlstra, Ingo Molnar, rt, tglx, Sebastian Andrzej Siewior,
	Rafael J. Wysocki, Viresh Kumar, linux-pm

Install the callbacks via the state machine.

Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Viresh Kumar <viresh.kumar@linaro.org>
Cc: linux-pm@vger.kernel.org
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
 drivers/cpufreq/cpufreq.c | 38 ++++++++++++--------------------------
 1 file changed, 12 insertions(+), 26 deletions(-)

diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 3dd4884c6f9e..e0bc632a259e 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -1358,7 +1358,7 @@ static int cpufreq_add_dev(struct device *dev, struct subsys_interface *sif)
 	return add_cpu_dev_symlink(policy, cpu);
 }
 
-static void cpufreq_offline(unsigned int cpu)
+static int cpufreq_offline(unsigned int cpu)
 {
 	struct cpufreq_policy *policy;
 	int ret;
@@ -1368,7 +1368,7 @@ static void cpufreq_offline(unsigned int cpu)
 	policy = cpufreq_cpu_get_raw(cpu);
 	if (!policy) {
 		pr_debug("%s: No cpu_data found\n", __func__);
-		return;
+		return 0;
 	}
 
 	down_write(&policy->rwsem);
@@ -1417,6 +1417,7 @@ static void cpufreq_offline(unsigned int cpu)
 
 unlock:
 	up_write(&policy->rwsem);
+	return 0;
 }
 
 /**
@@ -2332,28 +2333,6 @@ int cpufreq_update_policy(unsigned int cpu)
 }
 EXPORT_SYMBOL(cpufreq_update_policy);
 
-static int cpufreq_cpu_callback(struct notifier_block *nfb,
-					unsigned long action, void *hcpu)
-{
-	unsigned int cpu = (unsigned long)hcpu;
-
-	switch (action & ~CPU_TASKS_FROZEN) {
-	case CPU_ONLINE:
-	case CPU_DOWN_FAILED:
-		cpufreq_online(cpu);
-		break;
-
-	case CPU_DOWN_PREPARE:
-		cpufreq_offline(cpu);
-		break;
-	}
-	return NOTIFY_OK;
-}
-
-static struct notifier_block __refdata cpufreq_cpu_notifier = {
-	.notifier_call = cpufreq_cpu_callback,
-};
-
 /*********************************************************************
  *               BOOST						     *
  *********************************************************************/
@@ -2455,6 +2434,7 @@ EXPORT_SYMBOL_GPL(cpufreq_boost_enabled);
 /*********************************************************************
  *               REGISTER / UNREGISTER CPUFREQ DRIVER                *
  *********************************************************************/
+static enum cpuhp_state hp_online;
 
 /**
  * cpufreq_register_driver - register a CPU Frequency driver
@@ -2517,7 +2497,13 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data)
 		goto err_if_unreg;
 	}
 
-	register_hotcpu_notifier(&cpufreq_cpu_notifier);
+	ret = cpuhp_setup_state_nocalls(CPUHP_AP_ONLINE_DYN, "cpufreq:online",
+					cpufreq_online,
+					cpufreq_offline);
+	if (ret < 0)
+		goto err_if_unreg;
+	hp_online = ret;
+
 	pr_debug("driver %s up and running\n", driver_data->name);
 	goto out;
 
@@ -2556,7 +2542,7 @@ int cpufreq_unregister_driver(struct cpufreq_driver *driver)
 	get_online_cpus();
 	subsys_interface_unregister(&cpufreq_interface);
 	remove_boost_sysfs_file();
-	unregister_hotcpu_notifier(&cpufreq_cpu_notifier);
+	cpuhp_remove_state_nocalls(hp_online);
 
 	write_lock_irqsave(&cpufreq_driver_lock, flags);
 
-- 
2.9.3

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

* [PATCH 13/21] padata: Convert to hotplug state machine
  2016-09-06 17:04 cpu hotplug: convert more drivers (batch #3) Sebastian Andrzej Siewior
                   ` (12 preceding siblings ...)
  2016-09-06 17:04 ` [PATCH 12/21] cpufreq: " Sebastian Andrzej Siewior
@ 2016-09-06 17:04 ` Sebastian Andrzej Siewior
  2016-09-19 19:57   ` [tip:smp/hotplug] " tip-bot for Sebastian Andrzej Siewior
  2016-09-06 17:04 ` [PATCH 14/21] fault-injection: cpu: " Sebastian Andrzej Siewior
                   ` (7 subsequent siblings)
  21 siblings, 1 reply; 83+ messages in thread
From: Sebastian Andrzej Siewior @ 2016-09-06 17:04 UTC (permalink / raw)
  To: linux-kernel
  Cc: Peter Zijlstra, Ingo Molnar, rt, tglx, Sebastian Andrzej Siewior,
	Steffen Klassert, linux-crypto

Install the callbacks via the state machine. CPU-hotplug multinstance support
is used with the nocalls() version. Maybe parts of padata_alloc() could be
moved into the online callback so that we could invoke ->startup callback for
instance and drop get_online_cpus().

Cc: Steffen Klassert <steffen.klassert@secunet.com>
Cc: linux-crypto@vger.kernel.org
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
 include/linux/padata.h |  2 +-
 kernel/padata.c        | 92 ++++++++++++++++++++++++++++----------------------
 2 files changed, 53 insertions(+), 41 deletions(-)

diff --git a/include/linux/padata.h b/include/linux/padata.h
index 113ee626a4dc..0f9e567d5e15 100644
--- a/include/linux/padata.h
+++ b/include/linux/padata.h
@@ -151,7 +151,7 @@ struct parallel_data {
  * @flags: padata flags.
  */
 struct padata_instance {
-	struct notifier_block		 cpu_notifier;
+	struct hlist_node		 node;
 	struct workqueue_struct		*wq;
 	struct parallel_data		*pd;
 	struct padata_cpumask		cpumask;
diff --git a/kernel/padata.c b/kernel/padata.c
index 993278895ccc..7848f0566403 100644
--- a/kernel/padata.c
+++ b/kernel/padata.c
@@ -30,6 +30,7 @@
 #include <linux/slab.h>
 #include <linux/sysfs.h>
 #include <linux/rcupdate.h>
+#include <linux/module.h>
 
 #define MAX_OBJ_NUM 1000
 
@@ -769,52 +770,43 @@ static inline int pinst_has_cpu(struct padata_instance *pinst, int cpu)
 		cpumask_test_cpu(cpu, pinst->cpumask.cbcpu);
 }
 
-
-static int padata_cpu_callback(struct notifier_block *nfb,
-			       unsigned long action, void *hcpu)
+static int padata_cpu_online(unsigned int cpu, struct hlist_node *node)
 {
-	int err;
 	struct padata_instance *pinst;
-	int cpu = (unsigned long)hcpu;
+	int ret;
 
-	pinst = container_of(nfb, struct padata_instance, cpu_notifier);
+	pinst = hlist_entry_safe(node, struct padata_instance, node);
+	if (!pinst_has_cpu(pinst, cpu))
+		return 0;
 
-	switch (action) {
-	case CPU_ONLINE:
-	case CPU_ONLINE_FROZEN:
-	case CPU_DOWN_FAILED:
-	case CPU_DOWN_FAILED_FROZEN:
-		if (!pinst_has_cpu(pinst, cpu))
-			break;
-		mutex_lock(&pinst->lock);
-		err = __padata_add_cpu(pinst, cpu);
-		mutex_unlock(&pinst->lock);
-		if (err)
-			return notifier_from_errno(err);
-		break;
-
-	case CPU_DOWN_PREPARE:
-	case CPU_DOWN_PREPARE_FROZEN:
-	case CPU_UP_CANCELED:
-	case CPU_UP_CANCELED_FROZEN:
-		if (!pinst_has_cpu(pinst, cpu))
-			break;
-		mutex_lock(&pinst->lock);
-		err = __padata_remove_cpu(pinst, cpu);
-		mutex_unlock(&pinst->lock);
-		if (err)
-			return notifier_from_errno(err);
-		break;
-	}
-
-	return NOTIFY_OK;
+	mutex_lock(&pinst->lock);
+	ret = __padata_add_cpu(pinst, cpu);
+	mutex_unlock(&pinst->lock);
+	return ret;
 }
+
+static int padata_cpu_prep_down(unsigned int cpu, struct hlist_node *node)
+{
+	struct padata_instance *pinst;
+	int ret;
+
+	pinst = hlist_entry_safe(node, struct padata_instance, node);
+	if (!pinst_has_cpu(pinst, cpu))
+		return 0;
+
+	mutex_lock(&pinst->lock);
+	ret = __padata_remove_cpu(pinst, cpu);
+	mutex_unlock(&pinst->lock);
+	return ret;
+}
+
+static enum cpuhp_state hp_online;
 #endif
 
 static void __padata_free(struct padata_instance *pinst)
 {
 #ifdef CONFIG_HOTPLUG_CPU
-	unregister_hotcpu_notifier(&pinst->cpu_notifier);
+	cpuhp_state_remove_instance_nocalls(hp_online, &pinst->node);
 #endif
 
 	padata_stop(pinst);
@@ -1012,11 +1004,8 @@ struct padata_instance *padata_alloc(struct workqueue_struct *wq,
 	mutex_init(&pinst->lock);
 
 #ifdef CONFIG_HOTPLUG_CPU
-	pinst->cpu_notifier.notifier_call = padata_cpu_callback;
-	pinst->cpu_notifier.priority = 0;
-	register_hotcpu_notifier(&pinst->cpu_notifier);
+	cpuhp_state_add_instance_nocalls(hp_online, &pinst->node);
 #endif
-
 	return pinst;
 
 err_free_masks:
@@ -1039,3 +1028,26 @@ void padata_free(struct padata_instance *pinst)
 	kobject_put(&pinst->kobj);
 }
 EXPORT_SYMBOL(padata_free);
+
+#ifdef CONFIG_HOTPLUG_CPU
+
+static __init int padata_driver_init(void)
+{
+	int ret;
+
+	ret = cpuhp_setup_state_multi(CPUHP_AP_ONLINE_DYN, "padata:online",
+				      padata_cpu_online,
+				      padata_cpu_prep_down);
+	if (ret < 0)
+		return ret;
+	hp_online = ret;
+	return 0;
+}
+module_init(padata_driver_init);
+
+static __exit void padata_driver_exit(void)
+{
+	cpuhp_remove_multi_state(hp_online);
+}
+module_exit(padata_driver_exit);
+#endif
-- 
2.9.3

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

* [PATCH 14/21] fault-injection: cpu: Convert to hotplug state machine
  2016-09-06 17:04 cpu hotplug: convert more drivers (batch #3) Sebastian Andrzej Siewior
                   ` (13 preceding siblings ...)
  2016-09-06 17:04 ` [PATCH 13/21] padata: Convert " Sebastian Andrzej Siewior
@ 2016-09-06 17:04 ` Sebastian Andrzej Siewior
  2016-09-19 19:57   ` [tip:smp/hotplug] fault-injection/cpu: " tip-bot for Sebastian Andrzej Siewior
  2016-09-06 17:04 ` [PATCH 15/21] mips: octeon: smp: " Sebastian Andrzej Siewior
                   ` (6 subsequent siblings)
  21 siblings, 1 reply; 83+ messages in thread
From: Sebastian Andrzej Siewior @ 2016-09-06 17:04 UTC (permalink / raw)
  To: linux-kernel
  Cc: Peter Zijlstra, Ingo Molnar, rt, tglx, Sebastian Andrzej Siewior,
	Akinobu Mita

Install the callbacks via the state machine.
This is just temporary. The longterm plan is to create a debugfs interface
where we can put the CPUs up and down from any given point to any given
point. So even if the conversations is not the prettiest - it is just
temporary.

Cc: Akinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
 include/linux/cpuhotplug.h      |  1 +
 lib/cpu-notifier-error-inject.c | 46 +++++++++++++++++++++++++++++++++++------
 2 files changed, 41 insertions(+), 6 deletions(-)

diff --git a/include/linux/cpuhotplug.h b/include/linux/cpuhotplug.h
index 0c33668d1626..4cbf88c955d6 100644
--- a/include/linux/cpuhotplug.h
+++ b/include/linux/cpuhotplug.h
@@ -43,6 +43,7 @@ enum cpuhp_state {
 	CPUHP_ARM_SHMOBILE_SCU_PREPARE,
 	CPUHP_SH_SH3X_PREPARE,
 	CPUHP_X86_MICRCODE_PREPARE,
+	CPUHP_NOTF_ERR_INJ_PREPARE,
 	CPUHP_TIMERS_DEAD,
 	CPUHP_BRINGUP_CPU,
 	CPUHP_AP_IDLE_DEAD,
diff --git a/lib/cpu-notifier-error-inject.c b/lib/cpu-notifier-error-inject.c
index 707ca24f7b18..0e2c9a1e958a 100644
--- a/lib/cpu-notifier-error-inject.c
+++ b/lib/cpu-notifier-error-inject.c
@@ -8,16 +8,47 @@ static int priority;
 module_param(priority, int, 0);
 MODULE_PARM_DESC(priority, "specify cpu notifier priority");
 
+#define UP_PREPARE 0
+#define UP_PREPARE_FROZEN 0
+#define DOWN_PREPARE 0
+#define DOWN_PREPARE_FROZEN 0
+
 static struct notifier_err_inject cpu_notifier_err_inject = {
 	.actions = {
-		{ NOTIFIER_ERR_INJECT_ACTION(CPU_UP_PREPARE) },
-		{ NOTIFIER_ERR_INJECT_ACTION(CPU_UP_PREPARE_FROZEN) },
-		{ NOTIFIER_ERR_INJECT_ACTION(CPU_DOWN_PREPARE) },
-		{ NOTIFIER_ERR_INJECT_ACTION(CPU_DOWN_PREPARE_FROZEN) },
+		{ NOTIFIER_ERR_INJECT_ACTION(UP_PREPARE) },
+		{ NOTIFIER_ERR_INJECT_ACTION(UP_PREPARE_FROZEN) },
+		{ NOTIFIER_ERR_INJECT_ACTION(DOWN_PREPARE) },
+		{ NOTIFIER_ERR_INJECT_ACTION(DOWN_PREPARE_FROZEN) },
 		{}
 	}
 };
 
+static int notf_err_handle(struct notifier_err_inject_action *action)
+{
+	int ret;
+
+	ret = action->error;
+	if (ret)
+		pr_info("Injecting error (%d) to %s\n", ret, action->name);
+	return ret;
+}
+
+static int notf_err_inj_up_prepare(unsigned int cpu)
+{
+	if (!cpuhp_tasks_frozen)
+		return notf_err_handle(&cpu_notifier_err_inject.actions[0]);
+	else
+		return notf_err_handle(&cpu_notifier_err_inject.actions[1]);
+}
+
+static int notf_err_inj_dead(unsigned int cpu)
+{
+	if (!cpuhp_tasks_frozen)
+		return notf_err_handle(&cpu_notifier_err_inject.actions[2]);
+	else
+		return notf_err_handle(&cpu_notifier_err_inject.actions[3]);
+}
+
 static struct dentry *dir;
 
 static int err_inject_init(void)
@@ -29,7 +60,10 @@ static int err_inject_init(void)
 	if (IS_ERR(dir))
 		return PTR_ERR(dir);
 
-	err = register_hotcpu_notifier(&cpu_notifier_err_inject.nb);
+	err = cpuhp_setup_state_nocalls(CPUHP_NOTF_ERR_INJ_PREPARE,
+					"cpu-err-notif:prepare",
+					notf_err_inj_up_prepare,
+					notf_err_inj_dead);
 	if (err)
 		debugfs_remove_recursive(dir);
 
@@ -38,7 +72,7 @@ static int err_inject_init(void)
 
 static void err_inject_exit(void)
 {
-	unregister_hotcpu_notifier(&cpu_notifier_err_inject.nb);
+	cpuhp_remove_state_nocalls(CPUHP_NOTF_ERR_INJ_PREPARE);
 	debugfs_remove_recursive(dir);
 }
 
-- 
2.9.3

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

* [PATCH 15/21] mips: octeon: smp: Convert to hotplug state machine
  2016-09-06 17:04 cpu hotplug: convert more drivers (batch #3) Sebastian Andrzej Siewior
                   ` (14 preceding siblings ...)
  2016-09-06 17:04 ` [PATCH 14/21] fault-injection: cpu: " Sebastian Andrzej Siewior
@ 2016-09-06 17:04 ` Sebastian Andrzej Siewior
  2016-09-07  8:24     ` Matt Redfearn
                     ` (2 more replies)
  2016-09-06 17:04 ` [PATCH 16/21] mips: loongson: smp: " Sebastian Andrzej Siewior
                   ` (5 subsequent siblings)
  21 siblings, 3 replies; 83+ messages in thread
From: Sebastian Andrzej Siewior @ 2016-09-06 17:04 UTC (permalink / raw)
  To: linux-kernel
  Cc: Peter Zijlstra, Ingo Molnar, rt, tglx, Sebastian Andrzej Siewior,
	Ralf Baechle, linux-mips

Install the callbacks via the state machine.

Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: linux-mips@linux-mips.org
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
 arch/mips/cavium-octeon/smp.c | 24 +++---------------------
 include/linux/cpuhotplug.h    |  1 +
 2 files changed, 4 insertions(+), 21 deletions(-)

diff --git a/arch/mips/cavium-octeon/smp.c b/arch/mips/cavium-octeon/smp.c
index 4d457d602d3b..228c1cab2912 100644
--- a/arch/mips/cavium-octeon/smp.c
+++ b/arch/mips/cavium-octeon/smp.c
@@ -380,29 +380,11 @@ static int octeon_update_boot_vector(unsigned int cpu)
 	return 0;
 }
 
-static int octeon_cpu_callback(struct notifier_block *nfb,
-	unsigned long action, void *hcpu)
-{
-	unsigned int cpu = (unsigned long)hcpu;
-
-	switch (action & ~CPU_TASKS_FROZEN) {
-	case CPU_UP_PREPARE:
-		octeon_update_boot_vector(cpu);
-		break;
-	case CPU_ONLINE:
-		pr_info("Cpu %d online\n", cpu);
-		break;
-	case CPU_DEAD:
-		break;
-	}
-
-	return NOTIFY_OK;
-}
-
 static int register_cavium_notifier(void)
 {
-	hotcpu_notifier(octeon_cpu_callback, 0);
-	return 0;
+	return cpuhp_setup_state_nocalls(CPUHP_MIPS_CAVIUM_PREPARE,
+					 "mips/cavium:prepare",
+					 octeon_update_boot_vector, NULL);
 }
 late_initcall(register_cavium_notifier);
 
diff --git a/include/linux/cpuhotplug.h b/include/linux/cpuhotplug.h
index 4cbf88c955d6..058d312fdf6f 100644
--- a/include/linux/cpuhotplug.h
+++ b/include/linux/cpuhotplug.h
@@ -44,6 +44,7 @@ enum cpuhp_state {
 	CPUHP_SH_SH3X_PREPARE,
 	CPUHP_X86_MICRCODE_PREPARE,
 	CPUHP_NOTF_ERR_INJ_PREPARE,
+	CPUHP_MIPS_CAVIUM_PREPARE,
 	CPUHP_TIMERS_DEAD,
 	CPUHP_BRINGUP_CPU,
 	CPUHP_AP_IDLE_DEAD,
-- 
2.9.3

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

* [PATCH 16/21] mips: loongson: smp: Convert to hotplug state machine
  2016-09-06 17:04 cpu hotplug: convert more drivers (batch #3) Sebastian Andrzej Siewior
                   ` (15 preceding siblings ...)
  2016-09-06 17:04 ` [PATCH 15/21] mips: octeon: smp: " Sebastian Andrzej Siewior
@ 2016-09-06 17:04 ` Sebastian Andrzej Siewior
  2016-09-19 15:10   ` Ralf Baechle
  2016-09-19 19:58   ` [tip:smp/hotplug] mips/loongson/smp: " tip-bot for Sebastian Andrzej Siewior
  2016-09-06 17:04 ` [PATCH 17/21] s390: mm: pfault: " Sebastian Andrzej Siewior
                   ` (4 subsequent siblings)
  21 siblings, 2 replies; 83+ messages in thread
From: Sebastian Andrzej Siewior @ 2016-09-06 17:04 UTC (permalink / raw)
  To: linux-kernel
  Cc: Peter Zijlstra, Ingo Molnar, rt, tglx, Sebastian Andrzej Siewior,
	Ralf Baechle, linux-mips

Install the callbacks via the state machine.

Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: linux-mips@linux-mips.org
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
 arch/mips/loongson64/loongson-3/smp.c | 34 ++++++++--------------------------
 include/linux/cpuhotplug.h            |  1 +
 2 files changed, 9 insertions(+), 26 deletions(-)

diff --git a/arch/mips/loongson64/loongson-3/smp.c b/arch/mips/loongson64/loongson-3/smp.c
index 2fec6f753a35..bd7c8cf5332d 100644
--- a/arch/mips/loongson64/loongson-3/smp.c
+++ b/arch/mips/loongson64/loongson-3/smp.c
@@ -677,7 +677,7 @@ void play_dead(void)
 	play_dead_at_ckseg1(state_addr);
 }
 
-void loongson3_disable_clock(int cpu)
+static int loongson3_disable_clock(unsigned int cpu)
 {
 	uint64_t core_id = cpu_data[cpu].core;
 	uint64_t package_id = cpu_data[cpu].package;
@@ -688,9 +688,10 @@ void loongson3_disable_clock(int cpu)
 		if (!(loongson_sysconf.workarounds & WORKAROUND_CPUHOTPLUG))
 			LOONGSON_FREQCTRL(package_id) &= ~(1 << (core_id * 4 + 3));
 	}
+	return 0;
 }
 
-void loongson3_enable_clock(int cpu)
+static int loongson3_enable_clock(unsigned int cpu)
 {
 	uint64_t core_id = cpu_data[cpu].core;
 	uint64_t package_id = cpu_data[cpu].package;
@@ -701,34 +702,15 @@ void loongson3_enable_clock(int cpu)
 		if (!(loongson_sysconf.workarounds & WORKAROUND_CPUHOTPLUG))
 			LOONGSON_FREQCTRL(package_id) |= 1 << (core_id * 4 + 3);
 	}
-}
-
-#define CPU_POST_DEAD_FROZEN	(CPU_POST_DEAD | CPU_TASKS_FROZEN)
-static int loongson3_cpu_callback(struct notifier_block *nfb,
-	unsigned long action, void *hcpu)
-{
-	unsigned int cpu = (unsigned long)hcpu;
-
-	switch (action) {
-	case CPU_POST_DEAD:
-	case CPU_POST_DEAD_FROZEN:
-		pr_info("Disable clock for CPU#%d\n", cpu);
-		loongson3_disable_clock(cpu);
-		break;
-	case CPU_UP_PREPARE:
-	case CPU_UP_PREPARE_FROZEN:
-		pr_info("Enable clock for CPU#%d\n", cpu);
-		loongson3_enable_clock(cpu);
-		break;
-	}
-
-	return NOTIFY_OK;
+	return 0;
 }
 
 static int register_loongson3_notifier(void)
 {
-	hotcpu_notifier(loongson3_cpu_callback, 0);
-	return 0;
+	return cpuhp_setup_state_nocalls(CPUHP_MIPS_LOONGSON_PREPARE,
+					 "mips/loongson:prepare",
+					 loongson3_enable_clock,
+					 loongson3_disable_clock);
 }
 early_initcall(register_loongson3_notifier);
 
diff --git a/include/linux/cpuhotplug.h b/include/linux/cpuhotplug.h
index 058d312fdf6f..9e56be3eaf3f 100644
--- a/include/linux/cpuhotplug.h
+++ b/include/linux/cpuhotplug.h
@@ -45,6 +45,7 @@ enum cpuhp_state {
 	CPUHP_X86_MICRCODE_PREPARE,
 	CPUHP_NOTF_ERR_INJ_PREPARE,
 	CPUHP_MIPS_CAVIUM_PREPARE,
+	CPUHP_MIPS_LOONGSON_PREPARE,
 	CPUHP_TIMERS_DEAD,
 	CPUHP_BRINGUP_CPU,
 	CPUHP_AP_IDLE_DEAD,
-- 
2.9.3

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

* [PATCH 17/21] s390: mm: pfault: Convert to hotplug state machine
  2016-09-06 17:04 cpu hotplug: convert more drivers (batch #3) Sebastian Andrzej Siewior
                   ` (16 preceding siblings ...)
  2016-09-06 17:04 ` [PATCH 16/21] mips: loongson: smp: " Sebastian Andrzej Siewior
@ 2016-09-06 17:04 ` Sebastian Andrzej Siewior
  2016-09-19 19:59   ` [tip:smp/hotplug] s390/mm/pfault: " tip-bot for Sebastian Andrzej Siewior
  2016-09-06 17:04 ` [PATCH 18/21] x86: apic: uv: " Sebastian Andrzej Siewior
                   ` (3 subsequent siblings)
  21 siblings, 1 reply; 83+ messages in thread
From: Sebastian Andrzej Siewior @ 2016-09-06 17:04 UTC (permalink / raw)
  To: linux-kernel
  Cc: Peter Zijlstra, Ingo Molnar, rt, tglx, Sebastian Andrzej Siewior,
	Martin Schwidefsky, Heiko Carstens, linux-s390

Install the callbacks via the state machine.

Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: linux-s390@vger.kernel.org
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
 arch/s390/mm/fault.c       | 30 ++++++++++++------------------
 include/linux/cpuhotplug.h |  1 +
 2 files changed, 13 insertions(+), 18 deletions(-)

diff --git a/arch/s390/mm/fault.c b/arch/s390/mm/fault.c
index a58bca62a93b..cbb73fabc91e 100644
--- a/arch/s390/mm/fault.c
+++ b/arch/s390/mm/fault.c
@@ -740,28 +740,21 @@ static void pfault_interrupt(struct ext_code ext_code,
 	put_task_struct(tsk);
 }
 
-static int pfault_cpu_notify(struct notifier_block *self, unsigned long action,
-			     void *hcpu)
+static int pfault_cpu_dead(unsigned int cpu)
 {
 	struct thread_struct *thread, *next;
 	struct task_struct *tsk;
 
-	switch (action & ~CPU_TASKS_FROZEN) {
-	case CPU_DEAD:
-		spin_lock_irq(&pfault_lock);
-		list_for_each_entry_safe(thread, next, &pfault_list, list) {
-			thread->pfault_wait = 0;
-			list_del(&thread->list);
-			tsk = container_of(thread, struct task_struct, thread);
-			wake_up_process(tsk);
-			put_task_struct(tsk);
-		}
-		spin_unlock_irq(&pfault_lock);
-		break;
-	default:
-		break;
+	spin_lock_irq(&pfault_lock);
+	list_for_each_entry_safe(thread, next, &pfault_list, list) {
+		thread->pfault_wait = 0;
+		list_del(&thread->list);
+		tsk = container_of(thread, struct task_struct, thread);
+		wake_up_process(tsk);
+		put_task_struct(tsk);
 	}
-	return NOTIFY_OK;
+	spin_unlock_irq(&pfault_lock);
+	return 0;
 }
 
 static int __init pfault_irq_init(void)
@@ -775,7 +768,8 @@ static int __init pfault_irq_init(void)
 	if (rc)
 		goto out_pfault;
 	irq_subclass_register(IRQ_SUBCLASS_SERVICE_SIGNAL);
-	hotcpu_notifier(pfault_cpu_notify, 0);
+	cpuhp_setup_state_nocalls(CPUHP_S390_PFAULT_DEAD, "s390/pfault:dead",
+				  NULL, pfault_cpu_dead);
 	return 0;
 
 out_pfault:
diff --git a/include/linux/cpuhotplug.h b/include/linux/cpuhotplug.h
index 9e56be3eaf3f..eb0298440206 100644
--- a/include/linux/cpuhotplug.h
+++ b/include/linux/cpuhotplug.h
@@ -26,6 +26,7 @@ enum cpuhp_state {
 	CPUHP_BLOCK_SOFTIRQ_DEAD,
 	CPUHP_VIRT_SCSI_DEAD,
 	CPUHP_ACPI_CPUDRV_DEAD,
+	CPUHP_S390_PFAULT_DEAD,
 	CPUHP_WORKQUEUE_PREP,
 	CPUHP_POWER_NUMA_PREPARE,
 	CPUHP_HRTIMERS_PREPARE,
-- 
2.9.3

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

* [PATCH 18/21] x86: apic: uv: Convert to hotplug state machine
  2016-09-06 17:04 cpu hotplug: convert more drivers (batch #3) Sebastian Andrzej Siewior
                   ` (17 preceding siblings ...)
  2016-09-06 17:04 ` [PATCH 17/21] s390: mm: pfault: " Sebastian Andrzej Siewior
@ 2016-09-06 17:04 ` Sebastian Andrzej Siewior
  2016-09-19 19:59   ` [tip:smp/hotplug] x86/apic/uv: " tip-bot for Sebastian Andrzej Siewior
  2016-09-06 17:04 ` [PATCH 19/21] blk: mq: reserve hotplug ID states for block Sebastian Andrzej Siewior
                   ` (2 subsequent siblings)
  21 siblings, 1 reply; 83+ messages in thread
From: Sebastian Andrzej Siewior @ 2016-09-06 17:04 UTC (permalink / raw)
  To: linux-kernel
  Cc: Peter Zijlstra, Ingo Molnar, rt, tglx, Sebastian Andrzej Siewior

Install the callbacks via the state machine.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
 arch/x86/kernel/apic/x2apic_uv_x.c | 31 ++++++-------------------------
 1 file changed, 6 insertions(+), 25 deletions(-)

diff --git a/arch/x86/kernel/apic/x2apic_uv_x.c b/arch/x86/kernel/apic/x2apic_uv_x.c
index cb0673c1e940..391b7f8b31c8 100644
--- a/arch/x86/kernel/apic/x2apic_uv_x.c
+++ b/arch/x86/kernel/apic/x2apic_uv_x.c
@@ -927,7 +927,7 @@ static void uv_heartbeat(unsigned long ignored)
 	mod_timer(timer, jiffies + SCIR_CPU_HB_INTERVAL);
 }
 
-static void uv_heartbeat_enable(int cpu)
+static int uv_heartbeat_enable(unsigned int cpu)
 {
 	while (!uv_cpu_scir_info(cpu)->enabled) {
 		struct timer_list *timer = &uv_cpu_scir_info(cpu)->timer;
@@ -941,43 +941,24 @@ static void uv_heartbeat_enable(int cpu)
 		/* also ensure that boot cpu is enabled */
 		cpu = 0;
 	}
+	return 0;
 }
 
 #ifdef CONFIG_HOTPLUG_CPU
-static void uv_heartbeat_disable(int cpu)
+static int uv_heartbeat_disable(unsigned int cpu)
 {
 	if (uv_cpu_scir_info(cpu)->enabled) {
 		uv_cpu_scir_info(cpu)->enabled = 0;
 		del_timer(&uv_cpu_scir_info(cpu)->timer);
 	}
 	uv_set_cpu_scir_bits(cpu, 0xff);
-}
-
-/*
- * cpu hotplug notifier
- */
-static int uv_scir_cpu_notify(struct notifier_block *self, unsigned long action,
-			      void *hcpu)
-{
-	long cpu = (long)hcpu;
-
-	switch (action & ~CPU_TASKS_FROZEN) {
-	case CPU_DOWN_FAILED:
-	case CPU_ONLINE:
-		uv_heartbeat_enable(cpu);
-		break;
-	case CPU_DOWN_PREPARE:
-		uv_heartbeat_disable(cpu);
-		break;
-	default:
-		break;
-	}
-	return NOTIFY_OK;
+	return 0;
 }
 
 static __init void uv_scir_register_cpu_notifier(void)
 {
-	hotcpu_notifier(uv_scir_cpu_notify, 0);
+	cpuhp_setup_state_nocalls(CPUHP_AP_ONLINE_DYN, "x86/x2apic-uvx:online",
+				  uv_heartbeat_enable, uv_heartbeat_disable);
 }
 
 #else /* !CONFIG_HOTPLUG_CPU */
-- 
2.9.3

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

* [PATCH 19/21] blk: mq: reserve hotplug ID states for block
  2016-09-06 17:04 cpu hotplug: convert more drivers (batch #3) Sebastian Andrzej Siewior
                   ` (18 preceding siblings ...)
  2016-09-06 17:04 ` [PATCH 18/21] x86: apic: uv: " Sebastian Andrzej Siewior
@ 2016-09-06 17:04 ` Sebastian Andrzej Siewior
  2016-09-19 20:03   ` [tip:smp/hotplug] blk/mq: Reserve hotplug ID states for block multiqueue tip-bot for Sebastian Andrzej Siewior
                     ` (2 more replies)
  2016-09-06 17:04 ` [PATCH 20/21] blk: mq: cpu-notif: Convert to hotplug state machine Sebastian Andrzej Siewior
  2016-09-06 17:04 ` [PATCH 21/21] blk: mq: " Sebastian Andrzej Siewior
  21 siblings, 3 replies; 83+ messages in thread
From: Sebastian Andrzej Siewior @ 2016-09-06 17:04 UTC (permalink / raw)
  To: linux-kernel
  Cc: Peter Zijlstra, Ingo Molnar, rt, tglx, Sebastian Andrzej Siewior,
	Jens Axboe

This patch only reseves two CPU hotplug ids for block/mq to avoid clashes
during merge.

Cc: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
 include/linux/cpuhotplug.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/linux/cpuhotplug.h b/include/linux/cpuhotplug.h
index eb0298440206..fceebbe77dd5 100644
--- a/include/linux/cpuhotplug.h
+++ b/include/linux/cpuhotplug.h
@@ -27,6 +27,7 @@ enum cpuhp_state {
 	CPUHP_VIRT_SCSI_DEAD,
 	CPUHP_ACPI_CPUDRV_DEAD,
 	CPUHP_S390_PFAULT_DEAD,
+	CPUHP_BLKMQ_DEAD,
 	CPUHP_WORKQUEUE_PREP,
 	CPUHP_POWER_NUMA_PREPARE,
 	CPUHP_HRTIMERS_PREPARE,
@@ -47,6 +48,7 @@ enum cpuhp_state {
 	CPUHP_NOTF_ERR_INJ_PREPARE,
 	CPUHP_MIPS_CAVIUM_PREPARE,
 	CPUHP_MIPS_LOONGSON_PREPARE,
+	CPUHP_BLK_MQ_PREPARE,
 	CPUHP_TIMERS_DEAD,
 	CPUHP_BRINGUP_CPU,
 	CPUHP_AP_IDLE_DEAD,
-- 
2.9.3

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

* [PATCH 20/21] blk: mq: cpu-notif: Convert to hotplug state machine
  2016-09-06 17:04 cpu hotplug: convert more drivers (batch #3) Sebastian Andrzej Siewior
                   ` (19 preceding siblings ...)
  2016-09-06 17:04 ` [PATCH 19/21] blk: mq: reserve hotplug ID states for block Sebastian Andrzej Siewior
@ 2016-09-06 17:04 ` Sebastian Andrzej Siewior
  2016-09-06 17:04 ` [PATCH 21/21] blk: mq: " Sebastian Andrzej Siewior
  21 siblings, 0 replies; 83+ messages in thread
From: Sebastian Andrzej Siewior @ 2016-09-06 17:04 UTC (permalink / raw)
  To: linux-kernel
  Cc: Peter Zijlstra, Ingo Molnar, rt, tglx, Sebastian Andrzej Siewior,
	Jens Axboe

Install the callbacks via the state machine. The only currently handled
callback is CPU_DEAD and this one is converted.

Cc: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
This patch against linux-next to take the block changes into account. It
depends on "blk: mq: reserve hotplug ID states for block"

 block/blk-mq-cpu.c     |   15 +++++++--------
 block/blk-mq.c         |   17 ++++-------------
 block/blk-mq.h         |    2 +-
 include/linux/blk-mq.h |    2 +-
 4 files changed, 13 insertions(+), 23 deletions(-)

--- a/block/blk-mq-cpu.c
+++ b/block/blk-mq-cpu.c
@@ -18,18 +18,16 @@
 static LIST_HEAD(blk_mq_cpu_notify_list);
 static DEFINE_RAW_SPINLOCK(blk_mq_cpu_notify_lock);
 
-static int blk_mq_main_cpu_notify(struct notifier_block *self,
-				  unsigned long action, void *hcpu)
+static int blk_mq_main_cpu_dead(unsigned int cpu)
 {
-	unsigned int cpu = (unsigned long) hcpu;
 	struct blk_mq_cpu_notifier *notify;
-	int ret = NOTIFY_OK;
+	int ret;
 
 	raw_spin_lock(&blk_mq_cpu_notify_lock);
 
 	list_for_each_entry(notify, &blk_mq_cpu_notify_list, list) {
-		ret = notify->notify(notify->data, action, cpu);
-		if (ret != NOTIFY_OK)
+		ret = notify->notify(notify->data, cpu);
+		if (ret)
 			break;
 	}
 
@@ -54,7 +52,7 @@ void blk_mq_unregister_cpu_notifier(stru
 }
 
 void blk_mq_init_cpu_notifier(struct blk_mq_cpu_notifier *notifier,
-			      int (*fn)(void *, unsigned long, unsigned int),
+			      int (*fn)(void *, unsigned int),
 			      void *data)
 {
 	notifier->notify = fn;
@@ -63,5 +61,6 @@ void blk_mq_init_cpu_notifier(struct blk
 
 void __init blk_mq_cpu_init(void)
 {
-	hotcpu_notifier(blk_mq_main_cpu_notify, 0);
+	cpuhp_setup_state_nocalls(CPUHP_BLKMQ_DEAD, "block/mq:dead", NULL,
+				  blk_mq_main_cpu_dead);
 }
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -1649,7 +1649,7 @@ static int blk_mq_hctx_cpu_offline(struc
 	spin_unlock(&ctx->lock);
 
 	if (list_empty(&tmp))
-		return NOTIFY_OK;
+		return 0;
 
 	ctx = blk_mq_get_ctx(q);
 	spin_lock(&ctx->lock);
@@ -1669,23 +1669,14 @@ static int blk_mq_hctx_cpu_offline(struc
 
 	blk_mq_run_hw_queue(hctx, true);
 	blk_mq_put_ctx(ctx);
-	return NOTIFY_OK;
+	return 0;
 }
 
-static int blk_mq_hctx_notify(void *data, unsigned long action,
-			      unsigned int cpu)
+static int blk_mq_hctx_notify(void *data, unsigned int cpu)
 {
 	struct blk_mq_hw_ctx *hctx = data;
 
-	if (action == CPU_DEAD || action == CPU_DEAD_FROZEN)
-		return blk_mq_hctx_cpu_offline(hctx, cpu);
-
-	/*
-	 * In case of CPU online, tags may be reallocated
-	 * in blk_mq_map_swqueue() after mapping is updated.
-	 */
-
-	return NOTIFY_OK;
+	return blk_mq_hctx_cpu_offline(hctx, cpu);
 }
 
 /* hctx->ctxs will be freed in queue's release handler */
--- a/block/blk-mq.h
+++ b/block/blk-mq.h
@@ -36,7 +36,7 @@ void blk_mq_wake_waiters(struct request_
  */
 struct blk_mq_cpu_notifier;
 void blk_mq_init_cpu_notifier(struct blk_mq_cpu_notifier *notifier,
-			      int (*fn)(void *, unsigned long, unsigned int),
+			      int (*fn)(void *, unsigned int),
 			      void *data);
 void blk_mq_register_cpu_notifier(struct blk_mq_cpu_notifier *notifier);
 void blk_mq_unregister_cpu_notifier(struct blk_mq_cpu_notifier *notifier);
--- a/include/linux/blk-mq.h
+++ b/include/linux/blk-mq.h
@@ -9,7 +9,7 @@ struct blk_flush_queue;
 struct blk_mq_cpu_notifier {
 	struct list_head list;
 	void *data;
-	int (*notify)(void *data, unsigned long action, unsigned int cpu);
+	int (*notify)(void *data, unsigned int cpu);
 };
 
 struct blk_mq_ctxmap {

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

* [PATCH 21/21] blk: mq: Convert to hotplug state machine
  2016-09-06 17:04 cpu hotplug: convert more drivers (batch #3) Sebastian Andrzej Siewior
                   ` (20 preceding siblings ...)
  2016-09-06 17:04 ` [PATCH 20/21] blk: mq: cpu-notif: Convert to hotplug state machine Sebastian Andrzej Siewior
@ 2016-09-06 17:04 ` Sebastian Andrzej Siewior
  21 siblings, 0 replies; 83+ messages in thread
From: Sebastian Andrzej Siewior @ 2016-09-06 17:04 UTC (permalink / raw)
  To: linux-kernel
  Cc: Peter Zijlstra, Ingo Molnar, rt, tglx, Sebastian Andrzej Siewior,
	Jens Axboe

Install the callbacks via the state machine.

Cc: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
This patch against linux-next to take the block changes into account. It
depends on "blk: mq: reserve hotplug ID states for block"

 block/blk-mq.c |   86 ++++++++++++++++++++++++++++-----------------------------
 1 file changed, 43 insertions(+), 43 deletions(-)

--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -2173,47 +2173,15 @@ static void blk_mq_queue_reinit(struct r
 	blk_mq_sysfs_register(q);
 }
 
-static int blk_mq_queue_reinit_notify(struct notifier_block *nb,
-				      unsigned long action, void *hcpu)
+/*
+ * New online cpumask which is going to be set in this hotplug event.
+ * Declare this cpumasks as global as cpu-hotplug operation is invoked
+ * one-by-one and dynamically allocating this could result in a failure.
+ */
+static struct cpumask cpuhp_online_new;
+static int blk_mq_queue_reinit_work(void)
 {
 	struct request_queue *q;
-	int cpu = (unsigned long)hcpu;
-	/*
-	 * New online cpumask which is going to be set in this hotplug event.
-	 * Declare this cpumasks as global as cpu-hotplug operation is invoked
-	 * one-by-one and dynamically allocating this could result in a failure.
-	 */
-	static struct cpumask online_new;
-
-	/*
-	 * Before hotadded cpu starts handling requests, new mappings must
-	 * be established.  Otherwise, these requests in hw queue might
-	 * never be dispatched.
-	 *
-	 * For example, there is a single hw queue (hctx) and two CPU queues
-	 * (ctx0 for CPU0, and ctx1 for CPU1).
-	 *
-	 * Now CPU1 is just onlined and a request is inserted into
-	 * ctx1->rq_list and set bit0 in pending bitmap as ctx1->index_hw is
-	 * still zero.
-	 *
-	 * And then while running hw queue, flush_busy_ctxs() finds bit0 is
-	 * set in pending bitmap and tries to retrieve requests in
-	 * hctx->ctxs[0]->rq_list.  But htx->ctxs[0] is a pointer to ctx0,
-	 * so the request in ctx1->rq_list is ignored.
-	 */
-	switch (action & ~CPU_TASKS_FROZEN) {
-	case CPU_DEAD:
-	case CPU_UP_CANCELED:
-		cpumask_copy(&online_new, cpu_online_mask);
-		break;
-	case CPU_UP_PREPARE:
-		cpumask_copy(&online_new, cpu_online_mask);
-		cpumask_set_cpu(cpu, &online_new);
-		break;
-	default:
-		return NOTIFY_OK;
-	}
 
 	mutex_lock(&all_q_mutex);
 
@@ -2237,13 +2205,44 @@ static int blk_mq_queue_reinit_notify(st
 	}
 
 	list_for_each_entry(q, &all_q_list, all_q_node)
-		blk_mq_queue_reinit(q, &online_new);
+		blk_mq_queue_reinit(q, &cpuhp_online_new);
 
 	list_for_each_entry(q, &all_q_list, all_q_node)
 		blk_mq_unfreeze_queue(q);
 
 	mutex_unlock(&all_q_mutex);
-	return NOTIFY_OK;
+	return 0;
+}
+
+static int blk_mq_queue_reinit_dead(unsigned int cpu)
+{
+	cpumask_copy(&cpuhp_online_new, cpu_online_mask);
+	return blk_mq_queue_reinit_work();
+}
+
+static int blk_mq_queue_reinit_prepare(unsigned int cpu)
+{
+	/*
+	 * Before hotadded cpu starts handling requests, new mappings must
+	 * be established.  Otherwise, these requests in hw queue might
+	 * never be dispatched.
+	 *
+	 * For example, there is a single hw queue (hctx) and two CPU queues
+	 * (ctx0 for CPU0, and ctx1 for CPU1).
+	 *
+	 * Now CPU1 is just onlined and a request is inserted into
+	 * ctx1->rq_list and set bit0 in pending bitmap as ctx1->index_hw is
+	 * still zero.
+	 *
+	 * And then while running hw queue, flush_busy_ctxs() finds bit0 is
+	 * set in pending bitmap and tries to retrieve requests in
+	 * hctx->ctxs[0]->rq_list.  But htx->ctxs[0] is a pointer to ctx0,
+	 * so the request in ctx1->rq_list is ignored.
+	 */
+
+	cpumask_copy(&cpuhp_online_new, cpu_online_mask);
+	cpumask_set_cpu(cpu, &cpuhp_online_new);
+	return blk_mq_queue_reinit_work();
 }
 
 static int __blk_mq_alloc_rq_maps(struct blk_mq_tag_set *set)
@@ -2447,8 +2446,9 @@ static int __init blk_mq_init(void)
 {
 	blk_mq_cpu_init();
 
-	hotcpu_notifier(blk_mq_queue_reinit_notify, 0);
-
+	cpuhp_setup_state_nocalls(CPUHP_BLK_MQ_PREPARE, "block/mq:prepare",
+				  blk_mq_queue_reinit_prepare,
+				  blk_mq_queue_reinit_dead);
 	return 0;
 }
 subsys_initcall(blk_mq_init);

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

* Re: [PATCH 02/21] ARM: shmobile: Convert to hotplug state machine
  2016-09-06 17:04   ` Sebastian Andrzej Siewior
  (?)
  (?)
@ 2016-09-06 18:05     ` Geert Uytterhoeven
  -1 siblings, 0 replies; 83+ messages in thread
From: Geert Uytterhoeven @ 2016-09-06 18:05 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Sebastian,

CC linux-renesas-soc

On Tue, Sep 6, 2016 at 7:04 PM, Sebastian Andrzej Siewior
<bigeasy@linutronix.de> wrote:
> Install the callbacks via the state machine.

Please describe why this is desirable.

> Cc: Simon Horman <horms@verge.net.au>
> Cc: Magnus Damm <magnus.damm@gmail.com>
> Cc: linux-arm-kernel@lists.infradead.org
> Cc: linux-sh@vger.kernel.org
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> ---
>  arch/arm/mach-shmobile/platsmp-scu.c | 26 ++++++++------------------
>  include/linux/cpuhotplug.h           |  1 +
>  2 files changed, 9 insertions(+), 18 deletions(-)
>
> diff --git a/arch/arm/mach-shmobile/platsmp-scu.c b/arch/arm/mach-shmobile/platsmp-scu.c
> index 8d478f1da265..d1ecaf37d142 100644
> --- a/arch/arm/mach-shmobile/platsmp-scu.c
> +++ b/arch/arm/mach-shmobile/platsmp-scu.c
> @@ -21,26 +21,14 @@
>  static phys_addr_t shmobile_scu_base_phys;
>  static void __iomem *shmobile_scu_base;
>
> -static int shmobile_smp_scu_notifier_call(struct notifier_block *nfb,
> -                                         unsigned long action, void *hcpu)
> +static int shmobile_scu_cpu_prepare(unsigned int cpu)
>  {
> -       unsigned int cpu = (long)hcpu;
> -
> -       switch (action) {
> -       case CPU_UP_PREPARE:
> -               /* For this particular CPU register SCU SMP boot vector */
> -               shmobile_smp_hook(cpu, virt_to_phys(shmobile_boot_scu),
> -                                 shmobile_scu_base_phys);
> -               break;
> -       };
> -
> -       return NOTIFY_OK;
> +       /* For this particular CPU register SCU SMP boot vector */
> +       shmobile_smp_hook(cpu, virt_to_phys(shmobile_boot_scu),
> +                         shmobile_scu_base_phys);
> +       return 0;
>  }
>
> -static struct notifier_block shmobile_smp_scu_notifier = {
> -       .notifier_call = shmobile_smp_scu_notifier_call,
> -};
> -
>  void __init shmobile_smp_scu_prepare_cpus(phys_addr_t scu_base_phys,
>                                           unsigned int max_cpus)
>  {
> @@ -54,7 +42,9 @@ void __init shmobile_smp_scu_prepare_cpus(phys_addr_t scu_base_phys,
>         scu_power_mode(shmobile_scu_base, SCU_PM_NORMAL);
>
>         /* Use CPU notifier for reset vector control */
> -       register_cpu_notifier(&shmobile_smp_scu_notifier);
> +       cpuhp_setup_state_nocalls(CPUHP_ARM_SHMOBILE_SCU_PREPARE,
> +                                 "arm/shmobile-scu:prepare",
> +                                 shmobile_scu_cpu_prepare, NULL);
>  }
>
>  #ifdef CONFIG_HOTPLUG_CPU
> diff --git a/include/linux/cpuhotplug.h b/include/linux/cpuhotplug.h
> index 0da071ff36d2..008eed0c0787 100644
> --- a/include/linux/cpuhotplug.h
> +++ b/include/linux/cpuhotplug.h
> @@ -35,6 +35,7 @@ enum cpuhp_state {
>         CPUHP_POWERPC_PMAC_PREPARE,
>         CPUHP_POWERPC_MMU_CTX_PREPARE,
>         CPUHP_NOTIFY_PREPARE,
> +       CPUHP_ARM_SHMOBILE_SCU_PREPARE,
>         CPUHP_TIMERS_DEAD,
>         CPUHP_BRINGUP_CPU,
>         CPUHP_AP_IDLE_DEAD,

What's the rationale behind adding all these numbers and always
iterating over all
of them, even though most/all of them cannot be used at the same time
(e.g. CPUHP_SH_SH3X_PREPARE is for SuperH, while
 CPUHP_ARM_SHMOBILE_SCU_PREPARE is for ARM)?

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

* Re: [PATCH 02/21] ARM: shmobile: Convert to hotplug state machine
@ 2016-09-06 18:05     ` Geert Uytterhoeven
  0 siblings, 0 replies; 83+ messages in thread
From: Geert Uytterhoeven @ 2016-09-06 18:05 UTC (permalink / raw)
  To: Sebastian Andrzej Siewior
  Cc: linux-kernel, Peter Zijlstra, Ingo Molnar, rt, Thomas Gleixner,
	Simon Horman, Magnus Damm, linux-arm-kernel, Linux-sh list,
	Linux-Renesas

Hi Sebastian,

CC linux-renesas-soc

On Tue, Sep 6, 2016 at 7:04 PM, Sebastian Andrzej Siewior
<bigeasy@linutronix.de> wrote:
> Install the callbacks via the state machine.

Please describe why this is desirable.

> Cc: Simon Horman <horms@verge.net.au>
> Cc: Magnus Damm <magnus.damm@gmail.com>
> Cc: linux-arm-kernel@lists.infradead.org
> Cc: linux-sh@vger.kernel.org
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> ---
>  arch/arm/mach-shmobile/platsmp-scu.c | 26 ++++++++------------------
>  include/linux/cpuhotplug.h           |  1 +
>  2 files changed, 9 insertions(+), 18 deletions(-)
>
> diff --git a/arch/arm/mach-shmobile/platsmp-scu.c b/arch/arm/mach-shmobile/platsmp-scu.c
> index 8d478f1da265..d1ecaf37d142 100644
> --- a/arch/arm/mach-shmobile/platsmp-scu.c
> +++ b/arch/arm/mach-shmobile/platsmp-scu.c
> @@ -21,26 +21,14 @@
>  static phys_addr_t shmobile_scu_base_phys;
>  static void __iomem *shmobile_scu_base;
>
> -static int shmobile_smp_scu_notifier_call(struct notifier_block *nfb,
> -                                         unsigned long action, void *hcpu)
> +static int shmobile_scu_cpu_prepare(unsigned int cpu)
>  {
> -       unsigned int cpu = (long)hcpu;
> -
> -       switch (action) {
> -       case CPU_UP_PREPARE:
> -               /* For this particular CPU register SCU SMP boot vector */
> -               shmobile_smp_hook(cpu, virt_to_phys(shmobile_boot_scu),
> -                                 shmobile_scu_base_phys);
> -               break;
> -       };
> -
> -       return NOTIFY_OK;
> +       /* For this particular CPU register SCU SMP boot vector */
> +       shmobile_smp_hook(cpu, virt_to_phys(shmobile_boot_scu),
> +                         shmobile_scu_base_phys);
> +       return 0;
>  }
>
> -static struct notifier_block shmobile_smp_scu_notifier = {
> -       .notifier_call = shmobile_smp_scu_notifier_call,
> -};
> -
>  void __init shmobile_smp_scu_prepare_cpus(phys_addr_t scu_base_phys,
>                                           unsigned int max_cpus)
>  {
> @@ -54,7 +42,9 @@ void __init shmobile_smp_scu_prepare_cpus(phys_addr_t scu_base_phys,
>         scu_power_mode(shmobile_scu_base, SCU_PM_NORMAL);
>
>         /* Use CPU notifier for reset vector control */
> -       register_cpu_notifier(&shmobile_smp_scu_notifier);
> +       cpuhp_setup_state_nocalls(CPUHP_ARM_SHMOBILE_SCU_PREPARE,
> +                                 "arm/shmobile-scu:prepare",
> +                                 shmobile_scu_cpu_prepare, NULL);
>  }
>
>  #ifdef CONFIG_HOTPLUG_CPU
> diff --git a/include/linux/cpuhotplug.h b/include/linux/cpuhotplug.h
> index 0da071ff36d2..008eed0c0787 100644
> --- a/include/linux/cpuhotplug.h
> +++ b/include/linux/cpuhotplug.h
> @@ -35,6 +35,7 @@ enum cpuhp_state {
>         CPUHP_POWERPC_PMAC_PREPARE,
>         CPUHP_POWERPC_MMU_CTX_PREPARE,
>         CPUHP_NOTIFY_PREPARE,
> +       CPUHP_ARM_SHMOBILE_SCU_PREPARE,
>         CPUHP_TIMERS_DEAD,
>         CPUHP_BRINGUP_CPU,
>         CPUHP_AP_IDLE_DEAD,

What's the rationale behind adding all these numbers and always
iterating over all
of them, even though most/all of them cannot be used at the same time
(e.g. CPUHP_SH_SH3X_PREPARE is for SuperH, while
 CPUHP_ARM_SHMOBILE_SCU_PREPARE is for ARM)?

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

* Re: [PATCH 02/21] ARM: shmobile: Convert to hotplug state machine
@ 2016-09-06 18:05     ` Geert Uytterhoeven
  0 siblings, 0 replies; 83+ messages in thread
From: Geert Uytterhoeven @ 2016-09-06 18:05 UTC (permalink / raw)
  To: Sebastian Andrzej Siewior
  Cc: linux-kernel, Peter Zijlstra, Ingo Molnar, rt, Thomas Gleixner,
	Simon Horman, Magnus Damm, linux-arm-kernel, Linux-sh list,
	Linux-Renesas

Hi Sebastian,

CC linux-renesas-soc

On Tue, Sep 6, 2016 at 7:04 PM, Sebastian Andrzej Siewior
<bigeasy@linutronix.de> wrote:
> Install the callbacks via the state machine.

Please describe why this is desirable.

> Cc: Simon Horman <horms@verge.net.au>
> Cc: Magnus Damm <magnus.damm@gmail.com>
> Cc: linux-arm-kernel@lists.infradead.org
> Cc: linux-sh@vger.kernel.org
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> ---
>  arch/arm/mach-shmobile/platsmp-scu.c | 26 ++++++++------------------
>  include/linux/cpuhotplug.h           |  1 +
>  2 files changed, 9 insertions(+), 18 deletions(-)
>
> diff --git a/arch/arm/mach-shmobile/platsmp-scu.c b/arch/arm/mach-shmobile/platsmp-scu.c
> index 8d478f1da265..d1ecaf37d142 100644
> --- a/arch/arm/mach-shmobile/platsmp-scu.c
> +++ b/arch/arm/mach-shmobile/platsmp-scu.c
> @@ -21,26 +21,14 @@
>  static phys_addr_t shmobile_scu_base_phys;
>  static void __iomem *shmobile_scu_base;
>
> -static int shmobile_smp_scu_notifier_call(struct notifier_block *nfb,
> -                                         unsigned long action, void *hcpu)
> +static int shmobile_scu_cpu_prepare(unsigned int cpu)
>  {
> -       unsigned int cpu = (long)hcpu;
> -
> -       switch (action) {
> -       case CPU_UP_PREPARE:
> -               /* For this particular CPU register SCU SMP boot vector */
> -               shmobile_smp_hook(cpu, virt_to_phys(shmobile_boot_scu),
> -                                 shmobile_scu_base_phys);
> -               break;
> -       };
> -
> -       return NOTIFY_OK;
> +       /* For this particular CPU register SCU SMP boot vector */
> +       shmobile_smp_hook(cpu, virt_to_phys(shmobile_boot_scu),
> +                         shmobile_scu_base_phys);
> +       return 0;
>  }
>
> -static struct notifier_block shmobile_smp_scu_notifier = {
> -       .notifier_call = shmobile_smp_scu_notifier_call,
> -};
> -
>  void __init shmobile_smp_scu_prepare_cpus(phys_addr_t scu_base_phys,
>                                           unsigned int max_cpus)
>  {
> @@ -54,7 +42,9 @@ void __init shmobile_smp_scu_prepare_cpus(phys_addr_t scu_base_phys,
>         scu_power_mode(shmobile_scu_base, SCU_PM_NORMAL);
>
>         /* Use CPU notifier for reset vector control */
> -       register_cpu_notifier(&shmobile_smp_scu_notifier);
> +       cpuhp_setup_state_nocalls(CPUHP_ARM_SHMOBILE_SCU_PREPARE,
> +                                 "arm/shmobile-scu:prepare",
> +                                 shmobile_scu_cpu_prepare, NULL);
>  }
>
>  #ifdef CONFIG_HOTPLUG_CPU
> diff --git a/include/linux/cpuhotplug.h b/include/linux/cpuhotplug.h
> index 0da071ff36d2..008eed0c0787 100644
> --- a/include/linux/cpuhotplug.h
> +++ b/include/linux/cpuhotplug.h
> @@ -35,6 +35,7 @@ enum cpuhp_state {
>         CPUHP_POWERPC_PMAC_PREPARE,
>         CPUHP_POWERPC_MMU_CTX_PREPARE,
>         CPUHP_NOTIFY_PREPARE,
> +       CPUHP_ARM_SHMOBILE_SCU_PREPARE,
>         CPUHP_TIMERS_DEAD,
>         CPUHP_BRINGUP_CPU,
>         CPUHP_AP_IDLE_DEAD,

What's the rationale behind adding all these numbers and always
iterating over all
of them, even though most/all of them cannot be used at the same time
(e.g. CPUHP_SH_SH3X_PREPARE is for SuperH, while
 CPUHP_ARM_SHMOBILE_SCU_PREPARE is for ARM)?

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

* [PATCH 02/21] ARM: shmobile: Convert to hotplug state machine
@ 2016-09-06 18:05     ` Geert Uytterhoeven
  0 siblings, 0 replies; 83+ messages in thread
From: Geert Uytterhoeven @ 2016-09-06 18:05 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Sebastian,

CC linux-renesas-soc

On Tue, Sep 6, 2016 at 7:04 PM, Sebastian Andrzej Siewior
<bigeasy@linutronix.de> wrote:
> Install the callbacks via the state machine.

Please describe why this is desirable.

> Cc: Simon Horman <horms@verge.net.au>
> Cc: Magnus Damm <magnus.damm@gmail.com>
> Cc: linux-arm-kernel at lists.infradead.org
> Cc: linux-sh at vger.kernel.org
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> ---
>  arch/arm/mach-shmobile/platsmp-scu.c | 26 ++++++++------------------
>  include/linux/cpuhotplug.h           |  1 +
>  2 files changed, 9 insertions(+), 18 deletions(-)
>
> diff --git a/arch/arm/mach-shmobile/platsmp-scu.c b/arch/arm/mach-shmobile/platsmp-scu.c
> index 8d478f1da265..d1ecaf37d142 100644
> --- a/arch/arm/mach-shmobile/platsmp-scu.c
> +++ b/arch/arm/mach-shmobile/platsmp-scu.c
> @@ -21,26 +21,14 @@
>  static phys_addr_t shmobile_scu_base_phys;
>  static void __iomem *shmobile_scu_base;
>
> -static int shmobile_smp_scu_notifier_call(struct notifier_block *nfb,
> -                                         unsigned long action, void *hcpu)
> +static int shmobile_scu_cpu_prepare(unsigned int cpu)
>  {
> -       unsigned int cpu = (long)hcpu;
> -
> -       switch (action) {
> -       case CPU_UP_PREPARE:
> -               /* For this particular CPU register SCU SMP boot vector */
> -               shmobile_smp_hook(cpu, virt_to_phys(shmobile_boot_scu),
> -                                 shmobile_scu_base_phys);
> -               break;
> -       };
> -
> -       return NOTIFY_OK;
> +       /* For this particular CPU register SCU SMP boot vector */
> +       shmobile_smp_hook(cpu, virt_to_phys(shmobile_boot_scu),
> +                         shmobile_scu_base_phys);
> +       return 0;
>  }
>
> -static struct notifier_block shmobile_smp_scu_notifier = {
> -       .notifier_call = shmobile_smp_scu_notifier_call,
> -};
> -
>  void __init shmobile_smp_scu_prepare_cpus(phys_addr_t scu_base_phys,
>                                           unsigned int max_cpus)
>  {
> @@ -54,7 +42,9 @@ void __init shmobile_smp_scu_prepare_cpus(phys_addr_t scu_base_phys,
>         scu_power_mode(shmobile_scu_base, SCU_PM_NORMAL);
>
>         /* Use CPU notifier for reset vector control */
> -       register_cpu_notifier(&shmobile_smp_scu_notifier);
> +       cpuhp_setup_state_nocalls(CPUHP_ARM_SHMOBILE_SCU_PREPARE,
> +                                 "arm/shmobile-scu:prepare",
> +                                 shmobile_scu_cpu_prepare, NULL);
>  }
>
>  #ifdef CONFIG_HOTPLUG_CPU
> diff --git a/include/linux/cpuhotplug.h b/include/linux/cpuhotplug.h
> index 0da071ff36d2..008eed0c0787 100644
> --- a/include/linux/cpuhotplug.h
> +++ b/include/linux/cpuhotplug.h
> @@ -35,6 +35,7 @@ enum cpuhp_state {
>         CPUHP_POWERPC_PMAC_PREPARE,
>         CPUHP_POWERPC_MMU_CTX_PREPARE,
>         CPUHP_NOTIFY_PREPARE,
> +       CPUHP_ARM_SHMOBILE_SCU_PREPARE,
>         CPUHP_TIMERS_DEAD,
>         CPUHP_BRINGUP_CPU,
>         CPUHP_AP_IDLE_DEAD,

What's the rationale behind adding all these numbers and always
iterating over all
of them, even though most/all of them cannot be used at the same time
(e.g. CPUHP_SH_SH3X_PREPARE is for SuperH, while
 CPUHP_ARM_SHMOBILE_SCU_PREPARE is for ARM)?

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert at linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

* Re: [PATCH 01/21] arm64: FP/SIMD: Convert to hotplug state machine
  2016-09-06 17:04   ` Sebastian Andrzej Siewior
@ 2016-09-06 18:14     ` Will Deacon
  -1 siblings, 0 replies; 83+ messages in thread
From: Will Deacon @ 2016-09-06 18:14 UTC (permalink / raw)
  To: Sebastian Andrzej Siewior
  Cc: linux-kernel, Peter Zijlstra, Ingo Molnar, rt, tglx,
	Catalin Marinas, linux-arm-kernel

On Tue, Sep 06, 2016 at 07:04:37PM +0200, Sebastian Andrzej Siewior wrote:
> Install the callbacks via the state machine.
> 
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Cc: Will Deacon <will.deacon@arm.com>
> Cc: linux-arm-kernel@lists.infradead.org
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> ---
>  arch/arm64/kernel/fpsimd.c | 22 +++++-----------------
>  include/linux/cpuhotplug.h |  1 +
>  2 files changed, 6 insertions(+), 17 deletions(-)

Looks fine to me:

Acked-by: Will Deacon <will.deacon@arm.com>

> diff --git a/include/linux/cpuhotplug.h b/include/linux/cpuhotplug.h
> index afd59e2ca4b3..0da071ff36d2 100644
> --- a/include/linux/cpuhotplug.h
> +++ b/include/linux/cpuhotplug.h
> @@ -20,6 +20,7 @@ enum cpuhp_state {
>  	CPUHP_SOFTIRQ_DEAD,
>  	CPUHP_NET_MVNETA_DEAD,
>  	CPUHP_CPUIDLE_DEAD,
> +	CPUHP_ARM64_FPSIMD_DEAD,
>  	CPUHP_WORKQUEUE_PREP,
>  	CPUHP_POWER_NUMA_PREPARE,
>  	CPUHP_HRTIMERS_PREPARE,

Are you planning to take this via your tree? The arm64 queue already
touches cpuhotplug.h for the hw-breakpoint and debugmon changes, so
there's a simple conflict to address here.

Will

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

* [PATCH 01/21] arm64: FP/SIMD: Convert to hotplug state machine
@ 2016-09-06 18:14     ` Will Deacon
  0 siblings, 0 replies; 83+ messages in thread
From: Will Deacon @ 2016-09-06 18:14 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Sep 06, 2016 at 07:04:37PM +0200, Sebastian Andrzej Siewior wrote:
> Install the callbacks via the state machine.
> 
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Cc: Will Deacon <will.deacon@arm.com>
> Cc: linux-arm-kernel at lists.infradead.org
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> ---
>  arch/arm64/kernel/fpsimd.c | 22 +++++-----------------
>  include/linux/cpuhotplug.h |  1 +
>  2 files changed, 6 insertions(+), 17 deletions(-)

Looks fine to me:

Acked-by: Will Deacon <will.deacon@arm.com>

> diff --git a/include/linux/cpuhotplug.h b/include/linux/cpuhotplug.h
> index afd59e2ca4b3..0da071ff36d2 100644
> --- a/include/linux/cpuhotplug.h
> +++ b/include/linux/cpuhotplug.h
> @@ -20,6 +20,7 @@ enum cpuhp_state {
>  	CPUHP_SOFTIRQ_DEAD,
>  	CPUHP_NET_MVNETA_DEAD,
>  	CPUHP_CPUIDLE_DEAD,
> +	CPUHP_ARM64_FPSIMD_DEAD,
>  	CPUHP_WORKQUEUE_PREP,
>  	CPUHP_POWER_NUMA_PREPARE,
>  	CPUHP_HRTIMERS_PREPARE,

Are you planning to take this via your tree? The arm64 queue already
touches cpuhotplug.h for the hw-breakpoint and debugmon changes, so
there's a simple conflict to address here.

Will

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

* Re: [PATCH 11/21] ACPI: processor: Convert to hotplug state machine
  2016-09-06 17:04 ` [PATCH 11/21] ACPI: processor: " Sebastian Andrzej Siewior
@ 2016-09-06 21:08   ` Rafael J. Wysocki
  2016-09-07 14:01     ` Sebastian Andrzej Siewior
  2016-09-19 19:56   ` [tip:smp/hotplug] ACPI/processor: " tip-bot for Sebastian Andrzej Siewior
  1 sibling, 1 reply; 83+ messages in thread
From: Rafael J. Wysocki @ 2016-09-06 21:08 UTC (permalink / raw)
  To: Sebastian Andrzej Siewior
  Cc: Linux Kernel Mailing List, Peter Zijlstra, Ingo Molnar, rt,
	Thomas Gleixner, Rafael J. Wysocki, Len Brown,
	ACPI Devel Maling List

On Tue, Sep 6, 2016 at 7:04 PM, Sebastian Andrzej Siewior
<bigeasy@linutronix.de> wrote:
> Install the callbacks via the state machine.
>
> Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
> Cc: Len Brown <lenb@kernel.org>
> Cc: linux-acpi@vger.kernel.org
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>

This appears to be part of a series, but what if it goes in
separately?  Would that be a problem?

Thanks,
Rafael

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

* Re: [PATCH 12/21] cpufreq: Convert to hotplug state machine
  2016-09-06 17:04 ` [PATCH 12/21] cpufreq: " Sebastian Andrzej Siewior
@ 2016-09-06 21:27   ` Rafael J. Wysocki
  2016-09-07 14:18     ` Sebastian Andrzej Siewior
  2016-09-19 19:56   ` [tip:smp/hotplug] " tip-bot for Sebastian Andrzej Siewior
  1 sibling, 1 reply; 83+ messages in thread
From: Rafael J. Wysocki @ 2016-09-06 21:27 UTC (permalink / raw)
  To: Sebastian Andrzej Siewior
  Cc: Linux Kernel Mailing List, Peter Zijlstra, Ingo Molnar, rt,
	Thomas Gleixner, Rafael J. Wysocki, Viresh Kumar, Linux PM

On Tue, Sep 6, 2016 at 7:04 PM, Sebastian Andrzej Siewior
<bigeasy@linutronix.de> wrote:
> Install the callbacks via the state machine.
>
> Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
> Cc: Viresh Kumar <viresh.kumar@linaro.org>
> Cc: linux-pm@vger.kernel.org
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> ---
>  drivers/cpufreq/cpufreq.c | 38 ++++++++++++--------------------------
>  1 file changed, 12 insertions(+), 26 deletions(-)
>
> diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
> index 3dd4884c6f9e..e0bc632a259e 100644
> --- a/drivers/cpufreq/cpufreq.c
> +++ b/drivers/cpufreq/cpufreq.c
> @@ -1358,7 +1358,7 @@ static int cpufreq_add_dev(struct device *dev, struct subsys_interface *sif)
>         return add_cpu_dev_symlink(policy, cpu);
>  }
>
> -static void cpufreq_offline(unsigned int cpu)
> +static int cpufreq_offline(unsigned int cpu)
>  {
>         struct cpufreq_policy *policy;
>         int ret;
> @@ -1368,7 +1368,7 @@ static void cpufreq_offline(unsigned int cpu)
>         policy = cpufreq_cpu_get_raw(cpu);
>         if (!policy) {
>                 pr_debug("%s: No cpu_data found\n", __func__);
> -               return;
> +               return 0;
>         }
>
>         down_write(&policy->rwsem);
> @@ -1417,6 +1417,7 @@ static void cpufreq_offline(unsigned int cpu)
>
>  unlock:
>         up_write(&policy->rwsem);
> +       return 0;
>  }
>
>  /**
> @@ -2332,28 +2333,6 @@ int cpufreq_update_policy(unsigned int cpu)
>  }
>  EXPORT_SYMBOL(cpufreq_update_policy);
>
> -static int cpufreq_cpu_callback(struct notifier_block *nfb,
> -                                       unsigned long action, void *hcpu)
> -{
> -       unsigned int cpu = (unsigned long)hcpu;
> -
> -       switch (action & ~CPU_TASKS_FROZEN) {
> -       case CPU_ONLINE:
> -       case CPU_DOWN_FAILED:
> -               cpufreq_online(cpu);
> -               break;
> -
> -       case CPU_DOWN_PREPARE:
> -               cpufreq_offline(cpu);
> -               break;
> -       }
> -       return NOTIFY_OK;
> -}
> -
> -static struct notifier_block __refdata cpufreq_cpu_notifier = {
> -       .notifier_call = cpufreq_cpu_callback,
> -};
> -
>  /*********************************************************************
>   *               BOOST                                              *
>   *********************************************************************/
> @@ -2455,6 +2434,7 @@ EXPORT_SYMBOL_GPL(cpufreq_boost_enabled);
>  /*********************************************************************
>   *               REGISTER / UNREGISTER CPUFREQ DRIVER                *
>   *********************************************************************/
> +static enum cpuhp_state hp_online;
>
>  /**
>   * cpufreq_register_driver - register a CPU Frequency driver
> @@ -2517,7 +2497,13 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data)
>                 goto err_if_unreg;
>         }
>
> -       register_hotcpu_notifier(&cpufreq_cpu_notifier);
> +       ret = cpuhp_setup_state_nocalls(CPUHP_AP_ONLINE_DYN, "cpufreq:online",
> +                                       cpufreq_online,
> +                                       cpufreq_offline);
> +       if (ret < 0)
> +               goto err_if_unreg;
> +       hp_online = ret;

hp_online is enum cpuhp_state (and we pass it to
cpuhp_remove_state_nocalls(() later on), but
cpuhp_setup_state_nocalls() returns an int (and that should be 0 if it
is not an error code AFAICS), so is this actually correct?

Thanks,
Rafael

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

* Re: [PATCH 15/21] mips: octeon: smp: Convert to hotplug state machine
@ 2016-09-07  8:24     ` Matt Redfearn
  0 siblings, 0 replies; 83+ messages in thread
From: Matt Redfearn @ 2016-09-07  8:24 UTC (permalink / raw)
  To: Sebastian Andrzej Siewior, linux-kernel
  Cc: Peter Zijlstra, Ingo Molnar, rt, tglx, Ralf Baechle, linux-mips

HI Sebastian,


On 06/09/16 18:04, Sebastian Andrzej Siewior wrote:
> Install the callbacks via the state machine.
>
> Cc: Ralf Baechle <ralf@linux-mips.org>
> Cc: linux-mips@linux-mips.org
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> ---
>   arch/mips/cavium-octeon/smp.c | 24 +++---------------------
>   include/linux/cpuhotplug.h    |  1 +
>   2 files changed, 4 insertions(+), 21 deletions(-)
>
> diff --git a/arch/mips/cavium-octeon/smp.c b/arch/mips/cavium-octeon/smp.c
> index 4d457d602d3b..228c1cab2912 100644
> --- a/arch/mips/cavium-octeon/smp.c
> +++ b/arch/mips/cavium-octeon/smp.c
> @@ -380,29 +380,11 @@ static int octeon_update_boot_vector(unsigned int cpu)
>   	return 0;
>   }
>   
> -static int octeon_cpu_callback(struct notifier_block *nfb,
> -	unsigned long action, void *hcpu)
> -{
> -	unsigned int cpu = (unsigned long)hcpu;
> -
> -	switch (action & ~CPU_TASKS_FROZEN) {
> -	case CPU_UP_PREPARE:
> -		octeon_update_boot_vector(cpu);
> -		break;
> -	case CPU_ONLINE:
> -		pr_info("Cpu %d online\n", cpu);
> -		break;
> -	case CPU_DEAD:
> -		break;
> -	}
> -
> -	return NOTIFY_OK;
> -}
> -
>   static int register_cavium_notifier(void)
>   {
> -	hotcpu_notifier(octeon_cpu_callback, 0);
> -	return 0;
> +	return cpuhp_setup_state_nocalls(CPUHP_MIPS_CAVIUM_PREPARE,
> +					 "mips/cavium:prepare",
> +					 octeon_update_boot_vector, NULL);

This looks like a nice change which results in much cleaner code

>   }
>   late_initcall(register_cavium_notifier);
>   
> diff --git a/include/linux/cpuhotplug.h b/include/linux/cpuhotplug.h
> index 4cbf88c955d6..058d312fdf6f 100644
> --- a/include/linux/cpuhotplug.h
> +++ b/include/linux/cpuhotplug.h
> @@ -44,6 +44,7 @@ enum cpuhp_state {
>   	CPUHP_SH_SH3X_PREPARE,
>   	CPUHP_X86_MICRCODE_PREPARE,
>   	CPUHP_NOTF_ERR_INJ_PREPARE,
> +	CPUHP_MIPS_CAVIUM_PREPARE,

But I'm curious why we have to create a new state here - this is going 
to get very unwieldy if every variant of every architecture has to have 
it's own state values in that enumeration. Can this use, what I assume 
is (and perhaps could be documented better in 
include/linux/cpuhotplug.h), the generic prepare state CPUHP_NOTIFY_PREPARE?

Thanks,
Matt

>   	CPUHP_TIMERS_DEAD,
>   	CPUHP_BRINGUP_CPU,
>   	CPUHP_AP_IDLE_DEAD,

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

* Re: [PATCH 15/21] mips: octeon: smp: Convert to hotplug state machine
@ 2016-09-07  8:24     ` Matt Redfearn
  0 siblings, 0 replies; 83+ messages in thread
From: Matt Redfearn @ 2016-09-07  8:24 UTC (permalink / raw)
  To: Sebastian Andrzej Siewior, linux-kernel
  Cc: Peter Zijlstra, Ingo Molnar, rt, tglx, Ralf Baechle, linux-mips

HI Sebastian,


On 06/09/16 18:04, Sebastian Andrzej Siewior wrote:
> Install the callbacks via the state machine.
>
> Cc: Ralf Baechle <ralf@linux-mips.org>
> Cc: linux-mips@linux-mips.org
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> ---
>   arch/mips/cavium-octeon/smp.c | 24 +++---------------------
>   include/linux/cpuhotplug.h    |  1 +
>   2 files changed, 4 insertions(+), 21 deletions(-)
>
> diff --git a/arch/mips/cavium-octeon/smp.c b/arch/mips/cavium-octeon/smp.c
> index 4d457d602d3b..228c1cab2912 100644
> --- a/arch/mips/cavium-octeon/smp.c
> +++ b/arch/mips/cavium-octeon/smp.c
> @@ -380,29 +380,11 @@ static int octeon_update_boot_vector(unsigned int cpu)
>   	return 0;
>   }
>   
> -static int octeon_cpu_callback(struct notifier_block *nfb,
> -	unsigned long action, void *hcpu)
> -{
> -	unsigned int cpu = (unsigned long)hcpu;
> -
> -	switch (action & ~CPU_TASKS_FROZEN) {
> -	case CPU_UP_PREPARE:
> -		octeon_update_boot_vector(cpu);
> -		break;
> -	case CPU_ONLINE:
> -		pr_info("Cpu %d online\n", cpu);
> -		break;
> -	case CPU_DEAD:
> -		break;
> -	}
> -
> -	return NOTIFY_OK;
> -}
> -
>   static int register_cavium_notifier(void)
>   {
> -	hotcpu_notifier(octeon_cpu_callback, 0);
> -	return 0;
> +	return cpuhp_setup_state_nocalls(CPUHP_MIPS_CAVIUM_PREPARE,
> +					 "mips/cavium:prepare",
> +					 octeon_update_boot_vector, NULL);

This looks like a nice change which results in much cleaner code

>   }
>   late_initcall(register_cavium_notifier);
>   
> diff --git a/include/linux/cpuhotplug.h b/include/linux/cpuhotplug.h
> index 4cbf88c955d6..058d312fdf6f 100644
> --- a/include/linux/cpuhotplug.h
> +++ b/include/linux/cpuhotplug.h
> @@ -44,6 +44,7 @@ enum cpuhp_state {
>   	CPUHP_SH_SH3X_PREPARE,
>   	CPUHP_X86_MICRCODE_PREPARE,
>   	CPUHP_NOTF_ERR_INJ_PREPARE,
> +	CPUHP_MIPS_CAVIUM_PREPARE,

But I'm curious why we have to create a new state here - this is going 
to get very unwieldy if every variant of every architecture has to have 
it's own state values in that enumeration. Can this use, what I assume 
is (and perhaps could be documented better in 
include/linux/cpuhotplug.h), the generic prepare state CPUHP_NOTIFY_PREPARE?

Thanks,
Matt

>   	CPUHP_TIMERS_DEAD,
>   	CPUHP_BRINGUP_CPU,
>   	CPUHP_AP_IDLE_DEAD,

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

* Re: [PATCH 06/21] x86: microcode: Convert to hotplug state machine
  2016-09-06 17:04 ` [PATCH 06/21] x86: microcode: " Sebastian Andrzej Siewior
@ 2016-09-07 11:36   ` Borislav Petkov
  2016-09-07 14:51     ` Sebastian Andrzej Siewior
  2016-09-07 16:45     ` [PATCH 06/21 v2] " Sebastian Andrzej Siewior
  0 siblings, 2 replies; 83+ messages in thread
From: Borislav Petkov @ 2016-09-07 11:36 UTC (permalink / raw)
  To: Sebastian Andrzej Siewior
  Cc: linux-kernel, Peter Zijlstra, Ingo Molnar, rt, tglx

On Tue, Sep 06, 2016 at 07:04:42PM +0200, Sebastian Andrzej Siewior wrote:
> Install the callbacks via the state machine. There is little hackery with
> mc_cpu_dead() which should only be called if CPU_UP failed durin resume.
> This change may not fully represent the current behaviour. The current code
> also behaves different if the CPU does not come up in the _cpu_up() state vs
> one of the CPU_ONLINE notifier returned an error. Not sure what kind of a
> problem is solved here.

You mean this:

        /* The CPU refused to come up during a system resume */
        if (action == CPU_UP_CANCELED_FROZEN)
                microcode_fini_cpu(cpu);

?

It clears internal state, i.e., invalidates the current microcode patch.

> 
> Cc: Borislav Petkov <bp@alien8.de>
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> ---
>  arch/x86/kernel/cpu/microcode/core.c | 71 +++++++++++++++---------------------
>  include/linux/cpuhotplug.h           |  1 +
>  2 files changed, 30 insertions(+), 42 deletions(-)
> 
> diff --git a/arch/x86/kernel/cpu/microcode/core.c b/arch/x86/kernel/cpu/microcode/core.c
> index df04b2d033f6..4fc67b51e22e 100644
> --- a/arch/x86/kernel/cpu/microcode/core.c
> +++ b/arch/x86/kernel/cpu/microcode/core.c

...

> -static struct notifier_block mc_cpu_notifier = {
> -	.notifier_call	= mc_cpu_callback,
> -};
> +static int mc_cpu_down_prep(unsigned int cpu)
> +{
> +	struct device *dev;
> +
> +	dev = get_cpu_device(cpu);
> +	/* Suspend is in progress, only remove the interface */
> +	sysfs_remove_group(&dev->kobj, &mc_attr_group);
> +	pr_debug("CPU%d removed\n", cpu);
> +	return 0;
> +}
> +
> +static int mc_cpu_dead(unsigned int cpu)
> +{
> +#ifdef CONFIG_SMP
> +	if (cpuhp_tasks_frozen)
> +		microcode_fini_cpu(cpu);
> +#endif
> +	return 0;
> +}

If this is corresponding to CPU_DEAD, then I'd like to point to that comment:

        /*
         * case CPU_DEAD:
         *
         * When a CPU goes offline, don't free up or invalidate the copy of
         * the microcode in kernel memory, so that we can reuse it when the
         * CPU comes back online without unnecessarily requesting the userspace
         * for it again.
         */

IOW, you don't need mc_cpu_dead().

-- 
Regards/Gruss,
    Boris.

ECO tip #101: Trim your mails when you reply.

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

* Re: [PATCH 02/21] ARM: shmobile: Convert to hotplug state machine
  2016-09-06 18:05     ` Geert Uytterhoeven
  (?)
  (?)
@ 2016-09-07 13:58       ` Sebastian Andrzej Siewior
  -1 siblings, 0 replies; 83+ messages in thread
From: Sebastian Andrzej Siewior @ 2016-09-07 13:58 UTC (permalink / raw)
  To: linux-arm-kernel

On 2016-09-06 20:05:37 [+0200], Geert Uytterhoeven wrote:
> Hi Sebastian,
Hi Geert,

> Please describe why this is desirable.

We have now an old and new infrastructure in place to handle hotplug
notifications while a CPU goes up and/or down. We want to get rid of the
old infrastructure and are converting its users away. 

> > diff --git a/include/linux/cpuhotplug.h b/include/linux/cpuhotplug.h
> > index 0da071ff36d2..008eed0c0787 100644
> > --- a/include/linux/cpuhotplug.h
> > +++ b/include/linux/cpuhotplug.h
> > @@ -35,6 +35,7 @@ enum cpuhp_state {
> >         CPUHP_POWERPC_PMAC_PREPARE,
> >         CPUHP_POWERPC_MMU_CTX_PREPARE,
> >         CPUHP_NOTIFY_PREPARE,
> > +       CPUHP_ARM_SHMOBILE_SCU_PREPARE,
> >         CPUHP_TIMERS_DEAD,
> >         CPUHP_BRINGUP_CPU,
> >         CPUHP_AP_IDLE_DEAD,
> 
> What's the rationale behind adding all these numbers and always
> iterating over all
> of them, even though most/all of them cannot be used at the same time
> (e.g. CPUHP_SH_SH3X_PREPARE is for SuperH, while
>  CPUHP_ARM_SHMOBILE_SCU_PREPARE is for ARM)?

PREPARE + STARTING states require static ids. The online callback has
dynamic allocations of ids since it was assumed that this is the most
common one.
We will most likely evaluate the situation once we done and total number
of IDS are not acceptable.

> 
> Gr{oetje,eeting}s,
> 
>                         Geert
> 

Sebastian

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

* Re: [PATCH 02/21] ARM: shmobile: Convert to hotplug state machine
@ 2016-09-07 13:58       ` Sebastian Andrzej Siewior
  0 siblings, 0 replies; 83+ messages in thread
From: Sebastian Andrzej Siewior @ 2016-09-07 13:58 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: linux-kernel, Peter Zijlstra, Ingo Molnar, rt, Thomas Gleixner,
	Simon Horman, Magnus Damm, linux-arm-kernel, Linux-sh list,
	Linux-Renesas

On 2016-09-06 20:05:37 [+0200], Geert Uytterhoeven wrote:
> Hi Sebastian,
Hi Geert,

> Please describe why this is desirable.

We have now an old and new infrastructure in place to handle hotplug
notifications while a CPU goes up and/or down. We want to get rid of the
old infrastructure and are converting its users away. 

> > diff --git a/include/linux/cpuhotplug.h b/include/linux/cpuhotplug.h
> > index 0da071ff36d2..008eed0c0787 100644
> > --- a/include/linux/cpuhotplug.h
> > +++ b/include/linux/cpuhotplug.h
> > @@ -35,6 +35,7 @@ enum cpuhp_state {
> >         CPUHP_POWERPC_PMAC_PREPARE,
> >         CPUHP_POWERPC_MMU_CTX_PREPARE,
> >         CPUHP_NOTIFY_PREPARE,
> > +       CPUHP_ARM_SHMOBILE_SCU_PREPARE,
> >         CPUHP_TIMERS_DEAD,
> >         CPUHP_BRINGUP_CPU,
> >         CPUHP_AP_IDLE_DEAD,
> 
> What's the rationale behind adding all these numbers and always
> iterating over all
> of them, even though most/all of them cannot be used at the same time
> (e.g. CPUHP_SH_SH3X_PREPARE is for SuperH, while
>  CPUHP_ARM_SHMOBILE_SCU_PREPARE is for ARM)?

PREPARE + STARTING states require static ids. The online callback has
dynamic allocations of ids since it was assumed that this is the most
common one.
We will most likely evaluate the situation once we done and total number
of IDS are not acceptable.

> 
> Gr{oetje,eeting}s,
> 
>                         Geert
> 

Sebastian

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

* Re: [PATCH 02/21] ARM: shmobile: Convert to hotplug state machine
@ 2016-09-07 13:58       ` Sebastian Andrzej Siewior
  0 siblings, 0 replies; 83+ messages in thread
From: Sebastian Andrzej Siewior @ 2016-09-07 13:58 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: linux-kernel, Peter Zijlstra, Ingo Molnar, rt, Thomas Gleixner,
	Simon Horman, Magnus Damm, linux-arm-kernel, Linux-sh list,
	Linux-Renesas

On 2016-09-06 20:05:37 [+0200], Geert Uytterhoeven wrote:
> Hi Sebastian,
Hi Geert,

> Please describe why this is desirable.

We have now an old and new infrastructure in place to handle hotplug
notifications while a CPU goes up and/or down. We want to get rid of the
old infrastructure and are converting its users away. 

> > diff --git a/include/linux/cpuhotplug.h b/include/linux/cpuhotplug.h
> > index 0da071ff36d2..008eed0c0787 100644
> > --- a/include/linux/cpuhotplug.h
> > +++ b/include/linux/cpuhotplug.h
> > @@ -35,6 +35,7 @@ enum cpuhp_state {
> >         CPUHP_POWERPC_PMAC_PREPARE,
> >         CPUHP_POWERPC_MMU_CTX_PREPARE,
> >         CPUHP_NOTIFY_PREPARE,
> > +       CPUHP_ARM_SHMOBILE_SCU_PREPARE,
> >         CPUHP_TIMERS_DEAD,
> >         CPUHP_BRINGUP_CPU,
> >         CPUHP_AP_IDLE_DEAD,
> 
> What's the rationale behind adding all these numbers and always
> iterating over all
> of them, even though most/all of them cannot be used at the same time
> (e.g. CPUHP_SH_SH3X_PREPARE is for SuperH, while
>  CPUHP_ARM_SHMOBILE_SCU_PREPARE is for ARM)?

PREPARE + STARTING states require static ids. The online callback has
dynamic allocations of ids since it was assumed that this is the most
common one.
We will most likely evaluate the situation once we done and total number
of IDS are not acceptable.

> 
> Gr{oetje,eeting}s,
> 
>                         Geert
> 

Sebastian

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

* [PATCH 02/21] ARM: shmobile: Convert to hotplug state machine
@ 2016-09-07 13:58       ` Sebastian Andrzej Siewior
  0 siblings, 0 replies; 83+ messages in thread
From: Sebastian Andrzej Siewior @ 2016-09-07 13:58 UTC (permalink / raw)
  To: linux-arm-kernel

On 2016-09-06 20:05:37 [+0200], Geert Uytterhoeven wrote:
> Hi Sebastian,
Hi Geert,

> Please describe why this is desirable.

We have now an old and new infrastructure in place to handle hotplug
notifications while a CPU goes up and/or down. We want to get rid of the
old infrastructure and are converting its users away. 

> > diff --git a/include/linux/cpuhotplug.h b/include/linux/cpuhotplug.h
> > index 0da071ff36d2..008eed0c0787 100644
> > --- a/include/linux/cpuhotplug.h
> > +++ b/include/linux/cpuhotplug.h
> > @@ -35,6 +35,7 @@ enum cpuhp_state {
> >         CPUHP_POWERPC_PMAC_PREPARE,
> >         CPUHP_POWERPC_MMU_CTX_PREPARE,
> >         CPUHP_NOTIFY_PREPARE,
> > +       CPUHP_ARM_SHMOBILE_SCU_PREPARE,
> >         CPUHP_TIMERS_DEAD,
> >         CPUHP_BRINGUP_CPU,
> >         CPUHP_AP_IDLE_DEAD,
> 
> What's the rationale behind adding all these numbers and always
> iterating over all
> of them, even though most/all of them cannot be used at the same time
> (e.g. CPUHP_SH_SH3X_PREPARE is for SuperH, while
>  CPUHP_ARM_SHMOBILE_SCU_PREPARE is for ARM)?

PREPARE + STARTING states require static ids. The online callback has
dynamic allocations of ids since it was assumed that this is the most
common one.
We will most likely evaluate the situation once we done and total number
of IDS are not acceptable.

> 
> Gr{oetje,eeting}s,
> 
>                         Geert
> 

Sebastian

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

* Re: [PATCH 11/21] ACPI: processor: Convert to hotplug state machine
  2016-09-06 21:08   ` Rafael J. Wysocki
@ 2016-09-07 14:01     ` Sebastian Andrzej Siewior
  2016-09-07 15:59       ` Rafael J. Wysocki
  0 siblings, 1 reply; 83+ messages in thread
From: Sebastian Andrzej Siewior @ 2016-09-07 14:01 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Linux Kernel Mailing List, Peter Zijlstra, Ingo Molnar, rt,
	Thomas Gleixner, Rafael J. Wysocki, Len Brown,
	ACPI Devel Maling List

On 2016-09-06 23:08:28 [+0200], Rafael J. Wysocki wrote:
> This appears to be part of a series, but what if it goes in
> separately?  Would that be a problem?

You would have to deal with conflicts in cpuhotplug.h. All other
requirements are merged.

> Thanks,
> Rafael

Sebastian

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

* Re: [PATCH 12/21] cpufreq: Convert to hotplug state machine
  2016-09-06 21:27   ` Rafael J. Wysocki
@ 2016-09-07 14:18     ` Sebastian Andrzej Siewior
  2016-09-07 15:58       ` Rafael J. Wysocki
  0 siblings, 1 reply; 83+ messages in thread
From: Sebastian Andrzej Siewior @ 2016-09-07 14:18 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Linux Kernel Mailing List, Peter Zijlstra, Ingo Molnar, rt,
	Thomas Gleixner, Rafael J. Wysocki, Viresh Kumar, Linux PM

On 2016-09-06 23:27:46 [+0200], Rafael J. Wysocki wrote:
> > +       ret = cpuhp_setup_state_nocalls(CPUHP_AP_ONLINE_DYN, "cpufreq:online",
> > +                                       cpufreq_online,
> > +                                       cpufreq_offline);
> > +       if (ret < 0)
> > +               goto err_if_unreg;
> > +       hp_online = ret;
> 
> hp_online is enum cpuhp_state (and we pass it to
> cpuhp_remove_state_nocalls(() later on), but
> cpuhp_setup_state_nocalls() returns an int (and that should be 0 if it
> is not an error code AFAICS), so is this actually correct?

Not sure what you are pointing out here. Let me try to cover it.
cpuhp_setup_state_nocalls() return <0 for errors. Those are are not
assigned to hp_online. It returns 0 for success on ID was !=
CPUHP_AP_ONLINE_DYN and >= 0 for success if ID was CPUHP_AP_ONLINE_DYN.
In the latter case the dynamic assigned ID is returned which should be
used if you plan to remove the callbacks.
Assigning an unsigned int to enum is okay because enumeration constants
itself should be an int.

> Thanks,
> Rafael

Sebastian

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

* Re: [PATCH 15/21] mips: octeon: smp: Convert to hotplug state machine
  2016-09-07  8:24     ` Matt Redfearn
  (?)
@ 2016-09-07 14:27     ` Sebastian Andrzej Siewior
  2016-09-08  8:34         ` Matt Redfearn
  -1 siblings, 1 reply; 83+ messages in thread
From: Sebastian Andrzej Siewior @ 2016-09-07 14:27 UTC (permalink / raw)
  To: Matt Redfearn
  Cc: linux-kernel, Peter Zijlstra, Ingo Molnar, rt, tglx,
	Ralf Baechle, linux-mips

On 2016-09-07 09:24:57 [+0100], Matt Redfearn wrote:
> HI Sebastian,
Hi Matt,

> > --- a/include/linux/cpuhotplug.h
> > +++ b/include/linux/cpuhotplug.h
> > @@ -44,6 +44,7 @@ enum cpuhp_state {
> >   	CPUHP_SH_SH3X_PREPARE,
> >   	CPUHP_X86_MICRCODE_PREPARE,
> >   	CPUHP_NOTF_ERR_INJ_PREPARE,
> > +	CPUHP_MIPS_CAVIUM_PREPARE,
> 
> But I'm curious why we have to create a new state here - this is going to
> get very unwieldy if every variant of every architecture has to have it's
> own state values in that enumeration. Can this use, what I assume is (and
> perhaps could be documented better in include/linux/cpuhotplug.h), the
> generic prepare state CPUHP_NOTIFY_PREPARE?

We can't share the states - one state is for one callback and one
callback only. If you want CPUHP_MIPS_PREPARE and you ensure that this
used only _once_ then this can be arranged.
For online states we have dynamic allocation of ids (which is what most
drivers should use). We don't have this of STARTING + PREPARE callbacks.

> Thanks,
> Matt
> 

Sebastian

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

* Re: [PATCH 06/21] x86: microcode: Convert to hotplug state machine
  2016-09-07 11:36   ` Borislav Petkov
@ 2016-09-07 14:51     ` Sebastian Andrzej Siewior
  2016-09-07 16:02       ` Borislav Petkov
  2016-09-07 16:45     ` [PATCH 06/21 v2] " Sebastian Andrzej Siewior
  1 sibling, 1 reply; 83+ messages in thread
From: Sebastian Andrzej Siewior @ 2016-09-07 14:51 UTC (permalink / raw)
  To: Borislav Petkov; +Cc: linux-kernel, Peter Zijlstra, Ingo Molnar, rt, tglx

On 2016-09-07 13:36:40 [+0200], Borislav Petkov wrote:
> You mean this:
> 
>         /* The CPU refused to come up during a system resume */
>         if (action == CPU_UP_CANCELED_FROZEN)
>                 microcode_fini_cpu(cpu);
correct.
> ?
> 
> It clears internal state, i.e., invalidates the current microcode patch.

it cleans the memory on Intel but not on AMD

> > diff --git a/arch/x86/kernel/cpu/microcode/core.c b/arch/x86/kernel/cpu/microcode/core.c
> > index df04b2d033f6..4fc67b51e22e 100644
> > --- a/arch/x86/kernel/cpu/microcode/core.c
> > +++ b/arch/x86/kernel/cpu/microcode/core.c
> 
> ...
> 
> > -static struct notifier_block mc_cpu_notifier = {
> > -	.notifier_call	= mc_cpu_callback,
> > -};
> > +static int mc_cpu_down_prep(unsigned int cpu)
> > +{
> > +	struct device *dev;
> > +
> > +	dev = get_cpu_device(cpu);
> > +	/* Suspend is in progress, only remove the interface */
> > +	sysfs_remove_group(&dev->kobj, &mc_attr_group);
> > +	pr_debug("CPU%d removed\n", cpu);
> > +	return 0;
> > +}
> > +
> > +static int mc_cpu_dead(unsigned int cpu)
> > +{
> > +#ifdef CONFIG_SMP
> > +	if (cpuhp_tasks_frozen)
> > +		microcode_fini_cpu(cpu);
> > +#endif
> > +	return 0;
> > +}
> 
> If this is corresponding to CPU_DEAD, then I'd like to point to that comment:
> 
>         /*
>          * case CPU_DEAD:
>          *
>          * When a CPU goes offline, don't free up or invalidate the copy of
>          * the microcode in kernel memory, so that we can reuse it when the
>          * CPU comes back online without unnecessarily requesting the userspace
>          * for it again.
>          */
> 
> IOW, you don't need mc_cpu_dead().
Okay. After a second look I would say so, too. On Intel we free memory
in this case but we don't set uci->valid back. Which means if the CPU
did not come up after resume we free the memory. If we try it (manually)
again and for some reason the CPU manages to get up, it will end up in
the ONLINE callback with no memory and uci->valid set.

I will prepare a patch with the DEAD state gone.

Sebastian

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

* Re: [PATCH 12/21] cpufreq: Convert to hotplug state machine
  2016-09-07 14:18     ` Sebastian Andrzej Siewior
@ 2016-09-07 15:58       ` Rafael J. Wysocki
  0 siblings, 0 replies; 83+ messages in thread
From: Rafael J. Wysocki @ 2016-09-07 15:58 UTC (permalink / raw)
  To: Sebastian Andrzej Siewior
  Cc: Rafael J. Wysocki, Linux Kernel Mailing List, Peter Zijlstra,
	Ingo Molnar, rt, Thomas Gleixner, Viresh Kumar, Linux PM

On Wednesday, September 07, 2016 04:18:29 PM Sebastian Andrzej Siewior wrote:
> On 2016-09-06 23:27:46 [+0200], Rafael J. Wysocki wrote:
> > > +       ret = cpuhp_setup_state_nocalls(CPUHP_AP_ONLINE_DYN, "cpufreq:online",
> > > +                                       cpufreq_online,
> > > +                                       cpufreq_offline);
> > > +       if (ret < 0)
> > > +               goto err_if_unreg;
> > > +       hp_online = ret;
> > 
> > hp_online is enum cpuhp_state (and we pass it to
> > cpuhp_remove_state_nocalls(() later on), but
> > cpuhp_setup_state_nocalls() returns an int (and that should be 0 if it
> > is not an error code AFAICS), so is this actually correct?
> 
> Not sure what you are pointing out here. Let me try to cover it.
> cpuhp_setup_state_nocalls() return <0 for errors. Those are are not
> assigned to hp_online. It returns 0 for success on ID was !=
> CPUHP_AP_ONLINE_DYN and >= 0 for success if ID was CPUHP_AP_ONLINE_DYN.
> In the latter case the dynamic assigned ID is returned which should be
> used if you plan to remove the callbacks.

OK, that last part wasn't clear to me.  The kerneldoc comment for
__cpuhp_setup_state() doesn't mention the possible non-zero return values
on success, which is a bit confusing IMHO.

> Assigning an unsigned int to enum is okay because enumeration constants
> itself should be an int.

But the unsigned int still may be out of range for the given enum, so I
wouldn't call it particularly clean. :-)

Anyway, please feel free to add

Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

to the patch.

Thanks,
Rafael

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

* Re: [PATCH 11/21] ACPI: processor: Convert to hotplug state machine
  2016-09-07 14:01     ` Sebastian Andrzej Siewior
@ 2016-09-07 15:59       ` Rafael J. Wysocki
  0 siblings, 0 replies; 83+ messages in thread
From: Rafael J. Wysocki @ 2016-09-07 15:59 UTC (permalink / raw)
  To: Sebastian Andrzej Siewior
  Cc: Rafael J. Wysocki, Linux Kernel Mailing List, Peter Zijlstra,
	Ingo Molnar, rt, Thomas Gleixner, Len Brown,
	ACPI Devel Maling List

On Wednesday, September 07, 2016 04:01:02 PM Sebastian Andrzej Siewior wrote:
> On 2016-09-06 23:08:28 [+0200], Rafael J. Wysocki wrote:
> > This appears to be part of a series, but what if it goes in
> > separately?  Would that be a problem?
> 
> You would have to deal with conflicts in cpuhotplug.h. All other
> requirements are merged.

OK

Please feel free to add

Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

and route it via tip.

Thanks,
Rafael

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

* Re: [PATCH 06/21] x86: microcode: Convert to hotplug state machine
  2016-09-07 14:51     ` Sebastian Andrzej Siewior
@ 2016-09-07 16:02       ` Borislav Petkov
  0 siblings, 0 replies; 83+ messages in thread
From: Borislav Petkov @ 2016-09-07 16:02 UTC (permalink / raw)
  To: Sebastian Andrzej Siewior
  Cc: linux-kernel, Peter Zijlstra, Ingo Molnar, rt, tglx

On Wed, Sep 07, 2016 at 04:51:47PM +0200, Sebastian Andrzej Siewior wrote:
> it cleans the memory on Intel but not on AMD

Check again. -> microcode_fini_cpu_amd()

-- 
Regards/Gruss,
    Boris.

ECO tip #101: Trim your mails when you reply.

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

* [PATCH 06/21 v2] x86: microcode: Convert to hotplug state machine
  2016-09-07 11:36   ` Borislav Petkov
  2016-09-07 14:51     ` Sebastian Andrzej Siewior
@ 2016-09-07 16:45     ` Sebastian Andrzej Siewior
  2016-09-19 19:54       ` [tip:smp/hotplug] x86/microcode: " tip-bot for Sebastian Andrzej Siewior
  1 sibling, 1 reply; 83+ messages in thread
From: Sebastian Andrzej Siewior @ 2016-09-07 16:45 UTC (permalink / raw)
  To: Borislav Petkov; +Cc: linux-kernel, Peter Zijlstra, Ingo Molnar, rt, tglx

Install the callbacks via the state machine. 
CPU_UP_CANCELED_FROZEN() is not preserved: It is only here to free memory in an
error case because it is assumed if the CPU does show up on resume it won't be
seen ever again. As per Borislav:
|IOW, you don't need mc_cpu_dead().

Cc: Borislav Petkov <bp@alien8.de>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
v1…v2: removal of mc_cpu_dead()

 arch/x86/kernel/cpu/microcode/core.c |   54 +++++++++++------------------------
 1 file changed, 18 insertions(+), 36 deletions(-)

--- a/arch/x86/kernel/cpu/microcode/core.c
+++ b/arch/x86/kernel/cpu/microcode/core.c
@@ -558,55 +558,36 @@ static struct syscore_ops mc_syscore_ops
 	.resume			= mc_bp_resume,
 };
 
-static int
-mc_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu)
+static int mc_cpu_online(unsigned int cpu)
 {
-	unsigned int cpu = (unsigned long)hcpu;
 	struct device *dev;
 
 	dev = get_cpu_device(cpu);
+	microcode_update_cpu(cpu);
+	pr_debug("CPU%d added\n", cpu);
 
-	switch (action & ~CPU_TASKS_FROZEN) {
-	case CPU_ONLINE:
-		microcode_update_cpu(cpu);
-		pr_debug("CPU%d added\n", cpu);
-		/*
-		 * "break" is missing on purpose here because we want to fall
-		 * through in order to create the sysfs group.
-		 */
-
-	case CPU_DOWN_FAILED:
-		if (sysfs_create_group(&dev->kobj, &mc_attr_group))
-			pr_err("Failed to create group for CPU%d\n", cpu);
-		break;
-
-	case CPU_DOWN_PREPARE:
-		/* Suspend is in progress, only remove the interface */
-		sysfs_remove_group(&dev->kobj, &mc_attr_group);
-		pr_debug("CPU%d removed\n", cpu);
-		break;
+	if (sysfs_create_group(&dev->kobj, &mc_attr_group))
+		pr_err("Failed to create group for CPU%d\n", cpu);
+	return 0;
+}
 
+static int mc_cpu_down_prep(unsigned int cpu)
+{
+	struct device *dev;
+
+	dev = get_cpu_device(cpu);
+	/* Suspend is in progress, only remove the interface */
+	sysfs_remove_group(&dev->kobj, &mc_attr_group);
+	pr_debug("CPU%d removed\n", cpu);
 	/*
-	 * case CPU_DEAD:
-	 *
 	 * When a CPU goes offline, don't free up or invalidate the copy of
 	 * the microcode in kernel memory, so that we can reuse it when the
 	 * CPU comes back online without unnecessarily requesting the userspace
 	 * for it again.
 	 */
-	}
-
-	/* The CPU refused to come up during a system resume */
-	if (action == CPU_UP_CANCELED_FROZEN)
-		microcode_fini_cpu(cpu);
-
-	return NOTIFY_OK;
+	return 0;
 }
 
-static struct notifier_block mc_cpu_notifier = {
-	.notifier_call	= mc_cpu_callback,
-};
-
 static struct attribute *cpu_root_microcode_attrs[] = {
 	&dev_attr_reload.attr,
 	NULL
@@ -665,7 +646,8 @@ int __init microcode_init(void)
 		goto out_ucode_group;
 
 	register_syscore_ops(&mc_syscore_ops);
-	register_hotcpu_notifier(&mc_cpu_notifier);
+	cpuhp_setup_state_nocalls(CPUHP_AP_ONLINE_DYN, "x86/microcode:online",
+				  mc_cpu_online, mc_cpu_down_prep);
 
 	pr_info("Microcode Update Driver: v" MICROCODE_VERSION
 		" <tigran@aivazian.fsnet.co.uk>, Peter Oruba\n");

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

* Re: [PATCH 15/21] mips: octeon: smp: Convert to hotplug state machine
@ 2016-09-08  8:34         ` Matt Redfearn
  0 siblings, 0 replies; 83+ messages in thread
From: Matt Redfearn @ 2016-09-08  8:34 UTC (permalink / raw)
  To: Sebastian Andrzej Siewior
  Cc: linux-kernel, Peter Zijlstra, Ingo Molnar, rt, tglx,
	Ralf Baechle, linux-mips

Hi Sebastian


On 07/09/16 15:27, Sebastian Andrzej Siewior wrote:
> On 2016-09-07 09:24:57 [+0100], Matt Redfearn wrote:
>> HI Sebastian,
> Hi Matt,
>
>>> --- a/include/linux/cpuhotplug.h
>>> +++ b/include/linux/cpuhotplug.h
>>> @@ -44,6 +44,7 @@ enum cpuhp_state {
>>>    	CPUHP_SH_SH3X_PREPARE,
>>>    	CPUHP_X86_MICRCODE_PREPARE,
>>>    	CPUHP_NOTF_ERR_INJ_PREPARE,
>>> +	CPUHP_MIPS_CAVIUM_PREPARE,
>> But I'm curious why we have to create a new state here - this is going to
>> get very unwieldy if every variant of every architecture has to have it's
>> own state values in that enumeration. Can this use, what I assume is (and
>> perhaps could be documented better in include/linux/cpuhotplug.h), the
>> generic prepare state CPUHP_NOTIFY_PREPARE?
> We can't share the states - one state is for one callback and one
> callback only. If you want CPUHP_MIPS_PREPARE and you ensure that this
> used only _once_ then this can be arranged.
> For online states we have dynamic allocation of ids (which is what most
> drivers should use). We don't have this of STARTING + PREPARE callbacks.

OK, fair enough - it just feels slightly unwieldy. That enumeration is 
going to grow to an enormous size to store every single callback which 
could be used, when no kernel is going to use all states, the majority 
of which exist for other architectures. As a result cpuhp_bp_states and 
cpuhp_ap_states are going to waste memory storing states that the kernel 
won't use.
But that's the design decision taken, so fine. I think we have to keep 
one enumeration value associated with one callback definition - anything 
else is going to end in a mess, so lets keep the values as you suggest.

Thanks,
Matt


>
>> Thanks,
>> Matt
>>
> Sebastian

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

* Re: [PATCH 15/21] mips: octeon: smp: Convert to hotplug state machine
@ 2016-09-08  8:34         ` Matt Redfearn
  0 siblings, 0 replies; 83+ messages in thread
From: Matt Redfearn @ 2016-09-08  8:34 UTC (permalink / raw)
  To: Sebastian Andrzej Siewior
  Cc: linux-kernel, Peter Zijlstra, Ingo Molnar, rt, tglx,
	Ralf Baechle, linux-mips

Hi Sebastian


On 07/09/16 15:27, Sebastian Andrzej Siewior wrote:
> On 2016-09-07 09:24:57 [+0100], Matt Redfearn wrote:
>> HI Sebastian,
> Hi Matt,
>
>>> --- a/include/linux/cpuhotplug.h
>>> +++ b/include/linux/cpuhotplug.h
>>> @@ -44,6 +44,7 @@ enum cpuhp_state {
>>>    	CPUHP_SH_SH3X_PREPARE,
>>>    	CPUHP_X86_MICRCODE_PREPARE,
>>>    	CPUHP_NOTF_ERR_INJ_PREPARE,
>>> +	CPUHP_MIPS_CAVIUM_PREPARE,
>> But I'm curious why we have to create a new state here - this is going to
>> get very unwieldy if every variant of every architecture has to have it's
>> own state values in that enumeration. Can this use, what I assume is (and
>> perhaps could be documented better in include/linux/cpuhotplug.h), the
>> generic prepare state CPUHP_NOTIFY_PREPARE?
> We can't share the states - one state is for one callback and one
> callback only. If you want CPUHP_MIPS_PREPARE and you ensure that this
> used only _once_ then this can be arranged.
> For online states we have dynamic allocation of ids (which is what most
> drivers should use). We don't have this of STARTING + PREPARE callbacks.

OK, fair enough - it just feels slightly unwieldy. That enumeration is 
going to grow to an enormous size to store every single callback which 
could be used, when no kernel is going to use all states, the majority 
of which exist for other architectures. As a result cpuhp_bp_states and 
cpuhp_ap_states are going to waste memory storing states that the kernel 
won't use.
But that's the design decision taken, so fine. I think we have to keep 
one enumeration value associated with one callback definition - anything 
else is going to end in a mess, so lets keep the values as you suggest.

Thanks,
Matt


>
>> Thanks,
>> Matt
>>
> Sebastian

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

* Re: [PATCH 03/21] ARM: OMAP: wakeupgen: Convert to hotplug state machine
  2016-09-06 17:04   ` Sebastian Andrzej Siewior
@ 2016-09-13 22:24     ` Tony Lindgren
  -1 siblings, 0 replies; 83+ messages in thread
From: Tony Lindgren @ 2016-09-13 22:24 UTC (permalink / raw)
  To: Sebastian Andrzej Siewior
  Cc: linux-kernel, Peter Zijlstra, Ingo Molnar, rt, tglx, linux-omap,
	linux-arm-kernel

* Sebastian Andrzej Siewior <bigeasy@linutronix.de> [160906 10:06]:
> Install the callbacks via the state machine.

Assuming this will get merged with the series:

Acked-by: Tony Lindgren <tony@atomide.com>

If you want me to pick it, please let me know.

Regards,

Tony

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

* [PATCH 03/21] ARM: OMAP: wakeupgen: Convert to hotplug state machine
@ 2016-09-13 22:24     ` Tony Lindgren
  0 siblings, 0 replies; 83+ messages in thread
From: Tony Lindgren @ 2016-09-13 22:24 UTC (permalink / raw)
  To: linux-arm-kernel

* Sebastian Andrzej Siewior <bigeasy@linutronix.de> [160906 10:06]:
> Install the callbacks via the state machine.

Assuming this will get merged with the series:

Acked-by: Tony Lindgren <tony@atomide.com>

If you want me to pick it, please let me know.

Regards,

Tony

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

* Re: [PATCH 15/21] mips: octeon: smp: Convert to hotplug state machine
  2016-09-06 17:04 ` [PATCH 15/21] mips: octeon: smp: " Sebastian Andrzej Siewior
  2016-09-07  8:24     ` Matt Redfearn
@ 2016-09-19 15:10   ` Ralf Baechle
  2016-09-19 19:58   ` [tip:smp/hotplug] mips/octeon/smp: " tip-bot for Sebastian Andrzej Siewior
  2 siblings, 0 replies; 83+ messages in thread
From: Ralf Baechle @ 2016-09-19 15:10 UTC (permalink / raw)
  To: Sebastian Andrzej Siewior
  Cc: linux-kernel, Peter Zijlstra, Ingo Molnar, rt, tglx, linux-mips

On Tue, Sep 06, 2016 at 07:04:51PM +0200, Sebastian Andrzej Siewior wrote:

I assume you want to upstream this as a single pull request, so

Acked-by: Ralf Baechle <ralf@linux-mips.org>

  Ralf

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

* Re: [PATCH 16/21] mips: loongson: smp: Convert to hotplug state machine
  2016-09-06 17:04 ` [PATCH 16/21] mips: loongson: smp: " Sebastian Andrzej Siewior
@ 2016-09-19 15:10   ` Ralf Baechle
  2016-09-19 19:58   ` [tip:smp/hotplug] mips/loongson/smp: " tip-bot for Sebastian Andrzej Siewior
  1 sibling, 0 replies; 83+ messages in thread
From: Ralf Baechle @ 2016-09-19 15:10 UTC (permalink / raw)
  To: Sebastian Andrzej Siewior
  Cc: linux-kernel, Peter Zijlstra, Ingo Molnar, rt, tglx, linux-mips

On Tue, Sep 06, 2016 at 07:04:52PM +0200, Sebastian Andrzej Siewior wrote:

> Install the callbacks via the state machine.

Same here, I assume you want to upstream this as a single pull request, so

Acked-by: Ralf Baechle <ralf@linux-mips.org>

  Ralf

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

* [tip:smp/hotplug] arm64/FP/SIMD: Convert to hotplug state machine
  2016-09-06 17:04   ` Sebastian Andrzej Siewior
  (?)
  (?)
@ 2016-09-19 19:51   ` tip-bot for Sebastian Andrzej Siewior
  -1 siblings, 0 replies; 83+ messages in thread
From: tip-bot for Sebastian Andrzej Siewior @ 2016-09-19 19:51 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: mingo, peterz, hpa, catalin.marinas, bigeasy, will.deacon, tglx,
	linux-kernel

Commit-ID:  c23a7266e6599e74305cc5b790f93398bb212380
Gitweb:     http://git.kernel.org/tip/c23a7266e6599e74305cc5b790f93398bb212380
Author:     Sebastian Andrzej Siewior <bigeasy@linutronix.de>
AuthorDate: Tue, 6 Sep 2016 19:04:37 +0200
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Mon, 19 Sep 2016 21:44:25 +0200

arm64/FP/SIMD: Convert to hotplug state machine

Install the callbacks via the state machine.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Acked-by: Will Deacon <will.deacon@arm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: rt@linutronix.de
Cc: linux-arm-kernel@lists.infradead.org
Link: http://lkml.kernel.org/r/20160906170457.32393-2-bigeasy@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

---
 arch/arm64/kernel/fpsimd.c | 22 +++++-----------------
 include/linux/cpuhotplug.h |  1 +
 2 files changed, 6 insertions(+), 17 deletions(-)

diff --git a/arch/arm64/kernel/fpsimd.c b/arch/arm64/kernel/fpsimd.c
index 975b274..394c61d 100644
--- a/arch/arm64/kernel/fpsimd.c
+++ b/arch/arm64/kernel/fpsimd.c
@@ -299,28 +299,16 @@ static inline void fpsimd_pm_init(void) { }
 #endif /* CONFIG_CPU_PM */
 
 #ifdef CONFIG_HOTPLUG_CPU
-static int fpsimd_cpu_hotplug_notifier(struct notifier_block *nfb,
-				       unsigned long action,
-				       void *hcpu)
+static int fpsimd_cpu_dead(unsigned int cpu)
 {
-	unsigned int cpu = (long)hcpu;
-
-	switch (action) {
-	case CPU_DEAD:
-	case CPU_DEAD_FROZEN:
-		per_cpu(fpsimd_last_state, cpu) = NULL;
-		break;
-	}
-	return NOTIFY_OK;
+	per_cpu(fpsimd_last_state, cpu) = NULL;
+	return 0;
 }
 
-static struct notifier_block fpsimd_cpu_hotplug_notifier_block = {
-	.notifier_call = fpsimd_cpu_hotplug_notifier,
-};
-
 static inline void fpsimd_hotplug_init(void)
 {
-	register_cpu_notifier(&fpsimd_cpu_hotplug_notifier_block);
+	cpuhp_setup_state_nocalls(CPUHP_ARM64_FPSIMD_DEAD, "arm64/fpsimd:dead",
+				  NULL, fpsimd_cpu_dead);
 }
 
 #else
diff --git a/include/linux/cpuhotplug.h b/include/linux/cpuhotplug.h
index afd59e2..0da071f 100644
--- a/include/linux/cpuhotplug.h
+++ b/include/linux/cpuhotplug.h
@@ -20,6 +20,7 @@ enum cpuhp_state {
 	CPUHP_SOFTIRQ_DEAD,
 	CPUHP_NET_MVNETA_DEAD,
 	CPUHP_CPUIDLE_DEAD,
+	CPUHP_ARM64_FPSIMD_DEAD,
 	CPUHP_WORKQUEUE_PREP,
 	CPUHP_POWER_NUMA_PREPARE,
 	CPUHP_HRTIMERS_PREPARE,

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

* [tip:smp/hotplug] ARM/shmobile: Convert to hotplug state machine
  2016-09-06 17:04   ` Sebastian Andrzej Siewior
                     ` (2 preceding siblings ...)
  (?)
@ 2016-09-19 19:52   ` tip-bot for Sebastian Andrzej Siewior
  -1 siblings, 0 replies; 83+ messages in thread
From: tip-bot for Sebastian Andrzej Siewior @ 2016-09-19 19:52 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: bigeasy, mingo, hpa, magnus.damm, horms, peterz, tglx, linux-kernel

Commit-ID:  657ebf7a2354f39cc7d3f4e64ee49dbf1c3cae4f
Gitweb:     http://git.kernel.org/tip/657ebf7a2354f39cc7d3f4e64ee49dbf1c3cae4f
Author:     Sebastian Andrzej Siewior <bigeasy@linutronix.de>
AuthorDate: Tue, 6 Sep 2016 19:04:38 +0200
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Mon, 19 Sep 2016 21:44:26 +0200

ARM/shmobile: Convert to hotplug state machine

Install the callbacks via the state machine so the old notifier based
cpuhotplug infrastructure can be removed.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: linux-sh@vger.kernel.org
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Magnus Damm <magnus.damm@gmail.com>
Cc: Simon Horman <horms@verge.net.au>
Cc: rt@linutronix.de
Cc: linux-arm-kernel@lists.infradead.org
Link: http://lkml.kernel.org/r/20160906170457.32393-3-bigeasy@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

---
 arch/arm/mach-shmobile/platsmp-scu.c | 26 ++++++++------------------
 include/linux/cpuhotplug.h           |  1 +
 2 files changed, 9 insertions(+), 18 deletions(-)

diff --git a/arch/arm/mach-shmobile/platsmp-scu.c b/arch/arm/mach-shmobile/platsmp-scu.c
index 8d478f1..d1ecaf3 100644
--- a/arch/arm/mach-shmobile/platsmp-scu.c
+++ b/arch/arm/mach-shmobile/platsmp-scu.c
@@ -21,26 +21,14 @@
 static phys_addr_t shmobile_scu_base_phys;
 static void __iomem *shmobile_scu_base;
 
-static int shmobile_smp_scu_notifier_call(struct notifier_block *nfb,
-					  unsigned long action, void *hcpu)
+static int shmobile_scu_cpu_prepare(unsigned int cpu)
 {
-	unsigned int cpu = (long)hcpu;
-
-	switch (action) {
-	case CPU_UP_PREPARE:
-		/* For this particular CPU register SCU SMP boot vector */
-		shmobile_smp_hook(cpu, virt_to_phys(shmobile_boot_scu),
-				  shmobile_scu_base_phys);
-		break;
-	};
-
-	return NOTIFY_OK;
+	/* For this particular CPU register SCU SMP boot vector */
+	shmobile_smp_hook(cpu, virt_to_phys(shmobile_boot_scu),
+			  shmobile_scu_base_phys);
+	return 0;
 }
 
-static struct notifier_block shmobile_smp_scu_notifier = {
-	.notifier_call = shmobile_smp_scu_notifier_call,
-};
-
 void __init shmobile_smp_scu_prepare_cpus(phys_addr_t scu_base_phys,
 					  unsigned int max_cpus)
 {
@@ -54,7 +42,9 @@ void __init shmobile_smp_scu_prepare_cpus(phys_addr_t scu_base_phys,
 	scu_power_mode(shmobile_scu_base, SCU_PM_NORMAL);
 
 	/* Use CPU notifier for reset vector control */
-	register_cpu_notifier(&shmobile_smp_scu_notifier);
+	cpuhp_setup_state_nocalls(CPUHP_ARM_SHMOBILE_SCU_PREPARE,
+				  "arm/shmobile-scu:prepare",
+				  shmobile_scu_cpu_prepare, NULL);
 }
 
 #ifdef CONFIG_HOTPLUG_CPU
diff --git a/include/linux/cpuhotplug.h b/include/linux/cpuhotplug.h
index 0da071f..008eed0 100644
--- a/include/linux/cpuhotplug.h
+++ b/include/linux/cpuhotplug.h
@@ -35,6 +35,7 @@ enum cpuhp_state {
 	CPUHP_POWERPC_PMAC_PREPARE,
 	CPUHP_POWERPC_MMU_CTX_PREPARE,
 	CPUHP_NOTIFY_PREPARE,
+	CPUHP_ARM_SHMOBILE_SCU_PREPARE,
 	CPUHP_TIMERS_DEAD,
 	CPUHP_BRINGUP_CPU,
 	CPUHP_AP_IDLE_DEAD,

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

* [tip:smp/hotplug] ARM/OMAP/wakeupgen: Convert to hotplug state machine
  2016-09-06 17:04   ` Sebastian Andrzej Siewior
  (?)
  (?)
@ 2016-09-19 19:52   ` tip-bot for Sebastian Andrzej Siewior
  -1 siblings, 0 replies; 83+ messages in thread
From: tip-bot for Sebastian Andrzej Siewior @ 2016-09-19 19:52 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: tony, hpa, mingo, tglx, bigeasy, linux-kernel, peterz

Commit-ID:  a4fa9cc220fef29162d38a0ada71f5569a116087
Gitweb:     http://git.kernel.org/tip/a4fa9cc220fef29162d38a0ada71f5569a116087
Author:     Sebastian Andrzej Siewior <bigeasy@linutronix.de>
AuthorDate: Tue, 6 Sep 2016 19:04:39 +0200
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Mon, 19 Sep 2016 21:44:26 +0200

ARM/OMAP/wakeupgen: Convert to hotplug state machine

Install the callbacks via the state machine.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Acked-by: Tony Lindgren <tony@atomide.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: rt@linutronix.de
Cc: linux-omap@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org
Link: http://lkml.kernel.org/r/20160906170457.32393-4-bigeasy@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

---
 arch/arm/mach-omap2/omap-wakeupgen.c | 35 +++++++++++++----------------------
 include/linux/cpuhotplug.h           |  1 +
 2 files changed, 14 insertions(+), 22 deletions(-)

diff --git a/arch/arm/mach-omap2/omap-wakeupgen.c b/arch/arm/mach-omap2/omap-wakeupgen.c
index 0c47543..369f95a 100644
--- a/arch/arm/mach-omap2/omap-wakeupgen.c
+++ b/arch/arm/mach-omap2/omap-wakeupgen.c
@@ -322,34 +322,25 @@ static void irq_save_secure_context(void)
 #endif
 
 #ifdef CONFIG_HOTPLUG_CPU
-static int irq_cpu_hotplug_notify(struct notifier_block *self,
-				  unsigned long action, void *hcpu)
+static int omap_wakeupgen_cpu_online(unsigned int cpu)
 {
-	unsigned int cpu = (unsigned int)hcpu;
-
-	/*
-	 * Corresponding FROZEN transitions do not have to be handled,
-	 * they are handled by at a higher level
-	 * (drivers/cpuidle/coupled.c).
-	 */
-	switch (action) {
-	case CPU_ONLINE:
-		wakeupgen_irqmask_all(cpu, 0);
-		break;
-	case CPU_DEAD:
-		wakeupgen_irqmask_all(cpu, 1);
-		break;
-	}
-	return NOTIFY_OK;
+	wakeupgen_irqmask_all(cpu, 0);
+	return 0;
 }
 
-static struct notifier_block irq_hotplug_notifier = {
-	.notifier_call = irq_cpu_hotplug_notify,
-};
+static int omap_wakeupgen_cpu_dead(unsigned int cpu)
+{
+	wakeupgen_irqmask_all(cpu, 1);
+	return 0;
+}
 
 static void __init irq_hotplug_init(void)
 {
-	register_hotcpu_notifier(&irq_hotplug_notifier);
+	cpuhp_setup_state_nocalls(CPUHP_AP_ONLINE_DYN, "arm/omap-wake:online",
+				  omap_wakeupgen_cpu_online, NULL);
+	cpuhp_setup_state_nocalls(CPUHP_ARM_OMAP_WAKE_DEAD,
+				  "arm/omap-wake:dead", NULL,
+				  omap_wakeupgen_cpu_dead);
 }
 #else
 static void __init irq_hotplug_init(void)
diff --git a/include/linux/cpuhotplug.h b/include/linux/cpuhotplug.h
index 008eed0..35859aa 100644
--- a/include/linux/cpuhotplug.h
+++ b/include/linux/cpuhotplug.h
@@ -21,6 +21,7 @@ enum cpuhp_state {
 	CPUHP_NET_MVNETA_DEAD,
 	CPUHP_CPUIDLE_DEAD,
 	CPUHP_ARM64_FPSIMD_DEAD,
+	CPUHP_ARM_OMAP_WAKE_DEAD,
 	CPUHP_WORKQUEUE_PREP,
 	CPUHP_POWER_NUMA_PREPARE,
 	CPUHP_HRTIMERS_PREPARE,

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

* [tip:smp/hotplug] ia64/mca: Convert to hotplug state machine
  2016-09-06 17:04   ` Sebastian Andrzej Siewior
  (?)
@ 2016-09-19 19:53   ` tip-bot for Sebastian Andrzej Siewior
  -1 siblings, 0 replies; 83+ messages in thread
From: tip-bot for Sebastian Andrzej Siewior @ 2016-09-19 19:53 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: mingo, bigeasy, fenghua.yu, hpa, peterz, tglx, tony.luck, linux-kernel

Commit-ID:  6b8d642239e866debbaa37f25e53837a5d141f33
Gitweb:     http://git.kernel.org/tip/6b8d642239e866debbaa37f25e53837a5d141f33
Author:     Sebastian Andrzej Siewior <bigeasy@linutronix.de>
AuthorDate: Tue, 6 Sep 2016 19:04:40 +0200
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Mon, 19 Sep 2016 21:44:26 +0200

ia64/mca: Convert to hotplug state machine

Install the callbacks via the state machine and let the core invoke
the callbacks on the already online CPUs.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: Tony Luck <tony.luck@intel.com>
Cc: linux-ia64@vger.kernel.org
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: rt@linutronix.de
Link: http://lkml.kernel.org/r/20160906170457.32393-5-bigeasy@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

---
 arch/ia64/kernel/mca.c | 26 ++++----------------------
 1 file changed, 4 insertions(+), 22 deletions(-)

diff --git a/arch/ia64/kernel/mca.c b/arch/ia64/kernel/mca.c
index eb9220c..c2858865 100644
--- a/arch/ia64/kernel/mca.c
+++ b/arch/ia64/kernel/mca.c
@@ -1890,7 +1890,7 @@ ia64_mca_cpu_init(void *cpu_data)
 							      PAGE_KERNEL)));
 }
 
-static void ia64_mca_cmc_vector_adjust(void *dummy)
+static int ia64_mca_cpu_online(unsigned int cpu)
 {
 	unsigned long flags;
 
@@ -1898,25 +1898,9 @@ static void ia64_mca_cmc_vector_adjust(void *dummy)
 	if (!cmc_polling_enabled)
 		ia64_mca_cmc_vector_enable(NULL);
 	local_irq_restore(flags);
+	return 0;
 }
 
-static int mca_cpu_callback(struct notifier_block *nfb,
-				      unsigned long action,
-				      void *hcpu)
-{
-	switch (action) {
-	case CPU_ONLINE:
-	case CPU_ONLINE_FROZEN:
-		ia64_mca_cmc_vector_adjust(NULL);
-		break;
-	}
-	return NOTIFY_OK;
-}
-
-static struct notifier_block mca_cpu_notifier = {
-	.notifier_call = mca_cpu_callback
-};
-
 /*
  * ia64_mca_init
  *
@@ -2111,15 +2095,13 @@ ia64_mca_late_init(void)
 	if (!mca_init)
 		return 0;
 
-	register_hotcpu_notifier(&mca_cpu_notifier);
-
 	/* Setup the CMCI/P vector and handler */
 	setup_timer(&cmc_poll_timer, ia64_mca_cmc_poll, 0UL);
 
 	/* Unmask/enable the vector */
 	cmc_polling_enabled = 0;
-	schedule_work(&cmc_enable_work);
-
+	cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "ia64/mca:online",
+			  ia64_mca_cpu_online, NULL);
 	IA64_MCA_DEBUG("%s: CMCI/P setup and enabled.\n", __func__);
 
 #ifdef CONFIG_ACPI

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

* [tip:smp/hotplug] sh/SH-X3 SMP: Convert to hotplug state machine
  2016-09-06 17:04   ` Sebastian Andrzej Siewior
  (?)
@ 2016-09-19 19:53   ` tip-bot for Sebastian Andrzej Siewior
  -1 siblings, 0 replies; 83+ messages in thread
From: tip-bot for Sebastian Andrzej Siewior @ 2016-09-19 19:53 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: hpa, peterz, bigeasy, tglx, mingo, linux-kernel

Commit-ID:  515332336be71d014bca1d29369c5d72baa38f71
Gitweb:     http://git.kernel.org/tip/515332336be71d014bca1d29369c5d72baa38f71
Author:     Sebastian Andrzej Siewior <bigeasy@linutronix.de>
AuthorDate: Tue, 6 Sep 2016 19:04:41 +0200
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Mon, 19 Sep 2016 21:44:27 +0200

sh/SH-X3 SMP: Convert to hotplug state machine

Install the callbacks via the state machine.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: linux-sh@vger.kernel.org
Cc: rt@linutronix.de
Link: http://lkml.kernel.org/r/20160906170457.32393-6-bigeasy@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

---
 arch/sh/kernel/cpu/sh4a/smp-shx3.c | 26 +++++---------------------
 include/linux/cpuhotplug.h         |  1 +
 2 files changed, 6 insertions(+), 21 deletions(-)

diff --git a/arch/sh/kernel/cpu/sh4a/smp-shx3.c b/arch/sh/kernel/cpu/sh4a/smp-shx3.c
index 839612c..0d3637c 100644
--- a/arch/sh/kernel/cpu/sh4a/smp-shx3.c
+++ b/arch/sh/kernel/cpu/sh4a/smp-shx3.c
@@ -122,32 +122,16 @@ static void shx3_update_boot_vector(unsigned int cpu)
 	__raw_writel(STBCR_RESET, STBCR_REG(cpu));
 }
 
-static int
-shx3_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
+static int shx3_cpu_prepare(unsigned int cpu)
 {
-	unsigned int cpu = (unsigned int)hcpu;
-
-	switch (action) {
-	case CPU_UP_PREPARE:
-		shx3_update_boot_vector(cpu);
-		break;
-	case CPU_ONLINE:
-		pr_info("CPU %u is now online\n", cpu);
-		break;
-	case CPU_DEAD:
-		break;
-	}
-
-	return NOTIFY_OK;
+	shx3_update_boot_vector(cpu);
+	return 0;
 }
 
-static struct notifier_block shx3_cpu_notifier = {
-	.notifier_call		= shx3_cpu_callback,
-};
-
 static int register_shx3_cpu_notifier(void)
 {
-	register_hotcpu_notifier(&shx3_cpu_notifier);
+	cpuhp_setup_state_nocalls(CPUHP_SH_SH3X_PREPARE, "sh/shx3:prepare",
+				  shx3_cpu_prepare, NULL);
 	return 0;
 }
 late_initcall(register_shx3_cpu_notifier);
diff --git a/include/linux/cpuhotplug.h b/include/linux/cpuhotplug.h
index 35859aa..8dec2a2 100644
--- a/include/linux/cpuhotplug.h
+++ b/include/linux/cpuhotplug.h
@@ -37,6 +37,7 @@ enum cpuhp_state {
 	CPUHP_POWERPC_MMU_CTX_PREPARE,
 	CPUHP_NOTIFY_PREPARE,
 	CPUHP_ARM_SHMOBILE_SCU_PREPARE,
+	CPUHP_SH_SH3X_PREPARE,
 	CPUHP_TIMERS_DEAD,
 	CPUHP_BRINGUP_CPU,
 	CPUHP_AP_IDLE_DEAD,

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

* [tip:smp/hotplug] x86/microcode: Convert to hotplug state machine
  2016-09-07 16:45     ` [PATCH 06/21 v2] " Sebastian Andrzej Siewior
@ 2016-09-19 19:54       ` tip-bot for Sebastian Andrzej Siewior
  0 siblings, 0 replies; 83+ messages in thread
From: tip-bot for Sebastian Andrzej Siewior @ 2016-09-19 19:54 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: peterz, linux-kernel, bp, bigeasy, hpa, mingo, tglx

Commit-ID:  29bd7fbc071598e939526f782293dbe137be3768
Gitweb:     http://git.kernel.org/tip/29bd7fbc071598e939526f782293dbe137be3768
Author:     Sebastian Andrzej Siewior <bigeasy@linutronix.de>
AuthorDate: Wed, 7 Sep 2016 18:45:23 +0200
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Mon, 19 Sep 2016 21:44:27 +0200

x86/microcode: Convert to hotplug state machine

Install the callbacks via the state machine. 
CPU_UP_CANCELED_FROZEN() is not preserved: It is only there to free memory in an
error case because it is assumed if the CPU does show up on resume it won't be
seen ever again. As per Borislav:
|IOW, you don't need mc_cpu_dead().

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: rt@linutronix.de
Link: http://lkml.kernel.org/r/20160907164523.46a2xnffha4bv63g@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

---
 arch/x86/kernel/cpu/microcode/core.c | 52 ++++++++++++------------------------
 1 file changed, 17 insertions(+), 35 deletions(-)

diff --git a/arch/x86/kernel/cpu/microcode/core.c b/arch/x86/kernel/cpu/microcode/core.c
index df04b2d..5ce5155 100644
--- a/arch/x86/kernel/cpu/microcode/core.c
+++ b/arch/x86/kernel/cpu/microcode/core.c
@@ -558,55 +558,36 @@ static struct syscore_ops mc_syscore_ops = {
 	.resume			= mc_bp_resume,
 };
 
-static int
-mc_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu)
+static int mc_cpu_online(unsigned int cpu)
 {
-	unsigned int cpu = (unsigned long)hcpu;
 	struct device *dev;
 
 	dev = get_cpu_device(cpu);
+	microcode_update_cpu(cpu);
+	pr_debug("CPU%d added\n", cpu);
 
-	switch (action & ~CPU_TASKS_FROZEN) {
-	case CPU_ONLINE:
-		microcode_update_cpu(cpu);
-		pr_debug("CPU%d added\n", cpu);
-		/*
-		 * "break" is missing on purpose here because we want to fall
-		 * through in order to create the sysfs group.
-		 */
-
-	case CPU_DOWN_FAILED:
-		if (sysfs_create_group(&dev->kobj, &mc_attr_group))
-			pr_err("Failed to create group for CPU%d\n", cpu);
-		break;
+	if (sysfs_create_group(&dev->kobj, &mc_attr_group))
+		pr_err("Failed to create group for CPU%d\n", cpu);
+	return 0;
+}
 
-	case CPU_DOWN_PREPARE:
-		/* Suspend is in progress, only remove the interface */
-		sysfs_remove_group(&dev->kobj, &mc_attr_group);
-		pr_debug("CPU%d removed\n", cpu);
-		break;
+static int mc_cpu_down_prep(unsigned int cpu)
+{
+	struct device *dev;
 
+	dev = get_cpu_device(cpu);
+	/* Suspend is in progress, only remove the interface */
+	sysfs_remove_group(&dev->kobj, &mc_attr_group);
+	pr_debug("CPU%d removed\n", cpu);
 	/*
-	 * case CPU_DEAD:
-	 *
 	 * When a CPU goes offline, don't free up or invalidate the copy of
 	 * the microcode in kernel memory, so that we can reuse it when the
 	 * CPU comes back online without unnecessarily requesting the userspace
 	 * for it again.
 	 */
-	}
-
-	/* The CPU refused to come up during a system resume */
-	if (action == CPU_UP_CANCELED_FROZEN)
-		microcode_fini_cpu(cpu);
-
-	return NOTIFY_OK;
+	return 0;
 }
 
-static struct notifier_block mc_cpu_notifier = {
-	.notifier_call	= mc_cpu_callback,
-};
-
 static struct attribute *cpu_root_microcode_attrs[] = {
 	&dev_attr_reload.attr,
 	NULL
@@ -665,7 +646,8 @@ int __init microcode_init(void)
 		goto out_ucode_group;
 
 	register_syscore_ops(&mc_syscore_ops);
-	register_hotcpu_notifier(&mc_cpu_notifier);
+	cpuhp_setup_state_nocalls(CPUHP_AP_ONLINE_DYN, "x86/microcode:online",
+				  mc_cpu_online, mc_cpu_down_prep);
 
 	pr_info("Microcode Update Driver: v" MICROCODE_VERSION
 		" <tigran@aivazian.fsnet.co.uk>, Peter Oruba\n");

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

* [tip:smp/hotplug] lib/irq_poll: Convert to hotplug state machine
  2016-09-06 17:04 ` [PATCH 07/21] lib: irq_poll: " Sebastian Andrzej Siewior
@ 2016-09-19 19:54   ` tip-bot for Sebastian Andrzej Siewior
  0 siblings, 0 replies; 83+ messages in thread
From: tip-bot for Sebastian Andrzej Siewior @ 2016-09-19 19:54 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: bigeasy, tglx, linux-kernel, peterz, mingo, axboe, hpa

Commit-ID:  75e12ed65312a56401f3b286ac7e12994301371c
Gitweb:     http://git.kernel.org/tip/75e12ed65312a56401f3b286ac7e12994301371c
Author:     Sebastian Andrzej Siewior <bigeasy@linutronix.de>
AuthorDate: Tue, 6 Sep 2016 19:04:43 +0200
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Mon, 19 Sep 2016 21:44:27 +0200

lib/irq_poll: Convert to hotplug state machine

Install the callbacks via the state machine.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: rt@linutronix.de
Link: http://lkml.kernel.org/r/20160906170457.32393-8-bigeasy@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

---
 include/linux/cpuhotplug.h |  1 +
 lib/irq_poll.c             | 26 +++++++++-----------------
 2 files changed, 10 insertions(+), 17 deletions(-)

diff --git a/include/linux/cpuhotplug.h b/include/linux/cpuhotplug.h
index 8dec2a2..2ca7b34 100644
--- a/include/linux/cpuhotplug.h
+++ b/include/linux/cpuhotplug.h
@@ -22,6 +22,7 @@ enum cpuhp_state {
 	CPUHP_CPUIDLE_DEAD,
 	CPUHP_ARM64_FPSIMD_DEAD,
 	CPUHP_ARM_OMAP_WAKE_DEAD,
+	CPUHP_IRQ_POLL_DEAD,
 	CPUHP_WORKQUEUE_PREP,
 	CPUHP_POWER_NUMA_PREPARE,
 	CPUHP_HRTIMERS_PREPARE,
diff --git a/lib/irq_poll.c b/lib/irq_poll.c
index 836f7db..2be5569 100644
--- a/lib/irq_poll.c
+++ b/lib/irq_poll.c
@@ -184,30 +184,21 @@ void irq_poll_init(struct irq_poll *iop, int weight, irq_poll_fn *poll_fn)
 }
 EXPORT_SYMBOL(irq_poll_init);
 
-static int irq_poll_cpu_notify(struct notifier_block *self,
-				 unsigned long action, void *hcpu)
+static int irq_poll_cpu_dead(unsigned int cpu)
 {
 	/*
 	 * If a CPU goes away, splice its entries to the current CPU
 	 * and trigger a run of the softirq
 	 */
-	if (action == CPU_DEAD || action == CPU_DEAD_FROZEN) {
-		int cpu = (unsigned long) hcpu;
-
-		local_irq_disable();
-		list_splice_init(&per_cpu(blk_cpu_iopoll, cpu),
-				 this_cpu_ptr(&blk_cpu_iopoll));
-		__raise_softirq_irqoff(IRQ_POLL_SOFTIRQ);
-		local_irq_enable();
-	}
+	local_irq_disable();
+	list_splice_init(&per_cpu(blk_cpu_iopoll, cpu),
+			 this_cpu_ptr(&blk_cpu_iopoll));
+	__raise_softirq_irqoff(IRQ_POLL_SOFTIRQ);
+	local_irq_enable();
 
-	return NOTIFY_OK;
+	return 0;
 }
 
-static struct notifier_block irq_poll_cpu_notifier = {
-	.notifier_call	= irq_poll_cpu_notify,
-};
-
 static __init int irq_poll_setup(void)
 {
 	int i;
@@ -216,7 +207,8 @@ static __init int irq_poll_setup(void)
 		INIT_LIST_HEAD(&per_cpu(blk_cpu_iopoll, i));
 
 	open_softirq(IRQ_POLL_SOFTIRQ, irq_poll_softirq);
-	register_hotcpu_notifier(&irq_poll_cpu_notifier);
+	cpuhp_setup_state_nocalls(CPUHP_IRQ_POLL_DEAD, "irq_poll:dead", NULL,
+				  irq_poll_cpu_dead);
 	return 0;
 }
 subsys_initcall(irq_poll_setup);

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

* [tip:smp/hotplug] block/softirq: Convert to hotplug state machine
  2016-09-06 17:04 ` [PATCH 08/21] block: softirq: " Sebastian Andrzej Siewior
@ 2016-09-19 19:55   ` tip-bot for Sebastian Andrzej Siewior
  0 siblings, 0 replies; 83+ messages in thread
From: tip-bot for Sebastian Andrzej Siewior @ 2016-09-19 19:55 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, hpa, peterz, tglx, mingo, bigeasy, axboe

Commit-ID:  9a659f43dfea27cca423d4e80809be447f4c9ce7
Gitweb:     http://git.kernel.org/tip/9a659f43dfea27cca423d4e80809be447f4c9ce7
Author:     Sebastian Andrzej Siewior <bigeasy@linutronix.de>
AuthorDate: Tue, 6 Sep 2016 19:04:44 +0200
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Mon, 19 Sep 2016 21:44:28 +0200

block/softirq: Convert to hotplug state machine

Install the callbacks via the state machine.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: rt@linutronix.de
Link: http://lkml.kernel.org/r/20160906170457.32393-9-bigeasy@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

---
 block/blk-softirq.c        | 27 ++++++++++-----------------
 include/linux/cpuhotplug.h |  1 +
 2 files changed, 11 insertions(+), 17 deletions(-)

diff --git a/block/blk-softirq.c b/block/blk-softirq.c
index 53b1737..96631e6 100644
--- a/block/blk-softirq.c
+++ b/block/blk-softirq.c
@@ -78,30 +78,21 @@ static int raise_blk_irq(int cpu, struct request *rq)
 }
 #endif
 
-static int blk_cpu_notify(struct notifier_block *self, unsigned long action,
-			  void *hcpu)
+static int blk_softirq_cpu_dead(unsigned int cpu)
 {
 	/*
 	 * If a CPU goes away, splice its entries to the current CPU
 	 * and trigger a run of the softirq
 	 */
-	if (action == CPU_DEAD || action == CPU_DEAD_FROZEN) {
-		int cpu = (unsigned long) hcpu;
-
-		local_irq_disable();
-		list_splice_init(&per_cpu(blk_cpu_done, cpu),
-				 this_cpu_ptr(&blk_cpu_done));
-		raise_softirq_irqoff(BLOCK_SOFTIRQ);
-		local_irq_enable();
-	}
+	local_irq_disable();
+	list_splice_init(&per_cpu(blk_cpu_done, cpu),
+			 this_cpu_ptr(&blk_cpu_done));
+	raise_softirq_irqoff(BLOCK_SOFTIRQ);
+	local_irq_enable();
 
-	return NOTIFY_OK;
+	return 0;
 }
 
-static struct notifier_block blk_cpu_notifier = {
-	.notifier_call	= blk_cpu_notify,
-};
-
 void __blk_complete_request(struct request *req)
 {
 	int ccpu, cpu;
@@ -180,7 +171,9 @@ static __init int blk_softirq_init(void)
 		INIT_LIST_HEAD(&per_cpu(blk_cpu_done, i));
 
 	open_softirq(BLOCK_SOFTIRQ, blk_done_softirq);
-	register_hotcpu_notifier(&blk_cpu_notifier);
+	cpuhp_setup_state_nocalls(CPUHP_BLOCK_SOFTIRQ_DEAD,
+				  "block/softirq:dead", NULL,
+				  blk_softirq_cpu_dead);
 	return 0;
 }
 subsys_initcall(blk_softirq_init);
diff --git a/include/linux/cpuhotplug.h b/include/linux/cpuhotplug.h
index 2ca7b34..d4274d5 100644
--- a/include/linux/cpuhotplug.h
+++ b/include/linux/cpuhotplug.h
@@ -23,6 +23,7 @@ enum cpuhp_state {
 	CPUHP_ARM64_FPSIMD_DEAD,
 	CPUHP_ARM_OMAP_WAKE_DEAD,
 	CPUHP_IRQ_POLL_DEAD,
+	CPUHP_BLOCK_SOFTIRQ_DEAD,
 	CPUHP_WORKQUEUE_PREP,
 	CPUHP_POWER_NUMA_PREPARE,
 	CPUHP_HRTIMERS_PREPARE,

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

* [tip:smp/hotplug] oprofile/timer: Convert to hotplug state machine
  2016-09-06 17:04 ` [PATCH 09/21] oprofile: timer: " Sebastian Andrzej Siewior
@ 2016-09-19 19:55   ` tip-bot for Sebastian Andrzej Siewior
  0 siblings, 0 replies; 83+ messages in thread
From: tip-bot for Sebastian Andrzej Siewior @ 2016-09-19 19:55 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, tglx, bigeasy, hpa, peterz, rric, mingo

Commit-ID:  a4e0591ece7d88634a802c4076db8c0debbde805
Gitweb:     http://git.kernel.org/tip/a4e0591ece7d88634a802c4076db8c0debbde805
Author:     Sebastian Andrzej Siewior <bigeasy@linutronix.de>
AuthorDate: Tue, 6 Sep 2016 19:04:45 +0200
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Mon, 19 Sep 2016 21:44:28 +0200

oprofile/timer: Convert to hotplug state machine

Install the callbacks via the state machine and let the core invoke
the callbacks on the already online CPUs.
Since the online target runs always on the target CPU we can drop
smp_call_function_single(). The functions is invoked with interrupts off to
keep the old calling convention. If the maintainer things that this function
can be called with interrupts enabled then it can be removed :)

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: Robert Richter <rric@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: oprofile-list@lists.sf.net
Cc: rt@linutronix.de
Link: http://lkml.kernel.org/r/20160906170457.32393-10-bigeasy@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

---
 drivers/oprofile/timer_int.c | 44 +++++++++++++++++++++++---------------------
 1 file changed, 23 insertions(+), 21 deletions(-)

diff --git a/drivers/oprofile/timer_int.c b/drivers/oprofile/timer_int.c
index bdef916..2498a6c 100644
--- a/drivers/oprofile/timer_int.c
+++ b/drivers/oprofile/timer_int.c
@@ -74,37 +74,39 @@ static void oprofile_hrtimer_stop(void)
 	put_online_cpus();
 }
 
-static int oprofile_cpu_notify(struct notifier_block *self,
-			       unsigned long action, void *hcpu)
+static int oprofile_timer_online(unsigned int cpu)
 {
-	long cpu = (long) hcpu;
-
-	switch (action) {
-	case CPU_ONLINE:
-	case CPU_ONLINE_FROZEN:
-		smp_call_function_single(cpu, __oprofile_hrtimer_start,
-					 NULL, 1);
-		break;
-	case CPU_DEAD:
-	case CPU_DEAD_FROZEN:
-		__oprofile_hrtimer_stop(cpu);
-		break;
-	}
-	return NOTIFY_OK;
+	local_irq_disable();
+	__oprofile_hrtimer_start(NULL);
+	local_irq_enable();
+	return 0;
 }
 
-static struct notifier_block __refdata oprofile_cpu_notifier = {
-	.notifier_call = oprofile_cpu_notify,
-};
+static int oprofile_timer_prep_down(unsigned int cpu)
+{
+	__oprofile_hrtimer_stop(cpu);
+	return 0;
+}
+
+static enum cpuhp_state hp_online;
 
 static int oprofile_hrtimer_setup(void)
 {
-	return register_hotcpu_notifier(&oprofile_cpu_notifier);
+	int ret;
+
+	ret = cpuhp_setup_state_nocalls(CPUHP_AP_ONLINE_DYN,
+					"oprofile/timer:online",
+					oprofile_timer_online,
+					oprofile_timer_prep_down);
+	if (ret < 0)
+		return ret;
+	hp_online = ret;
+	return 0;
 }
 
 static void oprofile_hrtimer_shutdown(void)
 {
-	unregister_hotcpu_notifier(&oprofile_cpu_notifier);
+	cpuhp_remove_state_nocalls(hp_online);
 }
 
 int oprofile_timer_init(struct oprofile_operations *ops)

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

* [tip:smp/hotplug] virtio scsi: Convert to hotplug state machine
  2016-09-06 17:04 ` Sebastian Andrzej Siewior
@ 2016-09-19 19:56   ` tip-bot for Sebastian Andrzej Siewior
  0 siblings, 0 replies; 83+ messages in thread
From: tip-bot for Sebastian Andrzej Siewior @ 2016-09-19 19:56 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: mingo, peterz, mst, tglx, linux-kernel, bigeasy, martin.petersen,
	hpa, jejb

Commit-ID:  8904f5a5afc4dd74e8fe2ab3eeb98018ef02f3e6
Gitweb:     http://git.kernel.org/tip/8904f5a5afc4dd74e8fe2ab3eeb98018ef02f3e6
Author:     Sebastian Andrzej Siewior <bigeasy@linutronix.de>
AuthorDate: Tue, 6 Sep 2016 19:04:46 +0200
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Mon, 19 Sep 2016 21:44:29 +0200

virtio scsi: Convert to hotplug state machine

Install the callbacks via the state machine. It uses the multi instance
infrastructure of the hotplug code to handle each interface.

virtscsi_set_affinity() is removed from virtscsi_init() because
virtscsi_cpu_notif_add() (the function which registers the instance) is invoked
right after it and the cpuhp_state_add_instance() functions invokes the startup
callback on all online CPUs.

The same thing can not be applied virtscsi_cpu_notif_remove() because
virtscsi_remove_vqs() invokes virtscsi_set_affinity() with affinity = false as
argument but the old CPU_DEAD state invoked the function with affinity = true
(which does not match the DEAD callback).

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: "James E.J. Bottomley" <jejb@linux.vnet.ibm.com>
Cc: linux-scsi@vger.kernel.org
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: virtualization@lists.linux-foundation.org
Cc: rt@linutronix.de
Link: http://lkml.kernel.org/r/20160906170457.32393-11-bigeasy@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

---
 drivers/scsi/virtio_scsi.c | 76 ++++++++++++++++++++++++++++++----------------
 include/linux/cpuhotplug.h |  1 +
 2 files changed, 50 insertions(+), 27 deletions(-)

diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c
index 7dbbb29..deefab3 100644
--- a/drivers/scsi/virtio_scsi.c
+++ b/drivers/scsi/virtio_scsi.c
@@ -107,8 +107,8 @@ struct virtio_scsi {
 	/* If the affinity hint is set for virtqueues */
 	bool affinity_hint_set;
 
-	/* CPU hotplug notifier */
-	struct notifier_block nb;
+	struct hlist_node node;
+	struct hlist_node node_dead;
 
 	/* Protected by event_vq lock */
 	bool stop_events;
@@ -118,6 +118,7 @@ struct virtio_scsi {
 	struct virtio_scsi_vq req_vqs[];
 };
 
+static enum cpuhp_state virtioscsi_online;
 static struct kmem_cache *virtscsi_cmd_cache;
 static mempool_t *virtscsi_cmd_pool;
 
@@ -852,21 +853,33 @@ static void virtscsi_set_affinity(struct virtio_scsi *vscsi, bool affinity)
 	put_online_cpus();
 }
 
-static int virtscsi_cpu_callback(struct notifier_block *nfb,
-				 unsigned long action, void *hcpu)
+static int virtscsi_cpu_online(unsigned int cpu, struct hlist_node *node)
 {
-	struct virtio_scsi *vscsi = container_of(nfb, struct virtio_scsi, nb);
-	switch(action) {
-	case CPU_ONLINE:
-	case CPU_ONLINE_FROZEN:
-	case CPU_DEAD:
-	case CPU_DEAD_FROZEN:
-		__virtscsi_set_affinity(vscsi, true);
-		break;
-	default:
-		break;
-	}
-	return NOTIFY_OK;
+	struct virtio_scsi *vscsi = hlist_entry_safe(node, struct virtio_scsi,
+						     node);
+	__virtscsi_set_affinity(vscsi, true);
+	return 0;
+}
+
+static int virtscsi_cpu_notif_add(struct virtio_scsi *vi)
+{
+	int ret;
+
+	ret = cpuhp_state_add_instance(virtioscsi_online, &vi->node);
+	if (ret)
+		return ret;
+
+	ret = cpuhp_state_add_instance(CPUHP_VIRT_SCSI_DEAD, &vi->node_dead);
+	if (ret)
+		cpuhp_state_remove_instance(virtioscsi_online, &vi->node);
+	return ret;
+}
+
+static void virtscsi_cpu_notif_remove(struct virtio_scsi *vi)
+{
+	cpuhp_state_remove_instance_nocalls(virtioscsi_online, &vi->node);
+	cpuhp_state_remove_instance_nocalls(CPUHP_VIRT_SCSI_DEAD,
+					    &vi->node_dead);
 }
 
 static void virtscsi_init_vq(struct virtio_scsi_vq *virtscsi_vq,
@@ -929,8 +942,6 @@ static int virtscsi_init(struct virtio_device *vdev,
 		virtscsi_init_vq(&vscsi->req_vqs[i - VIRTIO_SCSI_VQ_BASE],
 				 vqs[i]);
 
-	virtscsi_set_affinity(vscsi, true);
-
 	virtscsi_config_set(vdev, cdb_size, VIRTIO_SCSI_CDB_SIZE);
 	virtscsi_config_set(vdev, sense_size, VIRTIO_SCSI_SENSE_SIZE);
 
@@ -987,12 +998,9 @@ static int virtscsi_probe(struct virtio_device *vdev)
 	if (err)
 		goto virtscsi_init_failed;
 
-	vscsi->nb.notifier_call = &virtscsi_cpu_callback;
-	err = register_hotcpu_notifier(&vscsi->nb);
-	if (err) {
-		pr_err("registering cpu notifier failed\n");
+	err = virtscsi_cpu_notif_add(vscsi);
+	if (err)
 		goto scsi_add_host_failed;
-	}
 
 	cmd_per_lun = virtscsi_config_get(vdev, cmd_per_lun) ?: 1;
 	shost->cmd_per_lun = min_t(u32, cmd_per_lun, shost->can_queue);
@@ -1049,7 +1057,7 @@ static void virtscsi_remove(struct virtio_device *vdev)
 
 	scsi_remove_host(shost);
 
-	unregister_hotcpu_notifier(&vscsi->nb);
+	virtscsi_cpu_notif_remove(vscsi);
 
 	virtscsi_remove_vqs(vdev);
 	scsi_host_put(shost);
@@ -1061,7 +1069,7 @@ static int virtscsi_freeze(struct virtio_device *vdev)
 	struct Scsi_Host *sh = virtio_scsi_host(vdev);
 	struct virtio_scsi *vscsi = shost_priv(sh);
 
-	unregister_hotcpu_notifier(&vscsi->nb);
+	virtscsi_cpu_notif_remove(vscsi);
 	virtscsi_remove_vqs(vdev);
 	return 0;
 }
@@ -1076,12 +1084,11 @@ static int virtscsi_restore(struct virtio_device *vdev)
 	if (err)
 		return err;
 
-	err = register_hotcpu_notifier(&vscsi->nb);
+	err = virtscsi_cpu_notif_add(vscsi);
 	if (err) {
 		vdev->config->del_vqs(vdev);
 		return err;
 	}
-
 	virtio_device_ready(vdev);
 
 	if (virtio_has_feature(vdev, VIRTIO_SCSI_F_HOTPLUG))
@@ -1136,6 +1143,16 @@ static int __init init(void)
 		pr_err("mempool_create() for virtscsi_cmd_pool failed\n");
 		goto error;
 	}
+	ret = cpuhp_setup_state_multi(CPUHP_AP_ONLINE_DYN,
+				      "scsi/virtio:online",
+				      virtscsi_cpu_online, NULL);
+	if (ret < 0)
+		goto error;
+	virtioscsi_online = ret;
+	ret = cpuhp_setup_state_multi(CPUHP_VIRT_SCSI_DEAD, "scsi/virtio:dead",
+				      NULL, virtscsi_cpu_online);
+	if (ret)
+		goto error;
 	ret = register_virtio_driver(&virtio_scsi_driver);
 	if (ret < 0)
 		goto error;
@@ -1151,12 +1168,17 @@ error:
 		kmem_cache_destroy(virtscsi_cmd_cache);
 		virtscsi_cmd_cache = NULL;
 	}
+	if (virtioscsi_online)
+		cpuhp_remove_multi_state(virtioscsi_online);
+	cpuhp_remove_multi_state(CPUHP_VIRT_SCSI_DEAD);
 	return ret;
 }
 
 static void __exit fini(void)
 {
 	unregister_virtio_driver(&virtio_scsi_driver);
+	cpuhp_remove_multi_state(virtioscsi_online);
+	cpuhp_remove_multi_state(CPUHP_VIRT_SCSI_DEAD);
 	mempool_destroy(virtscsi_cmd_pool);
 	kmem_cache_destroy(virtscsi_cmd_cache);
 }
diff --git a/include/linux/cpuhotplug.h b/include/linux/cpuhotplug.h
index d4274d5..e7146ee 100644
--- a/include/linux/cpuhotplug.h
+++ b/include/linux/cpuhotplug.h
@@ -24,6 +24,7 @@ enum cpuhp_state {
 	CPUHP_ARM_OMAP_WAKE_DEAD,
 	CPUHP_IRQ_POLL_DEAD,
 	CPUHP_BLOCK_SOFTIRQ_DEAD,
+	CPUHP_VIRT_SCSI_DEAD,
 	CPUHP_WORKQUEUE_PREP,
 	CPUHP_POWER_NUMA_PREPARE,
 	CPUHP_HRTIMERS_PREPARE,

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

* [tip:smp/hotplug] ACPI/processor: Convert to hotplug state machine
  2016-09-06 17:04 ` [PATCH 11/21] ACPI: processor: " Sebastian Andrzej Siewior
  2016-09-06 21:08   ` Rafael J. Wysocki
@ 2016-09-19 19:56   ` tip-bot for Sebastian Andrzej Siewior
  1 sibling, 0 replies; 83+ messages in thread
From: tip-bot for Sebastian Andrzej Siewior @ 2016-09-19 19:56 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, tglx, bigeasy, hpa, mingo, rjw, peterz, lenb

Commit-ID:  64f3bf2f85c5690228200d6b94eb6847049af70d
Gitweb:     http://git.kernel.org/tip/64f3bf2f85c5690228200d6b94eb6847049af70d
Author:     Sebastian Andrzej Siewior <bigeasy@linutronix.de>
AuthorDate: Tue, 6 Sep 2016 19:04:47 +0200
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Mon, 19 Sep 2016 21:44:29 +0200

ACPI/processor: Convert to hotplug state machine

Install the callbacks via the state machine.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Acked-by: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: linux-acpi@vger.kernel.org
Cc: rt@linutronix.de
Cc: Len Brown <lenb@kernel.org>
Link: http://lkml.kernel.org/r/20160906170457.32393-12-bigeasy@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

---
 drivers/acpi/processor_driver.c     | 91 +++++++++++++++++++------------------
 drivers/acpi/processor_throttling.c |  4 +-
 include/acpi/processor.h            |  4 +-
 include/linux/cpuhotplug.h          |  1 +
 4 files changed, 52 insertions(+), 48 deletions(-)

diff --git a/drivers/acpi/processor_driver.c b/drivers/acpi/processor_driver.c
index 0553aee..13e5ac4 100644
--- a/drivers/acpi/processor_driver.c
+++ b/drivers/acpi/processor_driver.c
@@ -110,55 +110,46 @@ static void acpi_processor_notify(acpi_handle handle, u32 event, void *data)
 
 static int __acpi_processor_start(struct acpi_device *device);
 
-static int acpi_cpu_soft_notify(struct notifier_block *nfb,
-					  unsigned long action, void *hcpu)
+static int acpi_soft_cpu_online(unsigned int cpu)
 {
-	unsigned int cpu = (unsigned long)hcpu;
 	struct acpi_processor *pr = per_cpu(processors, cpu);
 	struct acpi_device *device;
-	action &= ~CPU_TASKS_FROZEN;
-
-	switch (action) {
-	case CPU_ONLINE:
-	case CPU_DEAD:
-		break;
-	default:
-		return NOTIFY_DONE;
-	}
 
 	if (!pr || acpi_bus_get_device(pr->handle, &device))
-		return NOTIFY_DONE;
-
-	if (action == CPU_ONLINE) {
-		/*
-		 * CPU got physically hotplugged and onlined for the first time:
-		 * Initialize missing things.
-		 */
-		if (pr->flags.need_hotplug_init) {
-			int ret;
-
-			pr_info("Will online and init hotplugged CPU: %d\n",
-				pr->id);
-			pr->flags.need_hotplug_init = 0;
-			ret = __acpi_processor_start(device);
-			WARN(ret, "Failed to start CPU: %d\n", pr->id);
-		} else {
-			/* Normal CPU soft online event. */
-			acpi_processor_ppc_has_changed(pr, 0);
-			acpi_processor_hotplug(pr);
-			acpi_processor_reevaluate_tstate(pr, action);
-			acpi_processor_tstate_has_changed(pr);
-		}
-	} else if (action == CPU_DEAD) {
-		/* Invalidate flag.throttling after the CPU is offline. */
-		acpi_processor_reevaluate_tstate(pr, action);
+		return 0;
+	/*
+	 * CPU got physically hotplugged and onlined for the first time:
+	 * Initialize missing things.
+	 */
+	if (pr->flags.need_hotplug_init) {
+		int ret;
+
+		pr_info("Will online and init hotplugged CPU: %d\n",
+			pr->id);
+		pr->flags.need_hotplug_init = 0;
+		ret = __acpi_processor_start(device);
+		WARN(ret, "Failed to start CPU: %d\n", pr->id);
+	} else {
+		/* Normal CPU soft online event. */
+		acpi_processor_ppc_has_changed(pr, 0);
+		acpi_processor_hotplug(pr);
+		acpi_processor_reevaluate_tstate(pr, false);
+		acpi_processor_tstate_has_changed(pr);
 	}
-	return NOTIFY_OK;
+	return 0;
 }
 
-static struct notifier_block acpi_cpu_notifier = {
-	    .notifier_call = acpi_cpu_soft_notify,
-};
+static int acpi_soft_cpu_dead(unsigned int cpu)
+{
+	struct acpi_processor *pr = per_cpu(processors, cpu);
+	struct acpi_device *device;
+
+	if (!pr || acpi_bus_get_device(pr->handle, &device))
+		return 0;
+
+	acpi_processor_reevaluate_tstate(pr, true);
+	return 0;
+}
 
 #ifdef CONFIG_ACPI_CPU_FREQ_PSS
 static int acpi_pss_perf_init(struct acpi_processor *pr,
@@ -303,7 +294,7 @@ static int acpi_processor_stop(struct device *dev)
  * This is needed for the powernow-k8 driver, that works even without
  * ACPI, but needs symbols from this driver
  */
-
+static enum cpuhp_state hp_online;
 static int __init acpi_processor_driver_init(void)
 {
 	int result = 0;
@@ -315,11 +306,22 @@ static int __init acpi_processor_driver_init(void)
 	if (result < 0)
 		return result;
 
-	register_hotcpu_notifier(&acpi_cpu_notifier);
+	result = cpuhp_setup_state_nocalls(CPUHP_AP_ONLINE_DYN,
+					   "acpi/cpu-drv:online",
+					   acpi_soft_cpu_online, NULL);
+	if (result < 0)
+		goto err;
+	hp_online = result;
+	cpuhp_setup_state_nocalls(CPUHP_ACPI_CPUDRV_DEAD, "acpi/cpu-drv:dead",
+				  NULL, acpi_soft_cpu_dead);
+
 	acpi_thermal_cpufreq_init();
 	acpi_processor_ppc_init();
 	acpi_processor_throttling_init();
 	return 0;
+err:
+	driver_unregister(&acpi_processor_driver);
+	return result;
 }
 
 static void __exit acpi_processor_driver_exit(void)
@@ -329,7 +331,8 @@ static void __exit acpi_processor_driver_exit(void)
 
 	acpi_processor_ppc_exit();
 	acpi_thermal_cpufreq_exit();
-	unregister_hotcpu_notifier(&acpi_cpu_notifier);
+	cpuhp_remove_state_nocalls(hp_online);
+	cpuhp_remove_state_nocalls(CPUHP_ACPI_CPUDRV_DEAD);
 	driver_unregister(&acpi_processor_driver);
 }
 
diff --git a/drivers/acpi/processor_throttling.c b/drivers/acpi/processor_throttling.c
index c72e648..d51ca1c 100644
--- a/drivers/acpi/processor_throttling.c
+++ b/drivers/acpi/processor_throttling.c
@@ -375,11 +375,11 @@ int acpi_processor_tstate_has_changed(struct acpi_processor *pr)
  *	3. TSD domain
  */
 void acpi_processor_reevaluate_tstate(struct acpi_processor *pr,
-					unsigned long action)
+					bool is_dead)
 {
 	int result = 0;
 
-	if (action == CPU_DEAD) {
+	if (is_dead) {
 		/* When one CPU is offline, the T-state throttling
 		 * will be invalidated.
 		 */
diff --git a/include/acpi/processor.h b/include/acpi/processor.h
index bfe6b2e..f3db11c 100644
--- a/include/acpi/processor.h
+++ b/include/acpi/processor.h
@@ -359,7 +359,7 @@ extern int acpi_processor_set_throttling(struct acpi_processor *pr,
  * onlined/offlined. In such case the flags.throttling will be updated.
  */
 extern void acpi_processor_reevaluate_tstate(struct acpi_processor *pr,
-			unsigned long action);
+			bool is_dead);
 extern const struct file_operations acpi_processor_throttling_fops;
 extern void acpi_processor_throttling_init(void);
 #else
@@ -380,7 +380,7 @@ static inline int acpi_processor_set_throttling(struct acpi_processor *pr,
 }
 
 static inline void acpi_processor_reevaluate_tstate(struct acpi_processor *pr,
-			unsigned long action) {}
+			bool is_dead) {}
 
 static inline void acpi_processor_throttling_init(void) {}
 #endif	/* CONFIG_ACPI_CPU_FREQ_PSS */
diff --git a/include/linux/cpuhotplug.h b/include/linux/cpuhotplug.h
index e7146ee..7706987 100644
--- a/include/linux/cpuhotplug.h
+++ b/include/linux/cpuhotplug.h
@@ -25,6 +25,7 @@ enum cpuhp_state {
 	CPUHP_IRQ_POLL_DEAD,
 	CPUHP_BLOCK_SOFTIRQ_DEAD,
 	CPUHP_VIRT_SCSI_DEAD,
+	CPUHP_ACPI_CPUDRV_DEAD,
 	CPUHP_WORKQUEUE_PREP,
 	CPUHP_POWER_NUMA_PREPARE,
 	CPUHP_HRTIMERS_PREPARE,

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

* [tip:smp/hotplug] cpufreq: Convert to hotplug state machine
  2016-09-06 17:04 ` [PATCH 12/21] cpufreq: " Sebastian Andrzej Siewior
  2016-09-06 21:27   ` Rafael J. Wysocki
@ 2016-09-19 19:56   ` tip-bot for Sebastian Andrzej Siewior
  2016-09-20 14:56     ` [PATCH] cpufreq: fix up conversion " Sebastian Andrzej Siewior
  1 sibling, 1 reply; 83+ messages in thread
From: tip-bot for Sebastian Andrzej Siewior @ 2016-09-19 19:56 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: rjw, mingo, peterz, bigeasy, linux-kernel, tglx, hpa

Commit-ID:  27622b061eb4bb4d16b5d61219ac10a792010321
Gitweb:     http://git.kernel.org/tip/27622b061eb4bb4d16b5d61219ac10a792010321
Author:     Sebastian Andrzej Siewior <bigeasy@linutronix.de>
AuthorDate: Tue, 6 Sep 2016 19:04:48 +0200
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Mon, 19 Sep 2016 21:44:29 +0200

cpufreq: Convert to hotplug state machine

Install the callbacks via the state machine.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Acked-by: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: linux-pm@vger.kernel.org
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Viresh Kumar <viresh.kumar@linaro.or
Cc: rt@linutronix.de
Link: http://lkml.kernel.org/r/20160906170457.32393-13-bigeasy@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

---
 drivers/cpufreq/cpufreq.c | 38 ++++++++++++--------------------------
 1 file changed, 12 insertions(+), 26 deletions(-)

diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 3dd4884..e0bc632 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -1358,7 +1358,7 @@ static int cpufreq_add_dev(struct device *dev, struct subsys_interface *sif)
 	return add_cpu_dev_symlink(policy, cpu);
 }
 
-static void cpufreq_offline(unsigned int cpu)
+static int cpufreq_offline(unsigned int cpu)
 {
 	struct cpufreq_policy *policy;
 	int ret;
@@ -1368,7 +1368,7 @@ static void cpufreq_offline(unsigned int cpu)
 	policy = cpufreq_cpu_get_raw(cpu);
 	if (!policy) {
 		pr_debug("%s: No cpu_data found\n", __func__);
-		return;
+		return 0;
 	}
 
 	down_write(&policy->rwsem);
@@ -1417,6 +1417,7 @@ static void cpufreq_offline(unsigned int cpu)
 
 unlock:
 	up_write(&policy->rwsem);
+	return 0;
 }
 
 /**
@@ -2332,28 +2333,6 @@ unlock:
 }
 EXPORT_SYMBOL(cpufreq_update_policy);
 
-static int cpufreq_cpu_callback(struct notifier_block *nfb,
-					unsigned long action, void *hcpu)
-{
-	unsigned int cpu = (unsigned long)hcpu;
-
-	switch (action & ~CPU_TASKS_FROZEN) {
-	case CPU_ONLINE:
-	case CPU_DOWN_FAILED:
-		cpufreq_online(cpu);
-		break;
-
-	case CPU_DOWN_PREPARE:
-		cpufreq_offline(cpu);
-		break;
-	}
-	return NOTIFY_OK;
-}
-
-static struct notifier_block __refdata cpufreq_cpu_notifier = {
-	.notifier_call = cpufreq_cpu_callback,
-};
-
 /*********************************************************************
  *               BOOST						     *
  *********************************************************************/
@@ -2455,6 +2434,7 @@ EXPORT_SYMBOL_GPL(cpufreq_boost_enabled);
 /*********************************************************************
  *               REGISTER / UNREGISTER CPUFREQ DRIVER                *
  *********************************************************************/
+static enum cpuhp_state hp_online;
 
 /**
  * cpufreq_register_driver - register a CPU Frequency driver
@@ -2517,7 +2497,13 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data)
 		goto err_if_unreg;
 	}
 
-	register_hotcpu_notifier(&cpufreq_cpu_notifier);
+	ret = cpuhp_setup_state_nocalls(CPUHP_AP_ONLINE_DYN, "cpufreq:online",
+					cpufreq_online,
+					cpufreq_offline);
+	if (ret < 0)
+		goto err_if_unreg;
+	hp_online = ret;
+
 	pr_debug("driver %s up and running\n", driver_data->name);
 	goto out;
 
@@ -2556,7 +2542,7 @@ int cpufreq_unregister_driver(struct cpufreq_driver *driver)
 	get_online_cpus();
 	subsys_interface_unregister(&cpufreq_interface);
 	remove_boost_sysfs_file();
-	unregister_hotcpu_notifier(&cpufreq_cpu_notifier);
+	cpuhp_remove_state_nocalls(hp_online);
 
 	write_lock_irqsave(&cpufreq_driver_lock, flags);
 

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

* [tip:smp/hotplug] padata: Convert to hotplug state machine
  2016-09-06 17:04 ` [PATCH 13/21] padata: Convert " Sebastian Andrzej Siewior
@ 2016-09-19 19:57   ` tip-bot for Sebastian Andrzej Siewior
  0 siblings, 0 replies; 83+ messages in thread
From: tip-bot for Sebastian Andrzej Siewior @ 2016-09-19 19:57 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: hpa, mingo, linux-kernel, steffen.klassert, peterz, bigeasy, tglx

Commit-ID:  30e92153b4e6f1cd01e30c34d9ef6f0986f96b0e
Gitweb:     http://git.kernel.org/tip/30e92153b4e6f1cd01e30c34d9ef6f0986f96b0e
Author:     Sebastian Andrzej Siewior <bigeasy@linutronix.de>
AuthorDate: Tue, 6 Sep 2016 19:04:49 +0200
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Mon, 19 Sep 2016 21:44:30 +0200

padata: Convert to hotplug state machine

Install the callbacks via the state machine. CPU-hotplug multinstance support
is used with the nocalls() version. Maybe parts of padata_alloc() could be
moved into the online callback so that we could invoke ->startup callback for
instance and drop get_online_cpus().

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: Steffen Klassert <steffen.klassert@secunet.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: linux-crypto@vger.kernel.org
Cc: rt@linutronix.de
Link: http://lkml.kernel.org/r/20160906170457.32393-14-bigeasy@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

---
 include/linux/padata.h |  2 +-
 kernel/padata.c        | 88 ++++++++++++++++++++++++++++----------------------
 2 files changed, 51 insertions(+), 39 deletions(-)

diff --git a/include/linux/padata.h b/include/linux/padata.h
index 113ee62..0f9e567 100644
--- a/include/linux/padata.h
+++ b/include/linux/padata.h
@@ -151,7 +151,7 @@ struct parallel_data {
  * @flags: padata flags.
  */
 struct padata_instance {
-	struct notifier_block		 cpu_notifier;
+	struct hlist_node		 node;
 	struct workqueue_struct		*wq;
 	struct parallel_data		*pd;
 	struct padata_cpumask		cpumask;
diff --git a/kernel/padata.c b/kernel/padata.c
index 9932788..7848f05 100644
--- a/kernel/padata.c
+++ b/kernel/padata.c
@@ -30,6 +30,7 @@
 #include <linux/slab.h>
 #include <linux/sysfs.h>
 #include <linux/rcupdate.h>
+#include <linux/module.h>
 
 #define MAX_OBJ_NUM 1000
 
@@ -769,52 +770,43 @@ static inline int pinst_has_cpu(struct padata_instance *pinst, int cpu)
 		cpumask_test_cpu(cpu, pinst->cpumask.cbcpu);
 }
 
-
-static int padata_cpu_callback(struct notifier_block *nfb,
-			       unsigned long action, void *hcpu)
+static int padata_cpu_online(unsigned int cpu, struct hlist_node *node)
 {
-	int err;
 	struct padata_instance *pinst;
-	int cpu = (unsigned long)hcpu;
+	int ret;
 
-	pinst = container_of(nfb, struct padata_instance, cpu_notifier);
+	pinst = hlist_entry_safe(node, struct padata_instance, node);
+	if (!pinst_has_cpu(pinst, cpu))
+		return 0;
 
-	switch (action) {
-	case CPU_ONLINE:
-	case CPU_ONLINE_FROZEN:
-	case CPU_DOWN_FAILED:
-	case CPU_DOWN_FAILED_FROZEN:
-		if (!pinst_has_cpu(pinst, cpu))
-			break;
-		mutex_lock(&pinst->lock);
-		err = __padata_add_cpu(pinst, cpu);
-		mutex_unlock(&pinst->lock);
-		if (err)
-			return notifier_from_errno(err);
-		break;
+	mutex_lock(&pinst->lock);
+	ret = __padata_add_cpu(pinst, cpu);
+	mutex_unlock(&pinst->lock);
+	return ret;
+}
 
-	case CPU_DOWN_PREPARE:
-	case CPU_DOWN_PREPARE_FROZEN:
-	case CPU_UP_CANCELED:
-	case CPU_UP_CANCELED_FROZEN:
-		if (!pinst_has_cpu(pinst, cpu))
-			break;
-		mutex_lock(&pinst->lock);
-		err = __padata_remove_cpu(pinst, cpu);
-		mutex_unlock(&pinst->lock);
-		if (err)
-			return notifier_from_errno(err);
-		break;
-	}
+static int padata_cpu_prep_down(unsigned int cpu, struct hlist_node *node)
+{
+	struct padata_instance *pinst;
+	int ret;
+
+	pinst = hlist_entry_safe(node, struct padata_instance, node);
+	if (!pinst_has_cpu(pinst, cpu))
+		return 0;
 
-	return NOTIFY_OK;
+	mutex_lock(&pinst->lock);
+	ret = __padata_remove_cpu(pinst, cpu);
+	mutex_unlock(&pinst->lock);
+	return ret;
 }
+
+static enum cpuhp_state hp_online;
 #endif
 
 static void __padata_free(struct padata_instance *pinst)
 {
 #ifdef CONFIG_HOTPLUG_CPU
-	unregister_hotcpu_notifier(&pinst->cpu_notifier);
+	cpuhp_state_remove_instance_nocalls(hp_online, &pinst->node);
 #endif
 
 	padata_stop(pinst);
@@ -1012,11 +1004,8 @@ struct padata_instance *padata_alloc(struct workqueue_struct *wq,
 	mutex_init(&pinst->lock);
 
 #ifdef CONFIG_HOTPLUG_CPU
-	pinst->cpu_notifier.notifier_call = padata_cpu_callback;
-	pinst->cpu_notifier.priority = 0;
-	register_hotcpu_notifier(&pinst->cpu_notifier);
+	cpuhp_state_add_instance_nocalls(hp_online, &pinst->node);
 #endif
-
 	return pinst;
 
 err_free_masks:
@@ -1039,3 +1028,26 @@ void padata_free(struct padata_instance *pinst)
 	kobject_put(&pinst->kobj);
 }
 EXPORT_SYMBOL(padata_free);
+
+#ifdef CONFIG_HOTPLUG_CPU
+
+static __init int padata_driver_init(void)
+{
+	int ret;
+
+	ret = cpuhp_setup_state_multi(CPUHP_AP_ONLINE_DYN, "padata:online",
+				      padata_cpu_online,
+				      padata_cpu_prep_down);
+	if (ret < 0)
+		return ret;
+	hp_online = ret;
+	return 0;
+}
+module_init(padata_driver_init);
+
+static __exit void padata_driver_exit(void)
+{
+	cpuhp_remove_multi_state(hp_online);
+}
+module_exit(padata_driver_exit);
+#endif

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

* [tip:smp/hotplug] fault-injection/cpu: Convert to hotplug state machine
  2016-09-06 17:04 ` [PATCH 14/21] fault-injection: cpu: " Sebastian Andrzej Siewior
@ 2016-09-19 19:57   ` tip-bot for Sebastian Andrzej Siewior
  0 siblings, 0 replies; 83+ messages in thread
From: tip-bot for Sebastian Andrzej Siewior @ 2016-09-19 19:57 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: peterz, linux-kernel, mingo, akinobu.mita, bigeasy, tglx, hpa

Commit-ID:  8c58898b3ecb213ad7c52aa0c7c9d3201e559be1
Gitweb:     http://git.kernel.org/tip/8c58898b3ecb213ad7c52aa0c7c9d3201e559be1
Author:     Sebastian Andrzej Siewior <bigeasy@linutronix.de>
AuthorDate: Tue, 6 Sep 2016 19:04:50 +0200
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Mon, 19 Sep 2016 21:44:31 +0200

fault-injection/cpu: Convert to hotplug state machine

Install the callbacks via the state machine.

This is just a temporary vehicle to keep the interface working for now,
It'll be replaced by the sysfs interface which allows to step through the
hotplug state machine step by step.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Akinobu Mita <akinobu.mita@gmail.com>
Cc: rt@linutronix.de
Link: http://lkml.kernel.org/r/20160906170457.32393-15-bigeasy@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

---
 include/linux/cpuhotplug.h      |  1 +
 lib/cpu-notifier-error-inject.c | 46 +++++++++++++++++++++++++++++++++++------
 2 files changed, 41 insertions(+), 6 deletions(-)

diff --git a/include/linux/cpuhotplug.h b/include/linux/cpuhotplug.h
index 7706987..bb6231d 100644
--- a/include/linux/cpuhotplug.h
+++ b/include/linux/cpuhotplug.h
@@ -43,6 +43,7 @@ enum cpuhp_state {
 	CPUHP_ARM_SHMOBILE_SCU_PREPARE,
 	CPUHP_SH_SH3X_PREPARE,
 	CPUHP_TIMERS_DEAD,
+	CPUHP_NOTF_ERR_INJ_PREPARE,
 	CPUHP_BRINGUP_CPU,
 	CPUHP_AP_IDLE_DEAD,
 	CPUHP_AP_OFFLINE,
diff --git a/lib/cpu-notifier-error-inject.c b/lib/cpu-notifier-error-inject.c
index 707ca24..0e2c9a1 100644
--- a/lib/cpu-notifier-error-inject.c
+++ b/lib/cpu-notifier-error-inject.c
@@ -8,16 +8,47 @@ static int priority;
 module_param(priority, int, 0);
 MODULE_PARM_DESC(priority, "specify cpu notifier priority");
 
+#define UP_PREPARE 0
+#define UP_PREPARE_FROZEN 0
+#define DOWN_PREPARE 0
+#define DOWN_PREPARE_FROZEN 0
+
 static struct notifier_err_inject cpu_notifier_err_inject = {
 	.actions = {
-		{ NOTIFIER_ERR_INJECT_ACTION(CPU_UP_PREPARE) },
-		{ NOTIFIER_ERR_INJECT_ACTION(CPU_UP_PREPARE_FROZEN) },
-		{ NOTIFIER_ERR_INJECT_ACTION(CPU_DOWN_PREPARE) },
-		{ NOTIFIER_ERR_INJECT_ACTION(CPU_DOWN_PREPARE_FROZEN) },
+		{ NOTIFIER_ERR_INJECT_ACTION(UP_PREPARE) },
+		{ NOTIFIER_ERR_INJECT_ACTION(UP_PREPARE_FROZEN) },
+		{ NOTIFIER_ERR_INJECT_ACTION(DOWN_PREPARE) },
+		{ NOTIFIER_ERR_INJECT_ACTION(DOWN_PREPARE_FROZEN) },
 		{}
 	}
 };
 
+static int notf_err_handle(struct notifier_err_inject_action *action)
+{
+	int ret;
+
+	ret = action->error;
+	if (ret)
+		pr_info("Injecting error (%d) to %s\n", ret, action->name);
+	return ret;
+}
+
+static int notf_err_inj_up_prepare(unsigned int cpu)
+{
+	if (!cpuhp_tasks_frozen)
+		return notf_err_handle(&cpu_notifier_err_inject.actions[0]);
+	else
+		return notf_err_handle(&cpu_notifier_err_inject.actions[1]);
+}
+
+static int notf_err_inj_dead(unsigned int cpu)
+{
+	if (!cpuhp_tasks_frozen)
+		return notf_err_handle(&cpu_notifier_err_inject.actions[2]);
+	else
+		return notf_err_handle(&cpu_notifier_err_inject.actions[3]);
+}
+
 static struct dentry *dir;
 
 static int err_inject_init(void)
@@ -29,7 +60,10 @@ static int err_inject_init(void)
 	if (IS_ERR(dir))
 		return PTR_ERR(dir);
 
-	err = register_hotcpu_notifier(&cpu_notifier_err_inject.nb);
+	err = cpuhp_setup_state_nocalls(CPUHP_NOTF_ERR_INJ_PREPARE,
+					"cpu-err-notif:prepare",
+					notf_err_inj_up_prepare,
+					notf_err_inj_dead);
 	if (err)
 		debugfs_remove_recursive(dir);
 
@@ -38,7 +72,7 @@ static int err_inject_init(void)
 
 static void err_inject_exit(void)
 {
-	unregister_hotcpu_notifier(&cpu_notifier_err_inject.nb);
+	cpuhp_remove_state_nocalls(CPUHP_NOTF_ERR_INJ_PREPARE);
 	debugfs_remove_recursive(dir);
 }
 

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

* [tip:smp/hotplug] mips/octeon/smp: Convert to hotplug state machine
  2016-09-06 17:04 ` [PATCH 15/21] mips: octeon: smp: " Sebastian Andrzej Siewior
  2016-09-07  8:24     ` Matt Redfearn
  2016-09-19 15:10   ` Ralf Baechle
@ 2016-09-19 19:58   ` tip-bot for Sebastian Andrzej Siewior
  2 siblings, 0 replies; 83+ messages in thread
From: tip-bot for Sebastian Andrzej Siewior @ 2016-09-19 19:58 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: tglx, hpa, peterz, ralf, bigeasy, mingo, linux-kernel

Commit-ID:  dd6d7c6f3dc136c1bec6def840f7fa53f84d1fe6
Gitweb:     http://git.kernel.org/tip/dd6d7c6f3dc136c1bec6def840f7fa53f84d1fe6
Author:     Sebastian Andrzej Siewior <bigeasy@linutronix.de>
AuthorDate: Tue, 6 Sep 2016 19:04:51 +0200
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Mon, 19 Sep 2016 21:44:32 +0200

mips/octeon/smp: Convert to hotplug state machine

Install the callbacks via the state machine.

[ tglx: Renamed the state to MIPS_SOC_PREPARE so it can be reused by other
  	SOCs ]

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Acked-by: Ralf Baechle <ralf@linux-mips.org>
Cc: linux-mips@linux-mips.org
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: rt@linutronix.de
Link: http://lkml.kernel.org/r/20160906170457.32393-16-bigeasy@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

---
 arch/mips/cavium-octeon/smp.c | 24 +++---------------------
 include/linux/cpuhotplug.h    |  1 +
 2 files changed, 4 insertions(+), 21 deletions(-)

diff --git a/arch/mips/cavium-octeon/smp.c b/arch/mips/cavium-octeon/smp.c
index 4d457d60..256fe6f 100644
--- a/arch/mips/cavium-octeon/smp.c
+++ b/arch/mips/cavium-octeon/smp.c
@@ -380,29 +380,11 @@ static int octeon_update_boot_vector(unsigned int cpu)
 	return 0;
 }
 
-static int octeon_cpu_callback(struct notifier_block *nfb,
-	unsigned long action, void *hcpu)
-{
-	unsigned int cpu = (unsigned long)hcpu;
-
-	switch (action & ~CPU_TASKS_FROZEN) {
-	case CPU_UP_PREPARE:
-		octeon_update_boot_vector(cpu);
-		break;
-	case CPU_ONLINE:
-		pr_info("Cpu %d online\n", cpu);
-		break;
-	case CPU_DEAD:
-		break;
-	}
-
-	return NOTIFY_OK;
-}
-
 static int register_cavium_notifier(void)
 {
-	hotcpu_notifier(octeon_cpu_callback, 0);
-	return 0;
+	return cpuhp_setup_state_nocalls(CPUHP_MIPS_SOC_PREPARE,
+					 "mips/cavium:prepare",
+					 octeon_update_boot_vector, NULL);
 }
 late_initcall(register_cavium_notifier);
 
diff --git a/include/linux/cpuhotplug.h b/include/linux/cpuhotplug.h
index bb6231d..8f8a48b 100644
--- a/include/linux/cpuhotplug.h
+++ b/include/linux/cpuhotplug.h
@@ -44,6 +44,7 @@ enum cpuhp_state {
 	CPUHP_SH_SH3X_PREPARE,
 	CPUHP_TIMERS_DEAD,
 	CPUHP_NOTF_ERR_INJ_PREPARE,
+	CPUHP_MIPS_SOC_PREPARE,
 	CPUHP_BRINGUP_CPU,
 	CPUHP_AP_IDLE_DEAD,
 	CPUHP_AP_OFFLINE,

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

* [tip:smp/hotplug] mips/loongson/smp: Convert to hotplug state machine
  2016-09-06 17:04 ` [PATCH 16/21] mips: loongson: smp: " Sebastian Andrzej Siewior
  2016-09-19 15:10   ` Ralf Baechle
@ 2016-09-19 19:58   ` tip-bot for Sebastian Andrzej Siewior
  1 sibling, 0 replies; 83+ messages in thread
From: tip-bot for Sebastian Andrzej Siewior @ 2016-09-19 19:58 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: ralf, tglx, linux-kernel, peterz, bigeasy, hpa, mingo

Commit-ID:  e476d3129100ba18daea2224f38fdd7195118d4b
Gitweb:     http://git.kernel.org/tip/e476d3129100ba18daea2224f38fdd7195118d4b
Author:     Sebastian Andrzej Siewior <bigeasy@linutronix.de>
AuthorDate: Tue, 6 Sep 2016 19:04:52 +0200
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Mon, 19 Sep 2016 21:44:32 +0200

mips/loongson/smp: Convert to hotplug state machine

Install the callbacks via the state machine.

[ tglx: Reuse the MIPS_SOC_PREPARE state ]

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Acked-by: Ralf Baechle <ralf@linux-mips.org>
Cc: linux-mips@linux-mips.org
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: rt@linutronix.de
Link: http://lkml.kernel.org/r/20160906170457.32393-17-bigeasy@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

---
 arch/mips/loongson64/loongson-3/smp.c | 34 ++++++++--------------------------
 1 file changed, 8 insertions(+), 26 deletions(-)

diff --git a/arch/mips/loongson64/loongson-3/smp.c b/arch/mips/loongson64/loongson-3/smp.c
index 2fec6f7..99aab9f 100644
--- a/arch/mips/loongson64/loongson-3/smp.c
+++ b/arch/mips/loongson64/loongson-3/smp.c
@@ -677,7 +677,7 @@ void play_dead(void)
 	play_dead_at_ckseg1(state_addr);
 }
 
-void loongson3_disable_clock(int cpu)
+static int loongson3_disable_clock(unsigned int cpu)
 {
 	uint64_t core_id = cpu_data[cpu].core;
 	uint64_t package_id = cpu_data[cpu].package;
@@ -688,9 +688,10 @@ void loongson3_disable_clock(int cpu)
 		if (!(loongson_sysconf.workarounds & WORKAROUND_CPUHOTPLUG))
 			LOONGSON_FREQCTRL(package_id) &= ~(1 << (core_id * 4 + 3));
 	}
+	return 0;
 }
 
-void loongson3_enable_clock(int cpu)
+static int loongson3_enable_clock(unsigned int cpu)
 {
 	uint64_t core_id = cpu_data[cpu].core;
 	uint64_t package_id = cpu_data[cpu].package;
@@ -701,34 +702,15 @@ void loongson3_enable_clock(int cpu)
 		if (!(loongson_sysconf.workarounds & WORKAROUND_CPUHOTPLUG))
 			LOONGSON_FREQCTRL(package_id) |= 1 << (core_id * 4 + 3);
 	}
-}
-
-#define CPU_POST_DEAD_FROZEN	(CPU_POST_DEAD | CPU_TASKS_FROZEN)
-static int loongson3_cpu_callback(struct notifier_block *nfb,
-	unsigned long action, void *hcpu)
-{
-	unsigned int cpu = (unsigned long)hcpu;
-
-	switch (action) {
-	case CPU_POST_DEAD:
-	case CPU_POST_DEAD_FROZEN:
-		pr_info("Disable clock for CPU#%d\n", cpu);
-		loongson3_disable_clock(cpu);
-		break;
-	case CPU_UP_PREPARE:
-	case CPU_UP_PREPARE_FROZEN:
-		pr_info("Enable clock for CPU#%d\n", cpu);
-		loongson3_enable_clock(cpu);
-		break;
-	}
-
-	return NOTIFY_OK;
+	return 0;
 }
 
 static int register_loongson3_notifier(void)
 {
-	hotcpu_notifier(loongson3_cpu_callback, 0);
-	return 0;
+	return cpuhp_setup_state_nocalls(CPUHP_MIPS_SOC_PREPARE,
+					 "mips/loongson:prepare",
+					 loongson3_enable_clock,
+					 loongson3_disable_clock);
 }
 early_initcall(register_loongson3_notifier);
 

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

* [tip:smp/hotplug] s390/mm/pfault: Convert to hotplug state machine
  2016-09-06 17:04 ` [PATCH 17/21] s390: mm: pfault: " Sebastian Andrzej Siewior
@ 2016-09-19 19:59   ` tip-bot for Sebastian Andrzej Siewior
  0 siblings, 0 replies; 83+ messages in thread
From: tip-bot for Sebastian Andrzej Siewior @ 2016-09-19 19:59 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: bigeasy, tglx, hpa, heiko.carstens, peterz, mingo, linux-kernel,
	schwidefsky

Commit-ID:  84c9ceefecb8fe51c4bfa2a5424dd73bc024e41d
Gitweb:     http://git.kernel.org/tip/84c9ceefecb8fe51c4bfa2a5424dd73bc024e41d
Author:     Sebastian Andrzej Siewior <bigeasy@linutronix.de>
AuthorDate: Tue, 6 Sep 2016 19:04:53 +0200
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Mon, 19 Sep 2016 21:44:32 +0200

s390/mm/pfault: Convert to hotplug state machine

Install the callbacks via the state machine.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: linux-s390@vger.kernel.org
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: rt@linutronix.de
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Link: http://lkml.kernel.org/r/20160906170457.32393-18-bigeasy@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

---
 arch/s390/mm/fault.c       | 30 ++++++++++++------------------
 include/linux/cpuhotplug.h |  1 +
 2 files changed, 13 insertions(+), 18 deletions(-)

diff --git a/arch/s390/mm/fault.c b/arch/s390/mm/fault.c
index a58bca6..cbb73fa 100644
--- a/arch/s390/mm/fault.c
+++ b/arch/s390/mm/fault.c
@@ -740,28 +740,21 @@ out:
 	put_task_struct(tsk);
 }
 
-static int pfault_cpu_notify(struct notifier_block *self, unsigned long action,
-			     void *hcpu)
+static int pfault_cpu_dead(unsigned int cpu)
 {
 	struct thread_struct *thread, *next;
 	struct task_struct *tsk;
 
-	switch (action & ~CPU_TASKS_FROZEN) {
-	case CPU_DEAD:
-		spin_lock_irq(&pfault_lock);
-		list_for_each_entry_safe(thread, next, &pfault_list, list) {
-			thread->pfault_wait = 0;
-			list_del(&thread->list);
-			tsk = container_of(thread, struct task_struct, thread);
-			wake_up_process(tsk);
-			put_task_struct(tsk);
-		}
-		spin_unlock_irq(&pfault_lock);
-		break;
-	default:
-		break;
+	spin_lock_irq(&pfault_lock);
+	list_for_each_entry_safe(thread, next, &pfault_list, list) {
+		thread->pfault_wait = 0;
+		list_del(&thread->list);
+		tsk = container_of(thread, struct task_struct, thread);
+		wake_up_process(tsk);
+		put_task_struct(tsk);
 	}
-	return NOTIFY_OK;
+	spin_unlock_irq(&pfault_lock);
+	return 0;
 }
 
 static int __init pfault_irq_init(void)
@@ -775,7 +768,8 @@ static int __init pfault_irq_init(void)
 	if (rc)
 		goto out_pfault;
 	irq_subclass_register(IRQ_SUBCLASS_SERVICE_SIGNAL);
-	hotcpu_notifier(pfault_cpu_notify, 0);
+	cpuhp_setup_state_nocalls(CPUHP_S390_PFAULT_DEAD, "s390/pfault:dead",
+				  NULL, pfault_cpu_dead);
 	return 0;
 
 out_pfault:
diff --git a/include/linux/cpuhotplug.h b/include/linux/cpuhotplug.h
index 8f8a48b..dea6696 100644
--- a/include/linux/cpuhotplug.h
+++ b/include/linux/cpuhotplug.h
@@ -26,6 +26,7 @@ enum cpuhp_state {
 	CPUHP_BLOCK_SOFTIRQ_DEAD,
 	CPUHP_VIRT_SCSI_DEAD,
 	CPUHP_ACPI_CPUDRV_DEAD,
+	CPUHP_S390_PFAULT_DEAD,
 	CPUHP_WORKQUEUE_PREP,
 	CPUHP_POWER_NUMA_PREPARE,
 	CPUHP_HRTIMERS_PREPARE,

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

* [tip:smp/hotplug] x86/apic/uv: Convert to hotplug state machine
  2016-09-06 17:04 ` [PATCH 18/21] x86: apic: uv: " Sebastian Andrzej Siewior
@ 2016-09-19 19:59   ` tip-bot for Sebastian Andrzej Siewior
  0 siblings, 0 replies; 83+ messages in thread
From: tip-bot for Sebastian Andrzej Siewior @ 2016-09-19 19:59 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: peterz, mingo, hpa, bigeasy, tglx, linux-kernel

Commit-ID:  b067a7be411ccb31b6cc866fc213670c3acf4001
Gitweb:     http://git.kernel.org/tip/b067a7be411ccb31b6cc866fc213670c3acf4001
Author:     Sebastian Andrzej Siewior <bigeasy@linutronix.de>
AuthorDate: Tue, 6 Sep 2016 19:04:54 +0200
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Mon, 19 Sep 2016 21:44:33 +0200

x86/apic/uv: Convert to hotplug state machine

Install the callbacks via the state machine.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: rt@linutronix.de
Link: http://lkml.kernel.org/r/20160906170457.32393-19-bigeasy@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

---
 arch/x86/kernel/apic/x2apic_uv_x.c | 31 ++++++-------------------------
 1 file changed, 6 insertions(+), 25 deletions(-)

diff --git a/arch/x86/kernel/apic/x2apic_uv_x.c b/arch/x86/kernel/apic/x2apic_uv_x.c
index cb0673c..391b7f8 100644
--- a/arch/x86/kernel/apic/x2apic_uv_x.c
+++ b/arch/x86/kernel/apic/x2apic_uv_x.c
@@ -927,7 +927,7 @@ static void uv_heartbeat(unsigned long ignored)
 	mod_timer(timer, jiffies + SCIR_CPU_HB_INTERVAL);
 }
 
-static void uv_heartbeat_enable(int cpu)
+static int uv_heartbeat_enable(unsigned int cpu)
 {
 	while (!uv_cpu_scir_info(cpu)->enabled) {
 		struct timer_list *timer = &uv_cpu_scir_info(cpu)->timer;
@@ -941,43 +941,24 @@ static void uv_heartbeat_enable(int cpu)
 		/* also ensure that boot cpu is enabled */
 		cpu = 0;
 	}
+	return 0;
 }
 
 #ifdef CONFIG_HOTPLUG_CPU
-static void uv_heartbeat_disable(int cpu)
+static int uv_heartbeat_disable(unsigned int cpu)
 {
 	if (uv_cpu_scir_info(cpu)->enabled) {
 		uv_cpu_scir_info(cpu)->enabled = 0;
 		del_timer(&uv_cpu_scir_info(cpu)->timer);
 	}
 	uv_set_cpu_scir_bits(cpu, 0xff);
-}
-
-/*
- * cpu hotplug notifier
- */
-static int uv_scir_cpu_notify(struct notifier_block *self, unsigned long action,
-			      void *hcpu)
-{
-	long cpu = (long)hcpu;
-
-	switch (action & ~CPU_TASKS_FROZEN) {
-	case CPU_DOWN_FAILED:
-	case CPU_ONLINE:
-		uv_heartbeat_enable(cpu);
-		break;
-	case CPU_DOWN_PREPARE:
-		uv_heartbeat_disable(cpu);
-		break;
-	default:
-		break;
-	}
-	return NOTIFY_OK;
+	return 0;
 }
 
 static __init void uv_scir_register_cpu_notifier(void)
 {
-	hotcpu_notifier(uv_scir_cpu_notify, 0);
+	cpuhp_setup_state_nocalls(CPUHP_AP_ONLINE_DYN, "x86/x2apic-uvx:online",
+				  uv_heartbeat_enable, uv_heartbeat_disable);
 }
 
 #else /* !CONFIG_HOTPLUG_CPU */

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

* [tip:smp/hotplug] blk/mq: Reserve hotplug ID states for block multiqueue
  2016-09-06 17:04 ` [PATCH 19/21] blk: mq: reserve hotplug ID states for block Sebastian Andrzej Siewior
@ 2016-09-19 20:03   ` tip-bot for Sebastian Andrzej Siewior
  2016-09-19 21:24   ` [tip:smp/hotplug] blk/mq: Reserve hotplug " tip-bot for Sebastian Andrzej Siewior
  2016-09-21  7:45   ` tip-bot for Sebastian Andrzej Siewior
  2 siblings, 0 replies; 83+ messages in thread
From: tip-bot for Sebastian Andrzej Siewior @ 2016-09-19 20:03 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: hpa, mingo, bigeasy, tglx, linux-kernel, axboe, peterz

Commit-ID:  9049c3581449a096fb8a05bf0021d15531fb25d0
Gitweb:     http://git.kernel.org/tip/9049c3581449a096fb8a05bf0021d15531fb25d0
Author:     Sebastian Andrzej Siewior <bigeasy@linutronix.de>
AuthorDate: Tue, 6 Sep 2016 19:04:55 +0200
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Mon, 19 Sep 2016 21:57:39 +0200

blk/mq: Reserve hotplug ID states for block multiqueue

This patch only reserves two CPU hotplug ids for block/mq so the block tree
can apply the conversion patches.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: rt@linutronix.de
Link: http://lkml.kernel.org/r/20160906170457.32393-20-bigeasy@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

---
 include/linux/cpuhotplug.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/linux/cpuhotplug.h b/include/linux/cpuhotplug.h
index 242bf53..67ef8ec 100644
--- a/include/linux/cpuhotplug.h
+++ b/include/linux/cpuhotplug.h
@@ -14,6 +14,7 @@ enum cpuhp_state {
 	CPUHP_PERF_SUPERH,
 	CPUHP_X86_HPET_DEAD,
 	CPUHP_X86_APB_DEAD,
+	CPUHP_BLK_MQ_DEAD,
 	CPUHP_WORKQUEUE_PREP,
 	CPUHP_POWER_NUMA_PREPARE,
 	CPUHP_HRTIMERS_PREPARE,
@@ -22,6 +23,7 @@ enum cpuhp_state {
 	CPUHP_SMPCFD_PREPARE,
 	CPUHP_RCUTREE_PREP,
 	CPUHP_NOTIFY_PREPARE,
+	CPUHP_BLK_MQ_PREPARE,
 	CPUHP_TIMERS_DEAD,
 	CPUHP_BRINGUP_CPU,
 	CPUHP_AP_IDLE_DEAD,

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

* [tip:smp/hotplug] blk/mq: Reserve hotplug states for block multiqueue
  2016-09-06 17:04 ` [PATCH 19/21] blk: mq: reserve hotplug ID states for block Sebastian Andrzej Siewior
  2016-09-19 20:03   ` [tip:smp/hotplug] blk/mq: Reserve hotplug ID states for block multiqueue tip-bot for Sebastian Andrzej Siewior
@ 2016-09-19 21:24   ` tip-bot for Sebastian Andrzej Siewior
  2016-09-21  7:45   ` tip-bot for Sebastian Andrzej Siewior
  2 siblings, 0 replies; 83+ messages in thread
From: tip-bot for Sebastian Andrzej Siewior @ 2016-09-19 21:24 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: tglx, linux-kernel, hpa, peterz, mingo, axboe, bigeasy

Commit-ID:  91f926d31bf1be968523d30b4a7ad96ddda0c9a9
Gitweb:     http://git.kernel.org/tip/91f926d31bf1be968523d30b4a7ad96ddda0c9a9
Author:     Sebastian Andrzej Siewior <bigeasy@linutronix.de>
AuthorDate: Tue, 6 Sep 2016 19:04:55 +0200
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Mon, 19 Sep 2016 23:18:21 +0200

blk/mq: Reserve hotplug states for block multiqueue

This patch only reserves two CPU hotplug states for block/mq so the block tree
can apply the conversion patches.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: rt@linutronix.de
Link: http://lkml.kernel.org/r/20160906170457.32393-20-bigeasy@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

---
 include/linux/cpuhotplug.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/linux/cpuhotplug.h b/include/linux/cpuhotplug.h
index 242bf53..67ef8ec 100644
--- a/include/linux/cpuhotplug.h
+++ b/include/linux/cpuhotplug.h
@@ -14,6 +14,7 @@ enum cpuhp_state {
 	CPUHP_PERF_SUPERH,
 	CPUHP_X86_HPET_DEAD,
 	CPUHP_X86_APB_DEAD,
+	CPUHP_BLK_MQ_DEAD,
 	CPUHP_WORKQUEUE_PREP,
 	CPUHP_POWER_NUMA_PREPARE,
 	CPUHP_HRTIMERS_PREPARE,
@@ -22,6 +23,7 @@ enum cpuhp_state {
 	CPUHP_SMPCFD_PREPARE,
 	CPUHP_RCUTREE_PREP,
 	CPUHP_NOTIFY_PREPARE,
+	CPUHP_BLK_MQ_PREPARE,
 	CPUHP_TIMERS_DEAD,
 	CPUHP_BRINGUP_CPU,
 	CPUHP_AP_IDLE_DEAD,

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

* [PATCH] cpufreq: fix up conversion to hotplug state machine
  2016-09-19 19:56   ` [tip:smp/hotplug] " tip-bot for Sebastian Andrzej Siewior
@ 2016-09-20 14:56     ` Sebastian Andrzej Siewior
  2016-09-20 15:07       ` [tip:smp/hotplug] cpufreq: Fix " tip-bot for Sebastian Andrzej Siewior
  2016-09-20 16:17       ` [PATCH] cpufreq: fix " Rafael J. Wysocki
  0 siblings, 2 replies; 83+ messages in thread
From: Sebastian Andrzej Siewior @ 2016-09-20 14:56 UTC (permalink / raw)
  To: peterz, rjw, mingo, hpa, linux-kernel, tglx; +Cc: Borislav Petkov

The function cpufreq_register_driver() returns zero on success and since
commit 27622b061eb4 ("cpufreq: Convert to hotplug state machine")
erroneously a positive number. Due to the "if (x) assume_error" construct
all callers assumed an error and things went south.
This patch resets the return value back to zero in the success case.

Fixes: 27622b061eb4 ("cpufreq: Convert to hotplug state machine")
Reported-by: Borislav Petkov <bp@alien8.de>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
 drivers/cpufreq/cpufreq.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index e0bc632a259e..8b44de4d7438 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -2503,6 +2503,7 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data)
 	if (ret < 0)
 		goto err_if_unreg;
 	hp_online = ret;
+	ret = 0;
 
 	pr_debug("driver %s up and running\n", driver_data->name);
 	goto out;
-- 
2.9.3

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

* [tip:smp/hotplug] cpufreq: Fix up conversion to hotplug state machine
  2016-09-20 14:56     ` [PATCH] cpufreq: fix up conversion " Sebastian Andrzej Siewior
@ 2016-09-20 15:07       ` tip-bot for Sebastian Andrzej Siewior
  2016-09-20 16:08         ` Borislav Petkov
  2016-09-20 16:17       ` [PATCH] cpufreq: fix " Rafael J. Wysocki
  1 sibling, 1 reply; 83+ messages in thread
From: tip-bot for Sebastian Andrzej Siewior @ 2016-09-20 15:07 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, mingo, tglx, hpa, bp, bigeasy

Commit-ID:  5372e054a1928fe704cf0a5e2e139645a777b50a
Gitweb:     http://git.kernel.org/tip/5372e054a1928fe704cf0a5e2e139645a777b50a
Author:     Sebastian Andrzej Siewior <bigeasy@linutronix.de>
AuthorDate: Tue, 20 Sep 2016 16:56:28 +0200
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Tue, 20 Sep 2016 16:59:21 +0200

cpufreq: Fix up conversion to hotplug state machine

The function cpufreq_register_driver() returns zero on success and since
commit 27622b061eb4 ("cpufreq: Convert to hotplug state machine")
erroneously a positive number. Due to the "if (x) assume_error" construct
all callers assumed an error and as a consequence the cpu freq kworker
crashes with a NULL pointer dereference.

Reset the return value back to zero in the success case.

Fixes: 27622b061eb4 ("cpufreq: Convert to hotplug state machine")
Reported-by: Borislav Petkov <bp@alien8.de>
Reported-and-tested-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: peterz@infradead.org
Cc: rjw@rjwysocki.net
Link: http://lkml.kernel.org/r/20160920145628.lp2bmq72ip3oiash@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

---
 drivers/cpufreq/cpufreq.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index e0bc632..8b44de4 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -2503,6 +2503,7 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data)
 	if (ret < 0)
 		goto err_if_unreg;
 	hp_online = ret;
+	ret = 0;
 
 	pr_debug("driver %s up and running\n", driver_data->name);
 	goto out;

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

* Re: [tip:smp/hotplug] cpufreq: Fix up conversion to hotplug state machine
  2016-09-20 15:07       ` [tip:smp/hotplug] cpufreq: Fix " tip-bot for Sebastian Andrzej Siewior
@ 2016-09-20 16:08         ` Borislav Petkov
  0 siblings, 0 replies; 83+ messages in thread
From: Borislav Petkov @ 2016-09-20 16:08 UTC (permalink / raw)
  To: bigeasy, tglx, hpa, mingo, linux-kernel; +Cc: linux-tip-commits

On Tue, Sep 20, 2016 at 08:07:08AM -0700, tip-bot for Sebastian Andrzej Siewior wrote:
> Commit-ID:  5372e054a1928fe704cf0a5e2e139645a777b50a
> Gitweb:     http://git.kernel.org/tip/5372e054a1928fe704cf0a5e2e139645a777b50a
> Author:     Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> AuthorDate: Tue, 20 Sep 2016 16:56:28 +0200
> Committer:  Thomas Gleixner <tglx@linutronix.de>
> CommitDate: Tue, 20 Sep 2016 16:59:21 +0200
> 
> cpufreq: Fix up conversion to hotplug state machine
> 
> The function cpufreq_register_driver() returns zero on success and since
> commit 27622b061eb4 ("cpufreq: Convert to hotplug state machine")
> erroneously a positive number. Due to the "if (x) assume_error" construct
> all callers assumed an error and as a consequence the cpu freq kworker
> crashes with a NULL pointer dereference.
> 
> Reset the return value back to zero in the success case.
> 
> Fixes: 27622b061eb4 ("cpufreq: Convert to hotplug state machine")
> Reported-by: Borislav Petkov <bp@alien8.de>

	-and-tested-by: me.

Thanks!

-- 
Regards/Gruss,
    Boris.

ECO tip #101: Trim your mails when you reply.

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

* Re: [PATCH] cpufreq: fix up conversion to hotplug state machine
  2016-09-20 14:56     ` [PATCH] cpufreq: fix up conversion " Sebastian Andrzej Siewior
  2016-09-20 15:07       ` [tip:smp/hotplug] cpufreq: Fix " tip-bot for Sebastian Andrzej Siewior
@ 2016-09-20 16:17       ` Rafael J. Wysocki
  1 sibling, 0 replies; 83+ messages in thread
From: Rafael J. Wysocki @ 2016-09-20 16:17 UTC (permalink / raw)
  To: Sebastian Andrzej Siewior
  Cc: peterz, mingo, hpa, linux-kernel, tglx, Borislav Petkov

On Tuesday, September 20, 2016 04:56:28 PM Sebastian Andrzej Siewior wrote:
> The function cpufreq_register_driver() returns zero on success and since
> commit 27622b061eb4 ("cpufreq: Convert to hotplug state machine")
> erroneously a positive number. Due to the "if (x) assume_error" construct
> all callers assumed an error and things went south.
> This patch resets the return value back to zero in the success case.
> 
> Fixes: 27622b061eb4 ("cpufreq: Convert to hotplug state machine")
> Reported-by: Borislav Petkov <bp@alien8.de>
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>

ACK

> ---
>  drivers/cpufreq/cpufreq.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
> index e0bc632a259e..8b44de4d7438 100644
> --- a/drivers/cpufreq/cpufreq.c
> +++ b/drivers/cpufreq/cpufreq.c
> @@ -2503,6 +2503,7 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data)
>  	if (ret < 0)
>  		goto err_if_unreg;
>  	hp_online = ret;
> +	ret = 0;
>  
>  	pr_debug("driver %s up and running\n", driver_data->name);
>  	goto out;
> 

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

* [tip:smp/hotplug] blk/mq: Reserve hotplug states for block multiqueue
  2016-09-06 17:04 ` [PATCH 19/21] blk: mq: reserve hotplug ID states for block Sebastian Andrzej Siewior
  2016-09-19 20:03   ` [tip:smp/hotplug] blk/mq: Reserve hotplug ID states for block multiqueue tip-bot for Sebastian Andrzej Siewior
  2016-09-19 21:24   ` [tip:smp/hotplug] blk/mq: Reserve hotplug " tip-bot for Sebastian Andrzej Siewior
@ 2016-09-21  7:45   ` tip-bot for Sebastian Andrzej Siewior
  2 siblings, 0 replies; 83+ messages in thread
From: tip-bot for Sebastian Andrzej Siewior @ 2016-09-21  7:45 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: hpa, linux-kernel, tglx, axboe, peterz, bigeasy, mingo

Commit-ID:  e2a738f7a88f32622684d972d654a9fed026555f
Gitweb:     http://git.kernel.org/tip/e2a738f7a88f32622684d972d654a9fed026555f
Author:     Sebastian Andrzej Siewior <bigeasy@linutronix.de>
AuthorDate: Tue, 6 Sep 2016 19:04:55 +0200
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Tue, 20 Sep 2016 11:24:15 +0200

blk/mq: Reserve hotplug states for block multiqueue

This patch only reserves two CPU hotplug states for block/mq so the block tree
can apply the conversion patches.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: rt@linutronix.de
Link: http://lkml.kernel.org/r/20160906170457.32393-20-bigeasy@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

---
 include/linux/cpuhotplug.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/linux/cpuhotplug.h b/include/linux/cpuhotplug.h
index dcfe6191..2ac07d0 100644
--- a/include/linux/cpuhotplug.h
+++ b/include/linux/cpuhotplug.h
@@ -14,6 +14,7 @@ enum cpuhp_state {
 	CPUHP_PERF_SUPERH,
 	CPUHP_X86_HPET_DEAD,
 	CPUHP_X86_APB_DEAD,
+	CPUHP_BLK_MQ_DEAD,
 	CPUHP_WORKQUEUE_PREP,
 	CPUHP_POWER_NUMA_PREPARE,
 	CPUHP_HRTIMERS_PREPARE,
@@ -22,6 +23,7 @@ enum cpuhp_state {
 	CPUHP_SMPCFD_PREPARE,
 	CPUHP_RCUTREE_PREP,
 	CPUHP_NOTIFY_PREPARE,
+	CPUHP_BLK_MQ_PREPARE,
 	CPUHP_TIMERS_DEAD,
 	CPUHP_BRINGUP_CPU,
 	CPUHP_AP_IDLE_DEAD,

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

end of thread, other threads:[~2016-09-21  7:46 UTC | newest]

Thread overview: 83+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-06 17:04 cpu hotplug: convert more drivers (batch #3) Sebastian Andrzej Siewior
2016-09-06 17:04 ` [PATCH 01/21] arm64: FP/SIMD: Convert to hotplug state machine Sebastian Andrzej Siewior
2016-09-06 17:04   ` Sebastian Andrzej Siewior
2016-09-06 18:14   ` Will Deacon
2016-09-06 18:14     ` Will Deacon
2016-09-19 19:51   ` [tip:smp/hotplug] arm64/FP/SIMD: " tip-bot for Sebastian Andrzej Siewior
2016-09-06 17:04 ` [PATCH 02/21] ARM: shmobile: " Sebastian Andrzej Siewior
2016-09-06 17:04   ` Sebastian Andrzej Siewior
2016-09-06 17:04   ` Sebastian Andrzej Siewior
2016-09-06 18:05   ` Geert Uytterhoeven
2016-09-06 18:05     ` Geert Uytterhoeven
2016-09-06 18:05     ` Geert Uytterhoeven
2016-09-06 18:05     ` Geert Uytterhoeven
2016-09-07 13:58     ` Sebastian Andrzej Siewior
2016-09-07 13:58       ` Sebastian Andrzej Siewior
2016-09-07 13:58       ` Sebastian Andrzej Siewior
2016-09-07 13:58       ` Sebastian Andrzej Siewior
2016-09-19 19:52   ` [tip:smp/hotplug] ARM/shmobile: " tip-bot for Sebastian Andrzej Siewior
2016-09-06 17:04 ` [PATCH 03/21] ARM: OMAP: wakeupgen: " Sebastian Andrzej Siewior
2016-09-06 17:04   ` Sebastian Andrzej Siewior
2016-09-13 22:24   ` Tony Lindgren
2016-09-13 22:24     ` Tony Lindgren
2016-09-19 19:52   ` [tip:smp/hotplug] ARM/OMAP/wakeupgen: " tip-bot for Sebastian Andrzej Siewior
2016-09-06 17:04 ` [PATCH 04/21] ia64: mca: " Sebastian Andrzej Siewior
2016-09-06 17:04   ` Sebastian Andrzej Siewior
2016-09-19 19:53   ` [tip:smp/hotplug] ia64/mca: " tip-bot for Sebastian Andrzej Siewior
2016-09-06 17:04 ` [PATCH 05/21] sh: SH-X3 SMP: " Sebastian Andrzej Siewior
2016-09-06 17:04   ` Sebastian Andrzej Siewior
2016-09-19 19:53   ` [tip:smp/hotplug] sh/SH-X3 " tip-bot for Sebastian Andrzej Siewior
2016-09-06 17:04 ` [PATCH 06/21] x86: microcode: " Sebastian Andrzej Siewior
2016-09-07 11:36   ` Borislav Petkov
2016-09-07 14:51     ` Sebastian Andrzej Siewior
2016-09-07 16:02       ` Borislav Petkov
2016-09-07 16:45     ` [PATCH 06/21 v2] " Sebastian Andrzej Siewior
2016-09-19 19:54       ` [tip:smp/hotplug] x86/microcode: " tip-bot for Sebastian Andrzej Siewior
2016-09-06 17:04 ` [PATCH 07/21] lib: irq_poll: " Sebastian Andrzej Siewior
2016-09-19 19:54   ` [tip:smp/hotplug] lib/irq_poll: " tip-bot for Sebastian Andrzej Siewior
2016-09-06 17:04 ` [PATCH 08/21] block: softirq: " Sebastian Andrzej Siewior
2016-09-19 19:55   ` [tip:smp/hotplug] block/softirq: " tip-bot for Sebastian Andrzej Siewior
2016-09-06 17:04 ` [PATCH 09/21] oprofile: timer: " Sebastian Andrzej Siewior
2016-09-19 19:55   ` [tip:smp/hotplug] oprofile/timer: " tip-bot for Sebastian Andrzej Siewior
2016-09-06 17:04 ` [PATCH 10/21] virtio scsi: " Sebastian Andrzej Siewior
2016-09-06 17:04 ` Sebastian Andrzej Siewior
2016-09-19 19:56   ` [tip:smp/hotplug] " tip-bot for Sebastian Andrzej Siewior
2016-09-06 17:04 ` [PATCH 11/21] ACPI: processor: " Sebastian Andrzej Siewior
2016-09-06 21:08   ` Rafael J. Wysocki
2016-09-07 14:01     ` Sebastian Andrzej Siewior
2016-09-07 15:59       ` Rafael J. Wysocki
2016-09-19 19:56   ` [tip:smp/hotplug] ACPI/processor: " tip-bot for Sebastian Andrzej Siewior
2016-09-06 17:04 ` [PATCH 12/21] cpufreq: " Sebastian Andrzej Siewior
2016-09-06 21:27   ` Rafael J. Wysocki
2016-09-07 14:18     ` Sebastian Andrzej Siewior
2016-09-07 15:58       ` Rafael J. Wysocki
2016-09-19 19:56   ` [tip:smp/hotplug] " tip-bot for Sebastian Andrzej Siewior
2016-09-20 14:56     ` [PATCH] cpufreq: fix up conversion " Sebastian Andrzej Siewior
2016-09-20 15:07       ` [tip:smp/hotplug] cpufreq: Fix " tip-bot for Sebastian Andrzej Siewior
2016-09-20 16:08         ` Borislav Petkov
2016-09-20 16:17       ` [PATCH] cpufreq: fix " Rafael J. Wysocki
2016-09-06 17:04 ` [PATCH 13/21] padata: Convert " Sebastian Andrzej Siewior
2016-09-19 19:57   ` [tip:smp/hotplug] " tip-bot for Sebastian Andrzej Siewior
2016-09-06 17:04 ` [PATCH 14/21] fault-injection: cpu: " Sebastian Andrzej Siewior
2016-09-19 19:57   ` [tip:smp/hotplug] fault-injection/cpu: " tip-bot for Sebastian Andrzej Siewior
2016-09-06 17:04 ` [PATCH 15/21] mips: octeon: smp: " Sebastian Andrzej Siewior
2016-09-07  8:24   ` Matt Redfearn
2016-09-07  8:24     ` Matt Redfearn
2016-09-07 14:27     ` Sebastian Andrzej Siewior
2016-09-08  8:34       ` Matt Redfearn
2016-09-08  8:34         ` Matt Redfearn
2016-09-19 15:10   ` Ralf Baechle
2016-09-19 19:58   ` [tip:smp/hotplug] mips/octeon/smp: " tip-bot for Sebastian Andrzej Siewior
2016-09-06 17:04 ` [PATCH 16/21] mips: loongson: smp: " Sebastian Andrzej Siewior
2016-09-19 15:10   ` Ralf Baechle
2016-09-19 19:58   ` [tip:smp/hotplug] mips/loongson/smp: " tip-bot for Sebastian Andrzej Siewior
2016-09-06 17:04 ` [PATCH 17/21] s390: mm: pfault: " Sebastian Andrzej Siewior
2016-09-19 19:59   ` [tip:smp/hotplug] s390/mm/pfault: " tip-bot for Sebastian Andrzej Siewior
2016-09-06 17:04 ` [PATCH 18/21] x86: apic: uv: " Sebastian Andrzej Siewior
2016-09-19 19:59   ` [tip:smp/hotplug] x86/apic/uv: " tip-bot for Sebastian Andrzej Siewior
2016-09-06 17:04 ` [PATCH 19/21] blk: mq: reserve hotplug ID states for block Sebastian Andrzej Siewior
2016-09-19 20:03   ` [tip:smp/hotplug] blk/mq: Reserve hotplug ID states for block multiqueue tip-bot for Sebastian Andrzej Siewior
2016-09-19 21:24   ` [tip:smp/hotplug] blk/mq: Reserve hotplug " tip-bot for Sebastian Andrzej Siewior
2016-09-21  7:45   ` tip-bot for Sebastian Andrzej Siewior
2016-09-06 17:04 ` [PATCH 20/21] blk: mq: cpu-notif: Convert to hotplug state machine Sebastian Andrzej Siewior
2016-09-06 17:04 ` [PATCH 21/21] blk: mq: " Sebastian Andrzej Siewior

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.