diff mbox series

KVM: make uevents configurable

Message ID 20241122095806.4034415-1-bk@alpico.io (mailing list archive)
State New
Headers show
Series KVM: make uevents configurable | expand

Commit Message

Bernhard Kauer Nov. 22, 2024, 9:58 a.m. UTC
Handling of uevents in userlevel is a bottleneck for tiny VMs.

Running 10_000 VMs keeps one and a half cores busy for 5.4 seconds to let
systemd-udevd handle all messages.  That is roughly 27x longer than
the 0.2 seconds needed for running the VMs without them.

We choose a read-only module parameter here due to its simplicity and
ease of maintenance.

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

Comments

Marc Zyngier Nov. 25, 2024, 5:31 p.m. UTC | #1
On Fri, 22 Nov 2024 09:58:02 +0000,
Bernhard Kauer <bk@alpico.io> wrote:
> 
> Handling of uevents in userlevel is a bottleneck for tiny VMs.
> 
> Running 10_000 VMs keeps one and a half cores busy for 5.4 seconds to let
> systemd-udevd handle all messages.  That is roughly 27x longer than
> the 0.2 seconds needed for running the VMs without them.
> 
> We choose a read-only module parameter here due to its simplicity and
> ease of maintenance.
> 
> Signed-off-by: Bernhard Kauer <bk@alpico.io>
> ---
>  virt/kvm/kvm_main.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
> index 609e0bd68e8e..6139cd67a96a 100644
> --- a/virt/kvm/kvm_main.c
> +++ b/virt/kvm/kvm_main.c
> @@ -97,6 +97,9 @@ EXPORT_SYMBOL_GPL(halt_poll_ns_shrink);
>  bool debugfs_per_vm = true;
>  module_param(debugfs_per_vm, bool, 0644);
>  
> +bool disable_uevent_notify;
> +module_param(disable_uevent_notify, bool, 0444);
> +
>  /*
>   * Ordering of locks:
>   *
> @@ -6276,7 +6279,7 @@ static void kvm_uevent_notify_change(unsigned int type, struct kvm *kvm)
>  	struct kobj_uevent_env *env;
>  	unsigned long long created, active;
>  
> -	if (!kvm_dev.this_device || !kvm)
> +	if (!kvm_dev.this_device || !kvm || disable_uevent_notify)
>  		return;
>  
>  	mutex_lock(&kvm_lock);

Thanks for this. It was on my list of things to investigate, as this
is a bottleneck when running a lot of concurrent syzkaller tests which
create and destroy VMs repeatedly.

I'm not overly keen on the command-line flag though, as this is the
sort of things you'd like to be able to control more finely. Or at
least without having to trigger a reboot.

How about something such as a sysctl? with the kvm namespace?

Thanks,

	M.
diff mbox series

Patch

diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 609e0bd68e8e..6139cd67a96a 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -97,6 +97,9 @@  EXPORT_SYMBOL_GPL(halt_poll_ns_shrink);
 bool debugfs_per_vm = true;
 module_param(debugfs_per_vm, bool, 0644);
 
+bool disable_uevent_notify;
+module_param(disable_uevent_notify, bool, 0444);
+
 /*
  * Ordering of locks:
  *
@@ -6276,7 +6279,7 @@  static void kvm_uevent_notify_change(unsigned int type, struct kvm *kvm)
 	struct kobj_uevent_env *env;
 	unsigned long long created, active;
 
-	if (!kvm_dev.this_device || !kvm)
+	if (!kvm_dev.this_device || !kvm || disable_uevent_notify)
 		return;
 
 	mutex_lock(&kvm_lock);