Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Commit

Permalink
agent: enable memory hierarchical account
Browse files Browse the repository at this point in the history
Memory cgroup requires setting use_hierarchy to 1 on the root.

fixes #318

Signed-off-by: Julio Montes <[email protected]>
  • Loading branch information
Julio Montes committed Aug 9, 2018
1 parent fcfa054 commit 41c09c2
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,11 @@ const (

var (
// cgroup fs is mounted at /sys/fs when systemd is the init process
cgroupPath = "/sys/fs/cgroup"
cgroupCpusetPath = cgroupPath + "/cpuset"
cgroupPath = "/sys/fs/cgroup"
cgroupCpusetPath = cgroupPath + "/cpuset"
cgroupMemoryPath = cgroupPath + "/memory"
cgroupMemoryUseHierarchyPath = cgroupMemoryPath + "/memory.use_hierarchy"
cgroupMemoryUseHierarchyMode = os.FileMode(0400)
)

var initRootfsMounts = []initMount{
Expand Down Expand Up @@ -859,7 +862,10 @@ func cgroupsMount() error {
return err
}
}
return nil

// Enable memory hierarchical account.
// For more information see https://www.kernel.org/doc/Documentation/cgroup-v1/memory.txt
return ioutil.WriteFile(cgroupMemoryUseHierarchyPath, []byte{'1'}, cgroupMemoryUseHierarchyMode)
}

// initAgentAsInit will do the initializations such as setting up the rootfs
Expand Down

0 comments on commit 41c09c2

Please sign in to comment.