Skip to content

Commit

Permalink
add annotations to forbid small backing pages
Browse files Browse the repository at this point in the history
Signed-off-by: Maksim An <maksiman@microsoft.com>
  • Loading branch information
anmaxvl committed Mar 20, 2024
1 parent 6be41bc commit 5e9f54b
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 19 deletions.
5 changes: 5 additions & 0 deletions internal/hcs/schema2/memory_2.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ type Memory2 struct {
// the guest operating system).
EnableColdDiscardHint bool `json:"EnableColdDiscardHint,omitempty"`

// ForbidSmallBackingPages 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
// is `Small`, then it is forced to `Large` when this option is enabled.
ForbidSmallBackingPages bool `json:"ForbidSmallBackingPages,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
Expand Down
1 change: 1 addition & 0 deletions internal/oci/uvm.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ func specToUVMCreateOptionsCommon(ctx context.Context, opts *uvm.Options, s *spe
opts.ProcessDumpLocation = ParseAnnotationsString(s.Annotations, annotations.ContainerProcessDumpLocation, opts.ProcessDumpLocation)
opts.NoWritableFileShares = ParseAnnotationsBool(ctx, s.Annotations, annotations.DisableWritableFileShares, opts.NoWritableFileShares)
opts.DumpDirectoryPath = ParseAnnotationsString(s.Annotations, annotations.DumpDirectoryPath, opts.DumpDirectoryPath)
opts.ForbidSmallBackingPages = ParseAnnotationsBool(ctx, s.Annotations, annotations.MemoryForbidSmallBackingPages, opts.ForbidSmallBackingPages)
maps.Copy(opts.AdditionalHyperVConfig, parseHVSocketServiceTable(ctx, s.Annotations))
}

Expand Down
2 changes: 2 additions & 0 deletions internal/uvm/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ type Options struct {
// commit, set to true.
EnableDeferredCommit bool

ForbidSmallBackingPages bool

// ProcessorCount sets the number of vCPU's. If `0` will default to platform
// default.
ProcessorCount int32
Expand Down
30 changes: 16 additions & 14 deletions internal/uvm/create_lcow.go
Original file line number Diff line number Diff line change
Expand Up @@ -413,13 +413,14 @@ func makeLCOWVMGSDoc(ctx context.Context, opts *OptionsLCOW, uvm *UtilityVM) (_
Chipset: &hcsschema.Chipset{},
ComputeTopology: &hcsschema.Topology{
Memory: &hcsschema.Memory2{
SizeInMB: memorySizeInMB,
AllowOvercommit: opts.AllowOvercommit,
EnableDeferredCommit: opts.EnableDeferredCommit,
EnableColdDiscardHint: opts.EnableColdDiscardHint,
LowMMIOGapInMB: opts.LowMMIOGapInMB,
HighMMIOBaseInMB: opts.HighMMIOBaseInMB,
HighMMIOGapInMB: opts.HighMMIOGapInMB,
SizeInMB: memorySizeInMB,
AllowOvercommit: opts.AllowOvercommit,
EnableDeferredCommit: opts.EnableDeferredCommit,
EnableColdDiscardHint: opts.EnableColdDiscardHint,
LowMMIOGapInMB: opts.LowMMIOGapInMB,
HighMMIOBaseInMB: opts.HighMMIOBaseInMB,
HighMMIOGapInMB: opts.HighMMIOGapInMB,
ForbidSmallBackingPages: opts.ForbidSmallBackingPages,
},
Processor: processor,
},
Expand Down Expand Up @@ -625,13 +626,14 @@ func makeLCOWDoc(ctx context.Context, opts *OptionsLCOW, uvm *UtilityVM) (_ *hcs
Chipset: &hcsschema.Chipset{},
ComputeTopology: &hcsschema.Topology{
Memory: &hcsschema.Memory2{
SizeInMB: memorySizeInMB,
AllowOvercommit: opts.AllowOvercommit,
EnableDeferredCommit: opts.EnableDeferredCommit,
EnableColdDiscardHint: opts.EnableColdDiscardHint,
LowMMIOGapInMB: opts.LowMMIOGapInMB,
HighMMIOBaseInMB: opts.HighMMIOBaseInMB,
HighMMIOGapInMB: opts.HighMMIOGapInMB,
SizeInMB: memorySizeInMB,
AllowOvercommit: opts.AllowOvercommit,
EnableDeferredCommit: opts.EnableDeferredCommit,
EnableColdDiscardHint: opts.EnableColdDiscardHint,
LowMMIOGapInMB: opts.LowMMIOGapInMB,
HighMMIOBaseInMB: opts.HighMMIOBaseInMB,
HighMMIOGapInMB: opts.HighMMIOGapInMB,
ForbidSmallBackingPages: opts.ForbidSmallBackingPages,
},
Processor: processor,
},
Expand Down
11 changes: 6 additions & 5 deletions internal/uvm/create_wcow.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,11 +186,12 @@ func prepareConfigDoc(ctx context.Context, uvm *UtilityVM, opts *OptionsWCOW, uv
SizeInMB: memorySizeInMB,
AllowOvercommit: opts.AllowOvercommit,
// EnableHotHint is not compatible with physical.
EnableHotHint: opts.AllowOvercommit,
EnableDeferredCommit: opts.EnableDeferredCommit,
LowMMIOGapInMB: opts.LowMMIOGapInMB,
HighMMIOBaseInMB: opts.HighMMIOBaseInMB,
HighMMIOGapInMB: opts.HighMMIOGapInMB,
EnableHotHint: opts.AllowOvercommit,
EnableDeferredCommit: opts.EnableDeferredCommit,
LowMMIOGapInMB: opts.LowMMIOGapInMB,
HighMMIOBaseInMB: opts.HighMMIOBaseInMB,
HighMMIOGapInMB: opts.HighMMIOGapInMB,
ForbidSmallBackingPages: opts.ForbidSmallBackingPages,
},
Processor: processor,
},
Expand Down
2 changes: 2 additions & 0 deletions pkg/annotations/annotations.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ const (
// MemoryHighMMIOGapInMB indicates the high MMIO gap in MB.
MemoryHighMMIOGapInMB = "io.microsoft.virtualmachine.computetopology.memory.highmmiogapinmb"

MemoryForbidSmallBackingPages = "io.microsoft.virtualmachine.computetopology.memory.forbidsmallbackingpages"

// ProcessorCount overrides the hypervisor isolated vCPU count set
// via the OCI spec.
//
Expand Down

0 comments on commit 5e9f54b

Please # to comment.