import (
"os"
- "unsafe"
"golang.org/x/sys/unix"
)
}
// SetMempolicy wraps set_mempolicy.
-func SetMempolicy(mode uint, mask *unix.CPUSet) error {
+func SetMempolicy(mode int, 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 unix.SetMemPolicy(mode, mask)
})
return os.NewSyscallError("set_mempolicy", err)
}
type LinuxMemoryPolicy struct {
// Mode specifies memory policy mode without mode flags. See
// set_mempolicy() documentation for details.
- Mode uint `json:"mode,omitempty"`
+ Mode int `json:"mode,omitempty"`
// Flags contains mode flags.
- Flags uint `json:"flags,omitempty"`
+ Flags int `json:"flags,omitempty"`
// Nodes contains NUMA nodes to which the mode applies.
Nodes *unix.CPUSet `json:"nodes,omitempty"`
}
flag int
}
complexFlags map[string]func(*configs.Mount)
- mpolModeMap map[string]uint
- mpolModeFMap map[string]uint
+ mpolModeMap map[string]int
+ mpolModeFMap map[string]int
)
func initMaps() {
},
}
- mpolModeMap = map[string]uint{
- string(specs.MpolDefault): configs.MPOL_DEFAULT,
- string(specs.MpolPreferred): configs.MPOL_PREFERRED,
- string(specs.MpolBind): configs.MPOL_BIND,
- string(specs.MpolInterleave): configs.MPOL_INTERLEAVE,
- string(specs.MpolLocal): configs.MPOL_LOCAL,
- string(specs.MpolPreferredMany): configs.MPOL_PREFERRED_MANY,
- string(specs.MpolWeightedInterleave): configs.MPOL_WEIGHTED_INTERLEAVE,
+ mpolModeMap = map[string]int{
+ string(specs.MpolDefault): unix.MPOL_DEFAULT,
+ string(specs.MpolPreferred): unix.MPOL_PREFERRED,
+ string(specs.MpolBind): unix.MPOL_BIND,
+ string(specs.MpolInterleave): unix.MPOL_INTERLEAVE,
+ string(specs.MpolLocal): unix.MPOL_LOCAL,
+ string(specs.MpolPreferredMany): unix.MPOL_PREFERRED_MANY,
+ string(specs.MpolWeightedInterleave): unix.MPOL_WEIGHTED_INTERLEAVE,
}
- mpolModeFMap = map[string]uint{
- string(specs.MpolFStaticNodes): configs.MPOL_F_STATIC_NODES,
- string(specs.MpolFRelativeNodes): configs.MPOL_F_RELATIVE_NODES,
- string(specs.MpolFNumaBalancing): configs.MPOL_F_NUMA_BALANCING,
+ mpolModeFMap = map[string]int{
+ string(specs.MpolFStaticNodes): unix.MPOL_F_STATIC_NODES,
+ string(specs.MpolFRelativeNodes): unix.MPOL_F_RELATIVE_NODES,
+ string(specs.MpolFNumaBalancing): unix.MPOL_F_NUMA_BALANCING,
}
})
}