[Qemu-devel] [PATCH v2 2/2] s390x: Enable KVM huge page backing support

Janosch Frank posted 2 patches 7 years, 3 months ago
There is a newer version of this series
[Qemu-devel] [PATCH v2 2/2] s390x: Enable KVM huge page backing support
Posted by Janosch Frank 7 years, 3 months ago
QEMU has had huge page support for a longer time already, but KVM
memory management under s390x needed some changes to work with huge
backings.

Now that we have support, let's enable it if requested and
available. Otherwise we now properly tell the user if there is no
support and back out instead of failing to run the VM later on.

Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
---
 target/s390x/kvm.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c
index d923cf4240..26e6937498 100644
--- a/target/s390x/kvm.c
+++ b/target/s390x/kvm.c
@@ -285,6 +285,12 @@ int kvm_arch_init(MachineState *ms, KVMState *s)
 {
     MachineClass *mc = MACHINE_GET_CLASS(ms);
 
+    if (mem_path && kvm_vm_enable_cap(s, KVM_CAP_S390_HPAGE, 0)) {
+        error_report("Huge page backing was specified, "
+                     "but this KVM does not support huge pages");
+        return -EINVAL;
+    }
+
     mc->default_cpu_type = S390_CPU_TYPE_NAME("host");
     cap_sync_regs = kvm_check_extension(s, KVM_CAP_SYNC_REGS);
     cap_async_pf = kvm_check_extension(s, KVM_CAP_ASYNC_PF);
-- 
2.14.3


Re: [Qemu-devel] [PATCH v2 2/2] s390x: Enable KVM huge page backing support
Posted by Thomas Huth 7 years, 3 months ago
On 07/31/2018 11:09 AM, Janosch Frank wrote:
> QEMU has had huge page support for a longer time already, but KVM
> memory management under s390x needed some changes to work with huge
> backings.
> 
> Now that we have support, let's enable it if requested and
> available. Otherwise we now properly tell the user if there is no
> support and back out instead of failing to run the VM later on.
> 
> Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
> ---
>  target/s390x/kvm.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c
> index d923cf4240..26e6937498 100644
> --- a/target/s390x/kvm.c
> +++ b/target/s390x/kvm.c
> @@ -285,6 +285,12 @@ int kvm_arch_init(MachineState *ms, KVMState *s)
>  {
>      MachineClass *mc = MACHINE_GET_CLASS(ms);
>  
> +    if (mem_path && kvm_vm_enable_cap(s, KVM_CAP_S390_HPAGE, 0)) {
> +        error_report("Huge page backing was specified, "
> +                     "but this KVM does not support huge pages");
> +        return -EINVAL;
> +    }

I think you should also check the page size of the mem_path (e.g. with
qemu_mempath_getpagesize() ?), since a mem_path does not automatically
mean huge pages, does it?

 Thomas


PS: Please CC: qemu-s390x@nongnu.org for s390x patches!