[pve-devel] [PATCH] fix #2402: allow 1GB hugepages if 2MB is unavailable

Stefan Reiter s.reiter at proxmox.com
Thu Oct 10 12:08:29 CEST 2019


As reported in bug #2402, a system started with "default_hugepagesz=1G
hugepagesz=1G" does not have a /sys/kernel/mm/hugepages/hugepages-2048kB
directory.

To still allow 1GB hugepages, ignore the missing directory in hugepages_mount
(since it's not needed anyway), and correctly check if the requested hugepage
size is available in hugepages_size instead.

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

diff --git a/PVE/QemuServer/Memory.pm b/PVE/QemuServer/Memory.pm
index b579955..f311dce 100644
--- a/PVE/QemuServer/Memory.pm
+++ b/PVE/QemuServer/Memory.pm
@@ -358,7 +358,7 @@ sub hugepages_mount {
    my $mountdata = PVE::ProcFSTools::parse_proc_mounts();
 
    foreach my $size (qw(2048 1048576)) {
-	return if (! -d "/sys/kernel/mm/hugepages/hugepages-${size}kB");
+	next if (! -d "/sys/kernel/mm/hugepages/hugepages-${size}kB");
 
 	my $path = "/run/hugepages/kvm/${size}kB";
 
@@ -400,18 +400,20 @@ sub hugepages_size {
 	#try to use 1GB if available && memory size is matching
 	if (-d "/sys/kernel/mm/hugepages/hugepages-1048576kB" && ($size % 1024 == 0)) {
 	    return 1024;
-	} else {
+	} elsif (-d "/sys/kernel/mm/hugepages/hugepages-2048kB") {
 	    return 2;
 	}
 
+	die "your system doesn't support hugepages\n";
+
    } else {
 
 	my $hugepagesize = $conf->{hugepages} * 1024 . "kB";
 
 	if (! -d "/sys/kernel/mm/hugepages/hugepages-$hugepagesize") {
-		die "your system doesn't support hugepages of $hugepagesize";
+		die "your system doesn't support hugepages of $hugepagesize\n";
 	}
-	die "Memory size $size is not a multiple of the requested hugepages size $hugepagesize" if ($size % $conf->{hugepages}) != 0;
+	die "Memory size $size is not a multiple of the requested hugepages size $hugepagesize\n" if ($size % $conf->{hugepages}) != 0;
 	return $conf->{hugepages};
    }
 
-- 
2.20.1





More information about the pve-devel mailing list