Skip to content

Commit

Permalink
meminfo: add Percpu field (#588)
Browse files Browse the repository at this point in the history
Signed-off-by: wangqing <wangqing@uniontech.com>
Co-authored-by: wangqing <wangqing@uniontech.com>
  • Loading branch information
wangqingfree and wangqing committed Dec 14, 2023
1 parent 732ca0f commit 8f660d1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
5 changes: 5 additions & 0 deletions meminfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ type Meminfo struct {
VmallocUsed *uint64
// largest contiguous block of vmalloc area which is free
VmallocChunk *uint64
Percpu *uint64
HardwareCorrupted *uint64
AnonHugePages *uint64
ShmemHugePages *uint64
Expand Down Expand Up @@ -178,6 +179,7 @@ type Meminfo struct {
VmallocTotalBytes *uint64
VmallocUsedBytes *uint64
VmallocChunkBytes *uint64
PercpuBytes *uint64
HardwareCorruptedBytes *uint64
AnonHugePagesBytes *uint64
ShmemHugePagesBytes *uint64
Expand Down Expand Up @@ -339,6 +341,9 @@ func parseMemInfo(r io.Reader) (*Meminfo, error) {
case "VmallocChunk:":
m.VmallocChunk = &val
m.VmallocChunkBytes = &valBytes
case "Percpu:":
m.Percpu = &val
m.PercpuBytes = &valBytes
case "HardwareCorrupted:":
m.HardwareCorrupted = &val
m.HardwareCorruptedBytes = &valBytes
Expand Down
2 changes: 2 additions & 0 deletions meminfo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ func TestMeminfo(t *testing.T) {
VmallocTotal: newuint64(34359738367),
VmallocUsed: newuint64(36596),
VmallocChunk: newuint64(34359637840),
Percpu: newuint64(26176),
HardwareCorrupted: newuint64(0),
AnonHugePages: newuint64(12288),
HugePagesTotal: newuint64(0),
Expand Down Expand Up @@ -96,6 +97,7 @@ func TestMeminfo(t *testing.T) {
VmallocTotalBytes: newuint64(35184372087808),
VmallocUsedBytes: newuint64(37474304),
VmallocChunkBytes: newuint64(35184269148160),
PercpuBytes: newuint64(26804224),
HardwareCorruptedBytes: newuint64(0),
AnonHugePagesBytes: newuint64(12582912),
HugepagesizeBytes: newuint64(2097152),
Expand Down
3 changes: 2 additions & 1 deletion testdata/fixtures.ttar
Original file line number Diff line number Diff line change
Expand Up @@ -2317,7 +2317,7 @@ unused devices: <none>
Mode: 644
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Path: fixtures/proc/meminfo
Lines: 42
Lines: 43
MemTotal: 15666184 kB
MemFree: 440324 kB
Buffers: 1020128 kB
Expand Down Expand Up @@ -2351,6 +2351,7 @@ Committed_AS: 530844 kB
VmallocTotal: 34359738367 kB
VmallocUsed: 36596 kB
VmallocChunk: 34359637840 kB
Percpu: 26176 kB
HardwareCorrupted: 0 kB
AnonHugePages: 12288 kB
HugePages_Total: 0
Expand Down

0 comments on commit 8f660d1

Please sign in to comment.