All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 0/3] PPC/KVM support higher vCPU ids
@ 2016-05-26  8:02 Greg Kurz
  2016-05-26  8:02 ` [Qemu-devel] [PATCH 1/3] PPC/KVM: early validation of vcpu id Greg Kurz
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Greg Kurz @ 2016-05-26  8:02 UTC (permalink / raw)
  To: qemu-devel; +Cc: Paolo Bonzini, qemu-ppc, Alexander Graf, David Gibson

Now that KVM_CAP_MAX_VCPU_ID is in Linux 4.6, we can use it to support
topologies that generate vCPU ids >= KVM_MAX_VCPUS. This is especially
useful for PPC targets when the guest has fewer threads per core than
the host.

The first patch was already posted and accepted by David last month, but
since it hasn't been pushed to an official tree yet, I resend it so that
the series applies against master.

---

Greg Kurz (3):
      PPC/KVM: early validation of vcpu id
      linux-headers: update to Linux 4.6
      KVM: use KVM_CAP_MAX_VCPU_ID


 include/standard-headers/linux/pci_regs.h      |   20 +++++++++++++++++++-
 include/standard-headers/linux/virtio_config.h |    2 ++
 include/sysemu/kvm.h                           |    2 ++
 kvm-all.c                                      |   12 ++++++++++++
 linux-headers/asm-arm/unistd.h                 |    2 ++
 linux-headers/asm-arm64/unistd.h               |    3 +++
 linux-headers/asm-powerpc/unistd.h             |    2 ++
 linux-headers/asm-s390/kvm.h                   |    1 +
 linux-headers/asm-s390/unistd.h                |    4 +++-
 linux-headers/asm-x86/kvm.h                    |    6 +++---
 linux-headers/asm-x86/unistd_x32.h             |    2 ++
 linux-headers/linux/kvm.h                      |    1 +
 target-ppc/translate_init.c                    |    8 ++++++++
 13 files changed, 60 insertions(+), 5 deletions(-)

--
Greg

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Qemu-devel] [PATCH 1/3] PPC/KVM: early validation of vcpu id
  2016-05-26  8:02 [Qemu-devel] [PATCH 0/3] PPC/KVM support higher vCPU ids Greg Kurz
@ 2016-05-26  8:02 ` Greg Kurz
  2016-05-27  3:58   ` David Gibson
  2016-05-26  8:02 ` [Qemu-devel] [PATCH 2/3] linux-headers: update to Linux 4.6 Greg Kurz
  2016-05-26  8:02 ` [Qemu-devel] [PATCH 3/3] KVM: use KVM_CAP_MAX_VCPU_ID Greg Kurz
  2 siblings, 1 reply; 10+ messages in thread
From: Greg Kurz @ 2016-05-26  8:02 UTC (permalink / raw)
  To: qemu-devel; +Cc: Paolo Bonzini, qemu-ppc, Alexander Graf, David Gibson

The KVM API restricts vcpu ids to be < KVM_CAP_MAX_VCPUS. On PowerPC
targets, depending on the number of threads per core in the host and
in the guest, some topologies do generate higher vcpu ids actually.
When this happens, QEMU bails out with the following error:

kvm_init_vcpu failed: Invalid argument

The KVM_CREATE_VCPU ioctl has several EINVAL return paths, so it is
not possible to fully disambiguate.

This patch adds a check in the code that computes vcpu ids, so that
we can detect the error earlier, and print a friendlier message instead
of calling KVM_CREATE_VCPU with an obviously bogus vcpu id.

Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com>
---
 include/sysemu/kvm.h        |    2 ++
 kvm-all.c                   |    6 ++++++
 target-ppc/translate_init.c |    8 ++++++++
 3 files changed, 16 insertions(+)

diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h
index f9f00e2e56cb..f357ccde9122 100644
--- a/include/sysemu/kvm.h
+++ b/include/sysemu/kvm.h
@@ -345,6 +345,8 @@ int kvm_arch_init(MachineState *ms, KVMState *s);
 
 int kvm_arch_init_vcpu(CPUState *cpu);
 
+bool kvm_vcpu_id_is_valid(int vcpu_id);
+
 /* Returns VCPU ID to be used on KVM_CREATE_VCPU ioctl() */
 unsigned long kvm_arch_vcpu_id(CPUState *cpu);
 
diff --git a/kvm-all.c b/kvm-all.c
index f9ae8f9bf809..e56f38527815 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -1459,6 +1459,12 @@ static int kvm_max_vcpus(KVMState *s)
     return (ret) ? ret : kvm_recommended_vcpus(s);
 }
 
+bool kvm_vcpu_id_is_valid(int vcpu_id)
+{
+    KVMState *s = KVM_STATE(current_machine->accelerator);
+    return vcpu_id >= 0 && vcpu_id < kvm_max_vcpus(s);
+}
+
 static int kvm_init(MachineState *ms)
 {
     MachineClass *mc = MACHINE_GET_CLASS(ms);
diff --git a/target-ppc/translate_init.c b/target-ppc/translate_init.c
index 954195f5e494..a003c1029d31 100644
--- a/target-ppc/translate_init.c
+++ b/target-ppc/translate_init.c
@@ -9231,6 +9231,14 @@ static void ppc_cpu_realizefn(DeviceState *dev, Error **errp)
 #if !defined(CONFIG_USER_ONLY)
     cpu->cpu_dt_id = (cs->cpu_index / smp_threads) * max_smt
         + (cs->cpu_index % smp_threads);
+
+    if (kvm_enabled() && !kvm_vcpu_id_is_valid(cpu->cpu_dt_id)) {
+        error_setg(errp, "Can't create CPU with id %d in KVM", cpu->cpu_dt_id);
+        error_append_hint(errp, "Adjust the number of cpus to %d "
+                          "or try to raise the number of threads per core\n",
+                          cpu->cpu_dt_id * smp_threads / max_smt);
+        return;
+    }
 #endif
 
     if (tcg_enabled()) {

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [Qemu-devel] [PATCH 2/3] linux-headers: update to Linux 4.6
  2016-05-26  8:02 [Qemu-devel] [PATCH 0/3] PPC/KVM support higher vCPU ids Greg Kurz
  2016-05-26  8:02 ` [Qemu-devel] [PATCH 1/3] PPC/KVM: early validation of vcpu id Greg Kurz
