[pve-devel] [PATCH qemu-server] hugepages: fix memory size checking

Stefan Reiter s.reiter at proxmox.com
Mon Oct 28 14:30:41 CET 2019


The codepath for "any" hugepages did not check if memory size was even,
leading to the code below trying to allocate half a hugepage (e.g. VM
with 2049MiB RAM would lead to 1024.5 2kB hugepages).

Also improve error message for systems with only 1GB hugepages enabled.

Signed-off-by: Stefan Reiter <s.reiter at proxmox.com>
---
 PVE/QemuServer/Memory.pm | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/PVE/QemuServer/Memory.pm b/PVE/QemuServer/Memory.pm
index b4c9129..ab7d2c3 100644
--- a/PVE/QemuServer/Memory.pm
+++ b/PVE/QemuServer/Memory.pm
@@ -404,10 +404,11 @@ sub hugepages_size {
 	if ($gb_exists && ($size % 1024 == 0)) {
 	    return 1024;
 	} elsif (-d "/sys/kernel/mm/hugepages/hugepages-2048kB") {
+	    die "memory size must be even to use hugepages\n" if $size % 2 != 0;
 	    return 2;
 	}
 
-	die "your system doesn't support hugepages for memory size $size\n"
+	die "your system doesn't support hugepages for memory size $size (1GB hugepages would be supported)\n"
 	    if $gb_exists;
 
 	die "your system doesn't support hugepages\n";
-- 
2.20.1





More information about the pve-devel mailing list