Skip to content

Commit 31da8b0

Browse files
authored
Merge pull request #388 from dcantah/oom-group-kill
2 parents 568b349 + d72c9ce commit 31da8b0

File tree

5 files changed

+124
-92
lines changed

5 files changed

+124
-92
lines changed

cgroup2/manager.go

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,12 @@ var (
5959
)
6060

6161
type Event struct {
62-
Low uint64
63-
High uint64
64-
Max uint64
65-
OOM uint64
66-
OOMKill uint64
62+
Low uint64
63+
High uint64
64+
Max uint64
65+
OOM uint64
66+
OOMKill uint64
67+
OOMGroupKill uint64
6768
}
6869

6970
// Resources for a cgroups v2 unified hierarchy
@@ -679,11 +680,12 @@ func readMemoryEvents(cgroupPath string) (*stats.MemoryEvents, error) {
679680
return nil, nil
680681
}
681682
return &stats.MemoryEvents{
682-
Low: memoryEvents["low"],
683-
High: memoryEvents["high"],
684-
Max: memoryEvents["max"],
685-
Oom: memoryEvents["oom"],
686-
OomKill: memoryEvents["oom_kill"],
683+
Low: memoryEvents["low"],
684+
High: memoryEvents["high"],
685+
Max: memoryEvents["max"],
686+
Oom: memoryEvents["oom"],
687+
OomKill: memoryEvents["oom_kill"],
688+
OomGroupKill: memoryEvents["oom_group_kill"],
687689
}, nil
688690
}
689691

@@ -837,11 +839,12 @@ func (c *Manager) EventChan() (<-chan Event, <-chan error) {
837839
}
838840

839841
ec <- Event{
840-
Low: out["low"],
841-
High: out["high"],
842-
Max: out["max"],
843-
OOM: out["oom"],
844-
OOMKill: out["oom_kill"],
842+
Low: out["low"],
843+
High: out["high"],
844+
Max: out["max"],
845+
OOM: out["oom"],
846+
OOMKill: out["oom_kill"],
847+
OOMGroupKill: out["oom_group_kill"],
845848
}
846849

847850
if shouldExit {

cgroup2/memory.go

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,12 @@
1717
package cgroup2
1818

1919
type Memory struct {
20-
Swap *int64
21-
Min *int64
22-
Max *int64
23-
Low *int64
24-
High *int64
20+
Swap *int64
21+
Min *int64
22+
Max *int64
23+
Low *int64
24+
High *int64
25+
OOMGroup *bool
2526
}
2627

2728
func (r *Memory) Values() (o []Value) {
@@ -55,5 +56,15 @@ func (r *Memory) Values() (o []Value) {
5556
value: *r.High,
5657
})
5758
}
59+
if r.OOMGroup != nil {
60+
var val int64
61+
if *r.OOMGroup {
62+
val = 1
63+
}
64+
o = append(o, Value{
65+
filename: "memory.oom.group",
66+
value: val,
67+
})
68+
}
5869
return o
5970
}

cgroup2/stats/metrics.pb.go

Lines changed: 82 additions & 72 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cgroup2/stats/metrics.pb.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,13 @@ file {
509509
type: TYPE_UINT64
510510
json_name: "oomKill"
511511
}
512+
field {
513+
name: "oom_group_kill"
514+
number: 6
515+
label: LABEL_OPTIONAL
516+
type: TYPE_UINT64
517+
json_name: "oomGroupKill"
518+
}
512519
}
513520
message_type {
514521
name: "RdmaStat"

cgroup2/stats/metrics.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ message MemoryEvents {
9191
uint64 max = 3;
9292
uint64 oom = 4;
9393
uint64 oom_kill = 5;
94+
uint64 oom_group_kill = 6;
9495
}
9596

9697
message RdmaStat {

0 commit comments

Comments
 (0)