From patchwork Fri May 21 09:42:27 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Hajnoczi X-Patchwork-Id: 101376 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o4L9ghtv013522 for ; Fri, 21 May 2010 09:43:18 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932385Ab0EUJmk (ORCPT ); Fri, 21 May 2010 05:42:40 -0400 Received: from mtagate1.uk.ibm.com ([194.196.100.161]:35095 "EHLO mtagate1.uk.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932070Ab0EUJmj (ORCPT ); Fri, 21 May 2010 05:42:39 -0400 Received: from d06nrmr1407.portsmouth.uk.ibm.com (d06nrmr1407.portsmouth.uk.ibm.com [9.149.38.185]) by mtagate1.uk.ibm.com (8.13.1/8.13.1) with ESMTP id o4L9gZvR015168 for ; Fri, 21 May 2010 09:42:35 GMT Received: from d06av03.portsmouth.uk.ibm.com (d06av03.portsmouth.uk.ibm.com [9.149.37.213]) by d06nrmr1407.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id o4L9gZG6548912 for ; Fri, 21 May 2010 10:42:35 +0100 Received: from d06av03.portsmouth.uk.ibm.com (loopback [127.0.0.1]) by d06av03.portsmouth.uk.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id o4L9gZ8O004396 for ; Fri, 21 May 2010 10:42:35 +0100 Received: from stefan-thinkpad.manchester-maybrook.uk.ibm.com (dyn-9-174-219-32.manchester-maybrook.uk.ibm.com [9.174.219.32]) by d06av03.portsmouth.uk.ibm.com (8.12.11.20060308/8.12.11) with ESMTP id o4L9gYTE004252; Fri, 21 May 2010 10:42:34 +0100 From: Stefan Hajnoczi To: , Cc: Prerna Saxena , Anthony Liguori , Stefan Hajnoczi Subject: [PATCH 2/2] trace: Trace write requests in virtio-blk, multiwrite, and paio_submit Date: Fri, 21 May 2010 10:42:27 +0100 Message-Id: <1274434947-2863-3-git-send-email-stefanha@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1274434947-2863-1-git-send-email-stefanha@linux.vnet.ibm.com> References: <1274434947-2863-1-git-send-email-stefanha@linux.vnet.ibm.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Fri, 21 May 2010 09:43:18 +0000 (UTC) diff --git a/block.c b/block.c index bfe46e3..a7fb040 100644 --- a/block.c +++ b/block.c @@ -27,6 +27,7 @@ #include "block_int.h" #include "module.h" #include "qemu-objects.h" +#include "trace.h" #ifdef CONFIG_BSD #include @@ -1913,6 +1914,8 @@ static void multiwrite_cb(void *opaque, int ret) { MultiwriteCB *mcb = opaque; + trace_multiwrite_cb(mcb, ret); + if (ret < 0 && !mcb->error) { mcb->error = ret; multiwrite_user_cb(mcb); @@ -2044,6 +2047,8 @@ int bdrv_aio_multiwrite(BlockDriverState *bs, BlockRequest *reqs, int num_reqs) // Check for mergable requests num_reqs = multiwrite_merge(bs, reqs, num_reqs, mcb); + trace_bdrv_aio_multiwrite(mcb, mcb->num_callbacks, num_reqs); + // Run the aio requests for (i = 0; i < num_reqs; i++) { acb = bdrv_aio_writev(bs, reqs[i].sector, reqs[i].qiov, @@ -2054,9 +2059,11 @@ int bdrv_aio_multiwrite(BlockDriverState *bs, BlockRequest *reqs, int num_reqs) // submitted yet. Otherwise we'll wait for the submitted AIOs to // complete and report the error in the callback. if (mcb->num_requests == 0) { + trace_bdrv_aio_multiwrite_earlyfail(mcb); reqs[i].error = -EIO; goto fail; } else { + trace_bdrv_aio_multiwrite_latefail(mcb, i); mcb->num_requests++; multiwrite_cb(mcb, -EIO); break; diff --git a/hw/virtio-blk.c b/hw/virtio-blk.c index b05d15e..73b873e 100644 --- a/hw/virtio-blk.c +++ b/hw/virtio-blk.c @@ -13,6 +13,7 @@ #include #include +#include "trace.h" #include "virtio-blk.h" #include "block_int.h" #ifdef __linux__ @@ -50,6 +51,8 @@ static void virtio_blk_req_complete(VirtIOBlockReq *req, int status) { VirtIOBlock *s = req->dev; + trace_virtio_blk_req_complete(req, status); + req->in->status = status; virtqueue_push(s->vq, &req->elem, req->qiov.size + sizeof(*req->in)); virtio_notify(&s->vdev, s->vq); @@ -87,6 +90,8 @@ static void virtio_blk_rw_complete(void *opaque, int ret) { VirtIOBlockReq *req = opaque; + trace_virtio_blk_rw_complete(req, ret); + if (ret) { int is_read = !(req->out->type & VIRTIO_BLK_T_OUT); if (virtio_blk_handle_rw_error(req, -ret, is_read)) @@ -270,6 +275,7 @@ static void virtio_blk_handle_write(BlockRequest *blkreq, int *num_writes, blkreq[*num_writes].cb = virtio_blk_rw_complete; blkreq[*num_writes].opaque = req; blkreq[*num_writes].error = 0; + trace_virtio_blk_handle_write(req, req->out->sector, req->qiov.size / 512); (*num_writes)++; } diff --git a/posix-aio-compat.c b/posix-aio-compat.c index b43c531..57d83f0 100644 --- a/posix-aio-compat.c +++ b/posix-aio-compat.c @@ -23,6 +23,7 @@ #include #include "qemu-queue.h" +#include "trace.h" #include "osdep.h" #include "qemu-common.h" #include "block_int.h" @@ -583,6 +584,7 @@ BlockDriverAIOCB *paio_submit(BlockDriverState *bs, int fd, acb->next = posix_aio_state->first_aio; posix_aio_state->first_aio = acb; + trace_paio_submit(acb, opaque, sector_num, nb_sectors, type); qemu_paio_submit(acb); return &acb->common; } diff --git a/trace.h b/trace.h index 144aa1e..3c4564f 100644 --- a/trace.h +++ b/trace.h @@ -1,5 +1,12 @@ typedef enum { - TRACE_MAX + TRACE_MULTIWRITE_CB, + TRACE_BDRV_AIO_MULTIWRITE, + TRACE_BDRV_AIO_MULTIWRITE_EARLYFAIL, + TRACE_BDRV_AIO_MULTIWRITE_LATEFAIL, + TRACE_VIRTIO_BLK_REQ_COMPLETE, + TRACE_VIRTIO_BLK_RW_COMPLETE, + TRACE_VIRTIO_BLK_HANDLE_WRITE, + TRACE_PAIO_SUBMIT, } TraceEvent; void trace1(TraceEvent event, unsigned long x1); @@ -7,3 +14,36 @@ void trace2(TraceEvent event, unsigned long x1, unsigned long x2); void trace3(TraceEvent event, unsigned long x1, unsigned long x2, unsigned long x3); void trace4(TraceEvent event, unsigned long x1, unsigned long x2, unsigned long x3, unsigned long x4); void trace5(TraceEvent event, unsigned long x1, unsigned long x2, unsigned long x3, unsigned long x4, unsigned long x5); + +static inline void trace_multiwrite_cb(void *mcb, int ret) { + trace2(TRACE_MULTIWRITE_CB, (unsigned long)mcb, ret); +} + +static inline void trace_bdrv_aio_multiwrite(void *mcb, int num_callbacks, int num_reqs) { + trace3(TRACE_BDRV_AIO_MULTIWRITE, (unsigned long)mcb, num_callbacks, num_reqs); +} + +static inline void trace_bdrv_aio_multiwrite_earlyfail(void *mcb) { + trace1(TRACE_BDRV_AIO_MULTIWRITE_EARLYFAIL, (unsigned long)mcb); +} + +static inline void trace_bdrv_aio_multiwrite_latefail(void *mcb, int i) { + trace2(TRACE_BDRV_AIO_MULTIWRITE_LATEFAIL, (unsigned long)mcb, i); +} + +static inline void trace_virtio_blk_req_complete(void *req, int status) { + trace2(TRACE_VIRTIO_BLK_REQ_COMPLETE, (unsigned long)req, status); +} + +static inline void trace_virtio_blk_rw_complete(void *req, int ret) { + trace2(TRACE_VIRTIO_BLK_RW_COMPLETE, (unsigned long)req, ret); +} + +static inline void trace_virtio_blk_handle_write(void *req, unsigned long sector, unsigned long nsectors) { + trace3(TRACE_VIRTIO_BLK_HANDLE_WRITE, (unsigned long)req, sector, nsectors); +} + +static inline void trace_paio_submit(void *acb, void *opaque, unsigned long sector_num, unsigned long nb_sectors, unsigned long type) +{ + trace5(TRACE_PAIO_SUBMIT, (unsigned long)acb, (unsigned long)opaque, sector_num, nb_sectors, type); +} diff --git a/trace.py b/trace.py index f38ab6b..ba4476c 100755 --- a/trace.py +++ b/trace.py @@ -6,6 +6,14 @@ trace_fmt = 'LLLLLL' trace_len = struct.calcsize(trace_fmt) events = { + 0: ('multiwrite_cb', 'mcb', 'ret'), + 1: ('bdrv_aio_multiwrite', 'mcb', 'num_callbacks', 'num_reqs'), + 2: ('bdrv_aio_multiwrite_earlyfail', 'mcb'), + 3: ('bdrv_aio_multiwrite_latefail', 'mcb', 'i'), + 4: ('virtio_blk_req_complete', 'req', 'status'), + 5: ('virtio_blk_rw_complete', 'req', 'ret'), + 6: ('virtio_blk_handle_write', 'req', 'sector', 'nsectors'), + 7: ('paio_submit', 'acb', 'opaque', 'sector_num', 'nb_sectors', 'type'), } def read_record(fobj):