mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-04-30 20:54:26 +00:00
runtime: use system pagesize for hugepage test
In TestHandleHugepages it will do a mount operation with different pagesizes, but some systems only support 2M pagesize, test for a 1g pagesize will fail. This commit try to fix by only mount pagesizes under `/sys/kernel/mm/hugepages`, which are supported to mount by the OS. Fixes: #6029 Signed-off-by: Bin Liu <bin@hyper.sh>
This commit is contained in:
parent
0ec4aa1a86
commit
8551853cfe
@ -9,7 +9,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"runtime"
|
|
||||||
"strings"
|
"strings"
|
||||||
"syscall"
|
"syscall"
|
||||||
"testing"
|
"testing"
|
||||||
@ -34,18 +33,13 @@ func TestHandleHugepages(t *testing.T) {
|
|||||||
var mounts []specs.Mount
|
var mounts []specs.Mount
|
||||||
var hugepageLimits []specs.LinuxHugepageLimit
|
var hugepageLimits []specs.LinuxHugepageLimit
|
||||||
|
|
||||||
// On s390x, hugepage sizes must be set at boot and cannot be created ad hoc. Use any that
|
// Hugepage sizes must be set at boot time and cannot be created ad hoc.
|
||||||
// are present (default is 1M, can only be changed on LPAR). See
|
// Use any that are present.
|
||||||
// https://www.ibm.com/docs/en/linuxonibm/pdf/lku5dd05.pdf, p. 345 for more information.
|
|
||||||
if runtime.GOARCH == "s390x" {
|
|
||||||
dirs, err := os.ReadDir(sysHugepagesDir)
|
dirs, err := os.ReadDir(sysHugepagesDir)
|
||||||
assert.Nil(err)
|
assert.Nil(err)
|
||||||
for _, dir := range dirs {
|
for _, dir := range dirs {
|
||||||
formattedSizes = append(formattedSizes, strings.TrimPrefix(dir.Name(), "hugepages-"))
|
formattedSizes = append(formattedSizes, strings.TrimPrefix(dir.Name(), "hugepages-"))
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
formattedSizes = []string{"1G", "2M"}
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, formattedSize := range formattedSizes {
|
for _, formattedSize := range formattedSizes {
|
||||||
bytes, err := bytefmt.ToBytes(formattedSize)
|
bytes, err := bytefmt.ToBytes(formattedSize)
|
||||||
|
Loading…
Reference in New Issue
Block a user