Merge pull request #1960 from giuseppe/fix-kmem-systemd
systemd: fix setting kernel memory limit
This commit is contained in:
commit
c1e454b2a1
|
@ -5,6 +5,7 @@ package systemd
|
|||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"math"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
@ -590,6 +591,15 @@ func setKernelMemory(c *configs.Cgroup) error {
|
|||
if err := os.MkdirAll(path, 0755); err != nil {
|
||||
return err
|
||||
}
|
||||
// do not try to enable the kernel memory if we already have
|
||||
// tasks in the cgroup.
|
||||
content, err := ioutil.ReadFile(filepath.Join(path, "tasks"))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if len(content) > 0 {
|
||||
return nil
|
||||
}
|
||||
return fs.EnableKernelMemoryAccounting(path)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue