Skip to content

Commit

Permalink
cgroups: add support for oom control
Browse files Browse the repository at this point in the history
This patch add support for diable OOM Killer.

Signed-off-by: Hu Keping <hukeping@huawei.com>
  • Loading branch information
HuKeping committed Mar 6, 2015
1 parent 334b196 commit 295c708
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
6 changes: 6 additions & 0 deletions cgroups/fs/memory.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ func (s *MemoryGroup) Set(path string, cgroup *configs.Cgroup) error {
}
}

if cgroup.OomKillDisable {
if err := writeFile(path, "memory.oom_control", "1"); err != nil {
return err
}
}

return nil
}

Expand Down
3 changes: 3 additions & 0 deletions configs/cgroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,7 @@ type Cgroup struct {

// Parent slice to use for systemd TODO: remove in favor or parent
Slice string `json:"slice"`

// Whether to disable OOM Killer
OomKillDisable bool `json:"oom_kill_disable"`
}

0 comments on commit 295c708

Please sign in to comment.