From nobody Mon Feb 9 03:44:49 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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 ARC-Seal: i=1; a=rsa-sha256; t=1605848661; cv=none; d=zohomail.com; s=zohoarc; b=JY1g16NVDQkh0kKvNm18oyHLLHuAyHU2n4jIzsAyiAxfjuWGbcrvO3kE6SvPYfs+q7EMyfwL2ZC+vJEv3vs3s9mB5dHpODeht9J9RlfcpGM4ubQ0N+z2Ov8YBJBjqeaVc/uumAyQ21qNaKytGN6ykVvTP++G9GBzergOygnclPk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605848661; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=zCcAzDyVhlDH/ldNIj+YC/q03c+sF1oTAkK7uLR4SfQ=; b=eqGeA5fkegXugH9nL10Vzx7BCABqvWVIkk4jV1qT5FGuDU6QQ+LlKIuS2OxtizFZqHmruzhVTZEXYajubQMzQe+yhjawswsK2thCflmlGlbq0ZGgUluaqTSnIaQKFNY36ABwImuRaIvugzhdkO3btO5Fq4qSwlqvbF0PGRajSzM= ARC-Authentication-Results: i=1; mx.zohomail.com; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1605848660504151.7368810787557; Thu, 19 Nov 2020 21:04:20 -0800 (PST) Received: from localhost ([::1]:41108 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kfyao-0003O3-GJ for importer@patchew.org; Fri, 20 Nov 2020 00:04:18 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35608) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kfyZx-0002wJ-Kk for qemu-devel@nongnu.org; Fri, 20 Nov 2020 00:03:25 -0500 Received: from zxshcas1.zhaoxin.com ([203.148.12.81]:51856) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kfyZu-00076p-Gx for qemu-devel@nongnu.org; Fri, 20 Nov 2020 00:03:25 -0500 Received: from zxbjmbx1.zhaoxin.com (10.29.252.163) by ZXSHCAS1.zhaoxin.com (10.28.252.161) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Fri, 20 Nov 2020 13:03:12 +0800 Received: from zhaoxin-ubuntu20.04 (124.64.17.38) by zxbjmbx1.zhaoxin.com (10.29.252.163) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Fri, 20 Nov 2020 13:03:10 +0800 From: "zhaoxin\\RockCuioc" To: Subject: [PATCH v2] virtio-blk: seg_max do not subtract 2 if host has VIRTIO_RING_F_INDIRECT_DESC feature Date: Fri, 20 Nov 2020 13:03:03 +0800 Message-ID: <20201120050303.5769-1-RockCui-oc@zhaoxin.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [124.64.17.38] X-ClientProxiedBy: ZXSHCAS1.zhaoxin.com (10.28.252.161) To zxbjmbx1.zhaoxin.com (10.29.252.163) 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=203.148.12.81; envelope-from=RockCui-oc@zhaoxin.com; helo=ZXSHCAS1.zhaoxin.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: RockCui@zhaoxin.com, CobeChen@zhaoxin.com, flyfan@zhaoxin.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" v1 -> v2: fix codestyle checked by checkpatch.pl This patch modify virtio-blk seg_max when host has VIRTIO_RING_F_INDIRECT_D= ESC feature, when read/write virtio-blk disk in direct mode,=20 this patch can make the bio reach 512k but not 504k if the user buffer phys= ical segments are all discontinuous,when use ceph the size of 504k=20 will affect performance.This patch should be used in guest kernel version>= =3D4.14, kernel after this version virtio driver does not judge=20 total_sg and vring num if the host supports indirect descriptor tables. =20 Signed-off-by: zhaoxin\RockCuioc --- hw/block/virtio-blk.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c index bac2d6f..40bbbd7 100644 --- a/hw/block/virtio-blk.c +++ b/hw/block/virtio-blk.c @@ -932,7 +932,11 @@ static void virtio_blk_update_config(VirtIODevice *vde= v, uint8_t *config) blk_get_geometry(s->blk, &capacity); memset(&blkcfg, 0, sizeof(blkcfg)); virtio_stq_p(vdev, &blkcfg.capacity, capacity); - virtio_stl_p(vdev, &blkcfg.seg_max, + if virtio_host_has_feature(vdev, VIRTIO_RING_F_INDIRECT_DESC) + virtio_stl_p(vdev, &blkcfg.seg_max, + s->conf.seg_max_adjust ? s->conf.queue_size : 128); + else + virtio_stl_p(vdev, &blkcfg.seg_max, s->conf.seg_max_adjust ? s->conf.queue_size - 2 : 128 - 2= ); virtio_stw_p(vdev, &blkcfg.geometry.cylinders, conf->cyls); virtio_stl_p(vdev, &blkcfg.blk_size, blk_size); --=20 2.10.1.windows.1