Skip to contentSkip to conversation

Clear mem_path if we fall back to anonymous RAM allocation

PATCH In review David Gibson 7 participants 12 messages Apr 19, 2018 – Apr 21, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Clear mem_path if we fall back to anonymous RAM allocation

If the -mem-path option is set, we attempt to map the guest's RAM from a file in the given path; it's usually used to back guest RAM with hugepages. If we're unable to (e.g. not enough free hugepages) then we fall back to allocating normal anonymous pages. This behaviour can be surprising, but a comment in allocate_system_memory_nonnuma() suggests it's legacy behaviour we can't change.

What really isn't ok, though, is that in this case we leave mem_path set. That means functions which attempt to determine the pagesize of main RAM can erroneously think it is hugepage based on the requested path, even though it's not.

This is particular bad for the pseries machine type. KVM HV limitations mean the guest can't use pagesizes larger than the host page size used to back RAM. That means that such a fallback, rather than merely giving poorer performance that expected will cause the guest to freeze up early in boot as it attempts to use large page mappings that can't work.

This patch addresses the problem by clearing the mem_path variable when we fall back to anonymous pages, meaning that subsequent attempts to determine the RAM page size will get an accurate result.

---
 numa.c | 1 +
 1 file changed, 1 insertion(+)

Paolo et al, as with my earlier patches adding some extensions to the helpers for determining backing page sizes, if there are no objections can I get an ack to merge this via my ppc tree?

numa.c +1 -0
index 1116c90af9..78a869e598 100644
@@ -469,6 +469,7 @@ static void allocate_system_memory_nonnuma(MemoryRegion *mr, Object *owner,
             /* Legacy behavior: if allocation failed, fall back to
              * regular RAM allocation.
              */
+            mem_path = NULL;
             memory_region_init_ram_nomigrate(mr, owner, name, ram_size, &error_fatal);
         }
 #else
Signature · 1 line
2.14.3
#1 lore raw
Quoted 36 lines · On Thu, 19 Apr 2018 17:21:23 +1000 David Gibson <[email protected]>…

If the -mem-path option is set, we attempt to map the guest's RAM from a file in the given path; it's usually used to back guest RAM with hugepages. If we're unable to (e.g. not enough free hugepages) then we fall back to allocating normal anonymous pages. This behaviour can be surprising, but a comment in allocate_system_memory_nonnuma() suggests it's legacy behaviour we can't change.

What really isn't ok, though, is that in this case we leave mem_path set. That means functions which attempt to determine the pagesize of main RAM can erroneously think it is hugepage based on the requested path, even though it's not.

This is particular bad for the pseries machine type. KVM HV limitations mean the guest can't use pagesizes larger than the host page size used to back RAM. That means that such a fallback, rather than merely giving poorer performance that expected will cause the guest to freeze up early in boot as it attempts to use large page mappings that can't work.

This patch addresses the problem by clearing the mem_path variable when we fall back to anonymous pages, meaning that subsequent attempts to determine the RAM page size will get an accurate result.

---
 numa.c | 1 +
 1 file changed, 1 insertion(+)

Paolo et al, as with my earlier patches adding some extensions to the helpers for determining backing page sizes, if there are no objections can I get an ack to merge this via my ppc tree?

numa.c +0 -0
index 1116c90af9..78a869e598 100644

