kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nicholas Piggin <npiggin@gmail.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: Nicholas Piggin <npiggin@gmail.com>,
	kvm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] KVM: move struct kvm_vcpu * array to the bottom of struct kvm
Date: Fri,  5 Nov 2021 13:49:49 +1000	[thread overview]
Message-ID: <20211105034949.1397997-1-npiggin@gmail.com> (raw)

Increasing the max VCPUs on powerpc makes the kvm_arch member offset
great enough that some assembly breaks due to addressing constants
overflowing field widths.

Moving the vcpus array to the end of struct kvm prevents this from
happening. It has the side benefit that moving the large array out
from the middle of the structure should help keep other commonly
accessed fields in the same or adjacent cache lines.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---

It would next be possible to now make this a dynamically sized array,
and make the KVM_MAX_VCPUS more dynamic, however x86 kvm_svm uses its
own scheme rather than kvm_arch for some reason.

Thanks,
Nick

 include/linux/kvm_host.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index 0f18df7fe874..78cd9b63a6a5 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -553,7 +553,6 @@ struct kvm {
 	struct mutex slots_arch_lock;
 	struct mm_struct *mm; /* userspace tied to this vm */
 	struct kvm_memslots __rcu *memslots[KVM_ADDRESS_SPACE_NUM];
-	struct kvm_vcpu *vcpus[KVM_MAX_VCPUS];
 
 	/* Used to wait for completion of MMU notifiers.  */
 	spinlock_t mn_invalidate_lock;
@@ -623,6 +622,9 @@ struct kvm {
 	struct notifier_block pm_notifier;
 #endif
 	char stats_id[KVM_STATS_NAME_SIZE];
+
+	/* This array can be very large, so keep it at the bottom */
+	struct kvm_vcpu *vcpus[KVM_MAX_VCPUS];
 };
 
 #define kvm_err(fmt, ...) \
-- 
2.23.0


             reply	other threads:[~2021-11-05  3:50 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-05  3:49 Nicholas Piggin [this message]
2021-11-05 14:49 ` [PATCH] KVM: move struct kvm_vcpu * array to the bottom of struct kvm Sean Christopherson
2021-11-05 18:37   ` Marc Zyngier
2021-11-06  0:29   ` Nicholas Piggin
2021-11-08 15:35     ` Sean Christopherson

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=20211105034949.1397997-1-npiggin@gmail.com \
    --to=npiggin@gmail.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@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).