Skip to content

Commit

Permalink
Merge pull request #1258 from kiashok/cpuAffinity-oci
Browse files Browse the repository at this point in the history
Add support for windows CPU affinity
  • Loading branch information
AkihiroSuda authored Jan 6, 2025
2 parents 09fcb39 + b9e8fdb commit d61dee6
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
8 changes: 8 additions & 0 deletions config-windows.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,14 @@ 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.
* **`affinity`** *(array of objects, OPTIONAL)* - specifies the set of CPU to affinitize for this container.

Each entry has the following structure:

Ref: https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/miniport/ns-miniport-_group_affinity

* **`mask`** *(uint64, REQUIRED)* - specifies the CPU mask relative to this CPU group.
* **`group`** *(uint32, REQUIRED)* - specifies the processor group this mask refers to, as returned by GetLogicalProcessorInformationEx.

Ref: https://docs.microsoft.com/en-us/virtualization/api/hcs/schemareference#Container_Processor

Expand Down
11 changes: 11 additions & 0 deletions schema/config-windows.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,17 @@
},
"maximum": {
"$ref": "defs.json#/definitions/uint16"
},
"affinity": {
"type": "object",
"properties": {
"mask": {
"$ref": "defs.json#/definitions/uint64"
},
"group": {
"$ref": "defs.json#/definitions/uint32"
}
}
}
}
},
Expand Down
11 changes: 11 additions & 0 deletions specs-go/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Affinity []WindowsCPUGroupAffinity `json:"affinity,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.
Mask uint64 `json:"mask,omitempty"`
// Processor group the mask refers to, as returned by GetLogicalProcessorInformationEx.
Group uint32 `json:"group,omitempty"`
}

// WindowsStorageResources contains storage resource management settings.
Expand Down

0 comments on commit d61dee6

Please sign in to comment.