Skip to contentSkip to conversation

cpu/hotplug: allow the cpu in UP_PREPARE state to bringup again

RFC In review Longpeng(Mike) 2 participants 5 messages Sep 1, 2021 – Nov 22, 2021 CPU hotplug

lore
Share & tools
lore
#0 lore raw

RFC 1/1 cpu/hotplug: allow the cpu in UP_PREPARE state to bringup again

The cpu's cpu_hotplug_state will be set to CPU_UP_PREPARE before the cpu is waken up, but it won't be reset when the failure occurs. Then the user cannot to make the cpu online anymore, because the CPU_UP_PREPARE state makes cpu_check_up_prepare() unhappy.

We should allow the user to try again in this case.

---
 kernel/smpboot.c | 7 +++++++
 1 file changed, 7 insertions(+)
kernel/smpboot.c +7 -0
index f6bc0bc..d18f8ff 100644
@@ -392,6 +392,13 @@ int cpu_check_up_prepare(int cpu)
 		 */
 		return -EAGAIN;
 
+	case CPU_UP_PREPARE:
+		/*
+		 * The CPU failed to bringup last time, allow the user
+		 * continue to try to start it up.
+		 */
+		return 0;
+
 	default:
 
 		/* Should not happen.  Famous last words. */
Signature · 1 line
1.8.3.1
#1 lore raw
Quoted 6 lines · Longpeng(Mike)

The cpu's cpu_hotplug_state will be set to CPU_UP_PREPARE before the cpu is waken up, but it won't be reset when the failure occurs. Then the user cannot to make the cpu online anymore, because the CPU_UP_PREPARE state makes cpu_check_up_prepare() unhappy.

We should allow the user to try again in this case.

Can you please describe where it failed / what did you reach that state?

Quoted 25 lines
---
 kernel/smpboot.c | 7 +++++++
 1 file changed, 7 insertions(+)
kernel/smpboot.c +7 -0
index f6bc0bc..d18f8ff 100644
@@ -392,6 +392,13 @@ int cpu_check_up_prepare(int cpu)
 		 */
 		return -EAGAIN;
 
+	case CPU_UP_PREPARE:
+		/*
+		 * The CPU failed to bringup last time, allow the user
+		 * continue to try to start it up.
+		 */
+		return 0;
+
 	default:
 
 		/* Should not happen.  Famous last words. */
Signature · 1 line
1.8.3.1

Sebastian

#2 lore raw
Quoted 14 lines

-----Original Message-----
From: Sebastian Andrzej Siewior [mailto:[email protected]]
Sent: Thursday, September 30, 2021 10:01 PM
To: Longpeng (Mike, Cloud Infrastructure Service Product Dept.) <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Gonglei (Arei) <[email protected]>
Subject: Re: [RFC] cpu/hotplug: allow the cpu in UP_PREPARE state to bringup again

On 2021-09-01 13:11:43 [+0800], Longpeng(Mike) wrote:

Quoted 9 lines
Quoted 6 lines

The cpu's cpu_hotplug_state will be set to CPU_UP_PREPARE before the cpu is waken up, but it won't be reset when the failure occurs. Then the user cannot to make the cpu online anymore, because the CPU_UP_PREPARE state makes cpu_check_up_prepare() unhappy.

We should allow the user to try again in this case.

Can you please describe where it failed / what did you reach that state?

native_cpu_up
cpu_check_up_prepare
do_boot_cpu

    /* Wait 10s total for first sign of life from AP */

It will fail if the AP doesn't response in 10s and then cpu_hotplug_state will stay in CPU_UP_PREPARE state.

This could happen on a virtualized system, especially in some special usages, e.g. Software Enclaves [1][2]

[1] https://docs.aws.amazon.com/enclaves/latest/user/nitro-enclave.html
[2] https://www.alibabacloud.com/help/doc-detail/203433.htm?spm=a3c0i.23986742.6981761520.1.7e30715eZCRXmk

Quoted 27 lines
Quoted 24 lines
---
 kernel/smpboot.c | 7 +++++++
 1 file changed, 7 insertions(+)
kernel/smpboot.c +7 -1
index f6bc0bc..d18f8ff 100644
@@ -392,6 +392,13 @@ int cpu_check_up_prepare(int cpu)
 		 */
 		return -EAGAIN;
 
+	case CPU_UP_PREPARE:
+		/*
+		 * The CPU failed to bringup last time, allow the user
+		 * continue to try to start it up.
+		 */
+		return 0;
+
 	default:
 
 		/* Should not happen.  Famous last words. */
--
Quoted 1 line

1.8.3.1

Sebastian

#3 lore raw

Sorry for forgetting…

Quoted 25 lines · Cloud Infrastructure Service Product Dept.)
Quoted 12 lines

-----Original Message-----
From: Sebastian Andrzej Siewior [mailto:[email protected]]
Sent: Thursday, September 30, 2021 10:01 PM
To: Longpeng (Mike, Cloud Infrastructure Service Product Dept.) <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Gonglei (Arei) <[email protected]>
Subject: Re: [RFC] cpu/hotplug: allow the cpu in UP_PREPARE state to bringup again

On 2021-09-01 13:11:43 [+0800], Longpeng(Mike) wrote:

Quoted 9 lines
Quoted 6 lines

