Skip to content

Commit

Permalink
feature: add vNUMA support
Browse files Browse the repository at this point in the history
Add 2 ways of specifying vNUMA for WCOW (for now):
1. Heuristics approach in which the caller specifies max
   memory and processors per vNUMA node and the platform
   takes care of presenting vNUMA that matches the criteria
2. Explicit vNUMA mappings, where the caller can pass the
   physical pNUMA node indices and the corresponding
   processor counts and memory size for each vNUMA.

The following annotations have been added to enable
heuristics based placement:
- "io.microsoft.virtualmachine.computetopology.processor.numa.max-processors-per-node"
- "io.microsoft.virtualmachine.computetopology.processor.numa.max-size-per-node"
- "io.microsoft.virtualmachine.computetopology.numa.preferred-physical-nodes"

The following annotatinos have been added to enable
explicit placement:
- "io.microsoft.virtualmachine.computetopology.numa.mapped-physical-nodes"
- "io.microsoft.virtualmachine.computetopology.numa.count-of-processors"
- "io.microsoft.virtualmachine.computetopology.numa.count-of-memory-blocks"

Port vNUMA validation logic.

Signed-off-by: Maksim An <maksiman@microsoft.com>
  • Loading branch information
anmaxvl committed Jun 19, 2024
1 parent efb0296 commit 51f1aeb
Show file tree
Hide file tree
Showing 22 changed files with 672 additions and 41 deletions.
4 changes: 2 additions & 2 deletions internal/hcs/schema2/device.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/*
* HCS API
*
* No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
* No description provided (generated by Swagger Codegen https://github.com/swaggerapi/swaggercodegen)
*
* API version: 2.1
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
* Generated by: Swagger Codegen (https://github.com/swaggerapi/swaggercodegen.git)
*/

package hcsschema
Expand Down
79 changes: 55 additions & 24 deletions internal/hcs/schema2/memory_2.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
// Autogenerated code; DO NOT EDIT.

// Schema retrieved from branch 'main' and build '27598.1000.240410-1356'.

