Skip to contentSkip to conversation

s390x: Enable KVM huge page backing support

PATCH Superseded Janosch Frank 3 participants 6 messages Jul 31, 2018 – Aug 1, 2018

v3 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#1 lore raw

PATCH v3 1/2 kvm: sync linux headers

In reply to Janosch Frank

Import KVM_CAP_S390_HPAGE_1M
Placeholder for proper sync.

---
 linux-headers/linux/kvm.h | 1 +
 1 file changed, 1 insertion(+)
linux-headers/linux/kvm.h +1 -0
index 98f389a5a3..2aae948219 100644
@@ -949,6 +949,7 @@ struct kvm_ppc_resize_hpt {
 #define KVM_CAP_GET_MSR_FEATURES 153
 #define KVM_CAP_HYPERV_EVENTFD 154
 #define KVM_CAP_HYPERV_TLBFLUSH 155
+#define KVM_CAP_S390_HPAGE_1M 156
 
 #ifdef KVM_CAP_IRQ_ROUTING
 
Signature · 1 line
2.14.3
#0 lore raw

v3 cover s390x: Enable KVM huge page backing support

v3:
* Fixed Cap name
* Added mempath page size check and error reporting

Janosch Frank (2):
kvm: sync linux headers
s390x: Enable KVM huge page backing support

 linux-headers/linux/kvm.h |  1 +
 target/s390x/kvm.c        | 15 +++++++++++++++
 2 files changed, 16 insertions(+)
Signature · 1 line
2.14.3
#2 lore raw

PATCH v3 2/2 s390x: Enable KVM huge page backing support

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.

---
 target/s390x/kvm.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
target/s390x/kvm.c +15 -0
index d923cf4240..f961c3b84a 100644
@@ -34,6 +34,7 @@
 #include "qapi/error.h"
 #include "qemu/error-report.h"
 #include "qemu/timer.h"
+#include "qemu/mmap-alloc.h"
 #include "sysemu/sysemu.h"
 #include "sysemu/hw_accel.h"
 #include "hw/hw.h"
@@ -285,6 +286,20 @@ int kvm_arch_init(MachineState *ms, KVMState *s)
 {
     MachineClass *mc = MACHINE_GET_CLASS(ms);
 
+    if (mem_path) {
+        if (qemu_mempath_getpagesize(mem_path) != (1 << 20)) {
+            error_report("Huge page backing with pages > 1M was specified, "
+                         "but KVM does not support this memory backing");
+            return -EINVAL;
+
+        }
+        if (kvm_vm_enable_cap(s, KVM_CAP_S390_HPAGE_1M, 0)) {
+            error_report("Huge page backing with 1M pages was specified, "
+                         "but KVM does not support this memory backing");
+            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);
Signature · 1 line
2.14.3
#3 lore raw
Quoted 26 lines · On Tue, 31 Jul 2018 13:09:08 +0100 Janosch Frank <[email protected]> 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.

---
 target/s390x/kvm.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
target/s390x/kvm.c +1 -0
index d923cf4240..f961c3b84a 100644
@@ -34,6 +34,7 @@
 #include "qapi/error.h"
 #include "qemu/error-report.h"
 #include "qemu/timer.h"
+#include "qemu/mmap-alloc.h"
 #include "sysemu/sysemu.h"
 #include "sysemu/hw_accel.h"
 #include "hw/hw.h"

target/s390x/kvm.c int kvm_arch_init(MachineState *ms, KVMState *s) · line 290

Quoted 5 lines
target/s390x/kvm.c +2 -0
@@ -285,6 +286,20 @@ int kvm_arch_init(MachineState *ms, KVMState *s)
 {
     MachineClass *mc = MACHINE_GET_CLASS(ms);
 
+    if (mem_path) {
+        if (qemu_mempath_getpagesize(mem_path) != (1 << 20)) {

1 * MiB ?

Quoted 15 lines
target/s390x/kvm.c +12 -0
+            error_report("Huge page backing with pages > 1M was specified, "
+                         "but KVM does not support this memory backing");
+            return -EINVAL;
+
+        }
+        if (kvm_vm_enable_cap(s, KVM_CAP_S390_HPAGE_1M, 0)) {
+            error_report("Huge page backing with 1M pages was specified, "
+                         "but KVM does not support this memory backing");
+            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);
#4 lore raw
Quoted 32 lines · Cornelia Huck
Quoted 29 lines · On Tue, 31 Jul 2018 13:09:08 +0100 Janosch Frank <[email protected]> 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.

---
 target/s390x/kvm.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
target/s390x/kvm.c +1 -0
index d923cf4240..f961c3b84a 100644
@@ -34,6 +34,7 @@
 #include "qapi/error.h"
 #include "qemu/error-report.h"
 #include "qemu/timer.h"
+#include "qemu/mmap-alloc.h"
 #include "sysemu/sysemu.h"
 #include "sysemu/hw_accel.h"
 #include "hw/hw.h"
@@ -285,6 +286,20 @@ int kvm_arch_init(MachineState *ms, KVMState *s)
 {
     MachineClass *mc = MACHINE_GET_CLASS(ms);
 
Quoted 4 lines

target/s390x/kvm.c int kvm_arch_init(MachineState *ms, KVMState *s) · line 290

Quoted 2 lines
target/s390x/kvm.c +2 -0
+    if (mem_path) {
+        if (qemu_mempath_getpagesize(mem_path) != (1 << 20)) {

1 * MiB ?

I only looked for page size definitions, didn't know it exists, yes 1 * MiB is a bit nicer.

I'd wait for more comments before sending the v4 out, so consider this fixed.

Quoted 18 lines
Quoted 16 lines
target/s390x/kvm.c +12 -0
+            error_report("Huge page backing with pages > 1M was specified, "
+                         "but KVM does not support this memory backing");
+            return -EINVAL;
+
+        }
+        if (kvm_vm_enable_cap(s, KVM_CAP_S390_HPAGE_1M, 0)) {
+            error_report("Huge page backing with 1M pages was specified, "
+                         "but KVM does not support this memory backing");
+            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);
#5 lore raw
In reply to Janosch Frank
Quoted 26 lines · Janosch Frank

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.

---
 target/s390x/kvm.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
target/s390x/kvm.c +1 -0
index d923cf4240..f961c3b84a 100644
@@ -34,6 +34,7 @@
 #include "qapi/error.h"
 #include "qemu/error-report.h"
 #include "qemu/timer.h"
+#include "qemu/mmap-alloc.h"
 #include "sysemu/sysemu.h"
 #include "sysemu/hw_accel.h"
 #include "hw/hw.h"

target/s390x/kvm.c int kvm_arch_init(MachineState *ms, KVMState *s) · line 293

Quoted 8 lines
target/s390x/kvm.c +5 -0
@@ -285,6 +286,20 @@ int kvm_arch_init(MachineState *ms, KVMState *s)
 {
     MachineClass *mc = MACHINE_GET_CLASS(ms);
 
+    if (mem_path) {
+        if (qemu_mempath_getpagesize(mem_path) != (1 << 20)) {
+            error_report("Huge page backing with pages > 1M was specified, "
+                         "but KVM does not support this memory backing");
+            return -EINVAL;

I think you should use ">" instead of "!=" here. It does not make much too much sense, but it is still possible that the user specifies a mem_path with 4k, and you don't want to trigger the error message here (try something like qemu-system-s390x -mem-path /tmp/... for example).

Thomas