mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jinyu Tang <tjytimi@163.com>
To: Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>,
	x86@kernel.org, "H . Peter Anvin" <hpa@zytor.com>,
	Will Deacon <will@kernel.org>,
	Anup Patel <apatel@ventanamicro.com>,
	Julien Thierry <julien.thierry.kdev@gmail.com>
Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
	Jinyu Tang <tjytimi@163.com>
Subject: [PATCH RFC] x86: avoid one cpu limit for kvm
Date: Tue, 24 Dec 2024 21:09:52 +0800	[thread overview]
Message-ID: <20241224130952.112584-1-tjytimi@163.com> (raw)

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


             reply	other threads:[~2024-12-24 13:11 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-24 13:09 Jinyu Tang [this message]
2025-02-25 21:55 ` Ingo Molnar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241224130952.112584-1-tjytimi@163.com \
    --to=tjytimi@163.com \
    --cc=apatel@ventanamicro.com \
    --cc=hpa@zytor.com \
    --cc=julien.thierry.kdev@gmail.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=will@kernel.org \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®