diff mbox series

[1/1] arm64: Prevent offline CPU handling IRQs.

Message ID 20220713132843.49693-1-alvinzhan1234@gmail.com (mailing list archive)
State New, archived
Headers show
Series [1/1] arm64: Prevent offline CPU handling IRQs. | expand

Commit Message

alvinzhan1234@gmail.com July 13, 2022, 1:28 p.m. UTC
From: Alvin Zhan <alvinzhan1234@gmail.com>

Migrate all of the IRQs on this CPU after setting it offline may still cause the IRQs to be dispatched to this CPU.
To prevent offline CPU handling IRQs, we should migrate the IRQs away from this CPU before it is powered off.

Signed-off-by: Alvin Zhan <alvinzhan1234@gmail.com>
---
 arch/arm64/kernel/smp.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

Comments

Mark Rutland July 13, 2022, 4:32 p.m. UTC | #1
On Wed, Jul 13, 2022 at 09:28:43PM +0800, alvinzhan1234@gmail.com wrote:
> From: Alvin Zhan <alvinzhan1234@gmail.com>
> 
> Migrate all of the IRQs on this CPU after setting it offline may still cause
> the IRQs to be dispatched to this CPU.

I was under the impression that __cpu_disable() was called with interrupts
masked, since it's called via stop_machine_cpuslocked(), and hence interrupts
cannot be taken here (ignoring pseudo-NMIs for the moment).

Have you ever seen that actually happen?

Mark.

> To prevent offline CPU handling IRQs, we should migrate the IRQs away from
> this CPU before it is powered off.
> 
> Signed-off-by: Alvin Zhan <alvinzhan1234@gmail.com>
> ---
>  arch/arm64/kernel/smp.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c
> index 62ed361a4..c4c3c5ed5 100644
> --- a/arch/arm64/kernel/smp.c
> +++ b/arch/arm64/kernel/smp.c
> @@ -302,6 +302,11 @@ int __cpu_disable(void)
>  	remove_cpu_topology(cpu);
>  	numa_remove_cpu(cpu);
>  
> +	/*
> +	 * Migrate IRQs away from this CPU first.
> +	 */
> +	irq_migrate_all_off_this_cpu();
> +
>  	/*
>  	 * Take this CPU offline.  Once we clear this, we can't return,
>  	 * and we must not schedule until we're ready to give up the cpu.
> @@ -309,11 +314,6 @@ int __cpu_disable(void)
>  	set_cpu_online(cpu, false);
>  	ipi_teardown(cpu);
>  
> -	/*
> -	 * OK - migrate IRQs away from this CPU
> -	 */
> -	irq_migrate_all_off_this_cpu();
> -
>  	return 0;
>  }
>  
> -- 
> 2.34.1
>
diff mbox series

Patch

diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c
index 62ed361a4..c4c3c5ed5 100644
--- a/arch/arm64/kernel/smp.c
+++ b/arch/arm64/kernel/smp.c
@@ -302,6 +302,11 @@  int __cpu_disable(void)
 	remove_cpu_topology(cpu);
 	numa_remove_cpu(cpu);
 
+	/*
+	 * Migrate IRQs away from this CPU first.
+	 */
+	irq_migrate_all_off_this_cpu();
+
 	/*
 	 * Take this CPU offline.  Once we clear this, we can't return,
 	 * and we must not schedule until we're ready to give up the cpu.
@@ -309,11 +314,6 @@  int __cpu_disable(void)
 	set_cpu_online(cpu, false);
 	ipi_teardown(cpu);
 
-	/*
-	 * OK - migrate IRQs away from this CPU
-	 */
-	irq_migrate_all_off_this_cpu();
-
 	return 0;
 }