Skip to content

Commit

Permalink
update review idea
Browse files Browse the repository at this point in the history
Signed-off-by: Zheao.Li <me@manjusaka.me>
  • Loading branch information
Zheaoli committed Jan 16, 2024
1 parent 8ceb2af commit 823b283
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion libcontainer/cgroups/fs2/fs2.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func (m *Manager) GetStats() (*cgroups.Stats, error) {
if err := statMemory(m.dirPath, st); err != nil && !os.IsNotExist(err) {
errs = append(errs, err)
}
// memory event for CGRoup v2
// memory event for cgroup v2
if err := eventMemory(m.dirPath, st); err != nil && !os.IsNotExist(err) {
errs = append(errs, err)
}
Expand Down
14 changes: 7 additions & 7 deletions libcontainer/cgroups/fs2/memory.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,13 +243,13 @@ func eventMemory(dirPath string, stats *cgroups.Stats) error {
if err != nil {
return err
}
eventCount := cgroups.MemoryEventsCount{}
eventCount.Max = kv["max"]
eventCount.ReclaimLow = kv["low"]
eventCount.ReclaimHigh = kv["high"]
eventCount.Oom = kv["oom"]
eventCount.OomKill = kv["oom_kill"]
stats.MemoryStats.EventCount = eventCount
stats.MemoryStats.EventCount = cgroups.MemoryEventCount{
Max: kv["max"],
ReclaimLow: kv["low"],
ReclaimHigh: kv["high"],
OOM: kv["oom"],
OOMKill: kv["oom_kill"],
}

return nil
}
2 changes: 1 addition & 1 deletion libcontainer/cgroups/fscommon/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ func GetCgroupParamString(path, file string) (string, error) {
return strings.TrimSpace(contents), nil
}

// ReadKeyValueFile reads all key-value pairs from the specified cgroup file,
// ParseKeyValueFile reads all key-value pairs from the specified cgroup file,
// returns a map from key to value.
func ParseKeyValueFile(dir, file string) (map[string]uint64, error) {
content, err := cgroups.ReadFile(dir, file)
Expand Down
14 changes: 7 additions & 7 deletions libcontainer/cgroups/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,20 +105,20 @@ type MemoryStats struct {

Stats map[string]uint64 `json:"stats,omitempty"`
PSI *PSIStats `json:"psi,omitempty"`
EventCount MemoryEventsCount `json:"events_count,omitempty"`
EventCount MemoryEventCount `json:"events_count,omitempty"`
}

type MemoryEventsCount struct {
type MemoryEventCount struct {
// count of memory reclaim (when usage is under the low boundary)
ReclaimLow uint64 `json:"reclaim_low"`
// count of memory reclaim (when high memory boundary was exceeded)
ReclaimHigh uint64 `json:"reclaim_high"`
// the number of times the cgroup’s memory usage was about to go over the max boundary
// count of times the cgroup’s memory usage was about to go over the max boundary
Max uint64 `json:"max"`
// the number of time the cgroup’s memory usage was reached the limit and allocation was about to fail
Oom uint64 `json:"oom"`
// The number of processes belonging to this cgroup was oom killed
OomKill uint64 `json:"oom_kill"`
// count of times the cgroup’s memory usage was reached the limit and allocation was about to fail
OOM uint64 `json:"oom"`
// count of processes belonging to this container was oom killed
OOMKill uint64 `json:"oom_kill"`
}

type PageUsageByNUMA struct {
Expand Down
2 changes: 1 addition & 1 deletion types/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ type PSIData = cgroups.PSIData

type PSIStats = cgroups.PSIStats

type MemoryEventCount = cgroups.MemoryEventsCount
type MemoryEventCount = cgroups.MemoryEventCount

type Hugetlb struct {
Usage uint64 `json:"usage,omitempty"`
Expand Down

0 comments on commit 823b283

Please sign in to comment.