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

v4:
	* Now using MiB
	* Now supporting 4k memory backings

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        | 34 ++++++++++++++++++++++++++++++++--
 2 files changed, 33 insertions(+), 2 deletions(-)

-- 
2.14.3

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

* [Qemu-devel] [PATCH v4 1/2] kvm: sync linux headers
  2018-08-01 13:19 [Qemu-devel] [PATCH v4 0/2] s390x: Enable KVM huge page backing support Janosch Frank
@ 2018-08-01 13:19 ` Janosch Frank
  2018-08-01 13:19 ` [Qemu-devel] [PATCH v4 2/2] s390x: Enable KVM huge page backing support Janosch Frank
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 13+ messages in thread
From: Janosch Frank @ 2018-08-01 13:19 UTC (permalink / raw)
  To: qemu-devel; +Cc: borntraeger, david, cohuck, qemu-s390x

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] 13+ messages in thread

* [Qemu-devel] [PATCH v4 2/2] s390x: Enable KVM huge page backing support
  2018-08-01 13:19 [Qemu-devel] [PATCH v4 0/2] s390x: Enable KVM huge page backing support Janosch Frank
  2018-08-01 13:19 ` [Qemu-devel] [PATCH v4 1/2] kvm: sync linux headers Janosch Frank
@ 2018-08-01 13:19 ` Janosch Frank
  2018-08-01 13:25   ` David Hildenbrand
                     ` (2 more replies)
  2018-08-01 16:01 ` [Qemu-devel] [PATCH v4 0/2] " Cornelia Huck
  2018-08-01 18:49 ` no-reply
  3 siblings, 3 replies; 13+ messages in thread
From: Janosch Frank @ 2018-08-01 13:19 UTC (permalink / raw)
  To: qemu-devel; +Cc: borntraeger, david, cohuck, qemu-s390x

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 | 34 ++++++++++++++++++++++++++++++++--
 1 file changed, 32 insertions(+), 2 deletions(-)

diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c
index d923cf4240..d1c72975cf 100644
--- a/target/s390x/kvm.c
+++ b/target/s390x/kvm.c
@@ -34,6 +34,8 @@
 #include "qapi/error.h"
 #include "qemu/error-report.h"
 #include "qemu/timer.h"
+#include "qemu/units.h"
+#include "qemu/mmap-alloc.h"
 #include "sysemu/sysemu.h"
 #include "sysemu/hw_accel.h"
 #include "hw/hw.h"
@@ -139,6 +141,7 @@ static int cap_mem_op;
 static int cap_s390_irq;
 static int cap_ri;
 static int cap_gs;
+static int cap_hpage_1m;
 
 static int active_cmma;
 
@@ -220,9 +223,9 @@ static void kvm_s390_enable_cmma(void)
         .attr = KVM_S390_VM_MEM_ENABLE_CMMA,
     };
 
-    if (mem_path) {
+    if (cap_hpage_1m) {
         warn_report("CMM will not be enabled because it is not "
-                    "compatible with hugetlbfs.");
+                    "compatible with huge memory backings.");
         return;
     }
     rc = kvm_vm_ioctl(kvm_state, KVM_SET_DEVICE_ATTR, &attr);
@@ -281,10 +284,37 @@ void kvm_s390_crypto_reset(void)
     }
 }
 
