Make sure that image events are written *after* execution.

Fixes: #10812
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
This commit is contained in:
Valentin Rothberg
2021-06-30 11:32:48 +02:00
parent 0d8d805a76
commit 8b52204baa
12 changed files with 79 additions and 31 deletions

View File

@@ -0,0 +1,30 @@
// +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 {
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
}