1
0
mirror of https://github.com/opencontainers/runc.git synced 2026-10-23 19:49:01 +03:00
Files
runc/libcontainer/configs/memorypolicy.go
Kir Kolyshkin daf934fefc libct: use CPUSetDynamic for affinity and mempolicy masks
ToCPUSet was limited to unix.CPUSet (a fixed-size mask capped at 1024
CPUs). Switch CPUAffinity, LinuxMemoryPolicy.Nodes, ToCPUSet, and
SetMempolicy to unix.CPUSetDynamic, which can represent arbitrary CPU
and NUMA node IDs.

ToCPUSet now parses the input in a first pass to find the maximum value,
then allocates a mask large enough to hold it (out-of-range Set calls on
a dynamic mask are silently ignored). An arbitrary sanity cap is kept to
avoid huge allocations on bogus input.

This is backward compatible with reading older state.json: both the old
*unix.CPUSet (a fixed array) and the new CPUSetDynamic (a slice)
marshal to and from the same JSON array-of-numbers representation.

Update TestToCPUSet accordingly, adding coverage for values beyond the
old non-dynamic limit.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2026-07-27 17:12:24 -07:00

15 lines
460 B
Go

package configs
import "golang.org/x/sys/unix"
// LinuxMemoryPolicy contains memory policy configuration.
type LinuxMemoryPolicy struct {
// Mode specifies memory policy mode without mode flags. See
// set_mempolicy() documentation for details.
Mode int `json:"mode,omitempty"`
// Flags contains mode flags.
Flags int `json:"flags,omitempty"`
// Nodes contains NUMA nodes to which the mode applies.
Nodes unix.CPUSetDynamic `json:"nodes,omitempty"`
}