From: "zhaoxin\\RockCuioc" <RockCui-oc@zhaoxin.com>
To: <qemu-devel@nongnu.org>
Cc: RockCui@zhaoxin.com, CobeChen@zhaoxin.com, flyfan@zhaoxin.com
Subject: [PATCH] virtio-blk: seg_max do not subtract 2 if host has VIRTIO_RING_F_INDIRECT_DESC feature
Date: Thu, 19 Nov 2020 16:54:37 +0800 [thread overview]
Message-ID: <20201119085437.5333-1-RockCui-oc@zhaoxin.com> (raw)
This patch modify virtio-blk seg_max when host has VIRTIO_RING_F_INDIRECT_DESC feature, when read/write virtio-blk disk in direct mode,
this patch can make the bio reach 512k but not 504k if the user buffer physical segments are all discontinuous,when use ceph the size of 504k
will affect performance.This patch should be used in guest kernel version>=4.14, kernel after this version virtio driver does not judge
total_sg and vring num if the host supports indirect descriptor tables.
Signed-off-by: zhaoxin\RockCuioc <RockCui-oc@zhaoxin.com>
---
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 *vdev, 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);
--
2.10.1.windows.1
next reply other threads:[~2020-11-19 9:02 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-19 8:54 zhaoxin\RockCuioc [this message]
2020-11-19 9:06 ` [PATCH] virtio-blk: seg_max do not subtract 2 if host has VIRTIO_RING_F_INDIRECT_DESC feature no-reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201119085437.5333-1-RockCui-oc@zhaoxin.com \
--to=rockcui-oc@zhaoxin.com \
--cc=CobeChen@zhaoxin.com \
--cc=RockCui@zhaoxin.com \
--cc=flyfan@zhaoxin.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.