From patchwork Wed Oct 24 16:52:27 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasha Levin X-Patchwork-Id: 1639791 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 2A3CF3FCF7 for ; Wed, 24 Oct 2012 16:53:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756981Ab2JXQxH (ORCPT ); Wed, 24 Oct 2012 12:53:07 -0400 Received: from rcsinet15.oracle.com ([148.87.113.117]:46622 "EHLO rcsinet15.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753730Ab2JXQxG (ORCPT ); Wed, 24 Oct 2012 12:53:06 -0400 Received: from acsinet22.oracle.com (acsinet22.oracle.com [141.146.126.238]) by rcsinet15.oracle.com (Sentrion-MTA-4.2.2/Sentrion-MTA-4.2.2) with ESMTP id q9OGquHR012012 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 24 Oct 2012 16:52:57 GMT Received: from acsmt356.oracle.com (acsmt356.oracle.com [141.146.40.156]) by acsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id q9OGquEA012231 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 24 Oct 2012 16:52:56 GMT Received: from abhmt107.oracle.com (abhmt107.oracle.com [141.146.116.59]) by acsmt356.oracle.com (8.12.11.20060308/8.12.11) with ESMTP id q9OGquh9028563; Wed, 24 Oct 2012 11:52:56 -0500 Received: from lappy.us.oracle.com (/10.159.176.152) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 24 Oct 2012 09:52:55 -0700 From: Sasha Levin To: penberg@kernel.org Cc: gorcunov@openvz.org, asias.hejun@gmail.com, mingo@kernel.org, kvm@vger.kernel.org, Sasha Levin Subject: [PATCH 2/2] kvm tools: name threads Date: Wed, 24 Oct 2012 12:52:27 -0400 Message-Id: <1351097547-15938-2-git-send-email-sasha.levin@oracle.com> X-Mailer: git-send-email 1.7.12.4 In-Reply-To: <1351097547-15938-1-git-send-email-sasha.levin@oracle.com> References: <1351097547-15938-1-git-send-email-sasha.levin@oracle.com> X-Source-IP: acsinet22.oracle.com [141.146.126.238] Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Give threads a meaningful name. This makes debugging much easier, and everything else much prettier. Suggested-by: Ingo Molnar Signed-off-by: Sasha Levin --- tools/kvm/disk/core.c | 2 ++ tools/kvm/include/kvm/kvm.h | 7 +++++++ tools/kvm/ioeventfd.c | 2 ++ tools/kvm/kvm-ipc.c | 2 ++ tools/kvm/net/uip/tcp.c | 3 +++ tools/kvm/net/uip/udp.c | 3 +++ tools/kvm/ui/sdl.c | 2 ++ tools/kvm/ui/vnc.c | 2 ++ tools/kvm/util/threadpool.c | 2 ++ tools/kvm/virtio/blk.c | 2 ++ tools/kvm/virtio/net.c | 4 ++++ 11 files changed, 31 insertions(+) diff --git a/tools/kvm/disk/core.c b/tools/kvm/disk/core.c index b313b28..dd59751 100644 --- a/tools/kvm/disk/core.c +++ b/tools/kvm/disk/core.c @@ -63,6 +63,8 @@ static void *disk_image__thread(void *param) int nr, i; u64 dummy; + kvm__set_thread_name("disk-image-io"); + while (read(disk->evt, &dummy, sizeof(dummy)) > 0) { nr = io_getevents(disk->ctx, 1, ARRAY_SIZE(event), event, ¬ime); for (i = 0; i < nr; i++) diff --git a/tools/kvm/include/kvm/kvm.h b/tools/kvm/include/kvm/kvm.h index b460656..1c7fab7 100644 --- a/tools/kvm/include/kvm/kvm.h +++ b/tools/kvm/include/kvm/kvm.h @@ -10,6 +10,7 @@ #include #include #include +#include #define SIGKVMEXIT (SIGRTMIN + 0) #define SIGKVMPAUSE (SIGRTMIN + 1) @@ -118,4 +119,10 @@ static inline void *guest_flat_to_host(struct kvm *kvm, unsigned long offset) bool kvm__supports_extension(struct kvm *kvm, unsigned int extension); +static inline void kvm__set_thread_name(const char *name) +{ + prctl(PR_SET_NAME, name); +} + #endif /* KVM__KVM_H */ + diff --git a/tools/kvm/ioeventfd.c b/tools/kvm/ioeventfd.c index a68d8d0..ff665d4 100644 --- a/tools/kvm/ioeventfd.c +++ b/tools/kvm/ioeventfd.c @@ -24,6 +24,8 @@ static void *ioeventfd__thread(void *param) { u64 tmp = 1; + kvm__set_thread_name("ioeventfd-worker"); + for (;;) { int nfds, i; diff --git a/tools/kvm/kvm-ipc.c b/tools/kvm/kvm-ipc.c index d23edd2..bdcc0d1 100644 --- a/tools/kvm/kvm-ipc.c +++ b/tools/kvm/kvm-ipc.c @@ -260,6 +260,8 @@ static void *kvm_ipc__thread(void *param) struct epoll_event event; struct kvm *kvm = param; + kvm__set_thread_name("kvm-ipc"); + for (;;) { int nfds; diff --git a/tools/kvm/net/uip/tcp.c b/tools/kvm/net/uip/tcp.c index 711a716..830aa3f 100644 --- a/tools/kvm/net/uip/tcp.c +++ b/tools/kvm/net/uip/tcp.c @@ -1,5 +1,6 @@ #include "kvm/uip.h" +#include #include #include #include @@ -176,6 +177,8 @@ static void *uip_tcp_socket_thread(void *p) int len, left, ret; u8 *payload, *pos; + kvm__set_thread_name("uip-tcp"); + sk = p; payload = malloc(UIP_MAX_TCP_PAYLOAD); diff --git a/tools/kvm/net/uip/udp.c b/tools/kvm/net/uip/udp.c index d4518b2..5b6ec1c 100644 --- a/tools/kvm/net/uip/udp.c +++ b/tools/kvm/net/uip/udp.c @@ -1,5 +1,6 @@ #include "kvm/uip.h" +#include #include #include #include @@ -160,6 +161,8 @@ static void *uip_udp_socket_thread(void *p) int nfds; int i; + kvm__set_thread_name("uip-udp"); + info = p; do { diff --git a/tools/kvm/ui/sdl.c b/tools/kvm/ui/sdl.c index 172a12b..9994490 100644 --- a/tools/kvm/ui/sdl.c +++ b/tools/kvm/ui/sdl.c @@ -206,6 +206,8 @@ static void *sdl__thread(void *p) SDL_Event ev; Uint32 flags; + kvm__set_thread_name("kvm-sdl-worker"); + if (SDL_Init(SDL_INIT_VIDEO) != 0) die("Unable to initialize SDL"); diff --git a/tools/kvm/ui/vnc.c b/tools/kvm/ui/vnc.c index efdc0f4..12e4bd5 100644 --- a/tools/kvm/ui/vnc.c +++ b/tools/kvm/ui/vnc.c @@ -185,6 +185,8 @@ static void *vnc__thread(void *p) char argv[1][1] = {{0}}; int argc = 1; + kvm__set_thread_name("kvm-vnc-worker"); + server = rfbGetScreen(&argc, (char **) argv, fb->width, fb->height, 8, 3, 4); server->frameBuffer = fb->mem; server->alwaysShared = TRUE; diff --git a/tools/kvm/util/threadpool.c b/tools/kvm/util/threadpool.c index 85ac7e7..a363831 100644 --- a/tools/kvm/util/threadpool.c +++ b/tools/kvm/util/threadpool.c @@ -78,6 +78,8 @@ static void *thread_pool__threadfunc(void *param) { pthread_cleanup_push(thread_pool__threadfunc_cleanup, NULL); + kvm__set_thread_name("threadpool-worker"); + while (running) { struct thread_pool__job *curjob = NULL; diff --git a/tools/kvm/virtio/blk.c b/tools/kvm/virtio/blk.c index cff38aa..f76342c 100644 --- a/tools/kvm/virtio/blk.c +++ b/tools/kvm/virtio/blk.c @@ -179,6 +179,8 @@ static void *virtio_blk_thread(void *dev) u64 data; int r; + kvm__set_thread_name("virtio-blk-io"); + while (1) { r = read(bdev->io_efd, &data, sizeof(u64)); if (r < 0) diff --git a/tools/kvm/virtio/net.c b/tools/kvm/virtio/net.c index d6d344a..ac429cc 100644 --- a/tools/kvm/virtio/net.c +++ b/tools/kvm/virtio/net.c @@ -79,6 +79,8 @@ static void *virtio_net_rx_thread(void *p) u16 head; int len; + kvm__set_thread_name("virtio-net-rx"); + kvm = ndev->kvm; vq = &ndev->vqs[VIRTIO_NET_RX_QUEUE]; @@ -115,6 +117,8 @@ static void *virtio_net_tx_thread(void *p) u16 head; int len; + kvm__set_thread_name("virtio-net-tx"); + kvm = ndev->kvm; vq = &ndev->vqs[VIRTIO_NET_TX_QUEUE];