Skip to content

Commit 071c31a

Browse files
authored
Merge pull request #369 from gavinkflam/stats-hugetlb-failcnt
Add cgroup2 hugetlb failcnt metric
2 parents 1351ae1 + 14deda3 commit 071c31a

File tree

5 files changed

+44
-22
lines changed

5 files changed

+44
-22
lines changed

cgroup2/hugetlbv2_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package cgroup2
1919
import (
2020
"fmt"
2121
"os"
22+
"strconv"
2223
"testing"
2324

2425
"github.com/stretchr/testify/assert"
@@ -46,6 +47,8 @@ func TestCgroupv2HugetlbStats(t *testing.T) {
4647
for _, entry := range stats.Hugetlb {
4748
if entry.Pagesize == "2MB" {
4849
assert.Equal(t, uint64(1073741824), entry.Max)
50+
checkFileContent(t, c.path, "hugetlb."+entry.Pagesize+".current", strconv.FormatUint(entry.Current, 10))
51+
checkFileContent(t, c.path, "hugetlb."+entry.Pagesize+".events", "max "+strconv.FormatUint(entry.Failcnt, 10))
4952
break
5053
}
5154
}

cgroup2/stats/metrics.pb.go

Lines changed: 32 additions & 22 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
@@ -640,6 +640,13 @@ file {
640640
type: TYPE_STRING
641641
json_name: "pagesize"
642642
}
643+
field {
644+
name: "failcnt"
645+
number: 4
646+
label: LABEL_OPTIONAL
647+
type: TYPE_UINT64
648+
json_name: "failcnt"
649+
}
643650
}
644651
message_type {
645652
name: "NetworkStat"

cgroup2/stats/metrics.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ message HugeTlbStat {
122122
uint64 current = 1;
123123
uint64 max = 2;
124124
string pagesize = 3;
125+
uint64 failcnt = 4;
125126
}
126127

127128
message NetworkStat {

cgroup2/utils.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,7 @@ func readHugeTlbStats(path string) []*stats.HugeTlbStat {
394394
Max: getStatFileContentUint64(filepath.Join(path, "hugetlb."+pagesize+".max")),
395395
Current: getStatFileContentUint64(filepath.Join(path, "hugetlb."+pagesize+".current")),
396396
Pagesize: pagesize,
397+
Failcnt: getStatFileContentUint64(filepath.Join(path, "hugetlb."+pagesize+".events")),
397398
}
398399
}
399400
return usage

0 commit comments

Comments
 (0)