From c2121ec89a7485ff97ce7a2c38aa7aadd7222bd3 Mon Sep 17 00:00:00 2001 From: Kirtana Ashok Date: Thu, 5 Sep 2024 15:04:06 -0700 Subject: [PATCH] Remove AffinityPreferredNumaNodes and revendor Signed-off-by: Kirtana Ashok --- go.mod | 2 +- internal/hcsoci/create.go | 42 +++++++++---------- .../runtime-spec/specs-go/config.go | 12 ++++-- vendor/modules.txt | 2 +- 4 files changed, 32 insertions(+), 26 deletions(-) diff --git a/go.mod b/go.mod index b65dea35b8..68d9ceccfc 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/Microsoft/hcsshim -go 1.21.12 +go 1.22.4 require ( github.com/Microsoft/cosesign1go v1.1.0 diff --git a/internal/hcsoci/create.go b/internal/hcsoci/create.go index c43b0b88b9..f605bb4638 100644 --- a/internal/hcsoci/create.go +++ b/internal/hcsoci/create.go @@ -12,7 +12,6 @@ import ( "strconv" "github.com/Microsoft/go-winio/pkg/guid" - "github.com/Microsoft/hcsshim/internal/coreinfo" "github.com/Microsoft/hcsshim/internal/cow" "github.com/Microsoft/hcsshim/internal/guestpath" "github.com/Microsoft/hcsshim/internal/hcs" @@ -370,30 +369,31 @@ func setCPUAffinityOnJobObject(ctx context.Context, spec *specs.Spec, computeSys } } - if spec.Windows.Resources.CPU.AffinityPreferredNumaNodes != nil { - numaNodeInfo, err := coreinfo.GetNumaNodeToProcessorInfo() - if err != nil { - return fmt.Errorf("error getting numa node info: %v", err) - } - // check if cpu affinities are also set and consolidate the masks - if len(info) > 0 { - for _, numaNode := range numaNodeInfo { - doesCpuAffinityExist := false - for ind, _ := range info { - if info[ind].CpuGroup == numaNode.CpuGroup { - doesCpuAffinityExist = true - // overwrite the entire mask of the numa node - info[ind].CpuMask = numaNode.CpuMask - break + /* + if spec.Windows.Resources.CPU.AffinityPreferredNumaNodes != nil { + numaNodeInfo, err := coreinfo.GetNumaNodeToProcessorInfo() + if err != nil { + return fmt.Errorf("error getting numa node info: %v", err) + } + // check if cpu affinities are also set and consolidate the masks + if len(info) > 0 { + for _, numaNode := range numaNodeInfo { + doesCpuAffinityExist := false + for ind, _ := range info { + if info[ind].CpuGroup == numaNode.CpuGroup { + doesCpuAffinityExist = true + // overwrite the entire mask of the numa node + info[ind].CpuMask = numaNode.CpuMask + break + } + } + if !doesCpuAffinityExist { + info = append(info, numaNode) } - } - if !doesCpuAffinityExist { - info = append(info, numaNode) } } } - } - + */ return job.SetInformationJobObject(info) } diff --git a/vendor/github.com/opencontainers/runtime-spec/specs-go/config.go b/vendor/github.com/opencontainers/runtime-spec/specs-go/config.go index a164764f2d..8823e11cda 100644 --- a/vendor/github.com/opencontainers/runtime-spec/specs-go/config.go +++ b/vendor/github.com/opencontainers/runtime-spec/specs-go/config.go @@ -94,6 +94,8 @@ type Process struct { SelinuxLabel string `json:"selinuxLabel,omitempty" platform:"linux"` // IOPriority contains the I/O priority settings for the cgroup. IOPriority *LinuxIOPriority `json:"ioPriority,omitempty" platform:"linux"` + // ExecCPUAffinity specifies CPU affinity for exec processes. + ExecCPUAffinity *CPUAffinity `json:"execCPUAffinity,omitempty" platform:"linux"` } // LinuxCapabilities specifies the list of allowed capabilities that are kept for a process. @@ -127,6 +129,12 @@ const ( IOPRIO_CLASS_IDLE IOPriorityClass = "IOPRIO_CLASS_IDLE" ) +// CPUAffinity specifies process' CPU affinity. +type CPUAffinity struct { + Initial string `json:"initial,omitempty"` + Final string `json:"final,omitempty"` +} + // Box specifies dimensions of a rectangle. Used for specifying the size of a console. type Box struct { // Height is the vertical dimension of a box. @@ -629,8 +637,6 @@ type WindowsCPUResources struct { Maximum *uint16 `json:"maximum,omitempty"` // Set of CPUs to affinitize for this container. AffinityCPUs []WindowsCPUGroupAffinity `json:"affinityCPUs,omitempty"` - // Specifies preferred set of numa node numbers to affinitize for this container. - AffinityPreferredNumaNodes []uint32 `json:"affinityPreferredNumaNodes,omitempty"` } // Similar to _GROUP_AFFINITY struct defined in @@ -638,7 +644,7 @@ type WindowsCPUResources struct { type WindowsCPUGroupAffinity struct { // CPU mask relative to this CPU group. CPUMask uint64 `json:"cpuMask,omitempty"` - // Processor group the mask refers to, as returned by GetLogicalProcessorInformationEx. + // CPU group that this CPU belongs to. CPUGroup uint32 `json:"cpuGroup,omitempty"` } diff --git a/vendor/modules.txt b/vendor/modules.txt index 785785c92f..2a16108323 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -363,7 +363,7 @@ github.com/opencontainers/image-spec/specs-go/v1 github.com/opencontainers/runc/libcontainer/devices github.com/opencontainers/runc/libcontainer/user # github.com/opencontainers/runtime-spec v1.1.0 => ../../runtime-spec/ -## explicit; go 1.21.12 +## explicit; go 1.22.4 github.com/opencontainers/runtime-spec/specs-go # github.com/pelletier/go-toml v1.9.5 ## explicit; go 1.12