All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v3 0/2] s390x: Enable KVM huge page backing support
@ 2018-07-31 12:09 Janosch Frank
  2018-07-31 12:09 ` [Qemu-devel] [PATCH v3 1/2] kvm: sync linux headers Janosch Frank
  2018-07-31 12:09 ` [Qemu-devel] [PATCH v3 2/2] s390x: Enable KVM huge page backing support Janosch Frank
  0 siblings, 2 replies; 6+ messages in thread
From: Janosch Frank @ 2018-07-31 12:09 UTC (permalink / raw)
  To: qemu-devel; +Cc: borntraeger, david, cohuck

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(+)

-- 
2.14.3

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

* [Qemu-devel] [PATCH v3 1/2] kvm: sync linux headers
  2018-07-31 12:09 [Qemu-devel] [PATCH v3 0/2] s390x: Enable KVM huge page backing support Janosch Frank
@ 2018-07-31 12:09 ` Janosch Frank
  2018-07-31 12:09 ` [Qemu-devel] [PATCH v3 2/2] s390x: Enable KVM huge page backing support Janosch Frank
  1 sibling, 0 replies; 6+ messages in thread
From: Janosch Frank @ 2018-07-31 12:09 UTC (permalink / raw)
  To: qemu-devel; +Cc: borntraeger, david, cohuck

Import KVM_CAP_S390_HPAGE_1M
Placeholder for proper sync.

Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
---
 linux-headers/linux/kvm.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/linux-headers/linux/kvm.h b/linux-headers/linux/kvm.h
index 98f389a5a3..2aae948219 100644
--- a/linux-headers/linux/kvm.h
+++ b/linux-headers/linux/kvm.h
@@ -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
 
-- 
2.14.3

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

* [Qemu-devel] [PATCH v3 2/2] s390x: Enable KVM huge page backing support
  2018-07-31 12:09 [Qemu-devel] [PATCH v3 0/2] s390x: Enable KVM huge page backing support Janosch Frank
  2018-07-31 12:09 ` [Qemu-devel] [PATCH v3 1/2] kvm: sync linux headers Janosch Frank
@ 2018-07-31 12:09 ` Janosch Frank
  2018-07-31 13:06   ` Cornelia Huck
  2018-08-01 11:30   ` Thomas Huth
  1 sibling, 2 replies; 6+ messages in thread
From: Janosch Frank @ 2018-07-31 12:09 UTC (permalink / raw)
  To: qemu-devel; +Cc: borntraeger, david, cohuck

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 | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c
index d923cf4240..f961c3b84a 100644
--- a/target/s390x/kvm.c
+++ b/target/s390x/kvm.c
@@ -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);
-- 
2.14.3

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

* Re: [Qemu-devel] [PATCH v3 2/2] s390x: Enable KVM huge page backing support
  2018-07-31 12:09 ` [Qemu-devel] [PATCH v3 2/2] s390x: Enable KVM huge page backing support Janosch Frank
@ 2018-07-31 13:06   ` Cornelia Huck
  2018-07-31 13:19     ` Janosch Frank
  2018-08-01 11:30   ` Thomas Huth
  1 sibling, 1 reply; 6+ messages in thread
From: Cornelia Huck @ 2018-07-31 13:06 UTC (permalink / raw)
  To: Janosch Frank; +Cc: qemu-devel, borntraeger, david

On Tue, 31 Jul 2018 13:09:08 +0100
Janosch Frank <frankja@linux.ibm.com> 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 | 15 +++++++++++++++
>  1 file changed, 15 insertions(+)
> 
> diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c
> index d923cf4240..f961c3b84a 100644
> --- a/target/s390x/kvm.c
> +++ b/target/s390x/kvm.c
> @@ -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)) {

1 * MiB ?

> +            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);

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

* Re: [Qemu-devel] [PATCH v3 2/2] s390x: Enable KVM huge page backing support
  2018-07-31 13:06   ` Cornelia Huck
@ 2018-07-31 13:19     ` Janosch Frank
  0 siblings, 0 replies; 6+ messages in thread
From: Janosch Frank @ 2018-07-31 13:19 UTC (permalink / raw)
  To: Cornelia Huck; +Cc: borntraeger, qemu-devel, david

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

On 31.07.2018 15:06, Cornelia Huck wrote:
> On Tue, 31 Jul 2018 13:09:08 +0100
> Janosch Frank <frankja@linux.ibm.com> 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 | 15 +++++++++++++++
>>  1 file changed, 15 insertions(+)
>>
>> diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c
>> index d923cf4240..f961c3b84a 100644
>> --- a/target/s390x/kvm.c
>> +++ b/target/s390x/kvm.c
>> @@ -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)) {
> 
> 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.

> 
>> +            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);
> 
> 



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

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

* Re: [Qemu-devel] [PATCH v3 2/2] s390x: Enable KVM huge page backing support
  2018-07-31 12:09 ` [Qemu-devel] [PATCH v3 2/2] s390x: Enable KVM huge page backing support Janosch Frank
  2018-07-31 13:06   ` Cornelia Huck
@ 2018-08-01 11:30   ` Thomas Huth
  1 sibling, 0 replies; 6+ messages in thread
From: Thomas Huth @ 2018-08-01 11:30 UTC (permalink / raw)
  To: Janosch Frank, qemu-devel; +Cc: borntraeger, cohuck, david

On 07/31/2018 02:09 PM, 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 | 15 +++++++++++++++
>  1 file changed, 15 insertions(+)
> 
> diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c
> index d923cf4240..f961c3b84a 100644
> --- a/target/s390x/kvm.c
> +++ b/target/s390x/kvm.c
> @@ -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;

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

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

end of thread, other threads:[~2018-08-01 11:30 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-31 12:09 [Qemu-devel] [PATCH v3 0/2] s390x: Enable KVM huge page backing support Janosch Frank
2018-07-31 12:09 ` [Qemu-devel] [PATCH v3 1/2] kvm: sync linux headers Janosch Frank
2018-07-31 12:09 ` [Qemu-devel] [PATCH v3 2/2] s390x: Enable KVM huge page backing support Janosch Frank
2018-07-31 13:06   ` Cornelia Huck
2018-07-31 13:19     ` Janosch Frank
2018-08-01 11:30   ` Thomas Huth

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.