Skip to content

Commit

Permalink
neonvm: Add Guest.MemhpAutoMovableRatio (#1271)
Browse files Browse the repository at this point in the history
Allow to override default movable ratio that is set in
neonvm-controller.

related to neondatabase/cloud#23865
  • Loading branch information
petuhovskiy authored Feb 17, 2025
1 parent bee9186 commit 5540a6c
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 2 deletions.
6 changes: 5 additions & 1 deletion neonvm/apis/neonvm/v1/virtualmachine_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,11 @@ const (
type Guest struct {
// +optional
KernelImage *string `json:"kernelImage,omitempty"`

// Set the maximum MOVABLE:KERNEL memory ratio in %.
// Kernel default is 301%.
// See https://docs.kernel.org/admin-guide/mm/memory-hotplug.html
// +optional
MemhpAutoMovableRatio *string `json:"memhpAutoMovableRatio,omitempty"`
// +optional
AppendKernelCmdline *string `json:"appendKernelCmdline,omitempty"`

Expand Down
5 changes: 5 additions & 0 deletions neonvm/apis/neonvm/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions neonvm/config/crd/bases/vm.neon.tech_virtualmachines.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2729,6 +2729,12 @@ spec:
type: array
kernelImage:
type: string
memhpAutoMovableRatio:
description: |-
Set the maximum MOVABLE:KERNEL memory ratio in %.
Kernel default is 301%.
See https://docs.kernel.org/admin-guide/mm/memory-hotplug.html
type: string
memorySlotSize:
anyOf:
- type: integer
Expand Down
8 changes: 7 additions & 1 deletion pkg/neonvm/controllers/vm_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -1422,10 +1422,16 @@ func podSpec(
if config.DisableRunnerCgroup {
cmd = append(cmd, "-skip-cgroup-management")
}

memhpAutoMovableRatio := config.MemhpAutoMovableRatio
if specValue := vm.Spec.Guest.MemhpAutoMovableRatio; specValue != nil {
memhpAutoMovableRatio = *specValue
}

cmd = append(
cmd,
"-qemu-disk-cache-settings", config.QEMUDiskCacheSettings,
"-memhp-auto-movable-ratio", config.MemhpAutoMovableRatio,
"-memhp-auto-movable-ratio", memhpAutoMovableRatio,
)
// put these last, so that the earlier args are easier to see (because these
// can get quite large)
Expand Down

0 comments on commit 5540a6c

Please sign in to comment.