File: cgroups_linux.go

package info (click to toggle)
golang-github-kimmachinegun-automemlimit 0.7.4-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 232 kB
  • sloc: makefile: 3
file content (32 lines) | stat: -rw-r--r-- 1,047 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
//go:build linux
// +build linux

package memlimit

// FromCgroup retrieves the memory limit from the cgroup.
func FromCgroup() (uint64, error) {
	return fromCgroup(detectCgroupVersion)
}

// FromCgroupV1 retrieves the memory limit from the cgroup v1 controller.
// After v1.0.0, this function could be removed and FromCgroup should be used instead.
func FromCgroupV1() (uint64, error) {
	return fromCgroup(func(_ []mountInfo) (bool, bool) {
		return true, false
	})
}

// FromCgroupHybrid retrieves the memory limit from the cgroup v2 and v1 controller sequentially,
// basically, it is equivalent to FromCgroup.
// After v1.0.0, this function could be removed and FromCgroup should be used instead.
func FromCgroupHybrid() (uint64, error) {
	return FromCgroup()
}

// FromCgroupV2 retrieves the memory limit from the cgroup v2 controller.
// After v1.0.0, this function could be removed and FromCgroup should be used instead.
func FromCgroupV2() (uint64, error) {
	return fromCgroup(func(_ []mountInfo) (bool, bool) {
		return false, true
	})
}