numa.c static void allocate_system_memory_nonnuma(MemoryRegion *mr, Object *owner, · line 475

Quoted 7 lines
numa.c +1 -0
@@ -469,6 +469,7 @@ static void allocate_system_memory_nonnuma(MemoryRegion *mr, Object *owner,
             /* Legacy behavior: if allocation failed, fall back to
              * regular RAM allocation.
              */
+            mem_path = NULL;
             memory_region_init_ram_nomigrate(mr, owner, name, ram_size, &error_fatal);
         }
 #else

mem_path is also used by kvm_s390_apply_cpu_model(), and in ccw_init() memory is initialized before CPUs are so if QEM was started with -mem-path, then before patch created CPU won't have CMM enabled and print warning:

"CMM will not be enabled because it is not compatible with hugetlbfs."

and after patch it might enable CMM if we clear mem_path. So question is do we care about this?

PS:
CCing s390 folks.

#2 lore raw
Quoted 52 lines · On Thu, 19 Apr 2018 14:33:18 +0200 Igor Mammedov <[email protected]> wrote:
Quoted 36 lines · On Thu, 19 Apr 2018 17:21:23 +1000 David Gibson <[email protected]>…

If the -mem-path option is set, we attempt to map the guest's RAM from a file in the given path; it's usually used to back guest RAM with hugepages. If we're unable to (e.g. not enough free hugepages) then we fall back to allocating normal anonymous pages. This behaviour can be surprising, but a comment in allocate_system_memory_nonnuma() suggests it's legacy behaviour we can't change.

What really isn't ok, though, is that in this case we leave mem_path set. That means functions which attempt to determine the pagesize of main RAM can erroneously think it is hugepage based on the requested path, even though it's not.

This is particular bad for the pseries machine type. KVM HV limitations mean the guest can't use pagesizes larger than the host page size used to back RAM. That means that such a fallback, rather than merely giving poorer performance that expected will cause the guest to freeze up early in boot as it attempts to use large page mappings that can't work.

This patch addresses the problem by clearing the mem_path variable when we fall back to anonymous pages, meaning that subsequent attempts to determine the RAM page size will get an accurate result.

---
 numa.c | 1 +
 1 file changed, 1 insertion(+)

Paolo et al, as with my earlier patches adding some extensions to the helpers for determining backing page sizes, if there are no objections can I get an ack to merge this via my ppc tree?

numa.c +0 -0
index 1116c90af9..78a869e598 100644

numa.c static void allocate_system_memory_nonnuma(MemoryRegion *mr, Object *owner, · line 475

Quoted 7 lines
numa.c +1 -0
@@ -469,6 +469,7 @@ static void allocate_system_memory_nonnuma(MemoryRegion *mr, Object *owner,
             /* Legacy behavior: if allocation failed, fall back to
              * regular RAM allocation.
              */
+            mem_path = NULL;
             memory_region_init_ram_nomigrate(mr, owner, name, ram_size, &error_fatal);
         }
 #else  

mem_path is also used by kvm_s390_apply_cpu_model(), and in ccw_init() memory is initialized before CPUs are so if QEM was started with -mem-path, then before patch created CPU won't have CMM enabled and print warning:

Quoted 4 lines

"CMM will not be enabled because it is not compatible with hugetlbfs."

and after patch it might enable CMM if we clear mem_path. So question is do we care about this?

I don't quite remember the cmm semantics here -- Christian?

#3 lore raw
Quoted 55 lines · Cornelia Huck
Quoted 52 lines · On Thu, 19 Apr 2018 14:33:18 +0200 Igor Mammedov <[email protected]> wrote:
Quoted 36 lines · On Thu, 19 Apr 2018 17:21:23 +1000 David Gibson <[email protected]>…

If the -mem-path option is set, we attempt to map the guest's RAM from a file in the given path; it's usually used to back guest RAM with hugepages. If we're unable to (e.g. not enough free hugepages) then we fall back to allocating normal anonymous pages. This behaviour can be surprising, but a comment in allocate_system_memory_nonnuma() suggests it's legacy behaviour we can't change.

What really isn't ok, though, is that in this case we leave mem_path set. That means functions which attempt to determine the pagesize of main RAM can erroneously think it is hugepage based on the requested path, even though it's not.

This is particular bad for the pseries machine type. KVM HV limitations mean the guest can't use pagesizes larger than the host page size used to back RAM. That means that such a fallback, rather than merely giving poorer performance that expected will cause the guest to freeze up early in boot as it attempts to use large page mappings that can't work.

This patch addresses the problem by clearing the mem_path variable when we fall back to anonymous pages, meaning that subsequent attempts to determine the RAM page size will get an accurate result.

---
 numa.c | 1 +
 1 file changed, 1 insertion(+)

Paolo et al, as with my earlier patches adding some extensions to the helpers for determining backing page sizes, if there are no objections can I get an ack to merge this via my ppc tree?

numa.c +0 -0
index 1116c90af9..78a869e598 100644

numa.c static void allocate_system_memory_nonnuma(MemoryRegion *mr, Object *owner, · line 475

Quoted 7 lines
numa.c +1 -0
@@ -469,6 +469,7 @@ static void allocate_system_memory_nonnuma(MemoryRegion *mr, Object *owner,
             /* Legacy behavior: if allocation failed, fall back to
              * regular RAM allocation.
              */
+            mem_path = NULL;
             memory_region_init_ram_nomigrate(mr, owner, name, ram_size, &error_fatal);
         }
 #else  

mem_path is also used by kvm_s390_apply_cpu_model(), and in ccw_init() memory is initialized before CPUs are so if QEM was started with -mem-path, then before patch created CPU won't have CMM enabled and print warning:

Quoted 6 lines
Quoted 4 lines

"CMM will not be enabled because it is not compatible with hugetlbfs."

and after patch it might enable CMM if we clear mem_path. So question is do we care about this?

I don't quite remember the cmm semantics here -- Christian?

The CMMA interface does not work on large pages. I think the kernel will react with EFAULT in some cases (cmma migration and others) so qemu will probably fail unexpectedly.

But this patch seems to only clear mem-path if we do not allocate at all from hugetlbfs. So things should be ok, no?

#4 lore raw
Quoted 63 lines · Christian Borntraeger
Quoted 60 lines · Cornelia Huck
Quoted 56 lines · On Thu, 19 Apr 2018 14:33:18 +0200 Igor Mammedov <[email protected]> wrote:
Quoted 36 lines · On Thu, 19 Apr 2018 17:21:23 +1000 David Gibson <[email protected]>…

If the -mem-path option is set, we attempt to map the guest's RAM from a file in the given path; it's usually used to back guest RAM with hugepages. If we're unable to (e.g. not enough free hugepages) then we fall back to allocating normal anonymous pages. This behaviour can be surprising, but a comment in allocate_system_memory_nonnuma() suggests it's legacy behaviour we can't change.

What really isn't ok, though, is that in this case we leave mem_path set. That means functions which attempt to determine the pagesize of main RAM can erroneously think it is hugepage based on the requested path, even though it's not.

This is particular bad for the pseries machine type. KVM HV limitations mean the guest can't use pagesizes larger than the host page size used to back RAM. That means that such a fallback, rather than merely giving poorer performance that expected will cause the guest to freeze up early in boot as it attempts to use large page mappings that can't work.

This patch addresses the problem by clearing the mem_path variable when we fall back to anonymous pages, meaning that subsequent attempts to determine the RAM page size will get an accurate result.

---
 numa.c | 1 +
 1 file changed, 1 insertion(+)

Paolo et al, as with my earlier patches adding some extensions to the helpers for determining backing page sizes, if there are no objections can I get an ack to merge this via my ppc tree?

numa.c +0 -0
index 1116c90af9..78a869e598 100644

numa.c static void allocate_system_memory_nonnuma(MemoryRegion *mr, Object *owner, · line 475

Quoted 7 lines
numa.c +1 -0
@@ -469,6 +469,7 @@ static void allocate_system_memory_nonnuma(MemoryRegion *mr, Object *owner,
             /* Legacy behavior: if allocation failed, fall back to
              * regular RAM allocation.
              */
+            mem_path = NULL;
             memory_region_init_ram_nomigrate(mr, owner, name, ram_size, &error_fatal);
         }
 #else  

mem_path is also used by kvm_s390_apply_cpu_model(), and in ccw_init() memory is initialized before CPUs are so if QEM was started with -mem-path, then before patch created CPU won't have CMM enabled and print warning:

"CMM will not be enabled because it is not compatible with hugetlbfs."

and after patch it might enable CMM if we clear mem_path. So question is do we care about this?

Quoted 10 lines
Quoted 1 line

I don't quite remember the cmm semantics here -- Christian?

The CMMA interface does not work on large pages. I think the kernel will react with EFAULT in some cases (cmma migration and others) so qemu will probably fail unexpectedly.

But this patch seems to only clear mem-path if we do not allocate at all from hugetlbfs. So things should be ok, no?

This even looks like the right thing to me, as hugetlbfs was never supported.

Signature · 3 lines
Thanks,

David / dhildenb
#5 lore raw
Quoted 41 lines · On Thu, 19 Apr 2018 16:11:37 +0200 David Hildenbrand <[email protected]> wrote:
Quoted 40 lines · Christian Borntraeger
Quoted 37 lines · Cornelia Huck
Quoted 34 lines · On Thu, 19 Apr 2018 14:33:18 +0200 Igor Mammedov <[email protected]> wrote:
Quoted 31 lines · On Thu, 19 Apr 2018 17:21:23 +1000 David Gibson <[email protected]>…

If the -mem-path option is set, we attempt to map the guest's RAM from a file in the given path; it's usually used to back guest RAM with hugepages. If we're unable to (e.g. not enough free hugepages) then we fall back to allocating normal anonymous pages. This behaviour can be surprising, but a comment in allocate_system_memory_nonnuma() suggests it's legacy behaviour we can't change.

What really isn't ok, though, is that in this case we leave mem_path set. That means functions which attempt to determine the pagesize of main RAM can erroneously think it is hugepage based on the requested path, even though it's not.

This is particular bad for the pseries machine type. KVM HV limitations mean the guest can't use pagesizes larger than the host page size used to back RAM. That means that such a fallback, rather than merely giving poorer performance that expected will cause the guest to freeze up early in boot as it attempts to use large page mappings that can't work.

This patch addresses the problem by clearing the mem_path variable when we fall back to anonymous pages, meaning that subsequent attempts to determine the RAM page size will get an accurate result.

---
 numa.c | 1 +
 1 file changed, 1 insertion(+)

Paolo et al, as with my earlier patches adding some extensions to the helpers for determining backing page sizes, if there are no objections can I get an ack to merge this via my ppc tree?

Quoted 15 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
numa.c +0 -0
index 1116c90af9..78a869e598 100644
@@ -469,6 +469,7 @@ static void allocate_system_memory_nonnuma(MemoryRegion *mr, Object *owner,
             /* Legacy behavior: if allocation failed, fall back to
              * regular RAM allocation.
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

numa.c static void allocate_system_memory_nonnuma(MemoryRegion *mr, Object *owner, · line 475

Quoted 5 lines
numa.c +1 -0
              */
+            mem_path = NULL;
             memory_region_init_ram_nomigrate(mr, owner, name, ram_size, &error_fatal);
         }
 #else    

mem_path is also used by kvm_s390_apply_cpu_model(), and in ccw_init() memory is initialized before CPUs are

Something similar happens with spapr: kvm_fixup_page_sizes() calls qemu_getrampagesize() during CPU start, which happens before the machine init calls allocate_system_memory_nonnuma(). Shouldn't we allocate memory before calling spapr_init_cpus() in spapr_machine_init() then ?

Quoted 14 lines
Quoted 14 lines
Quoted 9 lines
Quoted 7 lines

so if QEM was started with -mem-path, then before patch created CPU won't have CMM enabled and print warning:

"CMM will not be enabled because it is not compatible with hugetlbfs."

and after patch it might enable CMM if we clear mem_path. So question is do we care about this?

I don't quite remember the cmm semantics here -- Christian?

The CMMA interface does not work on large pages. I think the kernel will react with EFAULT in some cases (cmma migration and others) so qemu will probably fail unexpectedly.

Quoted 8 lines
Quoted 4 lines

But this patch seems to only clear mem-path if we do not allocate at all from hugetlbfs. So things should be ok, no?

This even looks like the right thing to me, as hugetlbfs was never supported.

Unrelated to this patch, -mem-path can be passed something that doesn't sit in a hugetlbfs, in which case we use getpagesize()... is there a reason for kvm_s390_enable_cmma() to filter out this case as well ? Or should we rather check mem_path isn't NULL and points to a hugetlbfs ?

#6 lore raw
Quoted 60 lines · Greg Kurz
Quoted 41 lines · On Thu, 19 Apr 2018 16:11:37 +0200 David Hildenbrand <[email protected]> wrote:
Quoted 40 lines · Christian Borntraeger
Quoted 37 lines · Cornelia Huck
Quoted 34 lines · On Thu, 19 Apr 2018 14:33:18 +0200 Igor Mammedov <[email protected]> wrote:
Quoted 31 lines · On Thu, 19 Apr 2018 17:21:23 +1000 David Gibson <[email protected]>…

If the -mem-path option is set, we attempt to map the guest's RAM from a file in the given path; it's usually used to back guest RAM with hugepages. If we're unable to (e.g. not enough free hugepages) then we fall back to allocating normal anonymous pages. This behaviour can be surprising, but a comment in allocate_system_memory_nonnuma() suggests it's legacy behaviour we can't change.

What really isn't ok, though, is that in this case we leave mem_path set. That means functions which attempt to determine the pagesize of main RAM can erroneously think it is hugepage based on the requested path, even though it's not.

This is particular bad for the pseries machine type. KVM HV limitations mean the guest can't use pagesizes larger than the host page size used to back RAM. That means that such a fallback, rather than merely giving poorer performance that expected will cause the guest to freeze up early in boot as it attempts to use large page mappings that can't work.

This patch addresses the problem by clearing the mem_path variable when we fall back to anonymous pages, meaning that subsequent attempts to determine the RAM page size will get an accurate result.

---
 numa.c | 1 +
 1 file changed, 1 insertion(+)

Paolo et al, as with my earlier patches adding some extensions to the helpers for determining backing page sizes, if there are no objections can I get an ack to merge this via my ppc tree?

Quoted 15 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
numa.c +0 -0
index 1116c90af9..78a869e598 100644
@@ -469,6 +469,7 @@ static void allocate_system_memory_nonnuma(MemoryRegion *mr, Object *owner,
             /* Legacy behavior: if allocation failed, fall back to
              * regular RAM allocation.
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

numa.c static void allocate_system_memory_nonnuma(MemoryRegion *mr, Object *owner, · line 475

Quoted 5 lines
numa.c +1 -0
              */
+            mem_path = NULL;
             memory_region_init_ram_nomigrate(mr, owner, name, ram_size, &error_fatal);
         }
 #else    

mem_path is also used by kvm_s390_apply_cpu_model(), and in ccw_init() memory is initialized before CPUs are

Quoted 4 lines

Something similar happens with spapr: kvm_fixup_page_sizes() calls qemu_getrampagesize() during CPU start, which happens before the machine init calls allocate_system_memory_nonnuma(). Shouldn't we allocate memory before calling spapr_init_cpus() in spapr_machine_init() then ?

Note that the way kvm_fixup_page_sizes() works is broken in it's own right - this patch was actually written as a prliminary to fixing that.

Quoted 28 lines
Quoted 14 lines
Quoted 14 lines
Quoted 9 lines
Quoted 7 lines

so if QEM was started with -mem-path, then before patch created CPU won't have CMM enabled and print warning:

"CMM will not be enabled because it is not compatible with hugetlbfs."

and after patch it might enable CMM if we clear mem_path. So question is do we care about this?

I don't quite remember the cmm semantics here -- Christian?

The CMMA interface does not work on large pages. I think the kernel will react with EFAULT in some cases (cmma migration and others) so qemu will probably fail unexpectedly.

Quoted 8 lines
Quoted 4 lines

But this patch seems to only clear mem-path if we do not allocate at all from hugetlbfs. So things should be ok, no?

This even looks like the right thing to me, as hugetlbfs was never supported.

Unrelated to this patch, -mem-path can be passed something that doesn't sit in a hugetlbfs, in which case we use getpagesize()... is there a reason for kvm_s390_enable_cmma() to filter out this case as well ? Or should we rather check mem_path isn't NULL and points to a hugetlbfs ?

Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
#7 lore raw
In reply to Greg Kurz
Quoted 84 lines · Greg Kurz
Quoted 41 lines · On Thu, 19 Apr 2018 16:11:37 +0200 David Hildenbrand <[email protected]> wrote:
Quoted 40 lines · Christian Borntraeger
Quoted 37 lines · Cornelia Huck
Quoted 34 lines · On Thu, 19 Apr 2018 14:33:18 +0200 Igor Mammedov <[email protected]> wrote:
Quoted 31 lines · On Thu, 19 Apr 2018 17:21:23 +1000 David Gibson <[email protected]>…

If the -mem-path option is set, we attempt to map the guest's RAM from a file in the given path; it's usually used to back guest RAM with hugepages. If we're unable to (e.g. not enough free hugepages) then we fall back to allocating normal anonymous pages. This behaviour can be surprising, but a comment in allocate_system_memory_nonnuma() suggests it's legacy behaviour we can't change.

What really isn't ok, though, is that in this case we leave mem_path set. That means functions which attempt to determine the pagesize of main RAM can erroneously think it is hugepage based on the requested path, even though it's not.

This is particular bad for the pseries machine type. KVM HV limitations mean the guest can't use pagesizes larger than the host page size used to back RAM. That means that such a fallback, rather than merely giving poorer performance that expected will cause the guest to freeze up early in boot as it attempts to use large page mappings that can't work.

This patch addresses the problem by clearing the mem_path variable when we fall back to anonymous pages, meaning that subsequent attempts to determine the RAM page size will get an accurate result.

---
 numa.c | 1 +
 1 file changed, 1 insertion(+)

Paolo et al, as with my earlier patches adding some extensions to the helpers for determining backing page sizes, if there are no objections can I get an ack to merge this via my ppc tree?

Quoted 15 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
numa.c +0 -0
index 1116c90af9..78a869e598 100644
@@ -469,6 +469,7 @@ static void allocate_system_memory_nonnuma(MemoryRegion *mr, Object *owner,
             /* Legacy behavior: if allocation failed, fall back to
              * regular RAM allocation.
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

numa.c static void allocate_system_memory_nonnuma(MemoryRegion *mr, Object *owner, · line 475

Quoted 5 lines
numa.c +1 -0
              */
+            mem_path = NULL;
             memory_region_init_ram_nomigrate(mr, owner, name, ram_size, &error_fatal);
         }
 #else    

mem_path is also used by kvm_s390_apply_cpu_model(), and in ccw_init() memory is initialized before CPUs are

Something similar happens with spapr: kvm_fixup_page_sizes() calls qemu_getrampagesize() during CPU start, which happens before the machine init calls allocate_system_memory_nonnuma(). Shouldn't we allocate memory before calling spapr_init_cpus() in spapr_machine_init() then ?

Quoted 19 lines
Quoted 18 lines
Quoted 9 lines
Quoted 7 lines

so if QEM was started with -mem-path, then before patch created CPU won't have CMM enabled and print warning:

"CMM will not be enabled because it is not compatible with hugetlbfs."

and after patch it might enable CMM if we clear mem_path. So question is do we care about this?

I don't quite remember the cmm semantics here -- Christian?

The CMMA interface does not work on large pages. I think the kernel will react with EFAULT in some cases (cmma migration and others) so qemu will probably fail unexpectedly.

But this patch seems to only clear mem-path if we do not allocate at all from hugetlbfs. So things should be ok, no?

Quoted 8 lines
Quoted 3 lines

This even looks like the right thing to me, as hugetlbfs was never supported.

Unrelated to this patch, -mem-path can be passed something that doesn't sit in a hugetlbfs, in which case we use getpagesize()... is there a reason for kvm_s390_enable_cmma() to filter out this case as well ? Or should we rather check mem_path isn't NULL and points to a hugetlbfs ?

cmm is somewhat special, so I prefer to have it only for non-mem-path memory since I know that it works for anonymous pages. I would rather white list other mechanisms if necessary in the future.
backings

#8 lore raw
In reply to David Gibson
Quoted 12 lines · On Thu, 19 Apr 2018 17:21:23 +1000 David Gibson <[email protected]>…

If the -mem-path option is set, we attempt to map the guest's RAM from a file in the given path; it's usually used to back guest RAM with hugepages. If we're unable to (e.g. not enough free hugepages) then we fall back to allocating normal anonymous pages. This behaviour can be surprising, but a comment in allocate_system_memory_nonnuma() suggests it's legacy behaviour we can't change.

What really isn't ok, though, is that in this case we leave mem_path set. That means functions which attempt to determine the pagesize of main RAM can erroneously think it is hugepage based on the requested path, even though it's not.

Quoted 4 lines

This is particular bad for the pseries machine type. KVM HV limitations mean the guest can't use pagesizes larger than the host page size used to back RAM. That means that such a fallback, rather than merely giving poorer performance that expected will cause the guest to freeze up early in

s/that expected/than expected/

Quoted 27 lines

boot as it attempts to use large page mappings that can't work.

This patch addresses the problem by clearing the mem_path variable when we fall back to anonymous pages, meaning that subsequent attempts to determine the RAM page size will get an accurate result.

---
 numa.c | 1 +
 1 file changed, 1 insertion(+)

Paolo et al, as with my earlier patches adding some extensions to the helpers for determining backing page sizes, if there are no objections can I get an ack to merge this via my ppc tree?

numa.c +1 -0
index 1116c90af9..78a869e598 100644
@@ -469,6 +469,7 @@ static void allocate_system_memory_nonnuma(MemoryRegion *mr, Object *owner,
             /* Legacy behavior: if allocation failed, fall back to
              * regular RAM allocation.
              */
+            mem_path = NULL;
             memory_region_init_ram_nomigrate(mr, owner, name, ram_size, &error_fatal);
         }
 #else
#9 lore raw
Quoted 15 lines · Greg Kurz
Quoted 12 lines · On Thu, 19 Apr 2018 17:21:23 +1000 David Gibson <[email protected]>…

If the -mem-path option is set, we attempt to map the guest's RAM from a file in the given path; it's usually used to back guest RAM with hugepages. If we're unable to (e.g. not enough free hugepages) then we fall back to allocating normal anonymous pages. This behaviour can be surprising, but a comment in allocate_system_memory_nonnuma() suggests it's legacy behaviour we can't change.

What really isn't ok, though, is that in this case we leave mem_path set. That means functions which attempt to determine the pagesize of main RAM can erroneously think it is hugepage based on the requested path, even though it's not.

Quoted 6 lines
Quoted 4 lines

This is particular bad for the pseries machine type. KVM HV limitations mean the guest can't use pagesizes larger than the host page size used to back RAM. That means that such a fallback, rather than merely giving poorer performance that expected will cause the guest to freeze up early in

s/that expected/than expected/

Adjusted, thanks.

Quoted 29 lines
Quoted 28 lines

boot as it attempts to use large page mappings that can't work.

This patch addresses the problem by clearing the mem_path variable when we fall back to anonymous pages, meaning that subsequent attempts to determine the RAM page size will get an accurate result.

---
 numa.c | 1 +
 1 file changed, 1 insertion(+)

Paolo et al, as with my earlier patches adding some extensions to the helpers for determining backing page sizes, if there are no objections can I get an ack to merge this via my ppc tree?

numa.c +1 -0
index 1116c90af9..78a869e598 100644
@@ -469,6 +469,7 @@ static void allocate_system_memory_nonnuma(MemoryRegion *mr, Object *owner,
             /* Legacy behavior: if allocation failed, fall back to
              * regular RAM allocation.
              */
+            mem_path = NULL;
             memory_region_init_ram_nomigrate(mr, owner, name, ram_size, &error_fatal);
         }
 #else
Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
#10 lore raw
Quoted 3 lines · David Gibson

Paolo et al, as with my earlier patches adding some extensions to the helpers for determining backing page sizes, if there are no objections can I get an ack to merge this via my ppc tree?

Yes, go ahead!

Thanks,

Paolo

author Applied
#11 lore raw
Quoted 6 lines · Paolo Bonzini
Quoted 3 lines · David Gibson

Paolo et al, as with my earlier patches adding some extensions to the helpers for determining backing page sizes, if there are no objections can I get an ack to merge this via my ppc tree?

Yes, go ahead!

Thanks, applied to ppc-for-2.13.

Quoted 5 lines

Thanks,

Paolo

Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson