mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-10-22 20:39:41 +00:00
feat(runtime-rs): introduce huge page type to select VM RAM's backend
This commit allows us to specify the huge page backend when enabling huge page. Currently, we support two backends: thp and hugetlbfs, the default is hugetlbfs. To ensure backward compatibility, we introduce another configuration item "hugepage_type" to select the memory backend, which is available only when "enable_hugepages" is true. Besides, we add an annotation "io.katacontainers.config.hypervisor.hugepage_type" to configure huge page type per pod. Fixes: #6703 Signed-off-by: Guixiong Wei <weiguixiong@bytedance.com> Signed-off-by: Yipeng Yin <yinyipeng@bytedance.com>
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
use super::vmm_instance::VmmInstance;
|
||||
use crate::{
|
||||
device::DeviceType, hypervisor_persist::HypervisorState, kernel_param::KernelParams, VmmState,
|
||||
DEV_HUGEPAGES, HUGETLBFS, HYPERVISOR_DRAGONBALL, SHMEM,
|
||||
DEV_HUGEPAGES, HUGETLBFS, HUGE_SHMEM, HYPERVISOR_DRAGONBALL, SHMEM,
|
||||
};
|
||||
use anyhow::{anyhow, Context, Result};
|
||||
use async_trait::async_trait;
|
||||
@@ -19,7 +19,10 @@ use dragonball::{
|
||||
use kata_sys_util::mount;
|
||||
use kata_types::{
|
||||
capabilities::{Capabilities, CapabilityBits},
|
||||
config::{hypervisor::Hypervisor as HypervisorConfig, KATA_PATH},
|
||||
config::{
|
||||
hypervisor::{HugePageType, Hypervisor as HypervisorConfig},
|
||||
KATA_PATH,
|
||||
},
|
||||
};
|
||||
use nix::mount::MsFlags;
|
||||
use persist::sandbox_persist::Persist;
|
||||
@@ -175,7 +178,10 @@ impl DragonballInner {
|
||||
fn set_vm_base_config(&mut self) -> Result<()> {
|
||||
let serial_path = [&self.run_dir, "console.sock"].join("/");
|
||||
let (mem_type, mem_file_path) = if self.config.memory_info.enable_hugepages {
|
||||
(String::from(HUGETLBFS), String::from(DEV_HUGEPAGES))
|
||||
match self.config.memory_info.hugepage_type {
|
||||
HugePageType::THP => (String::from(HUGE_SHMEM), String::from("")),
|
||||
HugePageType::Hugetlbfs => (String::from(HUGETLBFS), String::from(DEV_HUGEPAGES)),
|
||||
}
|
||||
} else {
|
||||
(String::from(SHMEM), String::from(""))
|
||||
};
|
||||
|
@@ -52,6 +52,7 @@ const VM_ROOTFS_FILESYSTEM_EROFS: &str = "erofs";
|
||||
const DEV_HUGEPAGES: &str = "/dev/hugepages";
|
||||
pub const HUGETLBFS: &str = "hugetlbfs";
|
||||
const SHMEM: &str = "shmem";
|
||||
const HUGE_SHMEM: &str = "hugeshmem";
|
||||
|
||||
pub const HYPERVISOR_DRAGONBALL: &str = "dragonball";
|
||||
pub const HYPERVISOR_QEMU: &str = "qemu";
|
||||
|
Reference in New Issue
Block a user