* [Qemu-devel] [PATCH v2 0/2] Small fixes for SMT guests in Power9
@ 2018-01-14 19:23 Jose Ricardo Ziviani
2018-01-14 19:23 ` [Qemu-devel] [PATCH v2 1/2] ppc: Change Power9 compat table to support at most 8 threads/core Jose Ricardo Ziviani
2018-01-14 19:23 ` [Qemu-devel] [PATCH v2 2/2] ppc: spapr: Check if thread argument is supported by host KVM Jose Ricardo Ziviani
0 siblings, 2 replies; 5+ messages in thread
From: Jose Ricardo Ziviani @ 2018-01-14 19:23 UTC (permalink / raw)
To: qemu-ppc; +Cc: qemu-devel, david, groug, lvivier
v2:
- divided in two patches:
(1) enables smt8 mode to P9 guests
(2) checks if host supports the # of threads/core required
limitation: doesn't check guest running in compat mode
This patchset contains 2 changes:
(1) A P9 guest defined like -smp sockets=1,cores=1,threads=8 will be silently
changed to threads=4:
(guest) # lscpu
Architecture: ppc64le
Byte Order: Little Endian
CPU(s): 4
On-line CPU(s) list: 0-3
Thread(s) per core: 4
Core(s) per socket: 1
Socket(s): 1
NUMA node(s): 1
...
(qemu) info cpus
* CPU #0: nip=0xc0000000000db9cc thread_id=9440
CPU #1: nip=0xc0000000000db9cc thread_id=9441
CPU #2: nip=0xc0000000000db9cc thread_id=9442
CPU #3: nip=0xc0000000000db9cc thread_id=9443
CPU #4: nip=0x0000000000000100 (halted) thread_id=9444
CPU #5: nip=0x0000000000000100 (halted) thread_id=9445
CPU #6: nip=0x0000000000000100 (halted) thread_id=9446
CPU #7: nip=0x0000000000000100 (halted) thread_id=9447
This patch enables P9 guests to use emulated smt because KVM supports it:
(guest) # lscpu
Architecture: ppc64le
Byte Order: Little Endian
CPU(s): 8
On-line CPU(s) list: 0-7
Thread(s) per core: 8
Core(s) per socket: 1
Socket(s): 1
NUMA node(s): 1
(qemu) info cpus
* CPU #0: nip=0xc0000000000d30ac thread_id=68400
CPU #1: nip=0xc0000000000d30ac thread_id=68401
CPU #2: nip=0xc0000000000d30ac thread_id=68402
CPU #3: nip=0xc0000000000d30ac thread_id=68403
CPU #4: nip=0xc0000000000d30ac thread_id=68404
CPU #5: nip=0xc0000000000d30ac thread_id=68405
CPU #6: nip=0xc0000000000d30ac thread_id=68406
CPU #7: nip=0xc0000000000d30ac thread_id=68407
CPU hotplugging also works as expected:
(qemu) device_add host-spapr-cpu-core,id=core8,core-id=8
(qemu) info cpus
* CPU #0: nip=0xc0000000000d30ac thread_id=68400
CPU #1: nip=0xc0000000000d30ac thread_id=68401
CPU #2: nip=0xc0000000000d30ac thread_id=68402
CPU #3: nip=0xc0000000000d30ac thread_id=68403
CPU #4: nip=0xc0000000000d30ac thread_id=68404
CPU #5: nip=0xc0000000000d30ac thread_id=68405
CPU #6: nip=0xc0000000000d30ac thread_id=68406
CPU #7: nip=0xc0000000000d30ac thread_id=68407
CPU #8: nip=0xc0000000000d30ac thread_id=68492
CPU #9: nip=0xc0000000000d30ac thread_id=68493
CPU #10: nip=0xc0000000000d30ac thread_id=68494
CPU #11: nip=0xc0000000000d30ac thread_id=68495
CPU #12: nip=0xc0000000000d30ac thread_id=68496
CPU #13: nip=0xc0000000000d30ac thread_id=68497
CPU #14: nip=0xc0000000000d30ac thread_id=68498
CPU #15: nip=0xc0000000000d30ac thread_id=68499
(guest) # lscpu
Architecture: ppc64le
Byte Order: Little Endian
CPU(s): 16
On-line CPU(s) list: 0-15
Thread(s) per core: 8
Core(s) per socket: 2
Socket(s): 1
NUMA node(s): 1
(2) Checks if KVM supports the number of threads required
If users try to pass more threads/core than the host supports it displays an
error message and quits:
qemu-system-ppc64: KVM does not support 8 threads/core.
Available VSMT modes: 4 2 1.
Jose Ricardo Ziviani (2):
ppc: Change Power9 compat table to support at most 8 threads/core
ppc: spapr: Check if thread argument is supported by host KVM
hw/ppc/spapr.c | 10 ++++++++++
target/ppc/compat.c | 2 +-
target/ppc/kvm.c | 5 +++++
target/ppc/kvm_ppc.h | 6 ++++++
4 files changed, 22 insertions(+), 1 deletion(-)
--
2.14.3
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Qemu-devel] [PATCH v2 1/2] ppc: Change Power9 compat table to support at most 8 threads/core
2018-01-14 19:23 [Qemu-devel] [PATCH v2 0/2] Small fixes for SMT guests in Power9 Jose Ricardo Ziviani
@ 2018-01-14 19:23 ` Jose Ricardo Ziviani
2018-01-15 5:26 ` David Gibson
2018-01-14 19:23 ` [Qemu-devel] [PATCH v2 2/2] ppc: spapr: Check if thread argument is supported by host KVM Jose Ricardo Ziviani
1 sibling, 1 reply; 5+ messages in thread
From: Jose Ricardo Ziviani @ 2018-01-14 19:23 UTC (permalink / raw)
To: qemu-ppc; +Cc: qemu-devel, david, groug, lvivier
Increases the max smt mode to 8 for Power9. That's because KVM supports
smt emulation in this platform so QEMU should allow users to use it as
well.
Today if we try to pass -smp ...,threads=8, QEMU will silently truncate
it to smt4 mode and may cause a crash if we try to perform a cpu
hotplug.
Signed-off-by: Jose Ricardo Ziviani <joserz@linux.vnet.ibm.com>
---
target/ppc/compat.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/target/ppc/compat.c b/target/ppc/compat.c
index ad8f93c064..d1770cdc6f 100644
--- a/target/ppc/compat.c
+++ b/target/ppc/compat.c
@@ -73,7 +73,7 @@ static const CompatInfo compat_table[] = {
.pvr = CPU_POWERPC_LOGICAL_3_00,
.pcr = PCR_COMPAT_3_00,
.pcr_level = PCR_COMPAT_3_00,
- .max_threads = 4,
+ .max_threads = 8,
},
};
--
2.14.3
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [Qemu-devel] [PATCH v2 2/2] ppc: spapr: Check if thread argument is supported by host KVM
2018-01-14 19:23 [Qemu-devel] [PATCH v2 0/2] Small fixes for SMT guests in Power9 Jose Ricardo Ziviani
2018-01-14 19:23 ` [Qemu-devel] [PATCH v2 1/2] ppc: Change Power9 compat table to support at most 8 threads/core Jose Ricardo Ziviani
@ 2018-01-14 19:23 ` Jose Ricardo Ziviani
2018-01-15 5:49 ` David Gibson
1 sibling, 1 reply; 5+ messages in thread
From: Jose Ricardo Ziviani @ 2018-01-14 19:23 UTC (permalink / raw)
To: qemu-ppc; +Cc: qemu-devel, david, groug, lvivier
QEMU currently checks whether SMT passed is valid or not. However, it
doesn't check if KVM supports such mode when kvm is enabled.
This patch relies on KVM_CAP_PPC_SMT_POSSIBLE to make it sure that QEMU
will either set a valid SMT mode or warn an error message and quit.
Signed-off-by: Jose Ricardo Ziviani <joserz@linux.vnet.ibm.com>
---
hw/ppc/spapr.c | 10 ++++++++++
target/ppc/kvm.c | 5 +++++
target/ppc/kvm_ppc.h | 6 ++++++
3 files changed, 21 insertions(+)
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index d1acfe8858..aed4d25fc4 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -2261,12 +2261,22 @@ static void spapr_set_vsmt_mode(sPAPRMachineState *spapr, Error **errp)
"on a pseries machine");
goto out;
}
+
if (!is_power_of_2(smp_threads)) {
error_setg(&local_err, "Cannot support %d threads/core on a pseries "
"machine because it must be a power of 2", smp_threads);
goto out;
}
+ if (kvm_enabled() && kvmppc_cap_smt_possible() > 0) {
+ if ((kvmppc_cap_smt_possible() & smp_threads) != smp_threads) {
+ error_setg(&local_err, "KVM does not support %d threads/core.",
+ smp_threads);
+ kvmppc_hint_smt_possible(&local_err);
+ goto out;
+ }
+ }
+
/* Detemine the VSMT mode to use: */
if (vsmt_user) {
if (spapr->vsmt < smp_threads) {
diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c
index 914be687e7..4a8ff4d63c 100644
--- a/target/ppc/kvm.c
+++ b/target/ppc/kvm.c
@@ -2456,6 +2456,11 @@ bool kvmppc_has_cap_mmu_hash_v3(void)
return cap_mmu_hash_v3;
}
+int kvmppc_cap_smt_possible(void)
+{
+ return cap_ppc_smt_possible;
+}
+
PowerPCCPUClass *kvm_ppc_get_host_cpu_class(void)
{
uint32_t host_pvr = mfpvr();
diff --git a/target/ppc/kvm_ppc.h b/target/ppc/kvm_ppc.h
index ecb55493cc..2221850723 100644
--- a/target/ppc/kvm_ppc.h
+++ b/target/ppc/kvm_ppc.h
@@ -59,6 +59,7 @@ bool kvmppc_has_cap_fixup_hcalls(void);
bool kvmppc_has_cap_htm(void);
bool kvmppc_has_cap_mmu_radix(void);
bool kvmppc_has_cap_mmu_hash_v3(void);
+int kvmppc_cap_smt_possible(void);
int kvmppc_enable_hwrng(void);
int kvmppc_put_books_sregs(PowerPCCPU *cpu);
PowerPCCPUClass *kvm_ppc_get_host_cpu_class(void);
@@ -290,6 +291,11 @@ static inline bool kvmppc_has_cap_mmu_hash_v3(void)
return false;
}
+static inline int kvmppc_cap_smt_possible(void)
+{
+ return 0;
+}
+
static inline int kvmppc_enable_hwrng(void)
{
return -1;
--
2.14.3
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH v2 1/2] ppc: Change Power9 compat table to support at most 8 threads/core
2018-01-14 19:23 ` [Qemu-devel] [PATCH v2 1/2] ppc: Change Power9 compat table to support at most 8 threads/core Jose Ricardo Ziviani
@ 2018-01-15 5:26 ` David Gibson
0 siblings, 0 replies; 5+ messages in thread
From: David Gibson @ 2018-01-15 5:26 UTC (permalink / raw)
To: Jose Ricardo Ziviani; +Cc: qemu-ppc, qemu-devel, groug, lvivier
[-- Attachment #1: Type: text/plain, Size: 1274 bytes --]
On Sun, Jan 14, 2018 at 05:23:48PM -0200, Jose Ricardo Ziviani wrote:
> Increases the max smt mode to 8 for Power9. That's because KVM supports
> smt emulation in this platform so QEMU should allow users to use it as
> well.
>
> Today if we try to pass -smp ...,threads=8, QEMU will silently truncate
> it to smt4 mode and may cause a crash if we try to perform a cpu
> hotplug.
>
> Signed-off-by: Jose Ricardo Ziviani <joserz@linux.vnet.ibm.com>
Applied, with the addition of a comment explaining why we want this
despite the hardware limit.
> ---
> target/ppc/compat.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/target/ppc/compat.c b/target/ppc/compat.c
> index ad8f93c064..d1770cdc6f 100644
> --- a/target/ppc/compat.c
> +++ b/target/ppc/compat.c
> @@ -73,7 +73,7 @@ static const CompatInfo compat_table[] = {
> .pvr = CPU_POWERPC_LOGICAL_3_00,
> .pcr = PCR_COMPAT_3_00,
> .pcr_level = PCR_COMPAT_3_00,
> - .max_threads = 4,
> + .max_threads = 8,
> },
> };
>
--
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: 833 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH v2 2/2] ppc: spapr: Check if thread argument is supported by host KVM
2018-01-14 19:23 ` [Qemu-devel] [PATCH v2 2/2] ppc: spapr: Check if thread argument is supported by host KVM Jose Ricardo Ziviani
@ 2018-01-15 5:49 ` David Gibson
0 siblings, 0 replies; 5+ messages in thread
From: David Gibson @ 2018-01-15 5:49 UTC (permalink / raw)
To: Jose Ricardo Ziviani; +Cc: qemu-ppc, qemu-devel, groug, lvivier
[-- Attachment #1: Type: text/plain, Size: 3553 bytes --]
On Sun, Jan 14, 2018 at 05:23:49PM -0200, Jose Ricardo Ziviani wrote:
> QEMU currently checks whether SMT passed is valid or not. However, it
> doesn't check if KVM supports such mode when kvm is enabled.
That's not really true - the attempt to actually set the vsmt mode in
KVM later on in spapr_set_vsmt_mode() will fail if KVM can't support
the number of threads.
The error added here might be a bit easier to understand, since it
doesn't refer to vsmt modes, which might just confuse the issue.
The change isn't urgent, though.
> This patch relies on KVM_CAP_PPC_SMT_POSSIBLE to make it sure that QEMU
> will either set a valid SMT mode or warn an error message and quit.
>
> Signed-off-by: Jose Ricardo Ziviani <joserz@linux.vnet.ibm.com>
> ---
> hw/ppc/spapr.c | 10 ++++++++++
> target/ppc/kvm.c | 5 +++++
> target/ppc/kvm_ppc.h | 6 ++++++
> 3 files changed, 21 insertions(+)
>
> diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
> index d1acfe8858..aed4d25fc4 100644
> --- a/hw/ppc/spapr.c
> +++ b/hw/ppc/spapr.c
> @@ -2261,12 +2261,22 @@ static void spapr_set_vsmt_mode(sPAPRMachineState *spapr, Error **errp)
> "on a pseries machine");
> goto out;
> }
> +
> if (!is_power_of_2(smp_threads)) {
> error_setg(&local_err, "Cannot support %d threads/core on a pseries "
> "machine because it must be a power of 2", smp_threads);
> goto out;
> }
>
> + if (kvm_enabled() && kvmppc_cap_smt_possible() > 0) {
> + if ((kvmppc_cap_smt_possible() & smp_threads) != smp_threads) {
> + error_setg(&local_err, "KVM does not support %d threads/core.",
> + smp_threads);
> + kvmppc_hint_smt_possible(&local_err);
> + goto out;
> + }
> + }
I'd like to see a fallback for kernels that don't support the
smt_possible cap and vsmt mode setting (for those, we must have
smp_threads <= kvm_smt).
> +
> /* Detemine the VSMT mode to use: */
> if (vsmt_user) {
> if (spapr->vsmt < smp_threads) {
> diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c
> index 914be687e7..4a8ff4d63c 100644
> --- a/target/ppc/kvm.c
> +++ b/target/ppc/kvm.c
> @@ -2456,6 +2456,11 @@ bool kvmppc_has_cap_mmu_hash_v3(void)
> return cap_mmu_hash_v3;
> }
>
> +int kvmppc_cap_smt_possible(void)
> +{
> + return cap_ppc_smt_possible;
> +}
> +
> PowerPCCPUClass *kvm_ppc_get_host_cpu_class(void)
> {
> uint32_t host_pvr = mfpvr();
> diff --git a/target/ppc/kvm_ppc.h b/target/ppc/kvm_ppc.h
> index ecb55493cc..2221850723 100644
> --- a/target/ppc/kvm_ppc.h
> +++ b/target/ppc/kvm_ppc.h
> @@ -59,6 +59,7 @@ bool kvmppc_has_cap_fixup_hcalls(void);
> bool kvmppc_has_cap_htm(void);
> bool kvmppc_has_cap_mmu_radix(void);
> bool kvmppc_has_cap_mmu_hash_v3(void);
> +int kvmppc_cap_smt_possible(void);
> int kvmppc_enable_hwrng(void);
> int kvmppc_put_books_sregs(PowerPCCPU *cpu);
> PowerPCCPUClass *kvm_ppc_get_host_cpu_class(void);
> @@ -290,6 +291,11 @@ static inline bool kvmppc_has_cap_mmu_hash_v3(void)
> return false;
> }
>
> +static inline int kvmppc_cap_smt_possible(void)
> +{
> + return 0;
> +}
> +
> static inline int kvmppc_enable_hwrng(void)
> {
> return -1;
--
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: 833 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2018-01-15 6:52 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-14 19:23 [Qemu-devel] [PATCH v2 0/2] Small fixes for SMT guests in Power9 Jose Ricardo Ziviani
2018-01-14 19:23 ` [Qemu-devel] [PATCH v2 1/2] ppc: Change Power9 compat table to support at most 8 threads/core Jose Ricardo Ziviani
2018-01-15 5:26 ` David Gibson
2018-01-14 19:23 ` [Qemu-devel] [PATCH v2 2/2] ppc: spapr: Check if thread argument is supported by host KVM Jose Ricardo Ziviani
2018-01-15 5:49 ` David Gibson
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).