Skip to content

Commit 295c708

Browse files
committed
cgroups: add support for oom control
This patch add support for diable OOM Killer. Signed-off-by: Hu Keping <[email protected]>
1 parent 334b196 commit 295c708

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

cgroups/fs/memory.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@ func (s *MemoryGroup) Set(path string, cgroup *configs.Cgroup) error {
5656
}
5757
}
5858

59+
if cgroup.OomKillDisable {
60+
if err := writeFile(path, "memory.oom_control", "1"); err != nil {
61+
return err
62+
}
63+
}
64+
5965
return nil
6066
}
6167

configs/cgroup.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,7 @@ type Cgroup struct {
5151

5252
// Parent slice to use for systemd TODO: remove in favor or parent
5353
Slice string `json:"slice"`
54+
55+
// Whether to disable OOM Killer
56+
OomKillDisable bool `json:"oom_kill_disable"`
5457
}

0 commit comments

Comments
 (0)