From 4e8c7465adc2c2e7272cd68d55937ec09616ef58 Mon Sep 17 00:00:00 2001 From: Peter Grehan <grehan@FreeBSD.org> Date: Thu, 20 Dec 2012 23:01:53 +0000 Subject: [PATCH] Change thread name for the main kqueue event loop to "<vmname> mevent" so it can be easily distinguished from other non-vCPU threads in forthcoming changes. Obtained from: NetApp --- usr.sbin/bhyve/mevent.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/usr.sbin/bhyve/mevent.c b/usr.sbin/bhyve/mevent.c index 0d3b2872e1b4..a6109dbbd946 100644 --- a/usr.sbin/bhyve/mevent.c +++ b/usr.sbin/bhyve/mevent.c @@ -46,6 +46,7 @@ __FBSDID("$FreeBSD$"); #include <sys/time.h> #include <pthread.h> +#include <pthread_np.h> #include "mevent.h" @@ -55,6 +56,8 @@ __FBSDID("$FreeBSD$"); #define MEV_DISABLE 2 #define MEV_DEL_PENDING 3 +extern char *vmname; + static pthread_t mevent_tid; static int mevent_pipefd[2]; static pthread_mutex_t mevent_lmutex = PTHREAD_MUTEX_INITIALIZER; @@ -356,6 +359,15 @@ mevent_delete_close(struct mevent *evp) return (mevent_delete_event(evp, 1)); } +static void +mevent_set_name(void) +{ + char tname[MAXCOMLEN + 1]; + + snprintf(tname, sizeof(tname), "%s mevent", vmname); + pthread_set_name_np(mevent_tid, tname); +} + void mevent_dispatch(void) { @@ -367,6 +379,7 @@ mevent_dispatch(void) int ret; mevent_tid = pthread_self(); + mevent_set_name(); mfd = kqueue(); assert(mfd > 0);