* [PATCH RFC] x86: avoid one cpu limit for kvm
@ 2024-12-24 13:09 Jinyu Tang
2025-02-25 21:55 ` Ingo Molnar
0 siblings, 1 reply; 2+ messages in thread
From: Jinyu Tang @ 2024-12-24 13:09 UTC (permalink / raw)
To: Thomas Gleixner, Ingo Molnar, x86, H . Peter Anvin, Will Deacon,
Anup Patel, Julien Thierry
Cc: kvm, linux-kernel, Jinyu Tang
I run kernel by kvmtool but only one cpu can start in guset now,
because kvm use virt-ioapic and kvmtool set noapic cmdline for
x86 to disable ioapic route in kernel, and the latest cpu topo
code below makes cpu limitted just to one.
For x86 kvm, noapic cmdline is reasonable, virt-ioapic don't
need to init hardware ioapic, so change it for x86 kvm guest to
avoid one num limit.
Signed-off-by: Jinyu Tang <tjytimi@163.com>
---
arch/x86/kernel/cpu/topology.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/arch/x86/kernel/cpu/topology.c b/arch/x86/kernel/cpu/topology.c
index 621a151ccf7d..a73847b1a841 100644
--- a/arch/x86/kernel/cpu/topology.c
+++ b/arch/x86/kernel/cpu/topology.c
@@ -429,7 +429,9 @@ void __init topology_apply_cmdline_limits_early(void)
unsigned int possible = nr_cpu_ids;
/* 'maxcpus=0' 'nosmp' 'nolapic' 'disableapic' 'noapic' */
- if (!setup_max_cpus || ioapic_is_disabled || apic_is_disabled)
+ if (!setup_max_cpus ||
+ (ioapic_is_disabled && (x86_hyper_type != X86_HYPER_KVM)) ||
+ apic_is_disabled)
possible = 1;
/* 'possible_cpus=N' */
@@ -443,8 +445,10 @@ void __init topology_apply_cmdline_limits_early(void)
static __init bool restrict_to_up(void)
{
- if (!smp_found_config || ioapic_is_disabled)
+ if (!smp_found_config ||
+ (ioapic_is_disabled && (x86_hyper_type != X86_HYPER_KVM)))
return true;
+
/*
* XEN PV is special as it does not advertise the local APIC
* properly, but provides a fake topology for it so that the
--
2.43.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH RFC] x86: avoid one cpu limit for kvm
2024-12-24 13:09 [PATCH RFC] x86: avoid one cpu limit for kvm Jinyu Tang
@ 2025-02-25 21:55 ` Ingo Molnar
0 siblings, 0 replies; 2+ messages in thread
From: Ingo Molnar @ 2025-02-25 21:55 UTC (permalink / raw)
To: Jinyu Tang
Cc: Thomas Gleixner, Ingo Molnar, x86, H . Peter Anvin, Will Deacon,
Anup Patel, Julien Thierry, kvm, linux-kernel
* Jinyu Tang <tjytimi@163.com> wrote:
> I run kernel by kvmtool but only one cpu can start in guset now,
> because kvm use virt-ioapic and kvmtool set noapic cmdline for
> x86 to disable ioapic route in kernel, and the latest cpu topo
> code below makes cpu limitted just to one.
>
> For x86 kvm, noapic cmdline is reasonable, virt-ioapic don't
> need to init hardware ioapic, so change it for x86 kvm guest to
> avoid one num limit.
>
> Signed-off-by: Jinyu Tang <tjytimi@163.com>
> ---
> arch/x86/kernel/cpu/topology.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/arch/x86/kernel/cpu/topology.c b/arch/x86/kernel/cpu/topology.c
> index 621a151ccf7d..a73847b1a841 100644
> --- a/arch/x86/kernel/cpu/topology.c
> +++ b/arch/x86/kernel/cpu/topology.c
> @@ -429,7 +429,9 @@ void __init topology_apply_cmdline_limits_early(void)
> unsigned int possible = nr_cpu_ids;
>
> /* 'maxcpus=0' 'nosmp' 'nolapic' 'disableapic' 'noapic' */
> - if (!setup_max_cpus || ioapic_is_disabled || apic_is_disabled)
> + if (!setup_max_cpus ||
> + (ioapic_is_disabled && (x86_hyper_type != X86_HYPER_KVM)) ||
> + apic_is_disabled)
> possible = 1;
>
> /* 'possible_cpus=N' */
> @@ -443,8 +445,10 @@ void __init topology_apply_cmdline_limits_early(void)
>
> static __init bool restrict_to_up(void)
> {
> - if (!smp_found_config || ioapic_is_disabled)
> + if (!smp_found_config ||
> + (ioapic_is_disabled && (x86_hyper_type != X86_HYPER_KVM)))
> return true;
> +
> /*
> * XEN PV is special as it does not advertise the local APIC
> * properly, but provides a fake topology for it so that the
Just to confirm that this bug got fixed, current kvmtool boots fine
with multiple CPUs, correct?
Thanks,
Ingo
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-02-25 21:56 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-24 13:09 [PATCH RFC] x86: avoid one cpu limit for kvm Jinyu Tang
2025-02-25 21:55 ` Ingo Molnar
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox