From ad223f2b50260abc8e2f58f2708a74fb737923be Mon Sep 17 00:00:00 2001 From: Sebastien Boeuf Date: Tue, 7 Jan 2020 18:26:40 +0100 Subject: [PATCH] fs: Use cache=none by default The cache= option from the virtiofsd backend is meant to be used depending on how the user wants to use the guest page cache. For most use cases, we want to bypass the guest page cache to reduce the guest memory footprint, which is why "cache=none" should be the default. "cache=always" is the other option when the user wants to do something specific by using the guest page cache, but should not be the default anymore. Signed-off-by: Sebastien Boeuf --- docs/fs.md | 6 +++--- src/main.rs | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/fs.md b/docs/fs.md index 44c973cc6..fc35ec9fd 100644 --- a/docs/fs.md +++ b/docs/fs.md @@ -28,12 +28,12 @@ _Run virtiofsd_ -d \ -o vhost_user_socket=/tmp/virtiofs \ -o source=/tmp/shared_dir \ - -o cache=always + -o cache=none ``` -The `cache=always` option should be the default when using `virtiofsd` with the __cloud-hypervisor__ VMM. This allows the daemon to memory map the shared files, which gives better I/O performance. +The `cache=none` option should be the default when using `virtiofsd` with the __cloud-hypervisor__ VMM. This prevents from using the guest page cache, which reduces the memory footprint of the guest. When running multiple virtual machines on the same host, this will let the host deal with page cache, which will increase the density of virtual machines which can be launched. -The `cache=none` option is another way to run the daemon but because the _virtqueues_ are used to convey the files content in this case, the I/O performance is impacted. +The `cache=always` option will allow for the guest page cache to be used, which will increase the memory footprint of the guest. This option should be used only for specific use cases where a single VM is going to be running on a host. ### The kernel diff --git a/src/main.rs b/src/main.rs index 54cc7d599..682e8efb4 100755 --- a/src/main.rs +++ b/src/main.rs @@ -2935,12 +2935,12 @@ mod tests { #[cfg_attr(not(feature = "mmio"), test)] fn test_virtio_fs_dax_on_default_cache_size() { - test_virtio_fs(true, None, "always", &prepare_virtiofsd) + test_virtio_fs(true, None, "none", &prepare_virtiofsd) } #[cfg_attr(not(feature = "mmio"), test)] fn test_virtio_fs_dax_on_cache_size_1_gib() { - test_virtio_fs(true, Some(0x4000_0000), "always", &prepare_virtiofsd) + test_virtio_fs(true, Some(0x4000_0000), "none", &prepare_virtiofsd) } #[cfg_attr(not(feature = "mmio"), test)] @@ -3507,7 +3507,7 @@ mod tests { let vfio_tap2 = "vfio-tap2"; let (mut daemon_child, virtiofsd_socket_path) = - prepare_virtiofsd(&guest.tmp_dir, vfio_path.to_str().unwrap(), "always"); + prepare_virtiofsd(&guest.tmp_dir, vfio_path.to_str().unwrap(), "none"); let mut child = Command::new("target/release/cloud-hypervisor") .args(&["--cpus", "boot=4"])