cpu/hotplug: Allow the CPU in CPU_UP_PREPARE state to be brought up again.
Subsystems (3)
v2 cover cpu/hotplug: Allow the CPU in CPU_UP_PREPARE state to be brought up again.
This is a another repost of the previous patch (#2) and adding Boris (Ostrovsky)'s suggestion regarding the XEN bits.
The previous posts can be found at
https://lore.kernel.org/all/[email protected]/
https://lore.kernel.org/all/[email protected]/
Sebastian
PATCH v2 1/2 x86/xen: Allow to retry if cpu_initialize_context() failed.
From: Boris Ostrovsky <[email protected]>
If memory allocation in cpu_initialize_context() fails then it will bring up the VCPU and leave with the corresponding CPU bit set in xen_cpu_initialized_map.
The following (presumably successful) CPU bring up will BUG in xen_pv_cpu_up() because nothing for that VCPU would be initialized.
Clear the CPU bits, that were set in cpu_initialize_context() in case the memory allocation fails.
[ bigeasy: Creating a patch from Boris' email. ]
--- arch/x86/xen/smp_pv.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
arch/x86/xen/smp_pv.c +4 -1
@@ -260,8 +260,11 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)return 0 ; ctxt =kzalloc (sizeof (*ctxt),GFP_KERNEL ); -if (ctxt ==NULL ) +if (ctxt ==NULL ) { +cpumask_clear_cpu (cpu, xen_cpu_initialized_map); +cpumask_clear_cpu (cpu, cpu_callout_mask);return -ENOMEM ; + } gdt =get_cpu_gdt_rw (cpu);
Signature · 1 line
2.34.1
[tip: smp/core] x86/xen: Allow to retry if cpu_initialize_context() failed.
The following commit has been merged into the smp/core branch of tip:
The following commit has been merged into the smp/core branch of tip:
Commit-ID: e8a69f12f01f487c6a0e704eb14ccf2dd015277d Gitweb: https://git.kernel.org/tip/e8a69f12f01f487c6a0e704eb14ccf2dd015277d Author: Boris Ostrovsky <[email protected]> AuthorDate: Wed, 09 Feb 2022 09:02:13 +01:00 Committer: Thomas Gleixner <[email protected]> CommitterDate: Tue, 12 Apr 2022 14:13:01 +02:00
x86/xen: Allow to retry if cpu_initialize_context() failed.
If memory allocation in cpu_initialize_context() fails then it will bring up the VCPU and leave with the corresponding CPU bit set in xen_cpu_initialized_map.
The following (presumably successful) CPU bring up will BUG in xen_pv_cpu_up() because nothing for that VCPU would be initialized.
Clear the CPU bits, that were set in cpu_initialize_context() in case the memory allocation fails.
[ bigeasy: Creating a patch from Boris' email. ]
--- arch/x86/xen/smp_pv.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
arch/x86/xen/smp_pv.c +4 -1
@@ -260,8 +260,11 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)return 0 ; ctxt =kzalloc (sizeof (*ctxt),GFP_KERNEL ); -if (ctxt ==NULL ) +if (ctxt ==NULL ) { +cpumask_clear_cpu (cpu, xen_cpu_initialized_map); +cpumask_clear_cpu (cpu, cpu_callout_mask);return -ENOMEM ; + } gdt =get_cpu_gdt_rw (cpu);
PATCH v2 2/2 cpu/hotplug: Allow the CPU in CPU_UP_PREPARE state to be brought up again.
In reply to Sebastian Andrzej SiewiorFrom: "Longpeng(Mike)" <[email protected]>
A CPU will not show up in virtualized environment which includes an Enclave. The VM splits its resources into a primary VM and a Enclave VM. While the Enclave is active, the hypervisor will ignore all requests to bring up a CPU and this CPU will remain in CPU_UP_PREPARE state. The kernel will wait up to ten seconds for CPU to show up (do_boot_cpu()) and then rollback the hotplug state back to CPUHP_OFFLINE leaving the CPU state in CPU_UP_PREPARE. The CPU state is set back to CPUHP_TEARDOWN_CPU during the CPU_POST_DEAD stage.
After the Enclave VM terminates, the primary VM can bring up the CPU again.
Allow to bring up the CPU if it is in the CPU_UP_PREPARE state.
[bigeasy: Rewrite commit description.]
--- kernel/smpboot.c | 7 +++++++ 1 file changed, 7 insertions(+)
kernel/smpboot.c +7 -0
@@ -392,6 +392,13 @@ int cpu_check_up_prepare(int cpu)*/ return -EAGAIN ; +case CPU_UP_PREPARE : +/* +* Timeout while waiting for the CPU to show up. Allow to try +* again later. +*/ +return 0 ; +default :/* Should not happen. Famous last words. */
Signature · 1 line
2.34.1
The following commit has been merged into the smp/core branch of tip:
The following commit has been merged into the smp/core branch of tip:
Commit-ID: c7dfb2591b23856182e2c9da6b1d526ef7fd6b2e Gitweb: https://git.kernel.org/tip/c7dfb2591b23856182e2c9da6b1d526ef7fd6b2e Author: Longpeng(Mike) <[email protected]> AuthorDate: Wed, 09 Feb 2022 09:02:14 +01:00 Committer: Thomas Gleixner <[email protected]> CommitterDate: Tue, 12 Apr 2022 14:13:01 +02:00
cpu/hotplug: Allow the CPU in CPU_UP_PREPARE state to be brought up again.
A CPU will not show up in virtualized environment which includes an Enclave. The VM splits its resources into a primary VM and a Enclave VM. While the Enclave is active, the hypervisor will ignore all requests to bring up a CPU and this CPU will remain in CPU_UP_PREPARE state.
The kernel will wait up to ten seconds for CPU to show up (do_boot_cpu()) and then rollback the hotplug state back to CPUHP_OFFLINE leaving the CPU state in CPU_UP_PREPARE. The CPU state is set back to CPUHP_TEARDOWN_CPU during the CPU_POST_DEAD stage.
After the Enclave VM terminates, the primary VM can bring up the CPU again.
Allow to bring up the CPU if it is in the CPU_UP_PREPARE state.
[bigeasy: Rewrite commit description.]
--- kernel/smpboot.c | 7 +++++++ 1 file changed, 7 insertions(+)
kernel/smpboot.c +7 -0
@@ -392,6 +392,13 @@ int cpu_check_up_prepare(int cpu)*/ return -EAGAIN ; +case CPU_UP_PREPARE : +/* +* Timeout while waiting for the CPU to show up. Allow to try +* again later. +*/ +return 0 ; +default :/* Should not happen. Famous last words. */