merge #4726 into opencontainers/runc:main

Antti Kervinen (1):
  Add memory policy support

LGTMs: lifubang AkihiroSuda cyphar
This commit is contained in:
Aleksa Sarai
2025-10-08 05:18:13 +11:00
11 changed files with 286 additions and 6 deletions
+13
View File
@@ -2,6 +2,7 @@ package linux
import (
"os"
"unsafe"
"golang.org/x/sys/unix"
)
@@ -72,3 +73,15 @@ func Sendmsg(fd int, p, oob []byte, to unix.Sockaddr, flags int) error {
})
return os.NewSyscallError("sendmsg", err)
}
// SetMempolicy wraps set_mempolicy.
func SetMempolicy(mode uint, mask *unix.CPUSet) error {
err := retryOnEINTR(func() error {
_, _, errno := unix.Syscall(unix.SYS_SET_MEMPOLICY, uintptr(mode), uintptr(unsafe.Pointer(mask)), unsafe.Sizeof(*mask)*8)
if errno != 0 {
return errno
}
return nil
})
return os.NewSyscallError("set_mempolicy", err)
}