Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace hotplug cpu by online/offline CPU #1082

Open
mikhail-sakhnov opened this issue Sep 24, 2024 · 3 comments
Open

Replace hotplug cpu by online/offline CPU #1082

mikhail-sakhnov opened this issue Sep 24, 2024 · 3 comments
Assignees
Labels
t/feature Issue type: feature, for new features or requests

Comments

@mikhail-sakhnov
Copy link
Contributor

Problem description / Motivation

According to qemu documentation, hot plugging is not supported on arm. Marking cpu as online/offline is supported. We need to change acpi scripts used on x86_64 for hot plugging to support online/offline cpus on arm.

https://docs.kernel.org/next/arch/arm64/cpu-hotplug.html

https://www.qemu.org/docs/master/system/cpu-hotplug.html

Feature idea(s) / DoD

Implementation ideas

@mikhail-sakhnov mikhail-sakhnov added the t/feature Issue type: feature, for new features or requests label Sep 24, 2024
@mikhail-sakhnov mikhail-sakhnov self-assigned this Sep 24, 2024
@stradig
Copy link
Contributor

stradig commented Sep 24, 2024

I suggest to move that to the start and also switch to online/offline on x86. I believe that will autoscaling also more robust on x86.

@stradig stradig changed the title Arm and hotplug cpu Replace hotplug cpu by online/offline CPU Sep 24, 2024
@mikhail-sakhnov
Copy link
Contributor Author

mikhail-sakhnov commented Sep 27, 2024

CPU Scaling Feature via online/offline cpu state

Current Implementation

In the existing NeonVM platform, CPU hotplugging is used to dynamically scale CPU resources up or down. The NeonVM controller (neonvm/controllers/vm_controller.go) sends commands via QMP to the QEMU hypervisor. When CPUs are added or removed, a udev rule (neonvm/tools/vm-builder/files/vminit) inside the VM automatically marks the newly added CPUs as online.

While this method works effectively on x86_64 architectures, the ARM architecture in QEMU does not support CPU hotplugging.

Proposed Solution for ARM Architecture

To support CPU scaling on ARM, we will implement a different approach. Instead of hotplugging, all potential CPUs will be allocated to the VM instance during startup. Any CPUs beyond the current scaling limit will be marked as offline. The control of CPU states (online/offline) will no longer rely on the udev rule but will be handled through a VM control daemon running inside the VM.

Key Aspects:

  • Initial CPU Allocation: All possible CPUs will be assigned to the VM at startup. Only the CPUs required within the scaling limit will be marked as online, while the others remain offline.
  • Daemon for CPU State Management: The introduction of a VM control daemon will enable direct control over the online/offline status of the CPUs. This daemon will expose an API to manage the number of active CPUs.

Required Changes

  • NeonVM Controller Modification: Update the NeonVM controller to communicate with the VM control daemon API via vm-runner API for CPU scaling actions instead of using QMP directly to the QEMU monitor.
  • VM Runner API: For enhanced security, the daemon will be exposed through the VM Runner API to ensure secure interaction.
  • VM Control Daemon Implementation: Develop the VM control daemon that will run inside the VM to manage CPU states.
  • Expose VM Control Daemon: Integrate the control daemon via the VM Runner interface. Initial implementation is defined in the PR neonvm: Add new neonvm-daemon binary skeleton #1090
  • VM Builder Update: Modify the VM Builder to include the VM control daemon as part of the VM image, ensuring it is present and operational in all deployed instances.

@mikhail-sakhnov
Copy link
Contributor Author

both related PRs are in review: #1104 and #1111

#1090 been merged already.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
t/feature Issue type: feature, for new features or requests
Projects
None yet
Development

No branches or pull requests

2 participants