summaryrefslogtreecommitdiffstats
path: root/usr.sbin/vmd/vm.c
diff options
context:
space:
mode:
authormlarkin <mlarkin@openbsd.org>2019-11-29 00:51:27 +0000
committermlarkin <mlarkin@openbsd.org>2019-11-29 00:51:27 +0000
commitee8a17972edfbdf28d1cfbc33a2f60a327956a40 (patch)
tree84b15c86b253758357ebb4e4c13f2ddf6198bef1 /usr.sbin/vmd/vm.c
parentlots of dependencies go away here with ed25519 no longer needing (diff)
downloadwireguard-openbsd-ee8a17972edfbdf28d1cfbc33a2f60a327956a40.tar.xz
wireguard-openbsd-ee8a17972edfbdf28d1cfbc33a2f60a327956a40.zip
Fix at least one cause of VMs spinning at 100% host CPU
After debugging with ori@, it looks like an event ends up on the wrong libevent queue, and we end continually de-queueing and re-queueing the event continually. While it's unclear exactly why this happened, a clue on libevent's github issues page for the same problem pointed us to using a different event base for the device events. This seems to have unstuck ori@'s problematic VM, and I have also seen no more hangs after this. We have not completely separated the queues; ori@ will work on setting new libevent bases for those later. But those events are pretty frequency. with help from and ok ori@
Diffstat (limited to 'usr.sbin/vmd/vm.c')
-rw-r--r--usr.sbin/vmd/vm.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/usr.sbin/vmd/vm.c b/usr.sbin/vmd/vm.c
index 48776a74971..d787839cc1e 100644
--- a/usr.sbin/vmd/vm.c
+++ b/usr.sbin/vmd/vm.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vm.c,v 1.51 2019/07/17 05:51:07 pd Exp $ */
+/* $OpenBSD: vm.c,v 1.52 2019/11/29 00:51:28 mlarkin Exp $ */
/*
* Copyright (c) 2015 Mike Larkin <mlarkin@openbsd.org>
@@ -114,6 +114,8 @@ pthread_mutex_t vcpu_run_mtx[VMM_MAX_VCPUS_PER_VM];
uint8_t vcpu_hlt[VMM_MAX_VCPUS_PER_VM];
uint8_t vcpu_done[VMM_MAX_VCPUS_PER_VM];
+struct event_base *evbase;
+
/*
* Represents a standard register set for an OS to be booted
* as a flat 64 bit address space.
@@ -360,7 +362,7 @@ start_vm(struct vmd_vm *vm, int fd)
for (i = 0; i < VMM_MAX_NICS_PER_VM; i++)
nicfds[i] = vm->vm_ifs[i].vif_fd;
- event_init();
+ evbase = event_base_new();
if (vm->vm_state & VM_STATE_RECEIVED) {
restore_emulated_hw(vcp, vm->vm_receive_fd, nicfds,
@@ -1297,7 +1299,7 @@ event_thread(void *arg)
uint8_t *donep = arg;
intptr_t ret;
- ret = event_dispatch();
+ ret = event_base_dispatch(evbase);
mutex_lock(&threadmutex);
*donep = 1;