Skip to content

Commit

Permalink
Merge pull request #1275 from quanweiZhou/add-meminfo-fields
Browse files Browse the repository at this point in the history
[mem][linux] added additional meminfo fields
  • Loading branch information
shirou committed Jun 7, 2022
2 parents ce948d5 + ddaf2d7 commit 5722370
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions mem/mem.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ type VirtualMemoryStat struct {
VmallocChunk uint64 `json:"vmallocChunk"`
HugePagesTotal uint64 `json:"hugePagesTotal"`
HugePagesFree uint64 `json:"hugePagesFree"`
HugePagesRsvd uint64 `json:"hugePagesRsvd"`
HugePagesSurp uint64 `json:"hugePagesSurp"`
HugePageSize uint64 `json:"hugePageSize"`
}

Expand Down
12 changes: 12 additions & 0 deletions mem/mem_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,18 @@ func fillFromMeminfoWithContext() (*VirtualMemoryStat, *VirtualMemoryExStat, err
return ret, retEx, err
}
ret.HugePagesFree = t
case "HugePages_Rsvd":
t, err := strconv.ParseUint(value, 10, 64)
if err != nil {
return ret, retEx, err
}
ret.HugePagesRsvd = t
case "HugePages_Surp":
t, err := strconv.ParseUint(value, 10, 64)
if err != nil {
return ret, retEx, err
}
ret.HugePagesSurp = t
case "Hugepagesize":
t, err := strconv.ParseUint(value, 10, 64)
if err != nil {
Expand Down
4 changes: 4 additions & 0 deletions mem/mem_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ var virtualMemoryTests = []struct {
VmallocChunk: 0,
HugePagesTotal: 0,
HugePagesFree: 0,
HugePagesRsvd: 0,
HugePagesSurp: 0,
HugePageSize: 2097152,
},
},
Expand Down Expand Up @@ -101,6 +103,8 @@ var virtualMemoryTests = []struct {
VmallocChunk: 0,
HugePagesTotal: 0,
HugePagesFree: 0,
HugePagesRsvd: 0,
HugePagesSurp: 0,
HugePageSize: 0,
},
},
Expand Down

0 comments on commit 5722370

Please sign in to comment.