@ 2016-05-26  8:02 ` Greg Kurz
  2016-05-26  8:02 ` [Qemu-devel] [PATCH 3/3] KVM: use KVM_CAP_MAX_VCPU_ID Greg Kurz
  2 siblings, 0 replies; 10+ messages in thread
From: Greg Kurz @ 2016-05-26  8:02 UTC (permalink / raw)
  To: qemu-devel; +Cc: Paolo Bonzini, qemu-ppc, Alexander Graf, David Gibson

Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com>
---
 include/standard-headers/linux/pci_regs.h      |   20 +++++++++++++++++++-
 include/standard-headers/linux/virtio_config.h |    2 ++
 linux-headers/asm-arm/unistd.h                 |    2 ++
 linux-headers/asm-arm64/unistd.h               |    3 +++
 linux-headers/asm-powerpc/unistd.h             |    2 ++
 linux-headers/asm-s390/kvm.h                   |    1 +
 linux-headers/asm-s390/unistd.h                |    4 +++-
 linux-headers/asm-x86/kvm.h                    |    6 +++---
 linux-headers/asm-x86/unistd_x32.h             |    2 ++
 linux-headers/linux/kvm.h                      |    1 +
 10 files changed, 38 insertions(+), 5 deletions(-)

diff --git a/include/standard-headers/linux/pci_regs.h b/include/standard-headers/linux/pci_regs.h
index 1becea86c73c..404095124ae2 100644
--- a/include/standard-headers/linux/pci_regs.h
+++ b/include/standard-headers/linux/pci_regs.h
@@ -670,7 +670,8 @@
 #define PCI_EXT_CAP_ID_SECPCI	0x19	/* Secondary PCIe Capability */
 #define PCI_EXT_CAP_ID_PMUX	0x1A	/* Protocol Multiplexing */
 #define PCI_EXT_CAP_ID_PASID	0x1B	/* Process Address Space ID */
-#define PCI_EXT_CAP_ID_MAX	PCI_EXT_CAP_ID_PASID
+#define PCI_EXT_CAP_ID_DPC	0x1D	/* Downstream Port Containment */
+#define PCI_EXT_CAP_ID_MAX	PCI_EXT_CAP_ID_DPC
 
 #define PCI_EXT_CAP_DSN_SIZEOF	12
 #define PCI_EXT_CAP_MCAST_ENDPOINT_SIZEOF 40
@@ -946,4 +947,21 @@
 #define PCI_TPH_CAP_ST_SHIFT	16	/* st table shift */
 #define PCI_TPH_BASE_SIZEOF	12	/* size with no st table */
 
