From nobody Tue Nov 26 18:46:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1705672760; cv=none; d=zohomail.com; s=zohoarc; b=is0F+le/B3eqNiHdZZ2cwEYJaZFDKrh7W33nmSHH9xOlm9c0EGwHF2mSriKo5o0KSSw/oAiDJtfBxAOs8OnQ79vf5XB6ch4e6gL/PQpp0LXrEmjhNaKk3GI4Ar/M9RUmY8/9Sg6Dq49rebnfO5W+wpiwd/Pho7v/a0QgoPTRwf8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1705672760; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=E+kU4JGpgJaHzOYId5I252sBmL8LLwk8t+7ng/5sAHo=; b=NF7Lfjyn7iDumNvN09G0fTeevsqn4zX2Xaw+3S1gtiVhpyEAPU6VLW2TWrQ7jYvWbeWKMvREVZU+ftM18bLXzVU6wvM12JpUvoGmVhKM7CwmTHGHuMveRTKQ18Yx/k+27ySAvlQBZffogDGCusfJD6ybVH+2hYV2KeLmxuRgbcM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1705672760115503.21060812969495; Fri, 19 Jan 2024 05:59:20 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rQpOF-0004bQ-4J; Fri, 19 Jan 2024 08:58:35 -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 1rQpO8-0004Sz-De for qemu-devel@nongnu.org; Fri, 19 Jan 2024 08:58:29 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rQpO4-0000Y9-5D for qemu-devel@nongnu.org; Fri, 19 Jan 2024 08:58:27 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-112-WZkH6UfKPoqmSQcF0XhKeg-1; Fri, 19 Jan 2024 08:58:19 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0295980007C; Fri, 19 Jan 2024 13:58:19 +0000 (UTC) Received: from localhost (unknown [10.39.195.31]) by smtp.corp.redhat.com (Postfix) with ESMTP id 71D9C2166B33; Fri, 19 Jan 2024 13:58:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1705672702; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=E+kU4JGpgJaHzOYId5I252sBmL8LLwk8t+7ng/5sAHo=; b=GA+1yj3rMadncypx9vkaxULzRF3wFvLhG9feWLqOw87u6GiCIibdT3HWfXlZ/QnMSZqRR1 HHD0Jv6My7vsggH+hdUSEAKLbJLhlgChVtFbmcJzjaMW+aNDMh7Ix0bOKistAMcxnlAY9E z8EOVxGJqP0JiBSL+nV41OL8mX+NHj0= X-MC-Unique: WZkH6UfKPoqmSQcF0XhKeg-1 From: Stefan Hajnoczi To: qemu-devel@nongnu.org Cc: Stefan Hajnoczi , Thomas Huth , Hanna Reitz , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , qemu-block@nongnu.org, "Michael S. Tsirkin" , Kevin Wolf , Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 3/6] virtio-blk: rename dataplane to ioeventfd Date: Fri, 19 Jan 2024 08:57:45 -0500 Message-ID: <20240119135748.270944-4-stefanha@redhat.com> In-Reply-To: <20240119135748.270944-1-stefanha@redhat.com> References: <20240119135748.270944-1-stefanha@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.6 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=stefanha@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -45 X-Spam_score: -4.6 X-Spam_bar: ---- X-Spam_report: (-4.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-2.519, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1705672761032100001 Content-Type: text/plain; charset="utf-8" The dataplane code is really about using ioeventfd. It's used both for IOThreads (what we think of as dataplane) and for the core virtio-pci code's ioeventfd feature (which is enabled by default and used when no IOThread has been specified). Rename the code to reflect this. Signed-off-by: Stefan Hajnoczi --- include/hw/virtio/virtio-blk.h | 8 ++-- hw/block/virtio-blk.c | 78 +++++++++++++++++----------------- 2 files changed, 43 insertions(+), 43 deletions(-) diff --git a/include/hw/virtio/virtio-blk.h b/include/hw/virtio/virtio-blk.h index fecffdc303..833a9a344f 100644 --- a/include/hw/virtio/virtio-blk.h +++ b/include/hw/virtio/virtio-blk.h @@ -60,10 +60,10 @@ struct VirtIOBlock { unsigned short sector_mask; bool original_wce; VMChangeStateEntry *change; - bool dataplane_disabled; - bool dataplane_started; - bool dataplane_starting; - bool dataplane_stopping; + bool ioeventfd_disabled; + bool ioeventfd_started; + bool ioeventfd_starting; + bool ioeventfd_stopping; =20 /* * The AioContext for each virtqueue. The BlockDriverState will use the diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c index 47494ebadd..e342cb2cfb 100644 --- a/hw/block/virtio-blk.c +++ b/hw/block/virtio-blk.c @@ -64,7 +64,7 @@ static void virtio_blk_req_complete(VirtIOBlockReq *req, = unsigned char status) iov_discard_undo(&req->inhdr_undo); iov_discard_undo(&req->outhdr_undo); virtqueue_push(req->vq, &req->elem, req->in_len); - if (s->dataplane_started && !s->dataplane_disabled) { + if (s->ioeventfd_started && !s->ioeventfd_disabled) { virtio_notify_irqfd(vdev, req->vq); } else { virtio_notify(vdev, req->vq); @@ -1141,12 +1141,12 @@ static void virtio_blk_handle_output(VirtIODevice *= vdev, VirtQueue *vq) { VirtIOBlock *s =3D (VirtIOBlock *)vdev; =20 - if (!s->dataplane_disabled && !s->dataplane_started) { + if (!s->ioeventfd_disabled && !s->ioeventfd_started) { /* Some guests kick before setting VIRTIO_CONFIG_S_DRIVER_OK so st= art - * dataplane here instead of waiting for .set_status(). + * ioeventfd here instead of waiting for .set_status(). */ virtio_device_start_ioeventfd(vdev); - if (!s->dataplane_disabled) { + if (!s->ioeventfd_disabled) { return; } } @@ -1213,7 +1213,7 @@ static void virtio_blk_reset(VirtIODevice *vdev) VirtIOBlockReq *req; =20 /* Dataplane has stopped... */ - assert(!s->dataplane_started); + assert(!s->ioeventfd_started); =20 /* ...but requests may still be in flight. */ blk_drain(s->blk); @@ -1380,7 +1380,7 @@ static void virtio_blk_set_status(VirtIODevice *vdev,= uint8_t status) VirtIOBlock *s =3D VIRTIO_BLK(vdev); =20 if (!(status & (VIRTIO_CONFIG_S_DRIVER | VIRTIO_CONFIG_S_DRIVER_OK))) { - assert(!s->dataplane_started); + assert(!s->ioeventfd_started); } =20 if (!(status & VIRTIO_CONFIG_S_DRIVER_OK)) { @@ -1545,7 +1545,7 @@ static void virtio_blk_resize(void *opaque) aio_bh_schedule_oneshot(qemu_get_aio_context(), virtio_resize_cb, vdev= ); } =20 -static void virtio_blk_data_plane_detach(VirtIOBlock *s) +static void virtio_blk_ioeventfd_detach(VirtIOBlock *s) { VirtIODevice *vdev =3D VIRTIO_DEVICE(s); =20 @@ -1555,7 +1555,7 @@ static void virtio_blk_data_plane_detach(VirtIOBlock = *s) } } =20 -static void virtio_blk_data_plane_attach(VirtIOBlock *s) +static void virtio_blk_ioeventfd_attach(VirtIOBlock *s) { VirtIODevice *vdev =3D VIRTIO_DEVICE(s); =20 @@ -1570,8 +1570,8 @@ static void virtio_blk_drained_begin(void *opaque) { VirtIOBlock *s =3D opaque; =20 - if (s->dataplane_started) { - virtio_blk_data_plane_detach(s); + if (s->ioeventfd_started) { + virtio_blk_ioeventfd_detach(s); } } =20 @@ -1580,8 +1580,8 @@ static void virtio_blk_drained_end(void *opaque) { VirtIOBlock *s =3D opaque; =20 - if (s->dataplane_started) { - virtio_blk_data_plane_attach(s); + if (s->ioeventfd_started) { + virtio_blk_ioeventfd_attach(s); } } =20 @@ -1651,11 +1651,11 @@ static bool virtio_blk_vq_aio_context_init(VirtIOBl= ock *s, Error **errp) } =20 /* - * If dataplane is (re-)enabled while the guest is running there c= ould + * If ioeventfd is (re-)enabled while the guest is running there c= ould * be block jobs that can conflict. */ if (blk_op_is_blocked(conf->conf.blk, BLOCK_OP_TYPE_DATAPLANE, err= p)) { - error_prepend(errp, "cannot start virtio-blk dataplane: "); + error_prepend(errp, "cannot start virtio-blk ioeventfd: "); return false; } } @@ -1688,7 +1688,7 @@ static void virtio_blk_vq_aio_context_cleanup(VirtIOB= lock *s) { VirtIOBlkConf *conf =3D &s->conf; =20 - assert(!s->dataplane_started); + assert(!s->ioeventfd_started); =20 if (conf->iothread_vq_mapping_list) { IOThreadVirtQueueMappingList *node; @@ -1708,7 +1708,7 @@ static void virtio_blk_vq_aio_context_cleanup(VirtIOB= lock *s) } =20 /* Context: BQL held */ -static int virtio_blk_data_plane_start(VirtIODevice *vdev) +static int virtio_blk_start_ioeventfd(VirtIODevice *vdev) { VirtIOBlock *s =3D VIRTIO_BLK(vdev); BusState *qbus =3D BUS(qdev_get_parent_bus(DEVICE(s))); @@ -1718,11 +1718,11 @@ static int virtio_blk_data_plane_start(VirtIODevice= *vdev) Error *local_err =3D NULL; int r; =20 - if (s->dataplane_started || s->dataplane_starting) { + if (s->ioeventfd_started || s->ioeventfd_starting) { return 0; } =20 - s->dataplane_starting =3D true; + s->ioeventfd_starting =3D true; =20 /* Set up guest notifier (irq) */ r =3D k->set_guest_notifiers(qbus->parent, nvqs, true); @@ -1773,14 +1773,14 @@ static int virtio_blk_data_plane_start(VirtIODevice= *vdev) =20 /* * These fields must be visible to the IOThread when it processes the - * virtqueue, otherwise it will think dataplane has not started yet. + * virtqueue, otherwise it will think ioeventfd has not started yet. * - * Make sure ->dataplane_started is false when blk_set_aio_context() is + * Make sure ->ioeventfd_started is false when blk_set_aio_context() is * called above so that draining does not cause the host notifier to be * detached/attached prematurely. */ - s->dataplane_starting =3D false; - s->dataplane_started =3D true; + s->ioeventfd_starting =3D false; + s->ioeventfd_started =3D true; smp_wmb(); /* paired with aio_notify_accept() on the read side */ =20 /* Get this show started by hooking up our callbacks */ @@ -1812,8 +1812,8 @@ static int virtio_blk_data_plane_start(VirtIODevice *= vdev) fail_host_notifiers: k->set_guest_notifiers(qbus->parent, nvqs, false); fail_guest_notifiers: - s->dataplane_disabled =3D true; - s->dataplane_starting =3D false; + s->ioeventfd_disabled =3D true; + s->ioeventfd_starting =3D false; return -ENOSYS; } =20 @@ -1821,7 +1821,7 @@ static int virtio_blk_data_plane_start(VirtIODevice *= vdev) * * Context: BH in IOThread */ -static void virtio_blk_data_plane_stop_vq_bh(void *opaque) +static void virtio_blk_ioeventfd_stop_vq_bh(void *opaque) { VirtQueue *vq =3D opaque; EventNotifier *host_notifier =3D virtio_queue_get_host_notifier(vq); @@ -1836,7 +1836,7 @@ static void virtio_blk_data_plane_stop_vq_bh(void *op= aque) } =20 /* Context: BQL held */ -static void virtio_blk_data_plane_stop(VirtIODevice *vdev) +static void virtio_blk_stop_ioeventfd(VirtIODevice *vdev) { VirtIOBlock *s =3D VIRTIO_BLK(vdev); BusState *qbus =3D qdev_get_parent_bus(DEVICE(s)); @@ -1844,24 +1844,24 @@ static void virtio_blk_data_plane_stop(VirtIODevice= *vdev) unsigned i; unsigned nvqs =3D s->conf.num_queues; =20 - if (!s->dataplane_started || s->dataplane_stopping) { + if (!s->ioeventfd_started || s->ioeventfd_stopping) { return; } =20 /* Better luck next time. */ - if (s->dataplane_disabled) { - s->dataplane_disabled =3D false; - s->dataplane_started =3D false; + if (s->ioeventfd_disabled) { + s->ioeventfd_disabled =3D false; + s->ioeventfd_started =3D false; return; } - s->dataplane_stopping =3D true; + s->ioeventfd_stopping =3D true; =20 if (!blk_in_drain(s->conf.conf.blk)) { for (i =3D 0; i < nvqs; i++) { VirtQueue *vq =3D virtio_get_queue(vdev, i); AioContext *ctx =3D s->vq_aio_context[i]; =20 - aio_wait_bh_oneshot(ctx, virtio_blk_data_plane_stop_vq_bh, vq); + aio_wait_bh_oneshot(ctx, virtio_blk_ioeventfd_stop_vq_bh, vq); } } =20 @@ -1886,10 +1886,10 @@ static void virtio_blk_data_plane_stop(VirtIODevice= *vdev) } =20 /* - * Set ->dataplane_started to false before draining so that host notif= iers + * Set ->ioeventfd_started to false before draining so that host notif= iers * are not detached/attached anymore. */ - s->dataplane_started =3D false; + s->ioeventfd_started =3D false; =20 /* Wait for virtio_blk_dma_restart_bh() and in flight I/O to complete = */ blk_drain(s->conf.conf.blk); @@ -1903,7 +1903,7 @@ static void virtio_blk_data_plane_stop(VirtIODevice *= vdev) /* Clean up guest notifier (irq) */ k->set_guest_notifiers(qbus->parent, nvqs, false); =20 - s->dataplane_stopping =3D false; + s->ioeventfd_stopping =3D false; } =20 static void virtio_blk_device_realize(DeviceState *dev, Error **errp) @@ -2011,9 +2011,9 @@ static void virtio_blk_device_realize(DeviceState *de= v, Error **errp) } qemu_coroutine_inc_pool_size(conf->num_queues * conf->queue_size / 2); =20 - /* Don't start dataplane if transport does not support notifiers. */ + /* Don't start ioeventfd if transport does not support notifiers. */ if (!virtio_device_ioeventfd_enabled(vdev)) { - s->dataplane_disabled =3D true; + s->ioeventfd_disabled =3D true; } =20 virtio_blk_vq_aio_context_init(s, &err); @@ -2137,8 +2137,8 @@ static void virtio_blk_class_init(ObjectClass *klass,= void *data) vdc->reset =3D virtio_blk_reset; vdc->save =3D virtio_blk_save_device; vdc->load =3D virtio_blk_load_device; - vdc->start_ioeventfd =3D virtio_blk_data_plane_start; - vdc->stop_ioeventfd =3D virtio_blk_data_plane_stop; + vdc->start_ioeventfd =3D virtio_blk_start_ioeventfd; + vdc->stop_ioeventfd =3D virtio_blk_stop_ioeventfd; } =20 static const TypeInfo virtio_blk_info =3D { --=20 2.43.0