summaryrefslogtreecommitdiff
path: root/usr.sbin/vmd/vm.c
diff options
context:
space:
mode:
authorMike Larkin <mlarkin@cvs.openbsd.org>2019-11-29 00:51:29 +0000
committerMike Larkin <mlarkin@cvs.openbsd.org>2019-11-29 00:51:29 +0000
commit1d83bb6c290dd57db296c3d90fd5ce0509bdc944 (patch)
tree66a1484fce0caf02f617c2b26aed496a9ed963ff /usr.sbin/vmd/vm.c
parentcacfaa0626ff6a9543196d35ce5e68af2a8c94d3 (diff)
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;