mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-21 19:01:49 +00:00
Compact memory before requesting huge pages
Compact memory to make bigger contiguous blocks of memory available before allocating huge pages. https://www.kernel.org/doc/Documentation/sysctl/vm.txt
This commit is contained in:
parent
3f33bfd801
commit
b1308ed70a
@ -18,6 +18,7 @@ package e2e_node
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
@ -85,6 +86,15 @@ func makePodToVerifyHugePages(baseName string, hugePagesLimit resource.Quantity)
|
|||||||
|
|
||||||
// configureHugePages attempts to allocate 10Mi of 2Mi hugepages for testing purposes
|
// configureHugePages attempts to allocate 10Mi of 2Mi hugepages for testing purposes
|
||||||
func configureHugePages() error {
|
func configureHugePages() error {
|
||||||
|
// Compact memory to make bigger contiguous blocks of memory available
|
||||||
|
// before allocating huge pages.
|
||||||
|
// https://www.kernel.org/doc/Documentation/sysctl/vm.txt
|
||||||
|
if _, err := os.Stat("/proc/sys/vm/compact_memory"); err == nil {
|
||||||
|
err := exec.Command("/bin/sh", "-c", "echo 1 > /proc/sys/vm/compact_memory").Run()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
err := exec.Command("/bin/sh", "-c", "echo 5 > /proc/sys/vm/nr_hugepages").Run()
|
err := exec.Command("/bin/sh", "-c", "echo 5 > /proc/sys/vm/nr_hugepages").Run()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
Loading…
Reference in New Issue
Block a user