From patchwork Fri Mar 10 10:54:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Li X-Patchwork-Id: 13169162 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0E99FC64EC4 for ; Fri, 10 Mar 2023 10:55:31 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1paaPB-0001oP-Pp; Fri, 10 Mar 2023 05:55:23 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1paaOu-0001my-Ui; Fri, 10 Mar 2023 05:55:05 -0500 Received: from mail-pj1-x102a.google.com ([2607:f8b0:4864:20::102a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1paaOs-0001LG-Qq; Fri, 10 Mar 2023 05:55:04 -0500 Received: by mail-pj1-x102a.google.com with SMTP id y15-20020a17090aa40f00b00237ad8ee3a0so4819201pjp.2; Fri, 10 Mar 2023 02:55:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678445699; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Gvouo1mnqHL9qVfKSL/y8gLXUs6CkWkQQv524tgmQvQ=; b=SI2NKHWCeduergFryiNV0Ya5qb6WuAlHZHSq+kYNxYHygy01jtYNBIpwTJlhvwA1ou BmyoZnWjItG3weJqeUz3ymJI3aPzRLVNKvpulq+7JYSMbMfkhj+VOgQEn495TYLdPi9p IShGisn2XJzrid8xQJyMSO9RM8d9WKIGdBdLMf93yLJOYK+F1aZnelb+auPvnrFqisaL +FtJXi2EB9FIrmWT7UkKych93qAbaa29L1U6nq8zw4OTnuvtQ7rbuLI3OklIdx9d+Pnx TOO54qRl+vupzOlHbbLr2EVcJPABeIK15fS+8WNtrIzokdCQrjNAvdQmFjOEIt4SZuq6 KyqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678445699; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Gvouo1mnqHL9qVfKSL/y8gLXUs6CkWkQQv524tgmQvQ=; b=FO94tZ5YCWyPFYH5O8L98gGvhwiS3EYrL4POMsbtK81LKSqzN5Wodb/hqCyuIweCm/ Ns3O7t3S4W8fZkWxgBH3USQ4yv1aZLVfM3jp8DjUwTl8SKm3x71rfWpxXvxOJbOtB6ZM k2ZMLhqPfr3qnjVzquSFdlZq6QIrexe8HkpeV1snFvRCDyEGNXSzTU6FEQafNpMNprJg beUTXCbWC+6LcSyP1nOsBEwO0kNgKqhX715SXr7YKozptv5zCUJaMUake7+4cl1X8C0U Her7hE+y7vevJLpFYgSYeISdVP5ur7R2RLRlmgW53/JyR9wEllSqV7TLK+8Isf/Q7RUJ lD8w== X-Gm-Message-State: AO0yUKXVx0VCd45iwFi+54bg1xMq/++5zWkgq5hTUswoSkkX9GLirst2 qV93Nt57ilnP3967Oagn0QwJ+GWxA/MPTVhbsqg= X-Google-Smtp-Source: AK7set/HvpUfddg0YQ6QfBOggxb5I2H3aqx74KX+cZI2FFSaqaE04Af2RDnAliyDp+jVRfERCsD++g== X-Received: by 2002:a17:902:c103:b0:19e:7611:7162 with SMTP id 3-20020a170902c10300b0019e76117162mr21992880pli.16.1678445698852; Fri, 10 Mar 2023 02:54:58 -0800 (PST) Received: from fedlinux.. ([106.84.129.9]) by smtp.gmail.com with ESMTPSA id j9-20020a654309000000b00502e6bfedc0sm1081397pgq.0.2023.03.10.02.54.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Mar 2023 02:54:58 -0800 (PST) From: Sam Li To: qemu-devel@nongnu.org Cc: stefanha@redhat.com, damien.lemoal@opensource.wdc.com, Hanna Reitz , hare@suse.de, qemu-block@nongnu.org, Eric Blake , Paolo Bonzini , dmitry.fomichev@wdc.com, Cornelia Huck , Markus Armbruster , kvm@vger.kernel.org, "Michael S. Tsirkin" , Kevin Wolf , Raphael Norwitz , Sam Li Subject: [PATCH v7 4/4] virtio-blk: add some trace events for zoned emulation Date: Fri, 10 Mar 2023 18:54:31 +0800 Message-Id: <20230310105431.64271-5-faithilikerun@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230310105431.64271-1-faithilikerun@gmail.com> References: <20230310105431.64271-1-faithilikerun@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102a; envelope-from=faithilikerun@gmail.com; helo=mail-pj1-x102a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Signed-off-by: Sam Li Reviewed-by: Stefan Hajnoczi --- hw/block/trace-events | 7 +++++++ hw/block/virtio-blk.c | 12 ++++++++++++ 2 files changed, 19 insertions(+) diff --git a/hw/block/trace-events b/hw/block/trace-events index 2c45a62bd5..34be8b9135 100644 --- a/hw/block/trace-events +++ b/hw/block/trace-events @@ -44,9 +44,16 @@ pflash_write_unknown(const char *name, uint8_t cmd) "%s: unknown command 0x%02x" # virtio-blk.c virtio_blk_req_complete(void *vdev, void *req, int status) "vdev %p req %p status %d" virtio_blk_rw_complete(void *vdev, void *req, int ret) "vdev %p req %p ret %d" +virtio_blk_zone_report_complete(void *vdev, void *req, unsigned int nr_zones, int ret) "vdev %p req %p nr_zones %u ret %d" +virtio_blk_zone_mgmt_complete(void *vdev, void *req, int ret) "vdev %p req %p ret %d" +virtio_blk_zone_append_complete(void *vdev, void *req, int64_t sector, int ret) "vdev %p req %p, append sector 0x%" PRIx64 " ret %d" virtio_blk_handle_write(void *vdev, void *req, uint64_t sector, size_t nsectors) "vdev %p req %p sector %"PRIu64" nsectors %zu" virtio_blk_handle_read(void *vdev, void *req, uint64_t sector, size_t nsectors) "vdev %p req %p sector %"PRIu64" nsectors %zu" virtio_blk_submit_multireq(void *vdev, void *mrb, int start, int num_reqs, uint64_t offset, size_t size, bool is_write) "vdev %p mrb %p start %d num_reqs %d offset %"PRIu64" size %zu is_write %d" +virtio_blk_handle_zone_report(void *vdev, void *req, int64_t sector, unsigned int nr_zones) "vdev %p req %p sector 0x%" PRIx64 " nr_zones %u" +virtio_blk_handle_zone_mgmt(void *vdev, void *req, uint8_t op, int64_t sector, int64_t len) "vdev %p req %p op 0x%x sector 0x%" PRIx64 " len 0x%" PRIx64 "" +virtio_blk_handle_zone_reset_all(void *vdev, void *req, int64_t sector, int64_t len) "vdev %p req %p sector 0x%" PRIx64 " cap 0x%" PRIx64 "" +virtio_blk_handle_zone_append(void *vdev, void *req, int64_t sector) "vdev %p req %p, append sector 0x%" PRIx64 "" # hd-geometry.c hd_geometry_lchs_guess(void *blk, int cyls, int heads, int secs) "blk %p LCHS %d %d %d" diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c index 7605ca4f03..7ad45fda03 100644 --- a/hw/block/virtio-blk.c +++ b/hw/block/virtio-blk.c @@ -676,6 +676,7 @@ static void virtio_blk_zone_report_complete(void *opaque, int ret) int64_t nz = data->zone_report_data.nr_zones; int8_t err_status = VIRTIO_BLK_S_OK; + trace_virtio_blk_zone_report_complete(vdev, req, nz, ret); if (ret) { err_status = VIRTIO_BLK_S_ZONE_INVALID_CMD; goto out; @@ -792,6 +793,8 @@ static int virtio_blk_handle_zone_report(VirtIOBlockReq *req, nr_zones = (req->in_len - sizeof(struct virtio_blk_inhdr) - sizeof(struct virtio_blk_zone_report)) / sizeof(struct virtio_blk_zone_descriptor); + trace_virtio_blk_handle_zone_report(vdev, req, + offset >> BDRV_SECTOR_BITS, nr_zones); zone_size = sizeof(BlockZoneDescriptor) * nr_zones; data = g_malloc(sizeof(ZoneCmdData)); @@ -818,7 +821,9 @@ static void virtio_blk_zone_mgmt_complete(void *opaque, int ret) { VirtIOBlockReq *req = opaque; VirtIOBlock *s = req->dev; + VirtIODevice *vdev = VIRTIO_DEVICE(s); int8_t err_status = VIRTIO_BLK_S_OK; + trace_virtio_blk_zone_mgmt_complete(vdev, req,ret); if (ret) { err_status = VIRTIO_BLK_S_ZONE_INVALID_CMD; @@ -845,6 +850,8 @@ static int virtio_blk_handle_zone_mgmt(VirtIOBlockReq *req, BlockZoneOp op) /* Entire drive capacity */ offset = 0; len = capacity; + trace_virtio_blk_handle_zone_reset_all(vdev, req, 0, + bs->total_sectors); } else { if (bs->bl.zone_size > capacity - offset) { /* The zoned device allows the last smaller zone. */ @@ -852,6 +859,9 @@ static int virtio_blk_handle_zone_mgmt(VirtIOBlockReq *req, BlockZoneOp op) } else { len = bs->bl.zone_size; } + trace_virtio_blk_handle_zone_mgmt(vdev, req, op, + offset >> BDRV_SECTOR_BITS, + len >> BDRV_SECTOR_BITS); } if (!check_zoned_request(s, offset, len, false, &err_status)) { @@ -894,6 +904,7 @@ static void virtio_blk_zone_append_complete(void *opaque, int ret) err_status = VIRTIO_BLK_S_ZONE_INVALID_CMD; goto out; } + trace_virtio_blk_zone_append_complete(vdev, req, append_sector, ret); out: aio_context_acquire(blk_get_aio_context(s->conf.conf.blk)); @@ -915,6 +926,7 @@ static int virtio_blk_handle_zone_append(VirtIOBlockReq *req, int64_t offset = virtio_ldq_p(vdev, &req->out.sector) << BDRV_SECTOR_BITS; int64_t len = iov_size(out_iov, out_num); + trace_virtio_blk_handle_zone_append(vdev, req, offset >> BDRV_SECTOR_BITS); if (!check_zoned_request(s, offset, len, true, &err_status)) { goto out; }