From nobody Sat Apr 12 09:04:10 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513697067906759.8831021502002; Tue, 19 Dec 2017 07:24:27 -0800 (PST) Received: from localhost ([::1]:49334 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eRJkW-00058R-L4 for importer@patchew.org; Tue, 19 Dec 2017 10:24:08 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57987) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eRJa3-00056d-BJ for qemu-devel@nongnu.org; Tue, 19 Dec 2017 10:13:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eRJZv-0007Ez-FQ for qemu-devel@nongnu.org; Tue, 19 Dec 2017 10:13:19 -0500 Received: from mx1.redhat.com ([209.132.183.28]:55046) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eRJZv-0007EK-9C for qemu-devel@nongnu.org; Tue, 19 Dec 2017 10:13:11 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 815EB5D68B; Tue, 19 Dec 2017 15:13:10 +0000 (UTC) Received: from localhost (ovpn-117-161.ams2.redhat.com [10.36.117.161]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6384B62660; Tue, 19 Dec 2017 15:13:07 +0000 (UTC) From: Stefan Hajnoczi To: Date: Tue, 19 Dec 2017 15:11:37 +0000 Message-Id: <20171219151144.11120-17-stefanha@redhat.com> In-Reply-To: <20171219151144.11120-1-stefanha@redhat.com> References: <20171219151144.11120-1-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Tue, 19 Dec 2017 15:13:10 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL v2 16/23] virtio-blk: make queue size configurable X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Stefan Hajnoczi Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Mark Kanda Depending on the configuration, it can be beneficial to adjust the virtio-b= lk queue size to something other than the current default of 128. Add a new property to make the queue size configurable. Signed-off-by: Mark Kanda Reviewed-by: Karl Heubaum Reviewed-by: Martin K. Petersen Reviewed-by: Ameya More Message-id: 52e6d742811f10dbd16e996e86cf375b9577c187.1513005190.git.mark.ka= nda@oracle.com Signed-off-by: Stefan Hajnoczi --- include/hw/virtio/virtio-blk.h | 1 + hw/block/virtio-blk.c | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/include/hw/virtio/virtio-blk.h b/include/hw/virtio/virtio-blk.h index d3c8a6fa8c..5117431d96 100644 --- a/include/hw/virtio/virtio-blk.h +++ b/include/hw/virtio/virtio-blk.h @@ -39,6 +39,7 @@ struct VirtIOBlkConf uint32_t config_wce; uint32_t request_merging; uint16_t num_queues; + uint16_t queue_size; }; =20 struct VirtIOBlockDataPlane; diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c index 41a4ccdede..66ab0b19c8 100644 --- a/hw/block/virtio-blk.c +++ b/hw/block/virtio-blk.c @@ -928,6 +928,13 @@ static void virtio_blk_device_realize(DeviceState *dev= , Error **errp) error_setg(errp, "num-queues property must be larger than 0"); return; } + if (!is_power_of_2(conf->queue_size) || + conf->queue_size > VIRTQUEUE_MAX_SIZE) { + error_setg(errp, "invalid queue-size property (%" PRIu16 "), " + "must be a power of 2 (max %d)", + conf->queue_size, VIRTQUEUE_MAX_SIZE); + return; + } =20 blkconf_serial(&conf->conf, &conf->serial); if (!blkconf_apply_backend_options(&conf->conf, @@ -950,7 +957,7 @@ static void virtio_blk_device_realize(DeviceState *dev,= Error **errp) s->sector_mask =3D (s->conf.conf.logical_block_size / BDRV_SECTOR_SIZE= ) - 1; =20 for (i =3D 0; i < conf->num_queues; i++) { - virtio_add_queue(vdev, 128, virtio_blk_handle_output); + virtio_add_queue(vdev, conf->queue_size, virtio_blk_handle_output); } virtio_blk_data_plane_create(vdev, conf, &s->dataplane, &err); if (err !=3D NULL) { @@ -1009,6 +1016,7 @@ static Property virtio_blk_properties[] =3D { DEFINE_PROP_BIT("request-merging", VirtIOBlock, conf.request_merging, = 0, true), DEFINE_PROP_UINT16("num-queues", VirtIOBlock, conf.num_queues, 1), + DEFINE_PROP_UINT16("queue-size", VirtIOBlock, conf.queue_size, 128), DEFINE_PROP_LINK("iothread", VirtIOBlock, conf.iothread, TYPE_IOTHREAD, IOThread *), DEFINE_PROP_END_OF_LIST(), --=20 2.14.3