virtio-blk: avoid preallocating big SGL for data
Subsystems (4)
PATCH v2 1/1 virtio-blk: avoid preallocating big SGL for data
No need to pre-allocate a big buffer for the IO SGL anymore. If a device has lots of deep queues, preallocation for the sg list can consume substantial amounts of memory. For HW virtio-blk device, nr_hw_queues can be 64 or 128 and each queue's depth might be 128. This means the resulting preallocation for the data SGLs is big.
Switch to runtime allocation for SGL for lists longer than 2 entries. This is the approach used by NVMe drivers so it should be reasonable for virtio block as well. Runtime SGL allocation has always been the case for the legacy I/O path so this is nothing new.
The preallocated small SGL depends on SG_CHAIN so if the ARCH doesn't support SG_CHAIN, use only runtime allocation for the SGL.
Re-organize the setup of the IO request to fit the new sg chain mechanism.
No performance degradation was seen (fio libaio engine with 16 jobs and 128 iodepth):
IO size IOPs Rand Read (before/after) IOPs Rand Write (before/after)
-------- --------------------------------- ----------------------------------
512B 318K/316K 329K/325K
4KB 323K/321K 353K/349K
16KB 199K/208K 250K/275K
128KB 36K/36.1K 39.2K/41.7K
---
changes from V1:
- Kconfig update (from Christoph)
- Re-order cmd setup (from Christoph)
- use flexible sg pointer in the cmd (from Christoph)
- added perf numbers to commit msg (from Feng Li)
--- drivers/block/Kconfig | 1 + drivers/block/virtio_blk.c | 153 +++++++++++++++++++++++-------------- 2 files changed, 98 insertions(+), 56 deletions(-)
drivers/block/Kconfig +1 -0
@@ -395,6 +395,7 @@ config XEN_BLKDEV_BACKEND config VIRTIO_BLK tristate "Virtio block driver" depends on VIRTIO + select SG_POOL help This is the virtual block driver for virtio. It can be used with QEMU based VMMs (like KVM or Xen). Say Y or M.
drivers/block/virtio_blk.c +97 -56
217 lines not on this page · raw message
Signature · 1 line
2.18.1