The cpu's cpu_hotplug_state will be set to CPU_UP_PREPARE before the cpu is waken up, but it won't be reset when the failure occurs. Then the user cannot to make the cpu online anymore, because the CPU_UP_PREPARE state makes cpu_check_up_prepare() unhappy.

We should allow the user to try again in this case.

Can you please describe where it failed / what did you reach that state?

native_cpu_up
cpu_check_up_prepare
do_boot_cpu

Quoted 7 lines
    /* Wait 10s total for first sign of life from AP */

It will fail if the AP doesn't response in 10s and then cpu_hotplug_state will stay in CPU_UP_PREPARE state.

This could happen on a virtualized system, especially in some special usages, e.g. Software Enclaves [1][2]

So wakeup_cpu_via_init_nmi() / wakeup_secondary_cpu() succeeds but the CPU does not show up with 10 seconds.
Does the CPU come in later and spins in wait_for_master_cpu() or is the CPU completely missing?

Quoted 26 lines

[1] https://docs.aws.amazon.com/enclaves/latest/user/nitro-enclave.html
[2] https://www.alibabacloud.com/help/doc-detail/203433.htm?spm=a3c0i.23986742.6981761520.1.7e30715eZCRXmk

Quoted 22 lines
Quoted 22 lines
---
 kernel/smpboot.c | 7 +++++++
 1 file changed, 7 insertions(+)
kernel/smpboot.c +7 -0
index f6bc0bc..d18f8ff 100644
@@ -392,6 +392,13 @@ int cpu_check_up_prepare(int cpu)
 		 */
 		return -EAGAIN;
 
+	case CPU_UP_PREPARE:
+		/*
+		 * The CPU failed to bringup last time, allow the user
+		 * continue to try to start it up.
+		 */
+		return 0;
+
 	default:
 
Quoted 1 line
Quoted 1 line

kernel/smpboot.c int cpu_check_up_prepare(int cpu) · line 404

Quoted 1 line
kernel/smpboot.c +0 -0
 		/* Should not happen.  Famous last words. */

Sebastian

#4 lore raw
Quoted 47 lines

-----Original Message-----
From: Sebastian Andrzej Siewior [mailto:[email protected]]
Sent: Saturday, November 20, 2021 1:37 AM
To: Longpeng (Mike, Cloud Infrastructure Service Product Dept.) <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Gonglei (Arei) <[email protected]>
Subject: Re: [RFC] cpu/hotplug: allow the cpu in UP_PREPARE state to bringup again

Sorry for forgetting…

Quoted 30 lines · Cloud Infrastructure Service Product Dept.)
Quoted 12 lines

-----Original Message-----
From: Sebastian Andrzej Siewior [mailto:[email protected]]
Sent: Thursday, September 30, 2021 10:01 PM
To: Longpeng (Mike, Cloud Infrastructure Service Product Dept.) <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Gonglei (Arei) <[email protected]>
Subject: Re: [RFC] cpu/hotplug: allow the cpu in UP_PREPARE state to bringup again

On 2021-09-01 13:11:43 [+0800], Longpeng(Mike) wrote:

Quoted 9 lines
Quoted 6 lines

The cpu's cpu_hotplug_state will be set to CPU_UP_PREPARE before the cpu is waken up, but it won't be reset when the failure occurs. Then the user cannot to make the cpu online anymore, because the CPU_UP_PREPARE state makes cpu_check_up_prepare() unhappy.

We should allow the user to try again in this case.

Can you please describe where it failed / what did you reach that state?

native_cpu_up
cpu_check_up_prepare
do_boot_cpu

    /* Wait 10s total for first sign of life from AP */

It will fail if the AP doesn't response in 10s and then cpu_hotplug_state will stay in CPU_UP_PREPARE state.

Quoted 8 lines
Quoted 2 lines

This could happen on a virtualized system, especially in some special usages, e.g. Software Enclaves [1][2]

So wakeup_cpu_via_init_nmi() / wakeup_secondary_cpu() succeeds but the CPU does not show up with 10 seconds.
Does the CPU come in later and spins in wait_for_master_cpu() or is the CPU completely missing?

The cpu is completely missing at the moment since the hypervisor can reject all events that send to this cpu when the enclave vm is running.

But the cpu can receive the events and bring up again if the enclave vm is terminated.

Quoted 31 lines
Quoted 2 lines

[1] https://docs.aws.amazon.com/enclaves/latest/user/nitro-enclave.html
[2]

https://www.alibabacloud.com/help/doc-detail/203433.htm?spm=a3c0i.23986742.
6981761520.1.7e30715eZCRXmk

Quoted 24 lines
Quoted 24 lines
Quoted 24 lines
---
 kernel/smpboot.c | 7 +++++++
 1 file changed, 7 insertions(+)
kernel/smpboot.c +7 -0
index f6bc0bc..d18f8ff 100644
@@ -392,6 +392,13 @@ int cpu_check_up_prepare(int cpu)
 		 */
 		return -EAGAIN;
 
+	case CPU_UP_PREPARE:
+		/*
+		 * The CPU failed to bringup last time, allow the user
+		 * continue to try to start it up.
+		 */
+		return 0;
+
 	default:
 
Quoted 1 line
Quoted 1 line

kernel/smpboot.c int cpu_check_up_prepare(int cpu) · line 404

Quoted 1 line
kernel/smpboot.c +0 -0
 		/* Should not happen.  Famous last words. */

Sebastian