From fd1ac235667562ded9fbc61e4496b5bea47eae3e Mon Sep 17 00:00:00 2001 From: Kirtana Ashok Date: Fri, 7 Jun 2024 12:41:20 -0700 Subject: [PATCH] Add support for windows CPU affinity Signed-off-by: Kirtana Ashok --- config-windows.md | 1 + specs-go/config.go | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/config-windows.md b/config-windows.md index 73a6d639e..8efd719e3 100644 --- a/config-windows.md +++ b/config-windows.md @@ -82,6 +82,7 @@ The following parameters can be specified (mutually exclusive): * **`count`** *(uint64, OPTIONAL)* - specifies the number of CPUs available to the container. It represents the fraction of the configured processor `count` in a container in relation to the processors available in the host. The fraction ultimately determines the portion of processor cycles that the threads in a container can use during each scheduling interval, as the number of cycles per 10,000 cycles. * **`shares`** *(uint16, OPTIONAL)* - limits the share of processor time given to the container relative to other workloads on the processor. The processor `shares` (`weight` at the platform level) is a value between 0 and 10,000. * **`maximum`** *(uint16, OPTIONAL)* - determines the portion of processor cycles that the threads in a container can use during each scheduling interval, as the number of cycles per 10,000 cycles. Set processor `maximum` to a percentage times 100. +* **`affinityCPUs`** *(object, OPTIONAL)* - specifies the set of CPU to affinitize for this container. Ref: https://docs.microsoft.com/en-us/virtualization/api/hcs/schemareference#Container_Processor diff --git a/specs-go/config.go b/specs-go/config.go index 671f0d016..8823e11cd 100644 --- a/specs-go/config.go +++ b/specs-go/config.go @@ -635,6 +635,17 @@ type WindowsCPUResources struct { // cycles per 10,000 cycles. Set processor `maximum` to a percentage times // 100. Maximum *uint16 `json:"maximum,omitempty"` + // Set of CPUs to affinitize for this container. + AffinityCPUs []WindowsCPUGroupAffinity `json:"affinityCPUs,omitempty"` +} + +// Similar to _GROUP_AFFINITY struct defined in +// https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/miniport/ns-miniport-_group_affinity +type WindowsCPUGroupAffinity struct { + // CPU mask relative to this CPU group. + CPUMask uint64 `json:"cpuMask,omitempty"` + // CPU group that this CPU belongs to. + CPUGroup uint32 `json:"cpuGroup,omitempty"` } // WindowsStorageResources contains storage resource management settings.