Skip to content

Commit b9e8fdb

Browse files
committed
Add support for windows CPU affinity
Signed-off-by: Kirtana Ashok <[email protected]>
1 parent 9505701 commit b9e8fdb

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

config-windows.md

+8
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,14 @@ The following parameters can be specified (mutually exclusive):
8282
* **`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.
8383
* **`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.
8484
* **`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.
85+
* **`affinity`** *(array of objects, OPTIONAL)* - specifies the set of CPU to affinitize for this container.
86+
87+
Each entry has the following structure:
88+
89+
Ref: https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/miniport/ns-miniport-_group_affinity
90+
91+
* **`mask`** *(uint64, REQUIRED)* - specifies the CPU mask relative to this CPU group.
92+
* **`group`** *(uint32, REQUIRED)* - specifies the processor group this mask refers to, as returned by GetLogicalProcessorInformationEx.
8593

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

schema/config-windows.json

+11
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,17 @@
3838
},
3939
"maximum": {
4040
"$ref": "defs.json#/definitions/uint16"
41+
},
42+
"affinity": {
43+
"type": "object",
44+
"properties": {
45+
"mask": {
46+
"$ref": "defs.json#/definitions/uint64"
47+
},
48+
"group": {
49+
"$ref": "defs.json#/definitions/uint32"
50+
}
51+
}
4152
}
4253
}
4354
},

specs-go/config.go

+11
Original file line numberDiff line numberDiff line change
@@ -635,6 +635,17 @@ type WindowsCPUResources struct {
635635
// cycles per 10,000 cycles. Set processor `maximum` to a percentage times
636636
// 100.
637637
Maximum *uint16 `json:"maximum,omitempty"`
638+
// Set of CPUs to affinitize for this container.
639+
Affinity []WindowsCPUGroupAffinity `json:"affinity,omitempty"`
640+
}
641+
642+
// Similar to _GROUP_AFFINITY struct defined in
643+
// https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/miniport/ns-miniport-_group_affinity
644+
type WindowsCPUGroupAffinity struct {
645+
// CPU mask relative to this CPU group.
646+
Mask uint64 `json:"mask,omitempty"`
647+
// Processor group the mask refers to, as returned by GetLogicalProcessorInformationEx.
648+
Group uint32 `json:"group,omitempty"`
638649
}
639650

640651
// WindowsStorageResources contains storage resource management settings.

0 commit comments

Comments
 (0)