+/* Downstream Port Containment */
+#define PCI_EXP_DPC_CAP			4	/* DPC Capability */
+#define  PCI_EXP_DPC_CAP_RP_EXT		0x20	/* Root Port Extensions for DPC */
+#define  PCI_EXP_DPC_CAP_POISONED_TLP	0x40	/* Poisoned TLP Egress Blocking Supported */
+#define  PCI_EXP_DPC_CAP_SW_TRIGGER	0x80	/* Software Triggering Supported */
+#define  PCI_EXP_DPC_CAP_DL_ACTIVE	0x1000	/* ERR_COR signal on DL_Active supported */
+
+#define PCI_EXP_DPC_CTL			6	/* DPC control */
+#define  PCI_EXP_DPC_CTL_EN_NONFATAL 	0x02	/* Enable trigger on ERR_NONFATAL message */
+#define  PCI_EXP_DPC_CTL_INT_EN 	0x08	/* DPC Interrupt Enable */
+
+#define PCI_EXP_DPC_STATUS		8	/* DPC Status */
+#define  PCI_EXP_DPC_STATUS_TRIGGER	0x01	/* Trigger Status */
+#define  PCI_EXP_DPC_STATUS_INTERRUPT	0x08	/* Interrupt Status */
+
+#define PCI_EXP_DPC_SOURCE_ID		10	/* DPC Source Identifier */
+
 #endif /* LINUX_PCI_REGS_H */
diff --git a/include/standard-headers/linux/virtio_config.h b/include/standard-headers/linux/virtio_config.h
index bcc445b3d8c9..b30d0cb0c124 100644
--- a/include/standard-headers/linux/virtio_config.h
+++ b/include/standard-headers/linux/virtio_config.h
@@ -40,6 +40,8 @@
 #define VIRTIO_CONFIG_S_DRIVER_OK	4
 /* Driver has finished configuring features */
 #define VIRTIO_CONFIG_S_FEATURES_OK	8
+/* Device entered invalid state, driver must reset it */
+#define VIRTIO_CONFIG_S_NEEDS_RESET	0x40
 /* We've given up on this device. */
 #define VIRTIO_CONFIG_S_FAILED		0x80
 
diff --git a/linux-headers/asm-arm/unistd.h b/linux-headers/asm-arm/unistd.h
index 3f6f7279296f..ceb5450c811d 100644
--- a/linux-headers/asm-arm/unistd.h
+++ b/linux-headers/asm-arm/unistd.h
@@ -418,6 +418,8 @@
 #define __NR_membarrier			(__NR_SYSCALL_BASE+389)
 #define __NR_mlock2			(__NR_SYSCALL_BASE+390)
 #define __NR_copy_file_range		(__NR_SYSCALL_BASE+391)
+#define __NR_preadv2			(__NR_SYSCALL_BASE+392)
+#define __NR_pwritev2			(__NR_SYSCALL_BASE+393)
 
 /*
  * The following SWIs are ARM private.
diff --git a/linux-headers/asm-arm64/unistd.h b/linux-headers/asm-arm64/unistd.h
index 1caadc24e3fe..043d17a21342 100644
--- a/linux-headers/asm-arm64/unistd.h
+++ b/linux-headers/asm-arm64/unistd.h
@@ -13,4 +13,7 @@
  * You should have received a copy of the GNU General Public License
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
+
+#define __ARCH_WANT_RENAMEAT
+
 #include <asm-generic/unistd.h>
diff --git a/linux-headers/asm-powerpc/unistd.h b/linux-headers/asm-powerpc/unistd.h
index cd92d982f0df..1e66eba4c6ea 100644
--- a/linux-headers/asm-powerpc/unistd.h
+++ b/linux-headers/asm-powerpc/unistd.h
@@ -390,5 +390,7 @@
 #define __NR_membarrier		365
 #define __NR_mlock2		378
 #define __NR_copy_file_range	379
+#define __NR_preadv2		380
+#define __NR_pwritev2		381
 
 #endif /* _ASM_POWERPC_UNISTD_H_ */
diff --git a/linux-headers/asm-s390/kvm.h b/linux-headers/asm-s390/kvm.h
index a59499be0a82..09ae5dc2e90f 100644
--- a/linux-headers/asm-s390/kvm.h
+++ b/linux-headers/asm-s390/kvm.h
@@ -25,6 +25,7 @@
 #define KVM_DEV_FLIC_APF_DISABLE_WAIT	5
 #define KVM_DEV_FLIC_ADAPTER_REGISTER	6
 #define KVM_DEV_FLIC_ADAPTER_MODIFY	7