+static int kvm_s390_configure_mempath_backing(KVMState *s)
+{
+    size_t path_psize = qemu_mempath_getpagesize(mem_path);
+
+    if (path_psize == 4 * KiB)
+        return 0;
+
+    if (path_psize != 1 * MiB) {
+        error_report("Memory backing with 2G pages 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("Memory backing with 1M pages was specified, "
+                     "but KVM does not support this memory backing");
+        return -EINVAL;
+    }
+
+    cap_hpage_1m = 1;
+    return 0;
+}
+
 int kvm_arch_init(MachineState *ms, KVMState *s)
 {
     MachineClass *mc = MACHINE_GET_CLASS(ms);
 
+    if (mem_path && kvm_s390_configure_mempath_backing(s)) {
+        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] 13+ messages in thread

* Re: [Qemu-devel] [PATCH v4 2/2] s390x: Enable KVM huge page backing support
  2018-08-01 13:19 ` [Qemu-devel] [PATCH v4 2/2] s390x: Enable KVM huge page backing support Janosch Frank
@ 2018-08-01 13:25   ` David Hildenbrand
  2018-08-01 16:47   ` [Qemu-devel] [qemu-s390x] " Thomas Huth
  2018-08-02  7:02   ` [Qemu-devel] [PATCH v5] " Janosch Frank
  2 siblings, 0 replies; 13+ messages in thread
From: David Hildenbrand @ 2018-08-01 13:25 UTC (permalink / raw)
  To: Janosch Frank, qemu-devel; +Cc: borntraeger, cohuck, qemu-s390x

On 01.08.2018 15:19, 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 | 34 ++++++++++++++++++++++++++++++++--
>  1 file changed, 32 insertions(+), 2 deletions(-)
> 
> diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c
> index d923cf4240..d1c72975cf 100644
> --- a/target/s390x/kvm.c
> +++ b/target/s390x/kvm.c
> @@ -34,6 +34,8 @@
>  #include "qapi/error.h"
>  #include "qemu/error-report.h"
>  #include "qemu/timer.h"
> +#include "qemu/units.h"
> +#include "qemu/mmap-alloc.h"
>  #include "sysemu/sysemu.h"
>  #include "sysemu/hw_accel.h"
>  #include "hw/hw.h"
> @@ -139,6 +141,7 @@ static int cap_mem_op;
>  static int cap_s390_irq;
>  static int cap_ri;
>  static int cap_gs;
> +static int cap_hpage_1m;
>  
>  static int active_cmma;
>  
> @@ -220,9 +223,9 @@ static void kvm_s390_enable_cmma(void)
>          .attr = KVM_S390_VM_MEM_ENABLE_CMMA,
>      };
>  
> -    if (mem_path) {
> +    if (cap_hpage_1m) {
>          warn_report("CMM will not be enabled because it is not "
> -                    "compatible with hugetlbfs.");
> +                    "compatible with huge memory backings.");

This implies some change to certain setups (tmpfs), but as they are
absolutely not common (and never really were supported/expected to
work), I think this is fine.

Reviewed-by: David Hildenbrand <david@redhat.com>

>          return;
>      }
>      rc = kvm_vm_ioctl(kvm_state, KVM_SET_DEVICE_ATTR, &attr);
> @@ -281,10 +284,37 @@ void kvm_s390_crypto_reset(void)
>      }
>  }
>  
> +static int kvm_s390_configure_mempath_backing(KVMState *s)
> +{
> +    size_t path_psize = qemu_mempath_getpagesize(mem_path);
> +
> +    if (path_psize == 4 * KiB)
> +        return 0;
> +
> +    if (path_psize != 1 * MiB) {
> +        error_report("Memory backing with 2G pages 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("Memory backing with 1M pages was specified, "
> +                     "but KVM does not support this memory backing");
> +        return -EINVAL;
> +    }
> +
> +    cap_hpage_1m = 1;
> +    return 0;
> +}
> +
>  int kvm_arch_init(MachineState *ms, KVMState *s)
>  {
>      MachineClass *mc = MACHINE_GET_CLASS(ms);
>  
> +    if (mem_path && kvm_s390_configure_mempath_backing(s)) {
> +        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);
> 


-- 

Thanks,

David / dhildenb

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

* Re: [Qemu-devel] [PATCH v4 0/2] s390x: Enable KVM huge page backing support
  2018-08-01 13:19 [Qemu-devel] [PATCH v4 0/2] s390x: Enable KVM huge page backing support Janosch Frank
  2018-08-01 13:19 ` [Qemu-devel] [PATCH v4 1/2] kvm: sync linux headers Janosch Frank
  2018-08-01 13:19 ` [Qemu-devel] [PATCH v4 2/2] s390x: Enable KVM huge page backing support Janosch Frank
@ 2018-08-01 16:01 ` Cornelia Huck
  2018-08-20  9:03   ` Cornelia Huck
  2018-08-01 18:49 ` no-reply
  3 siblings, 1 reply; 13+ messages in thread
From: Cornelia Huck @ 2018-08-01 16:01 UTC (permalink / raw)
  To: Janosch Frank; +Cc: qemu-devel, borntraeger, david, qemu-s390x

On Wed,  1 Aug 2018 14:19:03 +0100
Janosch Frank <frankja@linux.ibm.com> wrote:

> v4:
> 	* Now using MiB
> 	* Now supporting 4k memory backings
> 
> 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        | 34 ++++++++++++++++++++++++++++++++--
>  2 files changed, 33 insertions(+), 2 deletions(-)
> 

Looks good to me.

Same comment as for the etoken patch: I'll queue this as soon as the
kernel interface has landed (and we can do a proper headers update).
Please ping me if I forget about it :)

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

* Re: [Qemu-devel] [qemu-s390x] [PATCH v4 2/2] s390x: Enable KVM huge page backing support
  2018-08-01 13:19 ` [Qemu-devel] [PATCH v4 2/2] s390x: Enable KVM huge page backing support Janosch Frank
  2018-08-01 13:25   ` David Hildenbrand
@ 2018-08-01 16:47   ` Thomas Huth
  2018-08-02  6:53     ` Janosch Frank
  2018-08-02  7:02   ` [Qemu-devel] [PATCH v5] " Janosch Frank
  2 siblings, 1 reply; 13+ messages in thread
From: Thomas Huth @ 2018-08-01 16:47 UTC (permalink / raw)
  To: Janosch Frank, qemu-devel; +Cc: borntraeger, qemu-s390x, cohuck, david

On 08/01/2018 03:19 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 | 34 ++++++++++++++++++++++++++++++++--
>  1 file changed, 32 insertions(+), 2 deletions(-)
> 
> diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c
> index d923cf4240..d1c72975cf 100644
> --- a/target/s390x/kvm.c
> +++ b/target/s390x/kvm.c
> @@ -34,6 +34,8 @@
>  #include "qapi/error.h"
>  #include "qemu/error-report.h"
>  #include "qemu/timer.h"
> +#include "qemu/units.h"
> +#include "qemu/mmap-alloc.h"
>  #include "sysemu/sysemu.h"
>  #include "sysemu/hw_accel.h"
>  #include "hw/hw.h"
> @@ -139,6 +141,7 @@ static int cap_mem_op;
>  static int cap_s390_irq;
>  static int cap_ri;
>  static int cap_gs;
> +static int cap_hpage_1m;
>  
>  static int active_cmma;
>  
> @@ -220,9 +223,9 @@ static void kvm_s390_enable_cmma(void)
>          .attr = KVM_S390_VM_MEM_ENABLE_CMMA,
>      };
>  
> -    if (mem_path) {
> +    if (cap_hpage_1m) {
>          warn_report("CMM will not be enabled because it is not "
> -                    "compatible with hugetlbfs.");
> +                    "compatible with huge memory backings.");
>          return;
>      }
>      rc = kvm_vm_ioctl(kvm_state, KVM_SET_DEVICE_ATTR, &attr);
> @@ -281,10 +284,37 @@ void kvm_s390_crypto_reset(void)
>      }
>  }
>  
> +static int kvm_s390_configure_mempath_backing(KVMState *s)
> +{
> +    size_t path_psize = qemu_mempath_getpagesize(mem_path);
> +
> +    if (path_psize == 4 * KiB)
> +        return 0;

Missing curly braces.

> +    if (path_psize != 1 * MiB) {
> +        error_report("Memory backing with 2G pages was specified, "
> +                     "but KVM does not support this memory backing");

May I suggest to use a text that rather matches the condition of the
if-statement (just in case there will be other sizes in the future...),
e.g. "Memory backing is only supported for 1 MiB huge pages" or
something similar.

 Thomas

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

* Re: [Qemu-devel] [PATCH v4 0/2] s390x: Enable KVM huge page backing support
  2018-08-01 13:19 [Qemu-devel] [PATCH v4 0/2] s390x: Enable KVM huge page backing support Janosch Frank
                   ` (2 preceding siblings ...)
  2018-08-01 16:01 ` [Qemu-devel] [PATCH v4 0/2] " Cornelia Huck
@ 2018-08-01 18:49 ` no-reply
  3 siblings, 0 replies; 13+ messages in thread
From: no-reply @ 2018-08-01 18:49 UTC (permalink / raw)
  To: frankja; +Cc: famz, qemu-devel, borntraeger, qemu-s390x, cohuck, david

Hi,

This series seems to have some coding style problems. See output below for
more information:

Type: series
Message-id: 20180801131905.148778-1-frankja@linux.ibm.com
Subject: [Qemu-devel] [PATCH v4 0/2] s390x: Enable KVM huge page backing support

=== TEST SCRIPT BEGIN ===
#!/bin/bash

BASE=base
n=1
total=$(git log --oneline $BASE.. | wc -l)
failed=0

git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram

commits="$(git log --format=%H --reverse $BASE..)"
for c in $commits; do
    echo "Checking PATCH $n/$total: $(git log -n 1 --format=%s $c)..."
    if ! git show $c --format=email | ./scripts/checkpatch.pl --mailback -; then
        failed=1
        echo
    fi
    n=$((n+1))
done

exit $failed
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
Switched to a new branch 'test'
4290dbe857 s390x: Enable KVM huge page backing support
adfd7a6890 kvm: sync linux headers

=== OUTPUT BEGIN ===
Checking PATCH 1/2: kvm: sync linux headers...
Checking PATCH 2/2: s390x: Enable KVM huge page backing support...
ERROR: braces {} are necessary for all arms of this statement
#59: FILE: target/s390x/kvm.c:291:
+    if (path_psize == 4 * KiB)
[...]

total: 1 errors, 0 warnings, 63 lines checked

Your patch has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.

=== OUTPUT END ===

Test command exited with code: 1


---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to patchew-devel@redhat.com

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

* Re: [Qemu-devel] [qemu-s390x] [PATCH v4 2/2] s390x: Enable KVM huge page backing support
  2018-08-01 16:47   ` [Qemu-devel] [qemu-s390x] " Thomas Huth
@ 2018-08-02  6:53     ` Janosch Frank
  2018-08-02  7:01       ` Thomas Huth
  0 siblings, 1 reply; 13+ messages in thread
From: Janosch Frank @ 2018-08-02  6:53 UTC (permalink / raw)
  To: Thomas Huth, qemu-devel; +Cc: borntraeger, qemu-s390x, cohuck, david

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

On 01.08.2018 18:47, Thomas Huth wrote:
> On 08/01/2018 03:19 PM, Janosch Frank wrote:
>> +static int kvm_s390_configure_mempath_backing(KVMState *s)
>> +{
>> +    size_t path_psize = qemu_mempath_getpagesize(mem_path);
>> +
>> +    if (path_psize == 4 * KiB)
>> +        return 0;
> 
> Missing curly braces.

urgh, right, this is not the kernel.

> 
>> +    if (path_psize != 1 * MiB) {
>> +        error_report("Memory backing with 2G pages was specified, "
>> +                     "but KVM does not support this memory backing");
> 
> May I suggest to use a text that rather matches the condition of the
> if-statement (just in case there will be other sizes in the future...),
> e.g. "Memory backing is only supported for 1 MiB huge pages" or
> something similar.
> 
>  Thomas
> 

That's actually the gist of it. s390 supports 4k, 1M and 2G and looking
at the POP I don't see a big chance of having any more sizes, as there
are not a lot of software bits left and adding support in OSs is a pain.
Also don't hold your breath for 2G, it would need a rewrite of gmap.c.

Also this is more explicit.




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

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

* Re: [Qemu-devel] [qemu-s390x] [PATCH v4 2/2] s390x: Enable KVM huge page backing support
  2018-08-02  6:53     ` Janosch Frank
@ 2018-08-02  7:01       ` Thomas Huth
  0 siblings, 0 replies; 13+ messages in thread
From: Thomas Huth @ 2018-08-02  7:01 UTC (permalink / raw)
  To: Janosch Frank, qemu-devel; +Cc: borntraeger, qemu-s390x, cohuck, david

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

On 08/02/2018 08:53 AM, Janosch Frank wrote:
> On 01.08.2018 18:47, Thomas Huth wrote:
>> On 08/01/2018 03:19 PM, Janosch Frank wrote:
>>> +static int kvm_s390_configure_mempath_backing(KVMState *s)
>>> +{
>>> +    size_t path_psize = qemu_mempath_getpagesize(mem_path);
>>> +
>>> +    if (path_psize == 4 * KiB)
>>> +        return 0;
>>
>> Missing curly braces.
> 
> urgh, right, this is not the kernel.
> 
>>
>>> +    if (path_psize != 1 * MiB) {
>>> +        error_report("Memory backing with 2G pages was specified, "
>>> +                     "but KVM does not support this memory backing");
>>
>> May I suggest to use a text that rather matches the condition of the
>> if-statement (just in case there will be other sizes in the future...),
>> e.g. "Memory backing is only supported for 1 MiB huge pages" or
>> something similar.
>>
>>  Thomas
>>
> 
> That's actually the gist of it. s390 supports 4k, 1M and 2G and looking
> at the POP I don't see a big chance of having any more sizes, as there
> are not a lot of software bits left and adding support in OSs is a pain.
> Also don't hold your breath for 2G, it would need a rewrite of gmap.c.

Well, never say never ... but if you want to keep the current text,
that's fine for me, too.

 Thomas


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

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

* [Qemu-devel] [PATCH v5] s390x: Enable KVM huge page backing support
  2018-08-01 13:19 ` [Qemu-devel] [PATCH v4 2/2] s390x: Enable KVM huge page backing support Janosch Frank
  2018-08-01 13:25   ` David Hildenbrand
  2018-08-01 16:47   ` [Qemu-devel] [qemu-s390x] " Thomas Huth
@ 2018-08-02  7:02   ` Janosch Frank
  2018-08-02 15:45     ` David Hildenbrand
  2018-08-03  5:58     ` [Qemu-devel] [qemu-s390x] " Thomas Huth
  2 siblings, 2 replies; 13+ messages in thread
From: Janosch Frank @ 2018-08-02  7:02 UTC (permalink / raw)
  To: qemu-devel; +Cc: borntraeger, david, cohuck, qemu-s390x

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>
Reviewed-by: David Hildenbrand <david@redhat.com>
---

Now featuring all of the required braces.

---
 target/s390x/kvm.c | 35 +++++++++++++++++++++++++++++++++--
 1 file changed, 33 insertions(+), 2 deletions(-)

diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c
index d923cf4240..8ba948c324 100644
--- a/target/s390x/kvm.c
+++ b/target/s390x/kvm.c
@@ -34,6 +34,8 @@
 #include "qapi/error.h"
 #include "qemu/error-report.h"
 #include "qemu/timer.h"
+#include "qemu/units.h"
+#include "qemu/mmap-alloc.h"
 #include "sysemu/sysemu.h"
 #include "sysemu/hw_accel.h"
 #include "hw/hw.h"
@@ -139,6 +141,7 @@ static int cap_mem_op;
 static int cap_s390_irq;
 static int cap_ri;
 static int cap_gs;
+static int cap_hpage_1m;
 
 static int active_cmma;
 
@@ -220,9 +223,9 @@ static void kvm_s390_enable_cmma(void)
         .attr = KVM_S390_VM_MEM_ENABLE_CMMA,
     };
 
-    if (mem_path) {
+    if (cap_hpage_1m) {
         warn_report("CMM will not be enabled because it is not "
-                    "compatible with hugetlbfs.");
+                    "compatible with huge memory backings.");
         return;
     }
     rc = kvm_vm_ioctl(kvm_state, KVM_SET_DEVICE_ATTR, &attr);
@@ -281,10 +284,38 @@ void kvm_s390_crypto_reset(void)
     }
 }
 
+static int kvm_s390_configure_mempath_backing(KVMState *s)
+{
+    size_t path_psize = qemu_mempath_getpagesize(mem_path);
+
+    if (path_psize == 4 * KiB) {
+        return 0;
+    }
+
+    if (path_psize != 1 * MiB) {
+        error_report("Memory backing with 2G pages 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("Memory backing with 1M pages was specified, "
+                     "but KVM does not support this memory backing");
+        return -EINVAL;
+    }
+
+    cap_hpage_1m = 1;
+    return 0;
+}
+
 int kvm_arch_init(MachineState *ms, KVMState *s)
 {
     MachineClass *mc = MACHINE_GET_CLASS(ms);
 
+    if (mem_path && kvm_s390_configure_mempath_backing(s)) {
+        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] 13+ messages in thread

* Re: [Qemu-devel] [PATCH v5] s390x: Enable KVM huge page backing support
  2018-08-02  7:02   ` [Qemu-devel] [PATCH v5] " Janosch Frank
@ 2018-08-02 15:45     ` David Hildenbrand
  2018-08-03  5:58     ` [Qemu-devel] [qemu-s390x] " Thomas Huth
  1 sibling, 0 replies; 13+ messages in thread
From: David Hildenbrand @ 2018-08-02 15:45 UTC (permalink / raw)
  To: Janosch Frank, qemu-devel; +Cc: borntraeger, cohuck, qemu-s390x

On 02.08.2018 09:02, 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>
> Reviewed-by: David Hildenbrand <david@redhat.com>
> ---
> 
> Now featuring all of the required braces.
> 
> ---
>  target/s390x/kvm.c | 35 +++++++++++++++++++++++++++++++++--
>  1 file changed, 33 insertions(+), 2 deletions(-)
> 
> diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c
> index d923cf4240..8ba948c324 100644
> --- a/target/s390x/kvm.c
> +++ b/target/s390x/kvm.c
> @@ -34,6 +34,8 @@
>  #include "qapi/error.h"
>  #include "qemu/error-report.h"
>  #include "qemu/timer.h"
> +#include "qemu/units.h"
> +#include "qemu/mmap-alloc.h"
>  #include "sysemu/sysemu.h"
>  #include "sysemu/hw_accel.h"
>  #include "hw/hw.h"
> @@ -139,6 +141,7 @@ static int cap_mem_op;
>  static int cap_s390_irq;
>  static int cap_ri;
>  static int cap_gs;
> +static int cap_hpage_1m;
>  
>  static int active_cmma;
>  
> @@ -220,9 +223,9 @@ static void kvm_s390_enable_cmma(void)
>          .attr = KVM_S390_VM_MEM_ENABLE_CMMA,
>      };
>  
> -    if (mem_path) {
> +    if (cap_hpage_1m) {
>          warn_report("CMM will not be enabled because it is not "
> -                    "compatible with hugetlbfs.");
> +                    "compatible with huge memory backings.");
>          return;
>      }
>      rc = kvm_vm_ioctl(kvm_state, KVM_SET_DEVICE_ATTR, &attr);
> @@ -281,10 +284,38 @@ void kvm_s390_crypto_reset(void)
>      }
>  }
>  
> +static int kvm_s390_configure_mempath_backing(KVMState *s)
> +{
> +    size_t path_psize = qemu_mempath_getpagesize(mem_path);
> +
> +    if (path_psize == 4 * KiB) {
> +        return 0;
> +    }
> +
> +    if (path_psize != 1 * MiB) {
> +        error_report("Memory backing with 2G pages 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("Memory backing with 1M pages was specified, "
> +                     "but KVM does not support this memory backing");
> +        return -EINVAL;
> +    }
> +
> +    cap_hpage_1m = 1;
> +    return 0;
> +}
> +
>  int kvm_arch_init(MachineState *ms, KVMState *s)
>  {
>      MachineClass *mc = MACHINE_GET_CLASS(ms);
>  
> +    if (mem_path && kvm_s390_configure_mempath_backing(s)) {
> +        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);
> 

Looks good to me.

-- 

Thanks,

David / dhildenb

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

* Re: [Qemu-devel] [qemu-s390x] [PATCH v5] s390x: Enable KVM huge page backing support
  2018-08-02  7:02   ` [Qemu-devel] [PATCH v5] " Janosch Frank
  2018-08-02 15:45     ` David Hildenbrand
@ 2018-08-03  5:58     ` Thomas Huth
  1 sibling, 0 replies; 13+ messages in thread
From: Thomas Huth @ 2018-08-03  5:58 UTC (permalink / raw)
  To: Janosch Frank, qemu-devel; +Cc: borntraeger, qemu-s390x, cohuck, david

On 08/02/2018 09:02 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>
> Reviewed-by: David Hildenbrand <david@redhat.com>
> ---
> 
> Now featuring all of the required braces.
> 
> ---
>  target/s390x/kvm.c | 35 +++++++++++++++++++++++++++++++++--
>  1 file changed, 33 insertions(+), 2 deletions(-)
> 
> diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c
> index d923cf4240..8ba948c324 100644
> --- a/target/s390x/kvm.c
> +++ b/target/s390x/kvm.c
> @@ -34,6 +34,8 @@
>  #include "qapi/error.h"
>  #include "qemu/error-report.h"
>  #include "qemu/timer.h"
> +#include "qemu/units.h"
> +#include "qemu/mmap-alloc.h"
>  #include "sysemu/sysemu.h"
>  #include "sysemu/hw_accel.h"
>  #include "hw/hw.h"
> @@ -139,6 +141,7 @@ static int cap_mem_op;
>  static int cap_s390_irq;
>  static int cap_ri;
>  static int cap_gs;
> +static int cap_hpage_1m;
>  
>  static int active_cmma;
>  
> @@ -220,9 +223,9 @@ static void kvm_s390_enable_cmma(void)
>          .attr = KVM_S390_VM_MEM_ENABLE_CMMA,
>      };
>  
> -    if (mem_path) {
> +    if (cap_hpage_1m) {
>          warn_report("CMM will not be enabled because it is not "
> -                    "compatible with hugetlbfs.");
> +                    "compatible with huge memory backings.");
>          return;
>      }
>      rc = kvm_vm_ioctl(kvm_state, KVM_SET_DEVICE_ATTR, &attr);
> @@ -281,10 +284,38 @@ void kvm_s390_crypto_reset(void)
>      }
>  }
>  
> +static int kvm_s390_configure_mempath_backing(KVMState *s)
> +{
> +    size_t path_psize = qemu_mempath_getpagesize(mem_path);
> +
> +    if (path_psize == 4 * KiB) {
> +        return 0;
> +    }
> +
> +    if (path_psize != 1 * MiB) {
> +        error_report("Memory backing with 2G pages 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("Memory backing with 1M pages was specified, "
> +                     "but KVM does not support this memory backing");
> +        return -EINVAL;
> +    }
> +
> +    cap_hpage_1m = 1;
> +    return 0;
> +}
> +
>  int kvm_arch_init(MachineState *ms, KVMState *s)
>  {
>      MachineClass *mc = MACHINE_GET_CLASS(ms);
>  
> +    if (mem_path && kvm_s390_configure_mempath_backing(s)) {
> +        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);

Reviewed-by: Thomas Huth <thuth@redhat.com>

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

* Re: [Qemu-devel] [PATCH v4 0/2] s390x: Enable KVM huge page backing support
  2018-08-01 16:01 ` [Qemu-devel] [PATCH v4 0/2] " Cornelia Huck
@ 2018-08-20  9:03   ` Cornelia Huck
  0 siblings, 0 replies; 13+ messages in thread
From: Cornelia Huck @ 2018-08-20  9:03 UTC (permalink / raw)
  To: Janosch Frank; +Cc: qemu-devel, borntraeger, david, qemu-s390x

On Wed, 1 Aug 2018 18:01:59 +0200
Cornelia Huck <cohuck@redhat.com> wrote:

> On Wed,  1 Aug 2018 14:19:03 +0100
> Janosch Frank <frankja@linux.ibm.com> wrote:
> 
> > v4:
> > 	* Now using MiB
> > 	* Now supporting 4k memory backings
> > 
> > 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        | 34 ++++++++++++++++++++++++++++++++--
> >  2 files changed, 33 insertions(+), 2 deletions(-)
> >   
> 
> Looks good to me.
> 
> Same comment as for the etoken patch: I'll queue this as soon as the
> kernel interface has landed (and we can do a proper headers update).
> Please ping me if I forget about it :)

Same comment as for the etoken patch, again :) Just pushed out to
s390-next.

Thanks, applied.

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

end of thread, other threads:[~2018-08-20  9:03 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-01 13:19 [Qemu-devel] [PATCH v4 0/2] s390x: Enable KVM huge page backing support Janosch Frank
2018-08-01 13:19 ` [Qemu-devel] [PATCH v4 1/2] kvm: sync linux headers Janosch Frank
2018-08-01 13:19 ` [Qemu-devel] [PATCH v4 2/2] s390x: Enable KVM huge page backing support Janosch Frank
2018-08-01 13:25   ` David Hildenbrand
2018-08-01 16:47   ` [Qemu-devel] [qemu-s390x] " Thomas Huth
2018-08-02  6:53     ` Janosch Frank
2018-08-02  7:01       ` Thomas Huth
2018-08-02  7:02   ` [Qemu-devel] [PATCH v5] " Janosch Frank
2018-08-02 15:45     ` David Hildenbrand
2018-08-03  5:58     ` [Qemu-devel] [qemu-s390x] " Thomas Huth
2018-08-01 16:01 ` [Qemu-devel] [PATCH v4 0/2] " Cornelia Huck
2018-08-20  9:03   ` Cornelia Huck
2018-08-01 18:49 ` no-reply

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.