Now that guenther@ landed thread names, this should help users understand vmd host cpu utilization better as it lets us distinguish between the libevent thread and the vcpu thread.
Example ps output: $ ps -AHf | grep vmd 30584 502984 p2 S+p 0:00.76 | |-- obj/vmd -d 46975 512305 ?? Sc 0:00.01 | | |-- vmd: priv (vmd) 39911 487276 ?? Spc 0:00.76 | | |-- vmd: control (vmd) 58206 418514 ?? Spc 0:00.01 | | |-- vmd: vmm (vmd) 43525 215149 ?? Sp 0:00.00 | | | |-- vmd: openbsd (vmd/event) 43525 316255 ?? Rp/5 0:00.77 | | | |-- vmd: openbsd (vmd/vcpu-0) 43525 270611 ?? Sp 0:00.00 | | | `-- vmd: openbsd (vmd) 43206 562455 ?? Spc 0:00.01 | | |-- vmd: agentx (vmd) 70005 431096 p3 R+p/9 0:00.00 | |-- grep vmd ok? -dv diff refs/heads/master refs/heads/vmd-threadnames commit - bfce157fda90a812e1a99aa179a4c42f12ebfa24 commit + c68a6ec15bd158fb7bc769fd5beefaace3d26d5c blob - f2852411550a07d25bf46f1e0de5ed317fb8c108 blob + 0bb3fd3f875ee4af1c92cd1f508bb09f3b8c865e --- usr.sbin/vmd/vm.c +++ usr.sbin/vmd/vm.c @@ -16,7 +16,7 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include <sys/param.h> /* PAGE_SIZE */ +#include <sys/param.h> /* PAGE_SIZE, MAXCOMLEN */ #include <sys/types.h> #include <sys/ioctl.h> #include <sys/queue.h> @@ -46,6 +46,7 @@ #include <limits.h> #include <poll.h> #include <pthread.h> +#include <pthread_np.h> #include <stddef.h> #include <stdio.h> #include <stdlib.h> @@ -1211,6 +1212,7 @@ run_vm(int child_cdrom, int child_disks[][VM_MAX_BASE_ size_t i; int ret; pthread_t *tid, evtid; + char tname[MAXCOMLEN + 1]; struct vm_run_params **vrp; void *exit_status; @@ -1353,6 +1355,10 @@ run_vm(int child_cdrom, int child_disks[][VM_MAX_BASE_ __func__, i); return (ret); } + + memset(tname, 0, sizeof(tname)); + snprintf(tname, sizeof(tname), "vcpu-%zu", i); + pthread_set_name_np(tid[i], tname); } log_debug("%s: waiting on events for VM %s", __func__, vcp->vcp_name); @@ -1362,6 +1368,7 @@ run_vm(int child_cdrom, int child_disks[][VM_MAX_BASE_ log_warn("%s: could not create event thread", __func__); return (ret); } + pthread_set_name_np(evtid, "event"); for (;;) { ret = pthread_cond_wait(&threadcond, &threadmutex);