+#define KVM_DEV_FLIC_CLEAR_IO_IRQ	8
 /*
  * We can have up to 4*64k pending subchannels + 8 adapter interrupts,
  * as well as up  to ASYNC_PF_PER_VCPU*KVM_MAX_VCPUS pfault done interrupts.
diff --git a/linux-headers/asm-s390/unistd.h b/linux-headers/asm-s390/unistd.h
index 885837ed5ec0..8a404fd3a1e9 100644
--- a/linux-headers/asm-s390/unistd.h
+++ b/linux-headers/asm-s390/unistd.h
@@ -311,7 +311,9 @@
 #define __NR_shutdown		373
 #define __NR_mlock2		374
 #define __NR_copy_file_range	375
-#define NR_syscalls 376
+#define __NR_preadv2		376
+#define __NR_pwritev2		377
+#define NR_syscalls 378
 
 /* 
  * There are some system calls that are not present on 64 bit, some
diff --git a/linux-headers/asm-x86/kvm.h b/linux-headers/asm-x86/kvm.h
index cd54147cb365..739c0c594022 100644
--- a/linux-headers/asm-x86/kvm.h
+++ b/linux-headers/asm-x86/kvm.h
@@ -216,9 +216,9 @@ struct kvm_cpuid_entry2 {
 	__u32 padding[3];
 };
 
-#define KVM_CPUID_FLAG_SIGNIFCANT_INDEX		BIT(0)
-#define KVM_CPUID_FLAG_STATEFUL_FUNC		BIT(1)
-#define KVM_CPUID_FLAG_STATE_READ_NEXT		BIT(2)
+#define KVM_CPUID_FLAG_SIGNIFCANT_INDEX		(1 << 0)
+#define KVM_CPUID_FLAG_STATEFUL_FUNC		(1 << 1)
+#define KVM_CPUID_FLAG_STATE_READ_NEXT		(1 << 2)
 
 /* for KVM_SET_CPUID2 */
 struct kvm_cpuid2 {
diff --git a/linux-headers/asm-x86/unistd_x32.h b/linux-headers/asm-x86/unistd_x32.h
index 8f77ee868a2f..0230779a84dc 100644
--- a/linux-headers/asm-x86/unistd_x32.h
+++ b/linux-headers/asm-x86/unistd_x32.h
@@ -306,7 +306,9 @@
 #define __NR_vmsplice (__X32_SYSCALL_BIT + 532)
 #define __NR_move_pages (__X32_SYSCALL_BIT + 533)
 #define __NR_preadv (__X32_SYSCALL_BIT + 534)
+#define __NR_preadv2 (__X32_SYSCALL_BIT + 534)
 #define __NR_pwritev (__X32_SYSCALL_BIT + 535)
+#define __NR_pwritev2 (__X32_SYSCALL_BIT + 535)
 #define __NR_rt_tgsigqueueinfo (__X32_SYSCALL_BIT + 536)
 #define __NR_recvmmsg (__X32_SYSCALL_BIT + 537)
 #define __NR_sendmmsg (__X32_SYSCALL_BIT + 538)
diff --git a/linux-headers/linux/kvm.h b/linux-headers/linux/kvm.h
index 3bae71a8743e..e60e21ba227e 100644
--- a/linux-headers/linux/kvm.h
+++ b/linux-headers/linux/kvm.h
@@ -865,6 +865,7 @@ struct kvm_ppc_smmu_info {
 #define KVM_CAP_SPAPR_TCE_64 125
 #define KVM_CAP_ARM_PMU_V3 126
 #define KVM_CAP_VCPU_ATTRIBUTES 127
+#define KVM_CAP_MAX_VCPU_ID 128
 
 #ifdef KVM_CAP_IRQ_ROUTING
 

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [Qemu-devel] [PATCH 3/3] KVM: use KVM_CAP_MAX_VCPU_ID
  2016-05-26  8:02 [Qemu-devel] [PATCH 0/3] PPC/KVM support higher vCPU ids Greg Kurz
  2016-05-26  8:02 ` [Qemu-devel] [PATCH 1/3] PPC/KVM: early validation of vcpu id Greg Kurz
  2016-05-26  8:02 ` [Qemu-devel] [PATCH 2/3] linux-headers: update to Linux 4.6 Greg Kurz
@ 2016-05-26  8:02 ` Greg Kurz
  2016-05-27  3:58   ` David Gibson
  2 siblings, 1 reply; 10+ messages in thread
From: Greg Kurz @ 2016-05-26  8:02 UTC (permalink / raw)
  To: qemu-devel; +Cc: Paolo Bonzini, qemu-ppc, Alexander Graf, David Gibson

As stated in linux/Documentation/virtual/kvm/api.txt:

The maximum possible value for max_vcpu_id can be retrieved using the
KVM_CAP_MAX_VCPU_ID of the KVM_CHECK_EXTENSION ioctl() at run-time.

If the KVM_CAP_MAX_VCPU_ID does not exist, you should assume that
max_vcpu_id is the same as the value returned from KVM_CAP_MAX_VCPUS.

Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com>
---
 kvm-all.c |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/kvm-all.c b/kvm-all.c
index e56f38527815..e74e0c6e2352 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -1459,10 +1459,16 @@ static int kvm_max_vcpus(KVMState *s)
     return (ret) ? ret : kvm_recommended_vcpus(s);
 }
 
+static int kvm_max_vcpu_id(KVMState *s)
+{
+    int ret = kvm_check_extension(s, KVM_CAP_MAX_VCPU_ID);
+    return (ret) ? ret : kvm_max_vcpus(s);
+}
+
 bool kvm_vcpu_id_is_valid(int vcpu_id)
 {
     KVMState *s = KVM_STATE(current_machine->accelerator);
-    return vcpu_id >= 0 && vcpu_id < kvm_max_vcpus(s);
+    return vcpu_id >= 0 && vcpu_id < kvm_max_vcpu_id(s);
 }
 
 static int kvm_init(MachineState *ms)

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [Qemu-devel] [PATCH 1/3] PPC/KVM: early validation of vcpu id
  2016-05-26  8:02 ` [Qemu-devel] [PATCH 1/3] PPC/KVM: early validation of vcpu id Greg Kurz
@ 2016-05-27  3:58   ` David Gibson
  0 siblings, 0 replies; 10+ messages in thread
From: David Gibson @ 2016-05-27  3:58 UTC (permalink / raw)
  To: Greg Kurz; +Cc: qemu-devel, Paolo Bonzini, qemu-ppc, Alexander Graf

[-- Attachment #1: Type: text/plain, Size: 3085 bytes --]

On Thu, May 26, 2016 at 10:02:10AM +0200, Greg Kurz wrote:
> The KVM API restricts vcpu ids to be < KVM_CAP_MAX_VCPUS. On PowerPC
> targets, depending on the number of threads per core in the host and
> in the guest, some topologies do generate higher vcpu ids actually.
> When this happens, QEMU bails out with the following error:
> 
> kvm_init_vcpu failed: Invalid argument
> 
> The KVM_CREATE_VCPU ioctl has several EINVAL return paths, so it is
> not possible to fully disambiguate.
> 
> This patch adds a check in the code that computes vcpu ids, so that
> we can detect the error earlier, and print a friendlier message instead
> of calling KVM_CREATE_VCPU with an obviously bogus vcpu id.
> 
> Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com>

Reviewed-by: David Gibson <david@gibson.dropbear.id.au>

> ---
>  include/sysemu/kvm.h        |    2 ++
>  kvm-all.c                   |    6 ++++++
>  target-ppc/translate_init.c |    8 ++++++++
>  3 files changed, 16 insertions(+)
> 
> diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h
> index f9f00e2e56cb..f357ccde9122 100644
> --- a/include/sysemu/kvm.h
> +++ b/include/sysemu/kvm.h
> @@ -345,6 +345,8 @@ int kvm_arch_init(MachineState *ms, KVMState *s);
>  
>  int kvm_arch_init_vcpu(CPUState *cpu);
>  
> +bool kvm_vcpu_id_is_valid(int vcpu_id);
> +
>  /* Returns VCPU ID to be used on KVM_CREATE_VCPU ioctl() */
>  unsigned long kvm_arch_vcpu_id(CPUState *cpu);
>  
> diff --git a/kvm-all.c b/kvm-all.c
> index f9ae8f9bf809..e56f38527815 100644
> --- a/kvm-all.c
> +++ b/kvm-all.c
> @@ -1459,6 +1459,12 @@ static int kvm_max_vcpus(KVMState *s)
>      return (ret) ? ret : kvm_recommended_vcpus(s);
>  }
>  
> +bool kvm_vcpu_id_is_valid(int vcpu_id)
> +{
> +    KVMState *s = KVM_STATE(current_machine->accelerator);
> +    return vcpu_id >= 0 && vcpu_id < kvm_max_vcpus(s);
> +}
> +
>  static int kvm_init(MachineState *ms)
>  {
>      MachineClass *mc = MACHINE_GET_CLASS(ms);
> diff --git a/target-ppc/translate_init.c b/target-ppc/translate_init.c
> index 954195f5e494..a003c1029d31 100644
> --- a/target-ppc/translate_init.c
> +++ b/target-ppc/translate_init.c
> @@ -9231,6 +9231,14 @@ static void ppc_cpu_realizefn(DeviceState *dev, Error **errp)
>  #if !defined(CONFIG_USER_ONLY)
>      cpu->cpu_dt_id = (cs->cpu_index / smp_threads) * max_smt
>          + (cs->cpu_index % smp_threads);
> +
> +    if (kvm_enabled() && !kvm_vcpu_id_is_valid(cpu->cpu_dt_id)) {
> +        error_setg(errp, "Can't create CPU with id %d in KVM", cpu->cpu_dt_id);
> +        error_append_hint(errp, "Adjust the number of cpus to %d "
> +                          "or try to raise the number of threads per core\n",
> +                          cpu->cpu_dt_id * smp_threads / max_smt);
> +        return;
> +    }
>  #endif
>  
>      if (tcg_enabled()) {
> 

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Qemu-devel] [PATCH 3/3] KVM: use KVM_CAP_MAX_VCPU_ID
  2016-05-26  8:02 ` [Qemu-devel] [PATCH 3/3] KVM: use KVM_CAP_MAX_VCPU_ID Greg Kurz
@ 2016-05-27  3:58   ` David Gibson
  2016-05-27 11:16     ` Greg Kurz
  0 siblings, 1 reply; 10+ messages in thread
From: David Gibson @ 2016-05-27  3:58 UTC (permalink / raw)
  To: Greg Kurz; +Cc: qemu-devel, Paolo Bonzini, qemu-ppc, Alexander Graf

[-- Attachment #1: Type: text/plain, Size: 1529 bytes --]

On Thu, May 26, 2016 at 10:02:23AM +0200, Greg Kurz wrote:
> As stated in linux/Documentation/virtual/kvm/api.txt:
> 
> The maximum possible value for max_vcpu_id can be retrieved using the
> KVM_CAP_MAX_VCPU_ID of the KVM_CHECK_EXTENSION ioctl() at run-time.
> 
> If the KVM_CAP_MAX_VCPU_ID does not exist, you should assume that
> max_vcpu_id is the same as the value returned from KVM_CAP_MAX_VCPUS.
> 
> Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com>

Reviewed-by: David Gibson <david@gibson.dropbear.id.au>

> ---
>  kvm-all.c |    8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/kvm-all.c b/kvm-all.c
> index e56f38527815..e74e0c6e2352 100644
> --- a/kvm-all.c
> +++ b/kvm-all.c
> @@ -1459,10 +1459,16 @@ static int kvm_max_vcpus(KVMState *s)
>      return (ret) ? ret : kvm_recommended_vcpus(s);
>  }
>  
> +static int kvm_max_vcpu_id(KVMState *s)
> +{
> +    int ret = kvm_check_extension(s, KVM_CAP_MAX_VCPU_ID);
> +    return (ret) ? ret : kvm_max_vcpus(s);
> +}
> +
>  bool kvm_vcpu_id_is_valid(int vcpu_id)
>  {
>      KVMState *s = KVM_STATE(current_machine->accelerator);
> -    return vcpu_id >= 0 && vcpu_id < kvm_max_vcpus(s);
> +    return vcpu_id >= 0 && vcpu_id < kvm_max_vcpu_id(s);
>  }
>  
>  static int kvm_init(MachineState *ms)
> 

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Qemu-devel] [PATCH 3/3] KVM: use KVM_CAP_MAX_VCPU_ID
  2016-05-27  3:58   ` David Gibson
@ 2016-05-27 11:16     ` Greg Kurz
  2016-06-07  8:42       ` Greg Kurz
  2016-06-13  8:42       ` Greg Kurz
  0 siblings, 2 replies; 10+ messages in thread
From: Greg Kurz @ 2016-05-27 11:16 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: David Gibson, qemu-ppc, qemu-devel, Alexander Graf

On Fri, 27 May 2016 13:58:28 +1000
David Gibson <david@gibson.dropbear.id.au> wrote:

> On Thu, May 26, 2016 at 10:02:23AM +0200, Greg Kurz wrote:
> > As stated in linux/Documentation/virtual/kvm/api.txt:
> > 
> > The maximum possible value for max_vcpu_id can be retrieved using the
> > KVM_CAP_MAX_VCPU_ID of the KVM_CHECK_EXTENSION ioctl() at run-time.
> > 
> > If the KVM_CAP_MAX_VCPU_ID does not exist, you should assume that
> > max_vcpu_id is the same as the value returned from KVM_CAP_MAX_VCPUS.
> > 
> > Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com>  
> 
> Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
> 

Paolo,

FYI Patch 1/3 was in David's pull request earlier today. It is now upstream.

You may now apply 2/3 and 3/3.

Thanks !

--
Greg

> > ---
> >  kvm-all.c |    8 +++++++-
> >  1 file changed, 7 insertions(+), 1 deletion(-)
> > 
> > diff --git a/kvm-all.c b/kvm-all.c
> > index e56f38527815..e74e0c6e2352 100644
> > --- a/kvm-all.c
> > +++ b/kvm-all.c
> > @@ -1459,10 +1459,16 @@ static int kvm_max_vcpus(KVMState *s)
> >      return (ret) ? ret : kvm_recommended_vcpus(s);
> >  }
> >  
> > +static int kvm_max_vcpu_id(KVMState *s)
> > +{
> > +    int ret = kvm_check_extension(s, KVM_CAP_MAX_VCPU_ID);
> > +    return (ret) ? ret : kvm_max_vcpus(s);
> > +}
> > +
> >  bool kvm_vcpu_id_is_valid(int vcpu_id)
> >  {
> >      KVMState *s = KVM_STATE(current_machine->accelerator);
> > -    return vcpu_id >= 0 && vcpu_id < kvm_max_vcpus(s);
> > +    return vcpu_id >= 0 && vcpu_id < kvm_max_vcpu_id(s);
> >  }
> >  
> >  static int kvm_init(MachineState *ms)
> >   
> 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Qemu-devel] [PATCH 3/3] KVM: use KVM_CAP_MAX_VCPU_ID
  2016-05-27 11:16     ` Greg Kurz
@ 2016-06-07  8:42       ` Greg Kurz
  2016-06-13  8:42       ` Greg Kurz
  1 sibling, 0 replies; 10+ messages in thread
From: Greg Kurz @ 2016-06-07  8:42 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: Alexander Graf, qemu-ppc, qemu-devel, David Gibson

On Fri, 27 May 2016 13:16:49 +0200
Greg Kurz <gkurz@linux.vnet.ibm.com> wrote:

> On Fri, 27 May 2016 13:58:28 +1000
> David Gibson <david@gibson.dropbear.id.au> wrote:
> 
> > On Thu, May 26, 2016 at 10:02:23AM +0200, Greg Kurz wrote:  
> > > As stated in linux/Documentation/virtual/kvm/api.txt:
> > > 
> > > The maximum possible value for max_vcpu_id can be retrieved using the
> > > KVM_CAP_MAX_VCPU_ID of the KVM_CHECK_EXTENSION ioctl() at run-time.
> > > 
> > > If the KVM_CAP_MAX_VCPU_ID does not exist, you should assume that
> > > max_vcpu_id is the same as the value returned from KVM_CAP_MAX_VCPUS.
> > > 
> > > Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com>    
> > 
> > Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
> >   
> 
> Paolo,
> 
> FYI Patch 1/3 was in David's pull request earlier today. It is now upstream.
> 
> You may now apply 2/3 and 3/3.
> 
> Thanks !
> 
> --
> Greg
> 

Ping ?

> > > ---
> > >  kvm-all.c |    8 +++++++-
> > >  1 file changed, 7 insertions(+), 1 deletion(-)
> > > 
> > > diff --git a/kvm-all.c b/kvm-all.c
> > > index e56f38527815..e74e0c6e2352 100644
> > > --- a/kvm-all.c
> > > +++ b/kvm-all.c
> > > @@ -1459,10 +1459,16 @@ static int kvm_max_vcpus(KVMState *s)
> > >      return (ret) ? ret : kvm_recommended_vcpus(s);
> > >  }
> > >  
> > > +static int kvm_max_vcpu_id(KVMState *s)
> > > +{
> > > +    int ret = kvm_check_extension(s, KVM_CAP_MAX_VCPU_ID);
> > > +    return (ret) ? ret : kvm_max_vcpus(s);
> > > +}
> > > +
> > >  bool kvm_vcpu_id_is_valid(int vcpu_id)
> > >  {
> > >      KVMState *s = KVM_STATE(current_machine->accelerator);
> > > -    return vcpu_id >= 0 && vcpu_id < kvm_max_vcpus(s);
> > > +    return vcpu_id >= 0 && vcpu_id < kvm_max_vcpu_id(s);
> > >  }
> > >  
> > >  static int kvm_init(MachineState *ms)
> > >     
> >   
> 
> 



-- 
Gregory Kurz                                     kurzgreg@fr.ibm.com
                                                 gkurz@linux.vnet.ibm.com
Software Engineer @ IBM/LTC                      http://www.ibm.com
Tel 33-5-6218-1607

"Anarchy is about taking complete responsibility for yourself."
        Alan Moore.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Qemu-devel] [PATCH 3/3] KVM: use KVM_CAP_MAX_VCPU_ID
  2016-05-27 11:16     ` Greg Kurz
  2016-06-07  8:42       ` Greg Kurz
