Skip to content

Implement Windows CPU Affinity Support #312

@nayuta723

Description

@nayuta723

Overview

Implement Windows CPU Affinity Support

oci-spec-rs is currently missing the Windows CPU Group Affinity features. I will add these to achieve parity with oci-spec-go.

  • Add WindowsCPUGroupAffinity struct
  • Add WindowsCPUResources.Affinity field

Runtime Spec Reference

Implemented in runtime-spec as follows:

Found in https://github.com/opencontainers/runtime-spec/blob/main/specs-go/config.go:

WindowsCPUResources

// WindowsCPUResources contains CPU resource management settings.
type WindowsCPUResources struct {
	// Count is 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.
	Count *uint64 `json:"count,omitempty"`
	// Shares 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 10000.
	Shares *uint16 `json:"shares,omitempty"`
	// Maximum 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.
	Maximum *uint16 `json:"maximum,omitempty"`
	// Set of CPUs to affinitize for this container.
	Affinity []WindowsCPUGroupAffinity `json:"affinity,omitempty"`
}

WindowsCPUGroupAffinity

// 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"`
}

Related to #309

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions