diff mbox series

KVM: x86: Make the debugfs per VM optional

Message ID 20241023083237.184359-1-bk@alpico.io (mailing list archive)
State New
Headers show
Series KVM: x86: Make the debugfs per VM optional | expand

Commit Message

Bernhard Kauer Oct. 23, 2024, 8:32 a.m. UTC
Creating a debugfs directory for each virtual machine is a suprisingly
costly operation as one has to synchronize multiple cores. However, short
living VMs seldom benefit from it.

Since there are valid use-cases we make this feature optional via a
module parameter. Disabling it saves 150us in the hello microbenchmark.

Signed-off-by: Bernhard Kauer <bk@alpico.io>
---
 virt/kvm/kvm_main.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index a48861363649..760e39cf86a8 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -94,6 +94,9 @@  unsigned int halt_poll_ns_shrink = 2;
 module_param(halt_poll_ns_shrink, uint, 0644);
 EXPORT_SYMBOL_GPL(halt_poll_ns_shrink);
 
+bool debugfs_per_vm = true;
+module_param(debugfs_per_vm, bool, 0644);
+
 /*
  * Ordering of locks:
  *
@@ -1050,7 +1053,7 @@  static int kvm_create_vm_debugfs(struct kvm *kvm, const char *fdname)
 	int kvm_debugfs_num_entries = kvm_vm_stats_header.num_desc +
 				      kvm_vcpu_stats_header.num_desc;
 
-	if (!debugfs_initialized())
+	if (!debugfs_initialized() || !debugfs_per_vm)
 		return 0;
 
 	snprintf(dir_name, sizeof(dir_name), "%d-%s", task_pid_nr(current), fdname);