mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-11 06:03:57 +08:00
[1.4] Add memory policy support
Implement support for Linux memory policy in OCI spec PR:
https://github.com/opencontainers/runtime-spec/pull/1282
Signed-off-by: Antti Kervinen <antti.kervinen@intel.com>
(cherry picked from commit eda7bdf80c)
Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
This commit is contained in:
committed by
Aleksa Sarai
parent
12ed7f7315
commit
910f134598
@@ -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