mirror of
git://git.proxmox.com/git/qemu-server.git
synced 2025-01-27 14:03:54 +03:00
fix #2402: allow 1GB hugepages if 2MB is unavailable
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 fix, ignore the missing directory in hugepages_mount (since it might not be needed anyway), and correctly check if the requested hugepage size is available in hugepages_size instead. Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
This commit is contained in:
parent
503be1f71e
commit
3d8d2e8dad
@ -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";
|
||||
|
||||
@ -398,20 +398,26 @@ sub hugepages_size {
|
||||
if ($conf->{hugepages} eq 'any') {
|
||||
|
||||
#try to use 1GB if available && memory size is matching
|
||||
if (-d "/sys/kernel/mm/hugepages/hugepages-1048576kB" && ($size % 1024 == 0)) {
|
||||
my $gb_exists = -d "/sys/kernel/mm/hugepages/hugepages-1048576kB";
|
||||
if ($gb_exists && ($size % 1024 == 0)) {
|
||||
return 1024;
|
||||
} else {
|
||||
} elsif (-d "/sys/kernel/mm/hugepages/hugepages-2048kB") {
|
||||
return 2;
|
||||
}
|
||||
|
||||
die "your system doesn't support hugepages for memory size $size\n"
|
||||
if $gb_exists;
|
||||
|
||||
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};
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user