linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Christophe Leroy <christophe.leroy@csgroup.eu>
To: Fabiano Rosas <farosas@linux.ibm.com>, kvm-ppc@vger.kernel.org
Cc: linuxppc-dev@lists.ozlabs.org, groug@kaod.org,
	david@gibson.dropbear.id.au
Subject: Re: [RFC PATCH 2/2] KVM: PPC: Book3S HV: Provide a more accurate MAX_VCPU_ID in P9
Date: Tue, 8 Mar 2022 14:34:09 +0100	[thread overview]
Message-ID: <f5ec9d55-bac3-b571-dfad-bd501cd364b3@csgroup.eu> (raw)
In-Reply-To: <20210412222656.3466987-3-farosas@linux.ibm.com>



Le 13/04/2021 à 00:26, Fabiano Rosas a écrit :
> The KVM_CAP_MAX_VCPU_ID capability was added by commit 0b1b1dfd52a6
> ("kvm: introduce KVM_MAX_VCPU_ID") to allow for vcpu ids larger than
> KVM_MAX_VCPU in powerpc.
> 
> For a P9 host we depend on the guest VSMT value to know what is the
> maximum number of vcpu id we can support:
> 
> kvmppc_core_vcpu_create_hv:
>      (...)
>      if (cpu_has_feature(CPU_FTR_ARCH_300)) {
> -->         if (id >= (KVM_MAX_VCPUS * kvm->arch.emul_smt_mode)) {
>                      pr_devel("KVM: VCPU ID too high\n");
>                      core = KVM_MAX_VCORES;
>              } else {
>                      BUG_ON(kvm->arch.smt_mode != 1);
>                      core = kvmppc_pack_vcpu_id(kvm, id);
>              }
>      } else {
>              core = id / kvm->arch.smt_mode;
>      }
> 
> which means that the value being returned by the capability today for
> a given guest is potentially way larger than what we actually support:
> 
> \#define KVM_MAX_VCPU_ID (MAX_SMT_THREADS * KVM_MAX_VCORES)
> 
> If the capability is queried before userspace enables the
> KVM_CAP_PPC_SMT ioctl there is not much we can do, but if the emulated
> smt mode is already known we could provide a more accurate value.
> 
> The only practical effect of this change today is to make the
> kvm_create_max_vcpus test pass for powerpc. The QEMU spapr machine has
> a lower max vcpu than what KVM allows so even KVM_MAX_VCPU is not
> reached.
> 
> Signed-off-by: Fabiano Rosas <farosas@linux.ibm.com>

This patch won't apply after commit a1c42ddedf35 ("kvm: rename 
KVM_MAX_VCPU_ID to KVM_MAX_VCPU_IDS")

Feel free to resubmit if still applicable.

Christsophe


> 
> ---
> I see that for ppc, QEMU uses the capability after enabling
> KVM_CAP_PPC_SMT, so we could change QEMU to issue the check extension
> on the vm fd so that it would get the more accurate value.
> ---
>   arch/powerpc/kvm/powerpc.c | 5 ++++-
>   1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c
> index a2a68a958fa0..95c9f47cc1b3 100644
> --- a/arch/powerpc/kvm/powerpc.c
> +++ b/arch/powerpc/kvm/powerpc.c
> @@ -649,7 +649,10 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext)
>   		r = KVM_MAX_VCPUS;
>   		break;
>   	case KVM_CAP_MAX_VCPU_ID:
> -		r = KVM_MAX_VCPU_ID;
> +		if (hv_enabled && cpu_has_feature(CPU_FTR_ARCH_300))
> +			r = KVM_MAX_VCPUS * ((kvm) ? kvm->arch.emul_smt_mode : 1);
> +		else
> +			r = KVM_MAX_VCPU_ID;
>   		break;
>   #ifdef CONFIG_PPC_BOOK3S_64
>   	case KVM_CAP_PPC_GET_SMMU_INFO:

  reply	other threads:[~2022-03-08 13:34 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-12 22:26 [RFC PATCH 0/2] kvm selftests and MAX_VCPU_ID Fabiano Rosas
2021-04-12 22:26 ` [RFC PATCH 1/2] KVM: selftests: Add max vcpus test for ppc64le Fabiano Rosas
2021-04-12 22:26 ` [RFC PATCH 2/2] KVM: PPC: Book3S HV: Provide a more accurate MAX_VCPU_ID in P9 Fabiano Rosas
2022-03-08 13:34   ` Christophe Leroy [this message]
2022-03-08 14:27     ` Fabiano Rosas

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=f5ec9d55-bac3-b571-dfad-bd501cd364b3@csgroup.eu \
    --to=christophe.leroy@csgroup.eu \
    --cc=david@gibson.dropbear.id.au \
    --cc=farosas@linux.ibm.com \
    --cc=groug@kaod.org \
    --cc=kvm-ppc@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.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;
as well as URLs for NNTP newsgroup(s).