Skip to contentSkip to conversation

s390x: Enable KVM huge page backing support

PATCH Superseded Janosch Frank 3 participants 3 messages Jul 31, 2018

v1 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 s390x: Enable KVM huge page backing support

From: Janosch Frank <[email protected]>

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.

---

Right now there's a conflict with arm for the capability, so I guess I'll have to touch the cap number soonish. :)

---
 linux-headers/linux/kvm.h | 1 +
 target/s390x/kvm.c        | 6 ++++++
 2 files changed, 7 insertions(+)
linux-headers/linux/kvm.h +1 -0
index 98f389a5a3..e3b1e3070c 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 156
 
 #ifdef KVM_CAP_IRQ_ROUTING
 
target/s390x/kvm.c +6 -0
index d923cf4240..1ce0b42039 100644
@@ -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);
Signature · 1 line
2.14.3
#1 lore raw
Quoted 11 lines · On Tue, 31 Jul 2018 09:42:36 +0100 Janosch Frank <[email protected]> wrote:

From: Janosch Frank <[email protected]>

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.

You may want to change author and signoff to the new, shorter address.

Quoted 4 lines

---

Right now there's a conflict with arm for the capability, so I guess I'll have to touch the cap number soonish. :)

You can fix this by spitting out the linux-headers update into a patch that will be replaced with a proper headers update :)

Quoted 23 lines
---
 linux-headers/linux/kvm.h | 1 +
 target/s390x/kvm.c        | 6 ++++++
 2 files changed, 7 insertions(+)
linux-headers/linux/kvm.h +1 -0
index 98f389a5a3..e3b1e3070c 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 156
 
 #ifdef KVM_CAP_IRQ_ROUTING
 
target/s390x/kvm.c +0 -0
index d923cf4240..1ce0b42039 100644

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

Quoted 6 lines
target/s390x/kvm.c +3 -0
@@ -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.");

Please drop the trailing '.', as by the documentation for error_report().

Quoted 6 lines
target/s390x/kvm.c +3 -0
+        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 lore raw
In reply to Janosch Frank
Quoted 41 lines · Janosch Frank

From: Janosch Frank <[email protected]>

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.

---

Right now there's a conflict with arm for the capability, so I guess I'll have to touch the cap number soonish. :)

---
 linux-headers/linux/kvm.h | 1 +
 target/s390x/kvm.c        | 6 ++++++
 2 files changed, 7 insertions(+)
linux-headers/linux/kvm.h +1 -0
index 98f389a5a3..e3b1e3070c 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 156
 
 #ifdef KVM_CAP_IRQ_ROUTING
 
target/s390x/kvm.c +0 -0
index d923cf4240..1ce0b42039 100644
@@ -285,6 +285,12 @@ int kvm_arch_init(MachineState *ms, KVMState *s)
 {
     MachineClass *mc = MACHINE_GET_CLASS(ms);

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

Quoted 10 lines
target/s390x/kvm.c +6 -0
 
+    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);

Okay, I wonder if now is the right time to actually detect the pagesize instead of relying on mempath pointing at hugetlbfs. I remember Power already doing such a detection.

mempath is just an indicator.

Signature · 3 lines
Thanks,

David / dhildenb