mirror of
https://github.com/containers/podman.git
synced 2025-12-01 10:38:05 +08:00
Pull in updates made to the filters code for images. Filters now perform an AND operation except for th reference filter which does an OR operation for positive case but an AND operation for negative cases. Signed-off-by: Urvashi Mohnani <umohnani@redhat.com>
33 lines
717 B
Go
33 lines
717 B
Go
//go:build linux
|
|
|
|
package sysinfo
|
|
|
|
import (
|
|
"unsafe"
|
|
|
|
"golang.org/x/sys/unix"
|
|
)
|
|
|
|
// NUMANodeCount queries the system for the count of Memory Nodes available
|
|
// for use to this process.
|
|
func NUMANodeCount() int {
|
|
// this is the correct flag name (not defined in the unix package)
|
|
//nolint:revive
|
|
MPOL_F_MEMS_ALLOWED := (1 << 2)
|
|
var mask [1024 / 64]uintptr
|
|
_, _, err := unix.RawSyscall6(unix.SYS_GET_MEMPOLICY, 0, uintptr(unsafe.Pointer(&mask[0])), uintptr(len(mask)*8), 0, uintptr(MPOL_F_MEMS_ALLOWED), 0)
|
|
if err != 0 {
|
|
return 0
|
|
}
|
|
|
|
// For every available thread a bit is set in the mask.
|
|
nmem := 0
|
|
for _, e := range mask {
|
|
if e == 0 {
|
|
continue
|
|
}
|
|
nmem += int(popcnt(uint64(e)))
|
|
}
|
|
return nmem
|
|
}
|