Skip to content

Commit

Permalink
Merge pull request #337 from jaypipes/arm-topo
Browse files Browse the repository at this point in the history
assume phys mem == usable mem on ARM
  • Loading branch information
ffromani committed May 2, 2023
2 parents 227643e + ae5a093 commit 6aad076
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions pkg/memory/memory_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,19 +64,31 @@ func AreaForNode(ctx *context.Context, nodeID int) (*Area, error) {
fmt.Sprintf("node%d", nodeID),
)

blockSizeBytes, err := memoryBlockSizeBytes(paths.SysDevicesSystemMemory)
if err != nil {
return nil, err
}
var err error
var blockSizeBytes uint64
var totPhys int64
var totUsable int64

totPhys, err := memoryTotalPhysicalBytesFromPath(path, blockSizeBytes)
totUsable, err = memoryTotalUsableBytesFromPath(filepath.Join(path, "meminfo"))
if err != nil {
return nil, err
}

totUsable, err := memoryTotalUsableBytesFromPath(filepath.Join(path, "meminfo"))
if err != nil {
return nil, err
blockSizeBytes, err = memoryBlockSizeBytes(paths.SysDevicesSystemMemory)
if err == nil {
totPhys, err = memoryTotalPhysicalBytesFromPath(path, blockSizeBytes)
if err != nil {
return nil, err
}
} else {
// NOTE(jaypipes): Some platforms (e.g. ARM) will not have a
// /sys/device/system/memory/block_size_bytes file. If this is the
// case, we set physical bytes equal to either the physical memory
// determined from syslog or the usable bytes
//
// see: https://bugzilla.redhat.com/show_bug.cgi?id=1794160
// see: https://github.com/jaypipes/ghw/issues/336
totPhys = memTotalPhysicalBytesFromSyslog(paths)
}

supportedHP, err := memorySupportedPageSizes(filepath.Join(path, "hugepages"))
Expand Down

0 comments on commit 6aad076

Please sign in to comment.