@ 2016-06-13  8:42       ` Greg Kurz
  2016-06-13 11:25         ` Paolo Bonzini
  1 sibling, 1 reply; 10+ messages in thread
From: Greg Kurz @ 2016-06-13  8:42 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: Alexander Graf, qemu-ppc, qemu-devel, David Gibson

On Fri, 27 May 2016 13:16:49 +0200
Greg Kurz <gkurz@linux.vnet.ibm.com> wrote:

> On Fri, 27 May 2016 13:58:28 +1000
> David Gibson <david@gibson.dropbear.id.au> wrote:
> 
> > On Thu, May 26, 2016 at 10:02:23AM +0200, Greg Kurz wrote:  
> > > As stated in linux/Documentation/virtual/kvm/api.txt:
> > > 
> > > The maximum possible value for max_vcpu_id can be retrieved using the
> > > KVM_CAP_MAX_VCPU_ID of the KVM_CHECK_EXTENSION ioctl() at run-time.
> > > 
> > > If the KVM_CAP_MAX_VCPU_ID does not exist, you should assume that
> > > max_vcpu_id is the same as the value returned from KVM_CAP_MAX_VCPUS.
> > > 
> > > Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com>    
> > 
> > Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
> >   
> 
> Paolo,
> 
> FYI Patch 1/3 was in David's pull request earlier today. It is now upstream.
> 
> You may now apply 2/3 and 3/3.
> 
> Thanks !
> 

