kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eduardo Habkost <ehabkost@redhat.com>
To: kvm@vger.kernel.org, Paolo Bonzini <pbonzini@redhat.com>
Cc: Sean Christopherson <seanjc@google.com>,
	Juergen Gross <jgross@suse.com>,
	Vitaly Kuznetsov <vkuznets@redhat.com>
Subject: [PATCH v2 1/3] kvm: x86: Set KVM_MAX_VCPU_ID to 4*KVM_MAX_VCPUS
Date: Fri,  3 Sep 2021 17:15:58 -0400	[thread overview]
Message-ID: <20210903211600.2002377-2-ehabkost@redhat.com> (raw)
In-Reply-To: <20210903211600.2002377-1-ehabkost@redhat.com>

Instead of requiring KVM_MAX_VCPU_ID to be manually increased
every time we increase KVM_MAX_VCPUS, set it to 4*KVM_MAX_VCPUS.
This should be enough for CPU topologies where Cores-per-Package
and Packages-per-Socket are not powers of 2.

In practice, this increases KVM_MAX_VCPU_ID from 1023 to 1152.
The only side effect of this change is making some fields in
struct kvm_ioapic larger, increasing the struct size from 1628 to
1780 bytes (in x86_64).

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
Note: this conflicts with:
  https://lore.kernel.org/lkml/20210903130808.30142-3-jgross@suse.com
  Date: Fri,  3 Sep 2021 15:08:03 +0200
  From: Juergen Gross <jgross@suse.com>
  Subject: [PATCH v2 2/6] x86/kvm: add boot parameter for adding vcpu-id bits
  Message-Id: <20210903130808.30142-3-jgross@suse.com>

I would be happy to drop this patch and resubmit the series if
Juergen's series gets merged first.  This is part of this series
only because I'm not sure how the final version of Juergen's
changes will look like and how long they will take to be merged.
---
 arch/x86/include/asm/kvm_host.h | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
index af6ce8d4c86a..f4cbc08b8d4d 100644
--- a/arch/x86/include/asm/kvm_host.h
+++ b/arch/x86/include/asm/kvm_host.h
@@ -39,7 +39,19 @@
 
 #define KVM_MAX_VCPUS 288
 #define KVM_SOFT_MAX_VCPUS 240
-#define KVM_MAX_VCPU_ID 1023
+
+/*
+ * In x86, the VCPU ID corresponds to the APIC ID, and APIC IDs
+ * might be larger than the actual number of VCPUs because the
+ * APIC ID encodes CPU topology information.
+ *
+ * In the worst case, we'll need less than one extra bit for the
+ * Core ID, and less than one extra bit for the Package (Die) ID,
+ * so ratio of 4 should be enough.
+ */
+#define KVM_VCPU_ID_RATIO 4
+#define KVM_MAX_VCPU_ID (KVM_MAX_VCPUS * KVM_VCPU_ID_RATIO)
+
 /* memory slots that are not exposed to userspace */
 #define KVM_PRIVATE_MEM_SLOTS 3
 
-- 
2.31.1


  reply	other threads:[~2021-09-03 21:16 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-03 21:15 [PATCH v2 0/3] kvm: x86: Set KVM_MAX_VCPUS=1024, KVM_SOFT_MAX_VCPUS=710 Eduardo Habkost
2021-09-03 21:15 ` Eduardo Habkost [this message]
2021-09-03 21:15 ` [PATCH v2 2/3] kvm: x86: Increase MAX_VCPUS to 1024 Eduardo Habkost
2021-09-03 21:16 ` [PATCH v2 3/3] kvm: x86: Increase KVM_SOFT_MAX_VCPUS to 710 Eduardo Habkost
2021-09-06 10:12 ` [PATCH v2 0/3] kvm: x86: Set KVM_MAX_VCPUS=1024, KVM_SOFT_MAX_VCPUS=710 Paolo Bonzini
2021-09-11  0:30   ` Sean Christopherson
2021-09-11 15:26     ` Eduardo Habkost
2021-09-13  5:09       ` Juergen Gross

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=20210903211600.2002377-2-ehabkost@redhat.com \
    --to=ehabkost@redhat.com \
    --cc=jgross@suse.com \
    --cc=kvm@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=seanjc@google.com \
    --cc=vkuznets@redhat.com \
    /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;
as well as URLs for NNTP newsgroup(s).