/*
* HCS API
* Schema Open API
*
* No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
*
* API version: 2.1
* API version: 2.4
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/

Expand All @@ -12,38 +16,65 @@ package hcsschema
type Memory2 struct {
SizeInMB uint64 `json:"SizeInMB,omitempty"`

Backing MemoryBackingType `json:"Backing,omitempty"`
// If enabled, then the VM's memory is backed by the Windows pagefile rather than physically backed, statically allocated memory.
AllowOvercommit bool `json:"AllowOvercommit,omitempty"`

EnableHotHint bool `json:"EnableHotHint,omitempty"`
BackingPageSize *MemoryBackingPageSize `json:"BackingPageSize,omitempty"`
// Fault clustering size for primary RAM. Backported to windows 10 version 2004
FaultClusterSizeShift uint32 `json:"FaultClusterSizeShift,omitempty"`
// Fault clustering size for direct mapped memory. Backported to windows 10 version 2004
DirectMapFaultClusterSizeShift uint32 `json:"DirectMapFaultClusterSizeShift,omitempty"`
// If enabled, then each backing page is physically pinned on first access.
PinBackingPages bool `json:"PinBackingPages,omitempty"`
// If enabled, then backing page chunks smaller than the backing page size are never used unless the system is under extreme memory pressure. If the backing page size is Small, then it is forced to Large when this option is enabled.
ForbidSmallBackingPages bool `json:"ForbidSmallBackingPages,omitempty"`

EnablePrivateCompressionStore bool `json:"EnablePrivateCompressionStore,omitempty"`
// If enabled, then the memory hot hint feature is exposed to the VM, allowing it to prefetch pages into its working set. (if supported by the guest operating system).
EnableHotHint bool `json:"EnableHotHint,omitempty"`
// If enabled, then the memory cold hint feature is exposed to the VM, allowing it to trim zeroed pages from its working set (if supported by the guest operating system).
EnableColdHint bool `json:"EnableColdHint,omitempty"`
// If enabled, then the memory cold discard hint feature is exposed to the VM, allowing it to trim non-zeroed pages from the working set (if supported by the guest operating system).
EnableColdDiscardHint bool `json:"EnableColdDiscardHint,omitempty"`
// If enabled, then the base address of direct-mapped host images is exposed to the guest.
ImageBaseAddressesExposed bool `json:"ImageBaseAddressesExposed,omitempty"`

EnableEpf bool `json:"EnableEpf,omitempty"`
SharedMemoryMB int64 `json:"SharedMemoryMB,omitempty"`

// EnableDeferredCommit is private in the schema. If regenerated need to add back.
EnableDeferredCommit bool `json:"EnableDeferredCommit,omitempty"`
DisableSharedMemoryMapping bool `json:"DisableSharedMemoryMapping,omitempty"`

// EnableColdDiscardHint if enabled, then the memory cold discard hint feature is exposed
// to the VM, allowing it to trim non-zeroed pages from the working set (if supported by
// the guest operating system).
EnableColdDiscardHint bool `json:"EnableColdDiscardHint,omitempty"`
SharedMemoryAccessSids []string `json:"SharedMemoryAccessSids,omitempty"`

// LowMmioGapInMB is the low MMIO region allocated below 4GB.
//
// TODO: This is pre-release support in schema 2.3. Need to add build number
// docs when a public build with this is out.
LowMMIOGapInMB uint64 `json:"LowMmioGapInMB,omitempty"`
EnableEpf bool `json:"EnableEpf,omitempty"`

// HighMmioBaseInMB is the high MMIO region allocated above 4GB (base and
// size).
//
// TODO: This is pre-release support in schema 2.3. Need to add build number
// docs when a public build with this is out.
// If enabled, then commit is not charged for each backing page until first access.
EnableDeferredCommit bool `json:"EnableDeferredCommit,omitempty"`
// Low MMIO region allocated below 4GB
LowMMIOGapInMB uint64 `json:"LowMmioGapInMB,omitempty"`
// High MMIO region allocated above 4GB (base and size)
HighMMIOBaseInMB uint64 `json:"HighMmioBaseInMB,omitempty"`

// HighMmioGapInMB is the high MMIO region.
//
// TODO: This is pre-release support in schema 2.3. Need to add build number
// docs when a public build with this is out.
HighMMIOGapInMB uint64 `json:"HighMmioGapInMB,omitempty"`

Vtl2AddressRangeBase uint64 `json:"Vtl2AddressRangeBase,omitempty"`

Vtl2AddressRangeSize uint64 `json:"Vtl2AddressRangeSize,omitempty"`

Vtl2MMIOAddressRangeSize uint64 `json:"Vtl2MmioAddressRangeSize,omitempty"`

Priority uint32 `json:"Priority,omitempty"`

LimitInMB uint64 `json:"LimitInMB,omitempty"`

ReservationInMB uint64 `json:"ReservationInMB,omitempty"`

TargetBuffer uint32 `json:"TargetBuffer,omitempty"`

MappingPageSize *MemoryBackingPageSize `json:"MappingPageSize,omitempty"`
// HCS currently doesn't support DM enable, will only have value for VMMS VM
EnableDynamicMemory bool `json:"EnableDynamicMemory,omitempty"`

// Appends the suffix to the image name prefix defined in vidinternal.h for any hosting process
HostingProcessNameSuffix string `json:"HostingProcessNameSuffix,omitempty"`
}
23 changes: 23 additions & 0 deletions internal/hcs/schema2/memory_backing_page_size.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Autogenerated code; DO NOT EDIT.

// Schema retrieved from branch 'main' and build '27598.1000.2404101356'.

/*
* Schema Open API
*
* No description provided (generated by Swagger Codegen https://github.com/swaggerapi/swaggercodegen)
*
* API version: 2.4
* Generated by: Swagger Codegen (https://github.com/swaggerapi/swaggercodegen.git)
*/

package hcsschema

type MemoryBackingPageSize string

// List of MemoryBackingPageSize
const (
MemoryBackingPageSize_SMALL MemoryBackingPageSize = "Small"
MemoryBackingPageSize_LARGE MemoryBackingPageSize = "Large"
MemoryBackingPageSize_HUGE MemoryBackingPageSize = "Huge"
)
23 changes: 23 additions & 0 deletions internal/hcs/schema2/memory_backing_type.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Autogenerated code; DO NOT EDIT.

// Schema retrieved from branch 'main' and build '27598.1000.2404101356'.

/*
* Schema Open API
*
* No description provided (generated by Swagger Codegen https://github.com/swaggerapi/swaggercodegen)
*
* API version: 2.4
* Generated by: Swagger Codegen (https://github.com/swaggerapi/swaggercodegen.git)
*/

package hcsschema

type MemoryBackingType string