Hi Paolo,

Just a friendly reminder. Without this patch, we cannot create more than
128 single-threaded vCPUs on POWER8 if the host has unsplit cores.

Thanks !

--
Greg

> --
> Greg
> 
> > > ---
> > >  kvm-all.c |    8 +++++++-
> > >  1 file changed, 7 insertions(+), 1 deletion(-)
> > > 
> > > diff --git a/kvm-all.c b/kvm-all.c
> > > index e56f38527815..e74e0c6e2352 100644
> > > --- a/kvm-all.c
> > > +++ b/kvm-all.c
> > > @@ -1459,10 +1459,16 @@ static int kvm_max_vcpus(KVMState *s)
> > >      return (ret) ? ret : kvm_recommended_vcpus(s);
> > >  }
> > >  
> > > +static int kvm_max_vcpu_id(KVMState *s)
> > > +{
> > > +    int ret = kvm_check_extension(s, KVM_CAP_MAX_VCPU_ID);
> > > +    return (ret) ? ret : kvm_max_vcpus(s);
> > > +}
> > > +
> > >  bool kvm_vcpu_id_is_valid(int vcpu_id)
> > >  {
> > >      KVMState *s = KVM_STATE(current_machine->accelerator);
> > > -    return vcpu_id >= 0 && vcpu_id < kvm_max_vcpus(s);
> > > +    return vcpu_id >= 0 && vcpu_id < kvm_max_vcpu_id(s);
> > >  }
> > >  
> > >  static int kvm_init(MachineState *ms)
> > >     
> >   
> 
> 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Qemu-devel] [PATCH 3/3] KVM: use KVM_CAP_MAX_VCPU_ID
  2016-06-13  8:42       ` Greg Kurz
@ 2016-06-13 11:25         ` Paolo Bonzini
  0 siblings, 0 replies; 10+ messages in thread
