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

[vmm]: support sandbox cgroup management in the host #52

Merged
merged 1 commit into from
Aug 22, 2023

Conversation

flyflypeng
Copy link
Member

fix: #51

reason:

  1. limit the vm process resource usage in the specified cgroup dir
  2. support pod_overhead conception actually, which limits the non-vcpu type threads of vm process into pod_overhead cgroup dir and set the pod_overhead resources limit in this cgroup dir.

@flyflypeng flyflypeng force-pushed the support-host-cgroup branch 6 times, most recently from 8b00a9a to a2aa43a Compare July 28, 2023 09:16
vmm/sandbox/src/cgroup.rs Outdated Show resolved Hide resolved
vmm/sandbox/src/cgroup.rs Outdated Show resolved Hide resolved
vmm/sandbox/src/cgroup.rs Outdated Show resolved Hide resolved
vmm/sandbox/src/cgroup.rs Show resolved Hide resolved
vmm/sandbox/src/cgroup.rs Show resolved Hide resolved
vmm/sandbox/src/vm.rs Outdated Show resolved Hide resolved
vmm/sandbox/src/sandbox.rs Outdated Show resolved Hide resolved
@flyflypeng flyflypeng force-pushed the support-host-cgroup branch 4 times, most recently from d5f61f4 to 06de8dc Compare August 11, 2023 08:55
@flyflypeng flyflypeng force-pushed the support-host-cgroup branch 2 times, most recently from 14704f1 to 5f89b25 Compare August 15, 2023 02:05
.github/workflows/ci.yml Outdated Show resolved Hide resolved
vmm/sandbox/src/sandbox.rs Outdated Show resolved Hide resolved
@flyflypeng flyflypeng force-pushed the support-host-cgroup branch 2 times, most recently from bfa8f96 to 9b9f8f4 Compare August 19, 2023 09:33
vmm/sandbox/src/cgroup.rs Show resolved Hide resolved
@@ -168,6 +172,24 @@ where
return Err(Error::AlreadyExist("sandbox".to_string()));
}

let mut sandbox_cgroups = SandboxCgroup::default();
let sandbox_cgroup_path = get_sandbox_cgroup_parent_path(&s.sandbox).unwrap();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can not assume that all sandbox has parent cgroup path defined. I think we can not unwrap here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix it!

@@ -70,6 +70,8 @@ pub trait VM: Serialize + Sync + Send {
async fn ping(&self) -> Result<()>;
fn socket_address(&self) -> String;
async fn wait_channel(&self) -> Option<Receiver<(u32, i128)>>;
async fn get_vcpu_threads(&self) -> Result<VcpuThreads>;
fn get_virtiofsd_pid(&self) -> Option<u32>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is too implementation specific, maybe we can add a method of name "pids()" and return a Vec of all pids related to this virtual machine.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I create a new struct Pids to encapsulate the vmm related processes pids, now it only contains the vmm_pid & virtiofsd_pid filed. Currently, it only includes the vmm_pid and virtiofsd_pid fields.
In the future, if we need to add more processes pid info, we can simply add new fields to the Struct Pids while maintaining consistency with the pids() trait interface.

@@ -70,6 +70,8 @@ pub trait VM: Serialize + Sync + Send {
async fn ping(&self) -> Result<()>;
fn socket_address(&self) -> String;
async fn wait_channel(&self) -> Option<Receiver<(u32, i128)>>;
async fn get_vcpu_threads(&self) -> Result<VcpuThreads>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall wen change the name of this method to "vcpus()" ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, vcpus func name looks more clearly.

@flyflypeng flyflypeng force-pushed the support-host-cgroup branch 3 times, most recently from 36fe09d to f33b0a0 Compare August 22, 2023 06:23
Copy link
Member

@Burning1020 Burning1020 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Burning1020 Burning1020 merged commit a83d09e into kuasar-io:main Aug 22, 2023
11 checks passed
fix: kuasar-io#51

reason:
1. limit the vm process resource usage in the specified cgroup dir
2. support pod_overhead conception actually, which limits the non-vcpu
type threads of vm process into pod_overhead cgroup dir and set the
pod_overhead resources limit in this cgroup dir.

Signed-off-by: flyflypeng <flyflyflypeng@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support limit VM process vcpu threads and non-vcpu threads seperately in the cgroup system
4 participants