// List of MemoryBackingType
const (
MemoryBackingType_PHYSICAL MemoryBackingType = "Physical"
MemoryBackingType_VIRTUAL MemoryBackingType = "Virtual"
MemoryBackingType_HYBRID MemoryBackingType = "Hybrid"
)
21 changes: 21 additions & 0 deletions internal/hcs/schema2/numa.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Autogenerated code; DO NOT EDIT.

// Schema retrieved from branch 'main' and build '27598.1000.240410-1356'.

/*
* Schema Open API
*
* No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
*
* API version: 2.4
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/

package hcsschema

type Numa struct {
VirtualNodeCount uint8 `json:"VirtualNodeCount,omitempty"`
PreferredPhysicalNodes []int64 `json:"PreferredPhysicalNodes,omitempty"`
Settings []NumaSetting `json:"Settings,omitempty"`
MaxSizePerNode uint64 `json:"MaxSizePerNode,omitempty"`
}
19 changes: 19 additions & 0 deletions internal/hcs/schema2/numa_node.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Autogenerated code; DO NOT EDIT.

// Schema retrieved from branch 'main' and build '27598.1000.240410-1356'.

/*
* Schema Open API
*
* No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
*
* API version: 2.4
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/

package hcsschema

type NumaNode struct {
VirtualNodeIndex uint32 `json:"VirtualNodeIndex,omitempty"`
PhysicalNodeIndex uint32 `json:"PhysicalNodeIndex,omitempty"`
}
21 changes: 21 additions & 0 deletions internal/hcs/schema2/numa_node_memory.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Autogenerated code; DO NOT EDIT.

// Schema retrieved from branch 'main' and build '27598.1000.240410-1356'.

/*
* Schema Open API
*
* No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
*
* API version: 2.4
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/

package hcsschema

type NumaNodeMemory struct {
// Total physical memory on on this physical NUMA node that is consumable by the VMs.
TotalConsumableMemoryInPages uint64 `json:"TotalConsumableMemoryInPages,omitempty"`
// Currently available physical memory on this physical NUMA node for the VMs.
AvailableMemoryInPages uint64 `json:"AvailableMemoryInPages,omitempty"`
}
19 changes: 19 additions & 0 deletions internal/hcs/schema2/numa_node_processor.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Autogenerated code; DO NOT EDIT.

// Schema retrieved from branch 'main' and build '27598.1000.240410-1356'.

/*
* Schema Open API
*
* No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
*
* API version: 2.4
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/

package hcsschema

type NumaNodeProcessor struct {
TotalAssignedProcessors uint32 `json:"TotalAssignedProcessors,omitempty"`
TotalAvailableProcessors uint32 `json:"TotalAvailableProcessors,omitempty"`
}
23 changes: 23 additions & 0 deletions internal/hcs/schema2/numa_processors.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Autogenerated code; DO NOT EDIT.

// Schema retrieved from branch 'main' and build '27598.1000.240410-1356'.

/*
* Schema Open API
*
* No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
*
* API version: 2.4
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/

package hcsschema

type NumaProcessors struct {
CountPerNode Range `json:"count_per_node,omitempty"`
NodePerSocket uint32 `json:"node_per_socket,omitempty"`
}

type Range struct {
Max uint32 `json:"max,omitempty"`
}
30 changes: 30 additions & 0 deletions internal/hcs/schema2/numa_setting.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Autogenerated code; DO NOT EDIT.

// Schema retrieved from branch 'main' and build '27598.1000.240410-1356'.

/*
* Schema Open API
*
* No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
*
* API version: 2.4
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/

package hcsschema

const (
WildcardPhysicalNodeNumber = 0xFF
NumaTopologyNodeCountMax = 64
NumaChildNodeCountMax = 64
)

type NumaSetting struct {
VirtualNodeNumber uint32 `json:"VirtualNodeNumber,omitempty"`
PhysicalNodeNumber uint32 `json:"PhysicalNodeNumber,omitempty"`
VirtualSocketNumber uint32 `json:"VirtualSocketNumber,omitempty"`
CountOfProcessors uint32 `json:"CountOfProcessors,omitempty"`
CountOfMemoryBlocks uint64 `json:"CountOfMemoryBlocks,omitempty"`
MemoryBackingType MemoryBackingType `json:"MemoryBackingType,omitempty"`
AccessTracingGranularity PageGranularity `json:"AccessTracingGranularity,omitempty"`
}
Loading

0 comments on commit 51f1aeb

Please sign in to comment.