From: Paolo Bonzini @ 2016-06-13 11:25 UTC (permalink / raw)
  To: Greg Kurz; +Cc: David Gibson, qemu-ppc, Alexander Graf, qemu-devel



On 13/06/2016 10:42, Greg Kurz wrote:
> On Fri, 27 May 2016 13:16:49 +0200
> Greg Kurz <gkurz@linux.vnet.ibm.com> wrote:
> 
>> On Fri, 27 May 2016 13:58:28 +1000
>> David Gibson <david@gibson.dropbear.id.au> wrote:
>>
>>> On Thu, May 26, 2016 at 10:02:23AM +0200, Greg Kurz wrote:  
>>>> As stated in linux/Documentation/virtual/kvm/api.txt:
>>>>
>>>> The maximum possible value for max_vcpu_id can be retrieved using the
>>>> KVM_CAP_MAX_VCPU_ID of the KVM_CHECK_EXTENSION ioctl() at run-time.
>>>>
>>>> If the KVM_CAP_MAX_VCPU_ID does not exist, you should assume that
>>>> max_vcpu_id is the same as the value returned from KVM_CAP_MAX_VCPUS.
>>>>
>>>> Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com>    
>>>
>>> Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
>>>   
>>
>> Paolo,
>>
>> FYI Patch 1/3 was in David's pull request earlier today. It is now upstream.
>>
>> You may now apply 2/3 and 3/3.
>>
>> Thanks !
>>
> 
> Hi Paolo,
> 
> Just a friendly reminder. Without this patch, we cannot create more than
> 128 single-threaded vCPUs on POWER8 if the host has unsplit cores.

Thanks!

Paolo

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2016-06-13 11:25 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-26  8:02 [Qemu-devel] [PATCH 0/3] PPC/KVM support higher vCPU ids Greg Kurz
2016-05-26  8:02 ` [Qemu-devel] [PATCH 1/3] PPC/KVM: early validation of vcpu id Greg Kurz
2016-05-27  3:58   ` David Gibson
2016-05-26  8:02 ` [Qemu-devel] [PATCH 2/3] linux-headers: update to Linux 4.6 Greg Kurz
2016-05-26  8:02 ` [Qemu-devel] [PATCH 3/3] KVM: use KVM_CAP_MAX_VCPU_ID Greg Kurz
2016-05-27  3:58   ` David Gibson
2016-05-27 11:16     ` Greg Kurz
2016-06-07  8:42       ` Greg Kurz
2016-06-13  8:42       ` Greg Kurz
2016-06-13 11:25         ` Paolo Bonzini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.