mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-10 21:53:57 +08:00
merge #4726 into opencontainers/runc:main
Antti Kervinen (1): Add memory policy support LGTMs: lifubang AkihiroSuda cyphar
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user